mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-20 22:21:13 +02:00
This change is only moving packages and updating import paths. Goal: expose `internal/pkg/provision` as `pkg/provision` to enable other projects to import Talos provisioning library. As cluster checks are almost always required as part of provisioning process, package `internal/pkg/cluster` was also made public as `pkg/cluster`. Other changes were direct dependencies discovered by `importvet` which were updated. Public packages (useful, general purpose packages with stable API): * `internal/pkg/conditions` -> `pkg/conditions` * `internal/pkg/tail` -> `pkg/tail` Private packages (used only on provisioning library internally): * `internal/pkg/inmemhttp` -> `pkg/provision/internal/inmemhttp` * `internal/pkg/kernel/vmlinuz` -> `pkg/provision/internal/vmlinuz` * `internal/pkg/cniutils` -> `pkg/provision/internal/cniutils` Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
// Package docker implements Provisioner via docker.
|
|
package docker
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/docker/docker/client"
|
|
|
|
"github.com/talos-systems/talos/pkg/config/types/v1alpha1"
|
|
"github.com/talos-systems/talos/pkg/config/types/v1alpha1/generate"
|
|
"github.com/talos-systems/talos/pkg/provision"
|
|
)
|
|
|
|
type provisioner struct {
|
|
client *client.Client
|
|
}
|
|
|
|
// NewProvisioner initializes docker provisioner.
|
|
func NewProvisioner(ctx context.Context) (provision.Provisioner, error) {
|
|
p := &provisioner{}
|
|
|
|
var err error
|
|
|
|
p.client, err = client.NewEnvClient()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return p, nil
|
|
}
|
|
|
|
// Close and release resources.
|
|
func (p *provisioner) Close() error {
|
|
if p.client != nil {
|
|
return p.client.Close()
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// GenOptions provides a list of additional config generate options.
|
|
func (p *provisioner) GenOptions(networkReq provision.NetworkRequest) []generate.GenOption {
|
|
ret := []generate.GenOption{
|
|
generate.WithPersist(false),
|
|
}
|
|
|
|
if len(networkReq.Nameservers) > 0 {
|
|
nameservers := make([]string, len(networkReq.Nameservers))
|
|
for i := range nameservers {
|
|
nameservers[i] = networkReq.Nameservers[i].String()
|
|
}
|
|
|
|
ret = append(ret, generate.WithNetworkConfig(
|
|
&v1alpha1.NetworkConfig{
|
|
NameServers: nameservers,
|
|
}),
|
|
)
|
|
}
|
|
|
|
return ret
|
|
}
|
|
|
|
// GetLoadBalancers returns internal/external loadbalancer endpoints.
|
|
func (p *provisioner) GetLoadBalancers(networkReq provision.NetworkRequest) (internalEndpoint, externalEndpoint string) {
|
|
// docker doesn't provide internal LB, so return empty string
|
|
// external LB is always localhost where docker exposes ports
|
|
return "", "127.0.0.1"
|
|
}
|