diff --git a/pkg/machinery/config/generate/secrets/clock.go b/pkg/machinery/config/generate/secrets/clock.go index f3716d6a19..f2f5878240 100644 --- a/pkg/machinery/config/generate/secrets/clock.go +++ b/pkg/machinery/config/generate/secrets/clock.go @@ -36,10 +36,3 @@ func (c *SystemClock) Now() time.Time { return c.fixedTime } - -// SetFixedTimestamp freezes the clock by setting a timestamp. -// -// Deprecated: use NewFixedClock instead. -func (c *SystemClock) SetFixedTimestamp(t time.Time) { - c.fixedTime = t -} diff --git a/pkg/machinery/config/generate/secrets/secrets.go b/pkg/machinery/config/generate/secrets/secrets.go index 08ab0414db..5ea6e1bf30 100644 --- a/pkg/machinery/config/generate/secrets/secrets.go +++ b/pkg/machinery/config/generate/secrets/secrets.go @@ -28,10 +28,6 @@ type Bundle struct { // Certs holds the base64 encoded keys and certificates. type Certs struct { - // Admin is Talos admin talosconfig client certificate and key. - // - // Deprecated: should not be used anymore. - Admin *x509.PEMEncodedCertificateAndKey `json:"Admin,omitempty" yaml:",omitempty"` // Etcd is etcd CA certificate and key. Etcd *x509.PEMEncodedCertificateAndKey `json:"Etcd"` // K8s is Kubernetes CA certificate and key. diff --git a/pkg/machinery/config/types/v1alpha1/bundle/bundle.go b/pkg/machinery/config/types/v1alpha1/bundle/bundle.go deleted file mode 100644 index 8c16d85701..0000000000 --- a/pkg/machinery/config/types/v1alpha1/bundle/bundle.go +++ /dev/null @@ -1,19 +0,0 @@ -// 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 bundle - -import "github.com/siderolabs/talos/pkg/machinery/config/bundle" - -// ConfigBundle defines the group of v1alpha1 config files. -// docgen: nodoc -// +k8s:deepcopy-gen=false -type ConfigBundle = bundle.Bundle - -// NewConfigBundle returns a new bundle. -// -// Deprecated: use bundle.NewBundle instead. -func NewConfigBundle(opts ...Option) (*ConfigBundle, error) { - return bundle.NewBundle(opts...) -} diff --git a/pkg/machinery/config/types/v1alpha1/bundle/options.go b/pkg/machinery/config/types/v1alpha1/bundle/options.go deleted file mode 100644 index ba4a07113a..0000000000 --- a/pkg/machinery/config/types/v1alpha1/bundle/options.go +++ /dev/null @@ -1,97 +0,0 @@ -// 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 bundle - -import ( - jsonpatch "github.com/evanphx/json-patch" - - "github.com/siderolabs/talos/pkg/machinery/config/bundle" - "github.com/siderolabs/talos/pkg/machinery/config/configpatcher" -) - -// Option controls config options specific to config bundle generation. -// -// Deprecated: user bundle.Option instead. -type Option = bundle.Option - -// InputOptions holds necessary params for generating an input. -// -// Deprecated: user bundle.InputOptions instead. -type InputOptions = bundle.InputOptions - -// Options describes generate parameters. -// -// Deprecated: user bundle.Options instead. -type Options = bundle.Options - -// DefaultOptions returns default options. -// -// Deprecated: user bundle.DefaultOptions instead. -func DefaultOptions() Options { - return bundle.DefaultOptions() -} - -// WithExistingConfigs sets the path to existing config files. -// -// Deprecated: use bundle.WithExistingConfigs instead. -func WithExistingConfigs(configPath string) Option { - return bundle.WithExistingConfigs(configPath) -} - -// WithInputOptions allows passing in of various params for net-new input generation. -// -// Deprecated: use bundle.WithInputOptions instead. -func WithInputOptions(inputOpts *InputOptions) Option { - return bundle.WithInputOptions(inputOpts) -} - -// WithVerbose allows setting verbose logging. -// -// Deprecated: use bundle.WithVerbose instead. -func WithVerbose(verbose bool) Option { - return bundle.WithVerbose(verbose) -} - -// WithJSONPatch allows patching every config in a bundle with a patch. -// -// Deprecated: use WithPatch instead. -func WithJSONPatch(patch jsonpatch.Patch) Option { - return WithPatch([]configpatcher.Patch{patch}) -} - -// WithPatch allows patching every config in a bundle with a patch. -// -// Deprecated: use bundle.WithPatch instead. -func WithPatch(patch []configpatcher.Patch) Option { - return bundle.WithPatch(patch) -} - -// WithJSONPatchControlPlane allows patching init and controlplane config in a bundle with a patch. -// -// Deprecated: use WithPatchControlPlane instead. -func WithJSONPatchControlPlane(patch jsonpatch.Patch) Option { - return WithPatchControlPlane([]configpatcher.Patch{patch}) -} - -// WithPatchControlPlane allows patching init and controlplane config in a bundle with a patch. -// -// Deprecated: use bundle.WithPatchControlPlane instead. -func WithPatchControlPlane(patch []configpatcher.Patch) Option { - return bundle.WithPatchControlPlane(patch) -} - -// WithJSONPatchWorker allows patching worker config in a bundle with a patch. -// -// Deprecated: use WithPatchWorker instead. -func WithJSONPatchWorker(patch jsonpatch.Patch) Option { - return WithPatchWorker([]configpatcher.Patch{patch}) -} - -// WithPatchWorker allows patching worker config in a bundle with a patch. -// -// Deprecated: use bundle.WithPatchWorker instead. -func WithPatchWorker(patch []configpatcher.Patch) Option { - return bundle.WithPatchWorker(patch) -} diff --git a/pkg/machinery/config/types/v1alpha1/generate/generate.go b/pkg/machinery/config/types/v1alpha1/generate/generate.go deleted file mode 100644 index 50693fbcd3..0000000000 --- a/pkg/machinery/config/types/v1alpha1/generate/generate.go +++ /dev/null @@ -1,137 +0,0 @@ -// 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 generate provides Talos machine configuration generation and client config generation. -// -// This package is deprecated, use github.com/siderolabs/talos/pkg/machinery/config/generate instead. -package generate - -import ( - "time" - - "github.com/siderolabs/crypto/x509" - - "github.com/siderolabs/talos/pkg/machinery/config" - "github.com/siderolabs/talos/pkg/machinery/config/generate" - "github.com/siderolabs/talos/pkg/machinery/config/generate/secrets" - "github.com/siderolabs/talos/pkg/machinery/config/machine" - v1alpha1 "github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1" - "github.com/siderolabs/talos/pkg/machinery/role" -) - -// Config returns the talos config for a given node type. -func Config(t machine.Type, in *Input) (*v1alpha1.Config, error) { - cfg, err := in.Config(t) - if err != nil { - return nil, err - } - - return cfg.RawV1Alpha1(), nil -} - -// Input holds info about certs, ips, and node type. -// -//nolint:maligned -type Input = generate.Input - -// Certs holds the base64 encoded keys and certificates. -type Certs = secrets.Certs - -// Cluster holds Talos cluster-wide secrets. -type Cluster = secrets.Cluster - -// Secrets holds the sensitive kubeadm data. -type Secrets = secrets.Secrets - -// TrustdInfo holds the trustd credentials. -type TrustdInfo = secrets.TrustdInfo - -// SecretsBundle holds trustd, kubeadm and certs information. -type SecretsBundle = secrets.Bundle - -// Clock system clock. -type Clock = secrets.Clock - -// SystemClock is a real system clock, but the time returned can be made fixed. -type SystemClock = secrets.SystemClock - -// NewClock creates new SystemClock. -// -// Deprecated: use secrets.NewClock instead. -func NewClock() *SystemClock { - return secrets.NewClock() -} - -// NewSecretsBundle creates secrets bundle generating all secrets or reading from the input options if provided. -// -// Deprecated: use generate.NewSecretsBundle instead. -func NewSecretsBundle(clock Clock, opts ...GenOption) (*SecretsBundle, error) { - o := generate.DefaultOptions() - - for _, opt := range opts { - if err := opt(&o); err != nil { - return nil, err - } - } - - return secrets.NewBundle(clock, o.VersionContract) -} - -// NewSecretsBundleFromKubernetesPKI creates secrets bundle by reading the contents -// of a Kubernetes PKI directory (typically `/etc/kubernetes/pki`) and using the provided bootstrapToken as input. -// -// Deprecated: use generate.NewSecretsBundleFromKubernetesPKI instead. -func NewSecretsBundleFromKubernetesPKI(pkiDir, bootstrapToken string, versionContract *config.VersionContract) (*SecretsBundle, error) { - return secrets.NewBundleFromKubernetesPKI(pkiDir, bootstrapToken, versionContract) -} - -// NewSecretsBundleFromConfig creates secrets bundle using existing config. -// -// Deprecated: use generate.NewSecretsBundleFromConfig instead. -func NewSecretsBundleFromConfig(clock Clock, c config.Provider) *SecretsBundle { - return secrets.NewBundleFromConfig(clock, c) -} - -// NewEtcdCA generates a CA for the Etcd PKI. -// -// Deprecated: use secrets.NewEtcdCA instead. -func NewEtcdCA(currentTime time.Time, contract *config.VersionContract) (ca *x509.CertificateAuthority, err error) { - return secrets.NewEtcdCA(currentTime, contract) -} - -// NewKubernetesCA generates a CA for the Kubernetes PKI. -// -// Deprecated: use secrets.NewKubernetesCA instead. -func NewKubernetesCA(currentTime time.Time, contract *config.VersionContract) (ca *x509.CertificateAuthority, err error) { - return secrets.NewKubernetesCA(currentTime, contract) -} - -// NewAggregatorCA generates a CA for the Kubernetes aggregator/front-proxy. -// -// Deprecated: use secrets.NewAggregatorCA instead. -func NewAggregatorCA(currentTime time.Time, contract *config.VersionContract) (ca *x509.CertificateAuthority, err error) { - return secrets.NewAggregatorCA(currentTime, contract) -} - -// NewTalosCA generates a CA for the Talos PKI. -// -// Deprecated: use secrets.NewTalosCA instead. -func NewTalosCA(currentTime time.Time) (ca *x509.CertificateAuthority, err error) { - return secrets.NewTalosCA(currentTime) -} - -// NewAdminCertificateAndKey generates the admin Talos certificate and key. -// -// Deperecated: use secrets.NewAdminCertificateAndKey instead. -func NewAdminCertificateAndKey(currentTime time.Time, ca *x509.PEMEncodedCertificateAndKey, roles role.Set, ttl time.Duration) (p *x509.PEMEncodedCertificateAndKey, err error) { - return secrets.NewAdminCertificateAndKey(currentTime, ca, roles, ttl) -} - -// NewInput generates the sensitive data required to generate all config -// types. -// -// Deprecated: use generate.NewInput instead. -func NewInput(clustername, endpoint, kubernetesVersion string, secrets *SecretsBundle, opts ...GenOption) (input *Input, err error) { - return generate.NewInput(clustername, endpoint, kubernetesVersion, append(opts, generate.WithSecretsBundle(secrets))...) -} diff --git a/pkg/machinery/config/types/v1alpha1/generate/options.go b/pkg/machinery/config/types/v1alpha1/generate/options.go deleted file mode 100644 index 34a127b463..0000000000 --- a/pkg/machinery/config/types/v1alpha1/generate/options.go +++ /dev/null @@ -1,191 +0,0 @@ -// 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 generate - -import ( - "github.com/siderolabs/talos/pkg/machinery/config" - "github.com/siderolabs/talos/pkg/machinery/config/generate" - "github.com/siderolabs/talos/pkg/machinery/config/generate/secrets" - v1alpha1 "github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1" - "github.com/siderolabs/talos/pkg/machinery/role" -) - -// GenOption controls generate options specific to input generation. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.GenOption instead. -type GenOption = generate.Option - -// WithEndpointList specifies endpoints to use when accessing Talos cluster. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithEndpointList instead. -func WithEndpointList(endpoints []string) GenOption { - return generate.WithEndpointList(endpoints) -} - -// WithLocalAPIServerPort specifies the local API server port for the cluster. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithLocalAPIServerPort instead. -func WithLocalAPIServerPort(port int) GenOption { - return generate.WithLocalAPIServerPort(port) -} - -// WithInstallDisk specifies install disk to use in Talos cluster. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithInstallDisk instead. -func WithInstallDisk(disk string) GenOption { - return generate.WithInstallDisk(disk) -} - -// WithAdditionalSubjectAltNames specifies additional SANs. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithAdditionalSubjectAltNames instead. -func WithAdditionalSubjectAltNames(sans []string) GenOption { - return generate.WithAdditionalSubjectAltNames(sans) -} - -// WithInstallImage specifies install container image to use in Talos cluster. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithInstallImage instead. -func WithInstallImage(imageRef string) GenOption { - return generate.WithInstallImage(imageRef) -} - -// WithInstallExtraKernelArgs specifies extra kernel arguments to pass to the installer. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithInstallExtraKernelArgs instead. -func WithInstallExtraKernelArgs(args []string) GenOption { - return generate.WithInstallExtraKernelArgs(args) -} - -// WithNetworkOptions adds network config generation option. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithNetworkOptions instead. -func WithNetworkOptions(opts ...v1alpha1.NetworkConfigOption) GenOption { - return generate.WithNetworkOptions(opts...) -} - -// WithRegistryMirror configures registry mirror endpoint(s). -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithRegistryMirror instead. -func WithRegistryMirror(host string, endpoints ...string) GenOption { - return generate.WithRegistryMirror(host, endpoints...) -} - -// WithRegistryCACert specifies the certificate of the certificate authority which signed certificate of the registry. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithRegistryCACert instead. -func WithRegistryCACert(host, cacert string) GenOption { - return generate.WithRegistryCACert(host, cacert) -} - -// WithRegistryInsecureSkipVerify marks registry host to skip TLS verification. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithRegistryInsecureSkipVerify instead. -func WithRegistryInsecureSkipVerify(host string) GenOption { - return generate.WithRegistryInsecureSkipVerify(host) -} - -// WithDNSDomain specifies domain name to use in Talos cluster. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithDNSDomain instead. -func WithDNSDomain(dnsDomain string) GenOption { - return generate.WithDNSDomain(dnsDomain) -} - -// WithDebug enables verbose logging to console for all services. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithDebug instead. -func WithDebug(enable bool) GenOption { - return generate.WithDebug(enable) -} - -// WithPersist enables persistence of machine config across reboots. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithPersist instead. -func WithPersist(enable bool) GenOption { - return generate.WithPersist(enable) -} - -// WithClusterCNIConfig specifies custom cluster CNI config. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithClusterCNIConfig instead. -func WithClusterCNIConfig(config *v1alpha1.CNIConfig) GenOption { - return generate.WithClusterCNIConfig(config) -} - -// WithUserDisks generates user partitions config. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithUserDisks instead. -func WithUserDisks(disks []*v1alpha1.MachineDisk) GenOption { - return generate.WithUserDisks(disks) -} - -// WithAllowSchedulingOnControlPlanes specifies AllowSchedulingOnControlPlane flag. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithAllowSchedulingOnControlPlanes instead. -func WithAllowSchedulingOnControlPlanes(enabled bool) GenOption { - return generate.WithAllowSchedulingOnControlPlanes(enabled) -} - -// WithVersionContract specifies version contract to use when generating. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithVersionContract instead. -func WithVersionContract(versionContract *config.VersionContract) GenOption { - return generate.WithVersionContract(versionContract) -} - -// WithSystemDiskEncryption specifies encryption settings for the system disk partitions. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithSystemDiskEncryption instead. -func WithSystemDiskEncryption(cfg *v1alpha1.SystemDiskEncryptionConfig) GenOption { - return generate.WithSystemDiskEncryption(cfg) -} - -// WithRoles specifies user roles. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithRoles instead. -func WithRoles(roles role.Set) GenOption { - return generate.WithRoles(roles) -} - -// WithClusterDiscovery enables cluster discovery feature. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithClusterDiscovery instead. -func WithClusterDiscovery(enabled bool) GenOption { - return generate.WithClusterDiscovery(enabled) -} - -// WithSysctls merges list of sysctls with new values. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithSysctls instead. -func WithSysctls(params map[string]string) GenOption { - return generate.WithSysctls(params) -} - -// WithSecrets reads secrets from a provided file. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.WithSecrets instead. -func WithSecrets(file string) GenOption { - return func(o *generate.Options) error { - bundle, err := secrets.LoadBundle(file) - if err != nil { - return err - } - - return generate.WithSecretsBundle(bundle)(o) - } -} - -// GenOptions describes generate parameters. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.GenOptions instead. -type GenOptions = generate.Options - -// DefaultGenOptions returns default options. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.DefaultGenOptions instead. -func DefaultGenOptions() GenOptions { - return generate.DefaultOptions() -} diff --git a/pkg/machinery/config/types/v1alpha1/generate/talosconfig.go b/pkg/machinery/config/types/v1alpha1/generate/talosconfig.go deleted file mode 100644 index 87b24d6473..0000000000 --- a/pkg/machinery/config/types/v1alpha1/generate/talosconfig.go +++ /dev/null @@ -1,16 +0,0 @@ -// 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 generate - -import ( - clientconfig "github.com/siderolabs/talos/pkg/machinery/client/config" -) - -// Talosconfig returns the talos admin Talos config. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/generate.Talosconfig instead. -func Talosconfig(in *Input, opts ...GenOption) (*clientconfig.Config, error) { - return in.Talosconfig() -} diff --git a/pkg/machinery/config/types/v1alpha1/machine/machine.go b/pkg/machinery/config/types/v1alpha1/machine/machine.go deleted file mode 100644 index 2bdc495948..0000000000 --- a/pkg/machinery/config/types/v1alpha1/machine/machine.go +++ /dev/null @@ -1,13 +0,0 @@ -// 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 machine defines common machine type. -package machine - -import "github.com/siderolabs/talos/pkg/machinery/config/machine" - -// Type represents a machine type. -// -// Deprecated: use github.com/siderolabs/talos/pkg/machinery/config/machine.Type instead. -type Type = machine.Type