From dc35e6fc725e60fa00536adb0c8644e56488c46e Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 17 Jun 2020 17:34:43 +0000 Subject: [PATCH] Rename 'BareMetal' to 'ExistingInfra' Also standardise the import name 'existinginfrav1' --- cmd/controller/main.go | 4 +- cmd/wksctl/main.go | 4 +- ...er.weave.works_existinginfraclusters.yaml} | 10 +-- ...r.weave.works_existinginframachiness.yaml} | 10 +-- docs/cluster.md | 6 +- .../controller/manifests/yaml/02_rbac.yaml | 8 +- .../controller/wksctl/cluster_controller.go | 12 +-- .../controller/wksctl/machine_controller.go | 38 +++++----- pkg/apis/wksprovider/machine/os/os.go | 28 +++---- pkg/cluster/machine/machine.go | 22 +++--- pkg/cluster/machine/machine_test.go | 44 +++++------ pkg/cluster/machine/machines_manifest.go | 6 +- pkg/{baremetal => existinginfra}/doc.go | 2 +- .../v1alpha3/doc.go | 0 .../v1alpha3/register.go | 8 +- .../v1alpha3/types.go | 30 ++++---- .../v1alpha3/zz_generated.deepcopy.go | 76 +++++++++---------- pkg/plan/recipe/install_plans.go | 4 +- pkg/plan/runners/ssh/ssh.go | 4 +- pkg/specs/parse_test.go | 21 ++--- pkg/specs/specs.go | 22 +++--- pkg/specs/validation.go | 14 ++-- pkg/specs/validation_test.go | 32 ++++---- pkg/utilities/manifest/manifest.go | 6 +- pkg/utilities/manifest/manifest_test.go | 16 ++-- .../integration/container/multimaster_test.go | 20 ++--- test/integration/test/apply_test.go | 22 +++--- test/integration/test/assets/cluster.yaml | 4 +- 28 files changed, 237 insertions(+), 236 deletions(-) rename config/crd/{cluster.weave.works_baremetalclusters.yaml => cluster.weave.works_existinginfraclusters.yaml} (96%) rename config/crd/{cluster.weave.works_baremetalmachines.yaml => cluster.weave.works_existinginframachiness.yaml} (92%) rename pkg/{baremetal => existinginfra}/doc.go (73%) rename pkg/{baremetal => existinginfra}/v1alpha3/doc.go (100%) rename pkg/{baremetal => existinginfra}/v1alpha3/register.go (87%) rename pkg/{baremetal => existinginfra}/v1alpha3/types.go (82%) rename pkg/{baremetal => existinginfra}/v1alpha3/zz_generated.deepcopy.go (80%) diff --git a/cmd/controller/main.go b/cmd/controller/main.go index 22317c3b..153ba5fd 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -8,8 +8,8 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" wks "github.com/weaveworks/wksctl/pkg/apis/wksprovider/controller/wksctl" - baremetalv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" machineutil "github.com/weaveworks/wksctl/pkg/cluster/machine" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "k8s.io/client-go/kubernetes" clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" "sigs.k8s.io/controller-runtime/pkg/client" @@ -91,7 +91,7 @@ func run(cmd *cobra.Command, args []string) { } log.Info("registering scheme for all resources") - if err := baremetalv1.AddToScheme(mgr.GetScheme()); err != nil { + if err := existinginfrav1.AddToScheme(mgr.GetScheme()); err != nil { log.Fatal(err) } if err := clusterv1.AddToScheme(mgr.GetScheme()); err != nil { diff --git a/cmd/wksctl/main.go b/cmd/wksctl/main.go index 761b78e9..901bfc90 100644 --- a/cmd/wksctl/main.go +++ b/cmd/wksctl/main.go @@ -20,7 +20,7 @@ import ( "github.com/weaveworks/wksctl/cmd/wksctl/registrysynccommands" "github.com/weaveworks/wksctl/cmd/wksctl/version" "github.com/weaveworks/wksctl/cmd/wksctl/zshcompletions" - baremetalv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" v "github.com/weaveworks/wksctl/pkg/version" ) @@ -48,7 +48,7 @@ func main() { if err := clusterv1.AddToScheme(scheme.Scheme); err != nil { log.Fatal(err) } - if err := baremetalv1.AddToScheme(scheme.Scheme); err != nil { + if err := existinginfrav1.AddToScheme(scheme.Scheme); err != nil { log.Fatal(err) } diff --git a/config/crd/cluster.weave.works_baremetalclusters.yaml b/config/crd/cluster.weave.works_existinginfraclusters.yaml similarity index 96% rename from config/crd/cluster.weave.works_baremetalclusters.yaml rename to config/crd/cluster.weave.works_existinginfraclusters.yaml index 6dbb0480..bf8396a6 100644 --- a/config/crd/cluster.weave.works_baremetalclusters.yaml +++ b/config/crd/cluster.weave.works_existinginfraclusters.yaml @@ -6,16 +6,16 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.3.0 creationTimestamp: null - name: baremetalclusters.cluster.weave.works + name: existinginfraclusters.cluster.weave.works labels: cluster.x-k8s.io/v1alpha3: v1alpha3 spec: group: cluster.weave.works names: - kind: BareMetalCluster - listKind: BareMetalClusterList - plural: baremetalclusters - singular: baremetalcluster + kind: ExistingInfraCluster + listKind: ExistingInfraClusterList + plural: existinginfraclusters + singular: existinginfracluster scope: Namespaced validation: openAPIV3Schema: diff --git a/config/crd/cluster.weave.works_baremetalmachines.yaml b/config/crd/cluster.weave.works_existinginframachiness.yaml similarity index 92% rename from config/crd/cluster.weave.works_baremetalmachines.yaml rename to config/crd/cluster.weave.works_existinginframachiness.yaml index 15a731d1..d33bbc82 100644 --- a/config/crd/cluster.weave.works_baremetalmachines.yaml +++ b/config/crd/cluster.weave.works_existinginframachiness.yaml @@ -6,16 +6,16 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.3.0 creationTimestamp: null - name: baremetalmachines.cluster.weave.works + name: existinginframachines.cluster.weave.works labels: cluster.x-k8s.io/v1alpha3: v1alpha3 spec: group: cluster.weave.works names: - kind: BareMetalMachine - listKind: BareMetalMachineList - plural: baremetalmachines - singular: baremetalmachine + kind: ExistingInfraMachine + listKind: ExistingInfraMachineList + plural: existinginframachines + singular: existinginframachine scope: Namespaced validation: openAPIV3Schema: diff --git a/docs/cluster.md b/docs/cluster.md index 1b4f8c4e..e580bce2 100644 --- a/docs/cluster.md +++ b/docs/cluster.md @@ -2,7 +2,7 @@ Here's an example of the cluster definition. It is spread across two objects: a `Cluster` which is defined by Kubernetes ClusterAPI and a -`BareMetalCluster` defined by Weaveworks. Here, both objects have the +`ExistingInfraCluster` defined by Weaveworks. Here, both objects have the same name `example`, and the field `infrastructureRef` points from one to the other. @@ -20,11 +20,11 @@ spec: serviceDomain: cluster.local infrastructureRef: apiVersion: cluster.weave.works/v1alpha3 - kind: BareMetalCluster + kind: ExistingInfraCluster name: example --- apiVersion: cluster.weave.works/v1alpha3 -kind: BareMetalCluster +kind: ExistingInfraCluster metadata: name: example spec: diff --git a/pkg/apis/wksprovider/controller/manifests/yaml/02_rbac.yaml b/pkg/apis/wksprovider/controller/manifests/yaml/02_rbac.yaml index 9af31c88..ba5ae57b 100644 --- a/pkg/apis/wksprovider/controller/manifests/yaml/02_rbac.yaml +++ b/pkg/apis/wksprovider/controller/manifests/yaml/02_rbac.yaml @@ -19,10 +19,10 @@ rules: - apiGroups: - cluster.weave.works resources: - - baremetalclusters - - baremetalclusters/status - - baremetalmachines - - baremetalmachines/status + - existinginfraclusters + - existinginfraclusters/status + - existinginframachines + - existinginframachines/status verbs: - get - list diff --git a/pkg/apis/wksprovider/controller/wksctl/cluster_controller.go b/pkg/apis/wksprovider/controller/wksctl/cluster_controller.go index c5fea5f9..4f2b3393 100644 --- a/pkg/apis/wksprovider/controller/wksctl/cluster_controller.go +++ b/pkg/apis/wksprovider/controller/wksctl/cluster_controller.go @@ -5,7 +5,7 @@ import ( "errors" log "github.com/sirupsen/logrus" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" corev1 "k8s.io/api/core/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" @@ -30,7 +30,7 @@ func (a *ClusterReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr e contextLog := log.WithField("name", req.NamespacedName) // request only contains the name of the object, so fetch it from the api-server - bmc := &baremetalspecv1.BareMetalCluster{} + bmc := &existinginfrav1.ExistingInfraCluster{} err := a.client.Get(ctx, req.NamespacedName, bmc) if err != nil { if apierrs.IsNotFound(err) { // isn't there; give in @@ -51,7 +51,7 @@ func (a *ClusterReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr e contextLog = contextLog.WithField("cluster", cluster.Name) if util.IsPaused(cluster, bmc) { - contextLog.Info("BareMetalCluster or linked Cluster is marked as paused. Won't reconcile") + contextLog.Info("ExistingInfraCluster or linked Cluster is marked as paused. Won't reconcile") return ctrl.Result{}, nil } @@ -61,10 +61,10 @@ func (a *ClusterReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr e return ctrl.Result{}, err } - // Attempt to Patch the BareMetalMachine object and status after each reconciliation. + // Attempt to Patch the ExistingInfraMachine object and status after each reconciliation. defer func() { if err := patchHelper.Patch(ctx, bmc); err != nil { - contextLog.Errorf("failed to patch BareMetalCluster: %v", err) + contextLog.Errorf("failed to patch ExistingInfraCluster: %v", err) if reterr == nil { reterr = err } @@ -85,7 +85,7 @@ func (a *ClusterReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr e func (r *ClusterReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error { controller, err := ctrl.NewControllerManagedBy(mgr). WithOptions(options). - For(&baremetalspecv1.BareMetalCluster{}). + For(&existinginfrav1.ExistingInfraCluster{}). WithEventFilter(pausedPredicates()). Build(r) diff --git a/pkg/apis/wksprovider/controller/wksctl/machine_controller.go b/pkg/apis/wksprovider/controller/wksctl/machine_controller.go index 0763b306..0121683e 100644 --- a/pkg/apis/wksprovider/controller/wksctl/machine_controller.go +++ b/pkg/apis/wksprovider/controller/wksctl/machine_controller.go @@ -14,8 +14,8 @@ import ( log "github.com/sirupsen/logrus" "github.com/weaveworks/wksctl/pkg/apis/wksprovider/machine/config" "github.com/weaveworks/wksctl/pkg/apis/wksprovider/machine/os" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" machineutil "github.com/weaveworks/wksctl/pkg/cluster/machine" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "github.com/weaveworks/wksctl/pkg/kubernetes/drain" "github.com/weaveworks/wksctl/pkg/plan" "github.com/weaveworks/wksctl/pkg/plan/recipe" @@ -70,7 +70,7 @@ func (r *MachineController) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr e contextLog := log.WithField("name", req.NamespacedName) // request only contains the name of the object, so fetch it from the api-server - bmm := &baremetalspecv1.BareMetalMachine{} + bmm := &existinginfrav1.ExistingInfraMachine{} err := r.client.Get(ctx, req.NamespacedName, bmm) if err != nil { if apierrs.IsNotFound(err) { // isn't there; give in @@ -98,22 +98,22 @@ func (r *MachineController) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr e } if util.IsPaused(cluster, bmm) { - contextLog.Info("BareMetalMachine or linked Cluster is marked as paused. Won't reconcile") + contextLog.Info("ExistingInfraMachine or linked Cluster is marked as paused. Won't reconcile") return ctrl.Result{}, nil } contextLog = contextLog.WithField("cluster", cluster.Name) - // Now go from the Cluster to the BareMetalCluster + // Now go from the Cluster to the ExistingInfraCluster if cluster.Spec.InfrastructureRef == nil || cluster.Spec.InfrastructureRef.Name == "" { contextLog.Info("Cluster is missing infrastructureRef") return ctrl.Result{}, nil } - bmc := &baremetalspecv1.BareMetalCluster{} + bmc := &existinginfrav1.ExistingInfraCluster{} if err := r.client.Get(ctx, client.ObjectKey{ Namespace: bmm.Namespace, Name: cluster.Spec.InfrastructureRef.Name, }, bmc); err != nil { - contextLog.Info("BareMetalCluster is not available yet") + contextLog.Info("ExistingInfraCluster is not available yet") return ctrl.Result{}, nil } @@ -122,10 +122,10 @@ func (r *MachineController) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr e if err != nil { return ctrl.Result{}, err } - // Attempt to Patch the BareMetalMachine object and status after each reconciliation. + // Attempt to Patch the ExistingInfraMachine object and status after each reconciliation. defer func() { if err := patchHelper.Patch(ctx, bmm); err != nil { - contextLog.Errorf("failed to patch BareMetalMachine: %v", err) + contextLog.Errorf("failed to patch ExistingInfraMachine: %v", err) if reterr == nil { reterr = err } @@ -148,7 +148,7 @@ func (r *MachineController) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr e return ctrl.Result{}, err } -func (a *MachineController) create(ctx context.Context, installer *os.OS, c *baremetalspecv1.BareMetalCluster, machine *clusterv1.Machine, bmm *baremetalspecv1.BareMetalMachine) error { +func (a *MachineController) create(ctx context.Context, installer *os.OS, c *existinginfrav1.ExistingInfraCluster, machine *clusterv1.Machine, bmm *existinginfrav1.ExistingInfraMachine) error { contextLog := log.WithFields(log.Fields{"machine": machine.Name, "cluster": c.Name}) contextLog.Info("creating machine...") @@ -180,7 +180,7 @@ func (a *MachineController) create(ctx context.Context, installer *os.OS, c *bar return nil } -func (a *MachineController) connectTo(ctx context.Context, c *baremetalspecv1.BareMetalCluster, m *baremetalspecv1.BareMetalMachine) (*os.OS, io.Closer, error) { +func (a *MachineController) connectTo(ctx context.Context, c *existinginfrav1.ExistingInfraCluster, m *existinginfrav1.ExistingInfraMachine) (*os.OS, io.Closer, error) { sshKey, err := a.sshKey(ctx) if err != nil { return nil, nil, gerrors.Wrap(err, "failed to read SSH key") @@ -315,7 +315,7 @@ func (a *MachineController) installNewBootstrapToken(ctx context.Context, ns str } // Delete the machine. If no error is returned, it is assumed that all dependent resources have been cleaned up. -func (a *MachineController) delete(ctx context.Context, c *baremetalspecv1.BareMetalCluster, machine *clusterv1.Machine, bmm *baremetalspecv1.BareMetalMachine) error { +func (a *MachineController) delete(ctx context.Context, c *existinginfrav1.ExistingInfraCluster, machine *clusterv1.Machine, bmm *existinginfrav1.ExistingInfraMachine) error { contextLog := log.WithFields(log.Fields{"machine": machine.Name, "cluster": c.Name}) contextLog.Info("deleting machine ...") @@ -356,7 +356,7 @@ func (a *MachineController) delete(ctx context.Context, c *baremetalspecv1.BareM } // Update the machine to the provided definition. -func (a *MachineController) update(ctx context.Context, c *baremetalspecv1.BareMetalCluster, machine *clusterv1.Machine, bmm *baremetalspecv1.BareMetalMachine) error { +func (a *MachineController) update(ctx context.Context, c *existinginfrav1.ExistingInfraCluster, machine *clusterv1.Machine, bmm *existinginfrav1.ExistingInfraMachine) error { contextLog := log.WithFields(log.Fields{"machine": machine.Name, "cluster": c.Name}) contextLog.Info("updating machine...") installer, closer, err := a.connectTo(ctx, c, bmm) @@ -531,7 +531,7 @@ func (a *MachineController) performActualUpdate( machine *clusterv1.Machine, node *corev1.Node, nodePlan *plan.Plan, - cluster *baremetalspecv1.BareMetalCluster) error { + cluster *existinginfrav1.ExistingInfraCluster) error { if err := drain.Drain(node, a.clientSet, drain.Params{ Force: true, DeleteLocalData: true, @@ -548,7 +548,7 @@ func (a *MachineController) performActualUpdate( return nil } -func (a *MachineController) getNodePlan(ctx context.Context, provider *baremetalspecv1.BareMetalCluster, machine *clusterv1.Machine, machineAddress string, installer *os.OS) (*plan.Plan, error) { +func (a *MachineController) getNodePlan(ctx context.Context, provider *existinginfrav1.ExistingInfraCluster, machine *clusterv1.Machine, machineAddress string, installer *os.OS) (*plan.Plan, error) { namespace := a.controllerNamespace secrets, err := a.kubeadmJoinSecrets(ctx) if err != nil { @@ -641,7 +641,7 @@ func (a *MachineController) getAuthSecrets(ctx context.Context, authConfigMap *v return authSecrets, nil } -func (a *MachineController) getProviderConfigMaps(ctx context.Context, provider *baremetalspecv1.BareMetalCluster) (map[string]*v1.ConfigMap, error) { +func (a *MachineController) getProviderConfigMaps(ctx context.Context, provider *existinginfrav1.ExistingInfraCluster) (map[string]*v1.ConfigMap, error) { fileSpecs := provider.Spec.OS.Files client := a.clientSet.CoreV1().ConfigMaps(a.controllerNamespace) configMaps := map[string]*v1.ConfigMap{} @@ -990,18 +990,18 @@ func (a *MachineController) recordEvent(object runtime.Object, eventType, reason } } -func (a *MachineController) getMachineAddress(m *baremetalspecv1.BareMetalMachine) string { +func (a *MachineController) getMachineAddress(m *existinginfrav1.ExistingInfraMachine) string { return m.Spec.Private.Address } func (a *MachineController) SetupWithManager(mgr ctrl.Manager, options controller.Options) error { controller, err := ctrl.NewControllerManagedBy(mgr). WithOptions(options). - For(&baremetalspecv1.BareMetalMachine{}). + For(&existinginfrav1.ExistingInfraMachine{}). Watches( &source.Kind{Type: &clusterv1.Machine{}}, &handler.EnqueueRequestsFromMapFunc{ - ToRequests: util.MachineToInfrastructureMapFunc(baremetalspecv1.SchemeGroupVersion.WithKind("BareMetalMachine")), + ToRequests: util.MachineToInfrastructureMapFunc(existinginfrav1.SchemeGroupVersion.WithKind("ExistingInfraMachine")), }, ). // TODO: add watch to reconcile all machines that need it @@ -1024,7 +1024,7 @@ type MachineControllerParams struct { Verbose bool } -// NewMachineController creates a new baremetal machine reconciler. +// NewMachineController creates a new existinginfra machine reconciler. func NewMachineController(params MachineControllerParams) (*MachineController, error) { return &MachineController{ client: params.Client, diff --git a/pkg/apis/wksprovider/machine/os/os.go b/pkg/apis/wksprovider/machine/os/os.go index 54c2470e..c8c324f9 100644 --- a/pkg/apis/wksprovider/machine/os/os.go +++ b/pkg/apis/wksprovider/machine/os/os.go @@ -22,8 +22,8 @@ import ( "github.com/weaveworks/wksctl/pkg/apis/wksprovider/controller/manifests" "github.com/weaveworks/wksctl/pkg/apis/wksprovider/machine/config" "github.com/weaveworks/wksctl/pkg/apis/wksprovider/machine/crds" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" "github.com/weaveworks/wksctl/pkg/cluster/machine" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "github.com/weaveworks/wksctl/pkg/plan" "github.com/weaveworks/wksctl/pkg/plan/recipe" "github.com/weaveworks/wksctl/pkg/plan/resource" @@ -292,7 +292,7 @@ func (o OS) CreateSeedNodeSetupPlan(params SeedNodeParams) (*plan.Plan, error) { // TODO(damien): Add a CNI section in cluster.yaml once we support more than one CNI plugin. const cni = "weave-net" - cniAdddon := baremetalspecv1.Addon{Name: cni} + cniAdddon := existinginfrav1.Addon{Name: cni} // we use the namespace defined in addon-namespace map to make weave-net run in kube-system // as weave-net requires to run in the kube-system namespace *only*. @@ -537,7 +537,7 @@ func storeIfNotEmpty(vals map[string]string, key, value string) { } } -func getAPIServerArgs(providerSpec *baremetalspecv1.BareMetalClusterSpec, pemSecretResources map[string]*secretResourceSpec) map[string]string { +func getAPIServerArgs(providerSpec *existinginfrav1.ExistingInfraClusterSpec, pemSecretResources map[string]*secretResourceSpec) map[string]string { result := map[string]string{} authnResourceSpec := pemSecretResources["authentication"] if authnResourceSpec != nil { @@ -574,7 +574,7 @@ func addClusterAPICRDs(b *plan.Builder) ([]string, error) { return crdIDs, nil } -func (o OS) seedNodeSetupPlan(params SeedNodeParams, providerSpec *baremetalspecv1.BareMetalClusterSpec, providerConfigMaps map[string]*v1.ConfigMap, authConfigMap *v1.ConfigMap, secretResources map[string]*secretResourceSpec, kubernetesVersion, kubernetesNamespace string) (*plan.Plan, error) { +func (o OS) seedNodeSetupPlan(params SeedNodeParams, providerSpec *existinginfrav1.ExistingInfraClusterSpec, providerConfigMaps map[string]*v1.ConfigMap, authConfigMap *v1.ConfigMap, secretResources map[string]*secretResourceSpec, kubernetesVersion, kubernetesNamespace string) (*plan.Plan, error) { secrets := map[string]resource.SecretData{} for k, v := range secretResources { secrets[k] = v.decrypted @@ -612,7 +612,7 @@ func (o OS) applySeedNodePlan(p *plan.Plan) error { return err } -func createConfigFileResourcesFromFiles(providerSpec *baremetalspecv1.BareMetalClusterSpec, configDir, namespace string) (map[string][]byte, map[string]*v1.ConfigMap, []*resource.File, error) { +func createConfigFileResourcesFromFiles(providerSpec *existinginfrav1.ExistingInfraClusterSpec, configDir, namespace string) (map[string][]byte, map[string]*v1.ConfigMap, []*resource.File, error) { fileSpecs := providerSpec.OS.Files configMapManifests, err := getConfigMapManifests(fileSpecs, configDir, namespace) if err != nil { @@ -633,7 +633,7 @@ func createConfigFileResourcesFromFiles(providerSpec *baremetalspecv1.BareMetalC return configMapManifests, configMaps, resources, nil } -func createConfigFileResourcesFromConfigMaps(fileSpecs []baremetalspecv1.FileSpec, configMaps map[string]*v1.ConfigMap) ([]*resource.File, error) { +func createConfigFileResourcesFromConfigMaps(fileSpecs []existinginfrav1.FileSpec, configMaps map[string]*v1.ConfigMap) ([]*resource.File, error) { fileResources := make([]*resource.File, len(fileSpecs)) for idx, file := range fileSpecs { source := &file.Source @@ -655,7 +655,7 @@ func createConfigFileResourcesFromConfigMaps(fileSpecs []baremetalspecv1.FileSpe return fileResources, nil } -func getConfigMapManifests(fileSpecs []baremetalspecv1.FileSpec, configDir, namespace string) (map[string][]byte, error) { +func getConfigMapManifests(fileSpecs []existinginfrav1.FileSpec, configDir, namespace string) (map[string][]byte, error) { configMapManifests := map[string][]byte{} for _, fileSpec := range fileSpecs { mapName := fileSpec.Source.ConfigMap @@ -707,7 +707,7 @@ type secretResourceSpec struct { // directory, decrypts it using the GitHub deploy key, creates file // resources for .pem files stored in the secret, and creates a SealedSecret resource // for them that can be used by the machine actuator -func processPemFilesIfAny(builder *plan.Builder, providerSpec *baremetalspecv1.BareMetalClusterSpec, configDir string, ns, privateKeyPath, certPath string) (map[string]*secretResourceSpec, *v1.ConfigMap, []byte, error) { +func processPemFilesIfAny(builder *plan.Builder, providerSpec *existinginfrav1.ExistingInfraClusterSpec, configDir string, ns, privateKeyPath, certPath string) (map[string]*secretResourceSpec, *v1.ConfigMap, []byte, error) { if err := checkPemValues(providerSpec, privateKeyPath, certPath); err != nil { return nil, nil, nil, err } @@ -780,7 +780,7 @@ func getPrivateKey(privateKeyPath string) (*rsa.PrivateKey, error) { return privateKey, nil } -func checkPemValues(providerSpec *baremetalspecv1.BareMetalClusterSpec, privateKeyPath, certPath string) error { +func checkPemValues(providerSpec *existinginfrav1.ExistingInfraClusterSpec, privateKeyPath, certPath string) error { if privateKeyPath == "" || certPath == "" { if providerSpec.Authentication != nil || providerSpec.Authorization != nil { return errors.New("Encryption keys not specified; cannot process authentication and authorization specifications.") @@ -930,7 +930,7 @@ func (o OS) configureFlux(b *plan.Builder, params SeedNodeParams) error { if err != nil { return errors.Wrap(err, "failed to process the git deploy key") } - fluxAddon := baremetalspecv1.Addon{Name: "flux", Params: gitParams} + fluxAddon := existinginfrav1.Addon{Name: "flux", Params: gitParams} manifests, err := buildAddon(fluxAddon, params.ImageRepository, params.ClusterManifestPath, params.GetAddonNamespace("flux")) if err != nil { return errors.Wrap(err, "failed to generate manifests for flux") @@ -1107,8 +1107,8 @@ type NodeParams struct { CertificateKey string // kubeadm's --certificate-key KubeletConfig config.KubeletConfig KubernetesVersion string - CRI baremetalspecv1.ContainerRuntime - ConfigFileSpecs []baremetalspecv1.FileSpec + CRI existinginfrav1.ContainerRuntime + ConfigFileSpecs []existinginfrav1.FileSpec ProviderConfigMaps map[string]*v1.ConfigMap AuthConfigMap *v1.ConfigMap Secrets map[string]resource.SecretData // kind of auth -> names/values as-in v1.Secret @@ -1259,7 +1259,7 @@ func fetchOSID(sshClient *ssh.Client) (string, error) { } // parseCluster converts the manifest file into a Cluster -func parseCluster(clusterManifestPath string) (bmc *baremetalspecv1.BareMetalCluster, err error) { +func parseCluster(clusterManifestPath string) (bmc *existinginfrav1.ExistingInfraCluster, err error) { f, err := os.Open(clusterManifestPath) if err != nil { return nil, err @@ -1303,7 +1303,7 @@ func parseAddons(ClusterManifestPath, namespace string, addonNamespaces map[stri return ret, nil } -func buildAddon(addonDefn baremetalspecv1.Addon, imageRepository string, ClusterManifestPath, namespace string) ([][]byte, error) { +func buildAddon(addonDefn existinginfrav1.Addon, imageRepository string, ClusterManifestPath, namespace string) ([][]byte, error) { log.WithField("addon", addonDefn.Name).Debug("building addon") // Generate the addon manifest. addon, err := addons.Get(addonDefn.Name) diff --git a/pkg/cluster/machine/machine.go b/pkg/cluster/machine/machine.go index 143d67a7..d87f980f 100644 --- a/pkg/cluster/machine/machine.go +++ b/pkg/cluster/machine/machine.go @@ -9,7 +9,7 @@ import ( "github.com/blang/semver" "github.com/pkg/errors" log "github.com/sirupsen/logrus" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "github.com/weaveworks/wksctl/pkg/kubernetes" "github.com/weaveworks/wksctl/pkg/utilities/manifest" "k8s.io/apimachinery/pkg/util/validation/field" @@ -40,8 +40,8 @@ func IsNode(machine *clusterv1.Machine) bool { // FirstMaster scans the provided array of machines and return the first // one which is a "Master" or nil if none. -// Machines and BareMetalMachines must be in the same order -func FirstMaster(machines []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine) (*clusterv1.Machine, *baremetalspecv1.BareMetalMachine) { +// Machines and ExistingInfraMachines must be in the same order +func FirstMaster(machines []*clusterv1.Machine, bl []*existinginfrav1.ExistingInfraMachine) (*clusterv1.Machine, *existinginfrav1.ExistingInfraMachine) { // TODO: validate size and ordering of lists for i, machine := range machines { if IsMaster(machine) { @@ -52,7 +52,7 @@ func FirstMaster(machines []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalM } // ParseManifest parses the provided machines manifest file. -func ParseManifest(file string) (ml []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine, err error) { +func ParseManifest(file string) (ml []*clusterv1.Machine, bl []*existinginfrav1.ExistingInfraMachine, err error) { f, err := os.Open(file) if err != nil { return nil, nil, err @@ -65,7 +65,7 @@ func ParseManifest(file string) (ml []*clusterv1.Machine, bl []*baremetalspecv1. } // Parse parses the provided machines io.Reader. -func Parse(r io.ReadCloser) (ml []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine, err error) { +func Parse(r io.ReadCloser) (ml []*clusterv1.Machine, bl []*existinginfrav1.ExistingInfraMachine, err error) { decoder := clusteryaml.NewYAMLDecoder(r) defer decoder.Close() @@ -80,7 +80,7 @@ func Parse(r io.ReadCloser) (ml []*clusterv1.Machine, bl []*baremetalspecv1.Bare switch v := obj.(type) { case *clusterv1.Machine: ml = append(ml, v) - case *baremetalspecv1.BareMetalMachine: + case *existinginfrav1.ExistingInfraMachine: bl = append(bl, v) default: return nil, nil, fmt.Errorf("unexpected type %T", v) @@ -91,7 +91,7 @@ func Parse(r io.ReadCloser) (ml []*clusterv1.Machine, bl []*baremetalspecv1.Bare } // Validate validates the provided machines. -func Validate(machines []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine) field.ErrorList { +func Validate(machines []*clusterv1.Machine, bl []*existinginfrav1.ExistingInfraMachine) field.ErrorList { if len(machines) == 0 { // Some other validations crash on empty list return field.ErrorList{nonFieldError("no machines")} } @@ -109,7 +109,7 @@ func Validate(machines []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMach // Check 1-1 correspondence between lists if len(machines) != len(bl) { - errors = append(errors, nonFieldError("mismatch: %d Machines and %d BareMetalMachines", len(machines), len(bl))) + errors = append(errors, nonFieldError("mismatch: %d Machines and %d ExistingInfraMachines", len(machines), len(bl))) } else { // TODO: what if the user has a mixture of our machines and someone else's? for i, m := range machines { @@ -270,7 +270,7 @@ func Populate(machines []*clusterv1.Machine) { // InvalidMachinesHandler encapsulates logic to apply in case of an invalid // machines manifest being provided. -type InvalidMachinesHandler = func(machines []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine, errors field.ErrorList) ([]*clusterv1.Machine, []*baremetalspecv1.BareMetalMachine, error) +type InvalidMachinesHandler = func(machines []*clusterv1.Machine, bl []*existinginfrav1.ExistingInfraMachine, errors field.ErrorList) ([]*clusterv1.Machine, []*existinginfrav1.ExistingInfraMachine, error) // NoOpInvalidMachinesHandler does nothing when an invalid machines manifest // is being provided. @@ -280,7 +280,7 @@ var NoOpInvalidMachinesHandler = func(machines []*clusterv1.Machine, errors fiel // ParseAndDefaultAndValidate parses the provided manifest, validates it and // defaults values where possible. -func ParseAndDefaultAndValidate(machinesManifestPath string, errorsHandler InvalidMachinesHandler) ([]*clusterv1.Machine, []*baremetalspecv1.BareMetalMachine, error) { +func ParseAndDefaultAndValidate(machinesManifestPath string, errorsHandler InvalidMachinesHandler) ([]*clusterv1.Machine, []*existinginfrav1.ExistingInfraMachine, error) { machines, bl, err := ParseManifest(machinesManifestPath) if err != nil { return nil, nil, err @@ -305,7 +305,7 @@ func GetKubernetesVersionFromManifest(machinesManifestPath string) (string, stri // GetKubernetesVersionFromMasterIn reads the version of the Kubernetes control // plane from the provided machines. If no version is configured, the default // Kubernetes version will be returned. -func GetKubernetesVersionFromMasterIn(machines []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine) (string, string, error) { +func GetKubernetesVersionFromMasterIn(machines []*clusterv1.Machine, bl []*existinginfrav1.ExistingInfraMachine) (string, string, error) { // Ensures all machines have the same version (either specified or empty): errs := Validate(machines, bl) if len(errs) > 0 { diff --git a/pkg/cluster/machine/machine_test.go b/pkg/cluster/machine/machine_test.go index 83ac4582..cbf8976a 100644 --- a/pkg/cluster/machine/machine_test.go +++ b/pkg/cluster/machine/machine_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" "github.com/weaveworks/wksctl/pkg/cluster/machine" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "github.com/weaveworks/wksctl/pkg/kubernetes" "github.com/weaveworks/wksctl/pkg/utilities/manifest" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -44,7 +44,7 @@ func TestIsNode(t *testing.T) { } func TestFirstMasterInPointersArray(t *testing.T) { - bl := []*baremetalspecv1.BareMetalMachine{nil, nil} + bl := []*existinginfrav1.ExistingInfraMachine{nil, nil} v1, _ := machine.FirstMaster([]*clusterv1.Machine{ &worker, &master, @@ -67,12 +67,12 @@ const machinesValid = ` set: master spec: infrastructureRef: - kind: BareMetalMachine + kind: ExistingInfraMachine name: master-0 version: "1.16.2" --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: master-0 spec: @@ -86,12 +86,12 @@ const machinesValid = ` set: node spec: infrastructureRef: - kind: BareMetalMachine + kind: ExistingInfraMachine name: node-0 version: "1.16.2" --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: node-0 spec: @@ -112,12 +112,12 @@ const machinesInconsistentKubeVersion = ` set: master spec: infrastructureRef: - kind: BareMetalMachine + kind: ExistingInfraMachine name: master-0 version: "1.16.4" --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: master-0 spec: @@ -131,12 +131,12 @@ const machinesInconsistentKubeVersion = ` set: node spec: infrastructureRef: - kind: BareMetalMachine + kind: ExistingInfraMachine name: node-0 version: "1.16.3" --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: node-0 spec: @@ -152,12 +152,12 @@ const machinesUnsupportedKubernetesVersion = ` apiVersion: "cluster.x-k8s.io/v1 set: master spec: infrastructureRef: - kind: BareMetalMachine + kind: ExistingInfraMachine name: master-0 version: "1.13.2" --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: master-0 spec: @@ -171,12 +171,12 @@ const machinesUnsupportedKubernetesVersion = ` apiVersion: "cluster.x-k8s.io/v1 set: node spec: infrastructureRef: - kind: BareMetalMachine + kind: ExistingInfraMachine name: node-0 version: "1.13.2" --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: node-0 spec: @@ -192,19 +192,19 @@ const machinesNoGodNoMaster = ` set: node spec: infrastructureRef: - kind: BareMetalMachine + kind: ExistingInfraMachine name: node-0 version: "1.16.2" --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: node-0 spec: address: "172.17.8.102" ` -func machinesFromString(t *testing.T, s string) ([]*clusterv1.Machine, []*baremetalspecv1.BareMetalMachine) { +func machinesFromString(t *testing.T, s string) ([]*clusterv1.Machine, []*existinginfrav1.ExistingInfraMachine) { r := ioutil.NopCloser(strings.NewReader(s)) machines, bml, err := machine.Parse(r) assert.NoError(t, err) @@ -222,7 +222,7 @@ func fieldsInError(errors field.ErrorList) []string { func TestValidateMachines(t *testing.T) { assert.NoError(t, clusterv1.AddToScheme(scheme.Scheme)) - assert.NoError(t, baremetalspecv1.AddToScheme(scheme.Scheme)) + assert.NoError(t, existinginfrav1.AddToScheme(scheme.Scheme)) tests := []struct { input string @@ -264,11 +264,11 @@ const machinesWithoutVersions = ` set: master spec: infrastructureRef: - kind: BareMetalMachine + kind: ExistingInfraMachine name: master-0 --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: master-0 spec: @@ -282,11 +282,11 @@ const machinesWithoutVersions = ` set: node spec: infrastructureRef: - kind: BareMetalMachine + kind: ExistingInfraMachine name: node-0 --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: node-0 spec: diff --git a/pkg/cluster/machine/machines_manifest.go b/pkg/cluster/machine/machines_manifest.go index 0da83a71..a75d8d47 100644 --- a/pkg/cluster/machine/machines_manifest.go +++ b/pkg/cluster/machine/machines_manifest.go @@ -7,7 +7,7 @@ import ( "github.com/pkg/errors" "github.com/thanhpk/randstr" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" "sigs.k8s.io/yaml" ) @@ -39,7 +39,7 @@ func UpdateWithGeneratedNames(r io.ReadCloser) (string, error) { namesTaken := readNames(machines) for i := range machines { if machines[i].ObjectMeta.GenerateName != "" { - // TODO: update BareMetalMachine list here too + // TODO: update ExistingInfraMachine list here too if len(bml) > i && bml[i].ObjectMeta.GenerateName != "" { return "", errors.New("generateName not implemented for v1alpha3") } @@ -55,7 +55,7 @@ func UpdateWithGeneratedNames(r io.ReadCloser) (string, error) { return buf.String(), err } -func WriteMachines(w io.Writer, machines []*clusterv1.Machine, bml []*baremetalspecv1.BareMetalMachine) error { +func WriteMachines(w io.Writer, machines []*clusterv1.Machine, bml []*existinginfrav1.ExistingInfraMachine) error { // Need to do this in a loop because we want a stream not an array for _, machine := range machines { manifestBytes, err := yaml.Marshal(machine) diff --git a/pkg/baremetal/doc.go b/pkg/existinginfra/doc.go similarity index 73% rename from pkg/baremetal/doc.go rename to pkg/existinginfra/doc.go index 5088d88f..b672226e 100644 --- a/pkg/baremetal/doc.go +++ b/pkg/existinginfra/doc.go @@ -2,4 +2,4 @@ // +k8s:openapi-gen=true // +k8s:defaulter-gen=TypeMeta -package baremetalproviderspec +package existinginfraproviderspec diff --git a/pkg/baremetal/v1alpha3/doc.go b/pkg/existinginfra/v1alpha3/doc.go similarity index 100% rename from pkg/baremetal/v1alpha3/doc.go rename to pkg/existinginfra/v1alpha3/doc.go diff --git a/pkg/baremetal/v1alpha3/register.go b/pkg/existinginfra/v1alpha3/register.go similarity index 87% rename from pkg/baremetal/v1alpha3/register.go rename to pkg/existinginfra/v1alpha3/register.go index 00947eb2..0f56eb58 100644 --- a/pkg/baremetal/v1alpha3/register.go +++ b/pkg/existinginfra/v1alpha3/register.go @@ -22,10 +22,10 @@ func init() { func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, - &BareMetalMachine{}, - &BareMetalMachineList{}, - &BareMetalCluster{}, - &BareMetalClusterList{}, + &ExistingInfraMachine{}, + &ExistingInfraMachineList{}, + &ExistingInfraCluster{}, + &ExistingInfraClusterList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/pkg/baremetal/v1alpha3/types.go b/pkg/existinginfra/v1alpha3/types.go similarity index 82% rename from pkg/baremetal/v1alpha3/types.go rename to pkg/existinginfra/v1alpha3/types.go index 4f6520fa..7a89dbcf 100644 --- a/pkg/baremetal/v1alpha3/types.go +++ b/pkg/existinginfra/v1alpha3/types.go @@ -8,15 +8,15 @@ import ( // +groupName=cluster.weave.works // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type BareMetalCluster struct { +type ExistingInfraCluster struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec BareMetalClusterSpec `json:"spec,omitempty"` - Status BareMetalClusterStatus `json:"status,omitempty"` + Spec ExistingInfraClusterSpec `json:"spec,omitempty"` + Status ExistingInfraClusterStatus `json:"status,omitempty"` } -type BareMetalClusterSpec struct { +type ExistingInfraClusterSpec struct { User string `json:"user"` DeprecatedSSHKeyPath string `json:"sshKeyPath"` HTTPProxy string `json:"httpProxy,omitempty"` @@ -38,15 +38,15 @@ type BareMetalClusterSpec struct { CloudProvider string `json:"cloudProvider,omitempty"` } -type BareMetalClusterStatus struct { +type ExistingInfraClusterStatus struct { Ready bool `json:"ready"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type BareMetalClusterList struct { +type ExistingInfraClusterList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []BareMetalCluster `json:"items"` + Items []ExistingInfraCluster `json:"items"` } type OSConfig struct { @@ -102,30 +102,30 @@ type Addon struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type BareMetalMachine struct { +type ExistingInfraMachine struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec BareMetalMachineSpec `json:"spec,omitempty"` - Status BareMetalMachineStatus `json:"status,omitempty"` + Spec ExistingInfraMachineSpec `json:"spec,omitempty"` + Status ExistingInfraMachineStatus `json:"status,omitempty"` } -type BareMetalMachineSpec struct { +type ExistingInfraMachineSpec struct { Private EndPoint `json:"private,omitempty"` Public EndPoint `json:"public,omitempty"` ProviderID string `json:"providerID,omitempty"` } -type BareMetalMachineStatus struct { +type ExistingInfraMachineStatus struct { Ready bool `json:"ready"` } -// BareMetalMachineList contains a list of Machine +// ExistingInfraMachineList contains a list of Machine // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type BareMetalMachineList struct { +type ExistingInfraMachineList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []BareMetalMachine `json:"items"` + Items []ExistingInfraMachine `json:"items"` } // EndPoint groups the details required to establish a connection. diff --git a/pkg/baremetal/v1alpha3/zz_generated.deepcopy.go b/pkg/existinginfra/v1alpha3/zz_generated.deepcopy.go similarity index 80% rename from pkg/baremetal/v1alpha3/zz_generated.deepcopy.go rename to pkg/existinginfra/v1alpha3/zz_generated.deepcopy.go index 57f17087..642285ee 100644 --- a/pkg/baremetal/v1alpha3/zz_generated.deepcopy.go +++ b/pkg/existinginfra/v1alpha3/zz_generated.deepcopy.go @@ -91,7 +91,7 @@ func (in *AuthorizationWebhook) DeepCopy() *AuthorizationWebhook { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BareMetalCluster) DeepCopyInto(out *BareMetalCluster) { +func (in *ExistingInfraCluster) DeepCopyInto(out *ExistingInfraCluster) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) @@ -99,18 +99,18 @@ func (in *BareMetalCluster) DeepCopyInto(out *BareMetalCluster) { out.Status = in.Status } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BareMetalCluster. -func (in *BareMetalCluster) DeepCopy() *BareMetalCluster { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExistingInfraCluster. +func (in *ExistingInfraCluster) DeepCopy() *ExistingInfraCluster { if in == nil { return nil } - out := new(BareMetalCluster) + out := new(ExistingInfraCluster) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BareMetalCluster) DeepCopyObject() runtime.Object { +func (in *ExistingInfraCluster) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -118,31 +118,31 @@ func (in *BareMetalCluster) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BareMetalClusterList) DeepCopyInto(out *BareMetalClusterList) { +func (in *ExistingInfraClusterList) DeepCopyInto(out *ExistingInfraClusterList) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]BareMetalCluster, len(*in)) + *out = make([]ExistingInfraCluster, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BareMetalClusterList. -func (in *BareMetalClusterList) DeepCopy() *BareMetalClusterList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExistingInfraClusterList. +func (in *ExistingInfraClusterList) DeepCopy() *ExistingInfraClusterList { if in == nil { return nil } - out := new(BareMetalClusterList) + out := new(ExistingInfraClusterList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BareMetalClusterList) DeepCopyObject() runtime.Object { +func (in *ExistingInfraClusterList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -150,7 +150,7 @@ func (in *BareMetalClusterList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BareMetalClusterSpec) DeepCopyInto(out *BareMetalClusterSpec) { +func (in *ExistingInfraClusterSpec) DeepCopyInto(out *ExistingInfraClusterSpec) { *out = *in if in.Authentication != nil { in, out := &in.Authentication, &out.Authentication @@ -179,33 +179,33 @@ func (in *BareMetalClusterSpec) DeepCopyInto(out *BareMetalClusterSpec) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BareMetalClusterSpec. -func (in *BareMetalClusterSpec) DeepCopy() *BareMetalClusterSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExistingInfraClusterSpec. +func (in *ExistingInfraClusterSpec) DeepCopy() *ExistingInfraClusterSpec { if in == nil { return nil } - out := new(BareMetalClusterSpec) + out := new(ExistingInfraClusterSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BareMetalClusterStatus) DeepCopyInto(out *BareMetalClusterStatus) { +func (in *ExistingInfraClusterStatus) DeepCopyInto(out *ExistingInfraClusterStatus) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BareMetalClusterStatus. -func (in *BareMetalClusterStatus) DeepCopy() *BareMetalClusterStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExistingInfraClusterStatus. +func (in *ExistingInfraClusterStatus) DeepCopy() *ExistingInfraClusterStatus { if in == nil { return nil } - out := new(BareMetalClusterStatus) + out := new(ExistingInfraClusterStatus) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BareMetalMachine) DeepCopyInto(out *BareMetalMachine) { +func (in *ExistingInfraMachine) DeepCopyInto(out *ExistingInfraMachine) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) @@ -213,18 +213,18 @@ func (in *BareMetalMachine) DeepCopyInto(out *BareMetalMachine) { out.Status = in.Status } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BareMetalMachine. -func (in *BareMetalMachine) DeepCopy() *BareMetalMachine { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExistingInfraMachine. +func (in *ExistingInfraMachine) DeepCopy() *ExistingInfraMachine { if in == nil { return nil } - out := new(BareMetalMachine) + out := new(ExistingInfraMachine) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BareMetalMachine) DeepCopyObject() runtime.Object { +func (in *ExistingInfraMachine) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -232,31 +232,31 @@ func (in *BareMetalMachine) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BareMetalMachineList) DeepCopyInto(out *BareMetalMachineList) { +func (in *ExistingInfraMachineList) DeepCopyInto(out *ExistingInfraMachineList) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]BareMetalMachine, len(*in)) + *out = make([]ExistingInfraMachine, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BareMetalMachineList. -func (in *BareMetalMachineList) DeepCopy() *BareMetalMachineList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExistingInfraMachineList. +func (in *ExistingInfraMachineList) DeepCopy() *ExistingInfraMachineList { if in == nil { return nil } - out := new(BareMetalMachineList) + out := new(ExistingInfraMachineList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BareMetalMachineList) DeepCopyObject() runtime.Object { +func (in *ExistingInfraMachineList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -264,33 +264,33 @@ func (in *BareMetalMachineList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BareMetalMachineSpec) DeepCopyInto(out *BareMetalMachineSpec) { +func (in *ExistingInfraMachineSpec) DeepCopyInto(out *ExistingInfraMachineSpec) { *out = *in out.Private = in.Private out.Public = in.Public } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BareMetalMachineSpec. -func (in *BareMetalMachineSpec) DeepCopy() *BareMetalMachineSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExistingInfraMachineSpec. +func (in *ExistingInfraMachineSpec) DeepCopy() *ExistingInfraMachineSpec { if in == nil { return nil } - out := new(BareMetalMachineSpec) + out := new(ExistingInfraMachineSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BareMetalMachineStatus) DeepCopyInto(out *BareMetalMachineStatus) { +func (in *ExistingInfraMachineStatus) DeepCopyInto(out *ExistingInfraMachineStatus) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BareMetalMachineStatus. -func (in *BareMetalMachineStatus) DeepCopy() *BareMetalMachineStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExistingInfraMachineStatus. +func (in *ExistingInfraMachineStatus) DeepCopy() *ExistingInfraMachineStatus { if in == nil { return nil } - out := new(BareMetalMachineStatus) + out := new(ExistingInfraMachineStatus) in.DeepCopyInto(out) return out } diff --git a/pkg/plan/recipe/install_plans.go b/pkg/plan/recipe/install_plans.go index e41092f3..6b19d4b7 100644 --- a/pkg/plan/recipe/install_plans.go +++ b/pkg/plan/recipe/install_plans.go @@ -7,7 +7,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/weaveworks/wksctl/pkg/apis/wksprovider/controller/manifests" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "github.com/weaveworks/wksctl/pkg/plan" "github.com/weaveworks/wksctl/pkg/plan/resource" "github.com/weaveworks/wksctl/pkg/utilities/envcfg" @@ -79,7 +79,7 @@ func BuildConfigMapPlan(manifests map[string][]byte, namespace string) plan.Reso } // BuildCRIPlan creates a plan for installing a CRI. Currently, Docker is the only supported CRI -func BuildCRIPlan(criSpec *baremetalspecv1.ContainerRuntime, cfg *envcfg.EnvSpecificConfig, pkgType resource.PkgType) plan.Resource { +func BuildCRIPlan(criSpec *existinginfrav1.ContainerRuntime, cfg *envcfg.EnvSpecificConfig, pkgType resource.PkgType) plan.Resource { b := plan.NewBuilder() // Docker Repo diff --git a/pkg/plan/runners/ssh/ssh.go b/pkg/plan/runners/ssh/ssh.go index 439925f4..c93512eb 100644 --- a/pkg/plan/runners/ssh/ssh.go +++ b/pkg/plan/runners/ssh/ssh.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" log "github.com/sirupsen/logrus" - "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" + "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "github.com/weaveworks/wksctl/pkg/plan" sshutil "github.com/weaveworks/wksctl/pkg/utilities/ssh" "golang.org/x/crypto/ssh" @@ -36,7 +36,7 @@ var _ plan.Runner = &Client{} const tcp = "tcp" -func NewClientForMachine(m *v1alpha3.BareMetalMachineSpec, user, keyPath string, printOutputs bool) (*Client, error) { +func NewClientForMachine(m *v1alpha3.ExistingInfraMachineSpec, user, keyPath string, printOutputs bool) (*Client, error) { ip := m.Public.Address port := m.Public.Port return NewClient(ClientParams{ diff --git a/pkg/specs/parse_test.go b/pkg/specs/parse_test.go index ba08c628..970e4c6b 100644 --- a/pkg/specs/parse_test.go +++ b/pkg/specs/parse_test.go @@ -2,25 +2,26 @@ package specs import ( "fmt" - "github.com/stretchr/testify/assert" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" "io/ioutil" - "k8s.io/client-go/kubernetes/scheme" - clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" "strings" "testing" + + "github.com/stretchr/testify/assert" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" + "k8s.io/client-go/kubernetes/scheme" + clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" ) const clusterMissingClusterDefinition = ` apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: user: "vagrant" ` -const clusterMissingBareMetalClusterDefinition = ` +const clusterMissingExistingInfraClusterDefinition = ` apiVersion: "cluster.x-k8s.io/v1alpha3" kind: Cluster metadata: @@ -32,7 +33,7 @@ spec: pods: cidrBlocks: ["192.168.0.0/16"] infrastructureRef: - kind: BareMetalCluster + kind: ExistingInfraCluster name: example ` @@ -48,10 +49,10 @@ func parseConfig(s string) (err error) { func TestParseCluster(t *testing.T) { assert.NoError(t, clusterv1.AddToScheme(scheme.Scheme)) - assert.NoError(t, baremetalspecv1.AddToScheme(scheme.Scheme)) - assert.NoError(t, parseConfig(mergeObjects(clusterMissingBareMetalClusterDefinition, clusterMissingClusterDefinition))) + assert.NoError(t, existinginfrav1.AddToScheme(scheme.Scheme)) + assert.NoError(t, parseConfig(mergeObjects(clusterMissingExistingInfraClusterDefinition, clusterMissingClusterDefinition))) // Verify that the objects individually don't result in a successful parse assert.Error(t, parseConfig(clusterMissingClusterDefinition)) - assert.Error(t, parseConfig(clusterMissingBareMetalClusterDefinition)) + assert.Error(t, parseConfig(clusterMissingExistingInfraClusterDefinition)) } diff --git a/pkg/specs/specs.go b/pkg/specs/specs.go index e0662767..33a69f00 100644 --- a/pkg/specs/specs.go +++ b/pkg/specs/specs.go @@ -6,8 +6,8 @@ import ( "github.com/pkg/errors" log "github.com/sirupsen/logrus" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" "github.com/weaveworks/wksctl/pkg/cluster/machine" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "github.com/weaveworks/wksctl/pkg/utilities" "k8s.io/apimachinery/pkg/util/validation/field" clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" @@ -20,8 +20,8 @@ import ( type Specs struct { Cluster *clusterv1.Cluster - ClusterSpec *baremetalspecv1.BareMetalClusterSpec - MasterSpec *baremetalspecv1.BareMetalMachineSpec + ClusterSpec *existinginfrav1.ExistingInfraClusterSpec + MasterSpec *existinginfrav1.ExistingInfraMachineSpec machineCount int masterCount int } @@ -36,7 +36,7 @@ func NewFromPaths(clusterManifestPath, machinesManifestPath string) *Specs { } // Get a "Specs" object that can create an SSHClient (and retrieve useful nested fields) -func New(cluster *clusterv1.Cluster, bmc *baremetalspecv1.BareMetalCluster, machines []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine) *Specs { +func New(cluster *clusterv1.Cluster, bmc *existinginfrav1.ExistingInfraCluster, machines []*clusterv1.Machine, bl []*existinginfrav1.ExistingInfraMachine) *Specs { _, master := machine.FirstMaster(machines, bl) if master == nil { log.Fatal("No master provided in manifest.") @@ -57,7 +57,7 @@ func New(cluster *clusterv1.Cluster, bmc *baremetalspecv1.BareMetalCluster, mach } } -func parseManifests(clusterManifestPath, machinesManifestPath string) (*clusterv1.Cluster, *baremetalspecv1.BareMetalCluster, []*clusterv1.Machine, []*baremetalspecv1.BareMetalMachine, error) { +func parseManifests(clusterManifestPath, machinesManifestPath string) (*clusterv1.Cluster, *existinginfrav1.ExistingInfraCluster, []*clusterv1.Machine, []*existinginfrav1.ExistingInfraMachine, error) { cluster, bmc, err := ParseClusterManifest(clusterManifestPath) if err != nil { return nil, nil, nil, nil, err @@ -71,7 +71,7 @@ func parseManifests(clusterManifestPath, machinesManifestPath string) (*clusterv "%s failed validation, use --skip-validation to force the operation", clusterManifestPath) } - errorsHandler := func(machines []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine, errors field.ErrorList) ([]*clusterv1.Machine, []*baremetalspecv1.BareMetalMachine, error) { + errorsHandler := func(machines []*clusterv1.Machine, bl []*existinginfrav1.ExistingInfraMachine, errors field.ErrorList) ([]*clusterv1.Machine, []*existinginfrav1.ExistingInfraMachine, error) { if len(errors) > 0 { utilities.PrintErrors(errors) return nil, nil, apierrors.InvalidMachineConfiguration( @@ -89,7 +89,7 @@ func parseManifests(clusterManifestPath, machinesManifestPath string) (*clusterv } // ParseCluster converts the manifest file into a Cluster -func ParseCluster(r io.ReadCloser) (cluster *clusterv1.Cluster, bmc *baremetalspecv1.BareMetalCluster, err error) { +func ParseCluster(r io.ReadCloser) (cluster *clusterv1.Cluster, bmc *existinginfrav1.ExistingInfraCluster, err error) { decoder := clusteryaml.NewYAMLDecoder(r) defer decoder.Close() @@ -104,7 +104,7 @@ func ParseCluster(r io.ReadCloser) (cluster *clusterv1.Cluster, bmc *baremetalsp switch v := obj.(type) { case *clusterv1.Cluster: cluster = v - case *baremetalspecv1.BareMetalCluster: + case *existinginfrav1.ExistingInfraCluster: bmc = v default: return nil, nil, errors.Errorf("unexpected type %T", v) @@ -116,13 +116,13 @@ func ParseCluster(r io.ReadCloser) (cluster *clusterv1.Cluster, bmc *baremetalsp } if bmc == nil { - return nil, nil, errors.New("parsed cluster manifest lacks BareMetalCluster definition") + return nil, nil, errors.New("parsed cluster manifest lacks ExistingInfraCluster definition") } return } -func ParseClusterManifest(file string) (*clusterv1.Cluster, *baremetalspecv1.BareMetalCluster, error) { +func ParseClusterManifest(file string) (*clusterv1.Cluster, *existinginfrav1.ExistingInfraCluster, error) { f, err := os.Open(file) if err != nil { return nil, nil, err @@ -132,7 +132,7 @@ func ParseClusterManifest(file string) (*clusterv1.Cluster, *baremetalspecv1.Bar return ParseCluster(f) } -func TranslateServerArgumentsToStringMap(args []baremetalspecv1.ServerArgument) map[string]string { +func TranslateServerArgumentsToStringMap(args []existinginfrav1.ServerArgument) map[string]string { result := map[string]string{} for _, arg := range args { result[arg.Name] = arg.Value diff --git a/pkg/specs/validation.go b/pkg/specs/validation.go index 896f083a..7b1dbc87 100644 --- a/pkg/specs/validation.go +++ b/pkg/specs/validation.go @@ -7,7 +7,7 @@ import ( "github.com/weaveworks/launcher/pkg/kubectl" "github.com/weaveworks/wksctl/pkg/addons" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "k8s.io/apimachinery/pkg/util/validation/field" clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" ) @@ -28,7 +28,7 @@ func populateNetwork(cluster *clusterv1.Cluster) { } } -type clusterValidationFunc func(*clusterv1.Cluster, *baremetalspecv1.BareMetalClusterSpec, string) field.ErrorList +type clusterValidationFunc func(*clusterv1.Cluster, *existinginfrav1.ExistingInfraClusterSpec, string) field.ErrorList func isValidCIDR(s string) (*net.IPNet, error) { ip, cidr, err := net.ParseCIDR(s) @@ -46,7 +46,7 @@ func networksIntersect(n1, n2 *net.IPNet) bool { return n2.Contains(n1.IP) || n1.Contains(n2.IP) } -func validateCIDRBlocks(cluster *clusterv1.Cluster, _ *baremetalspecv1.BareMetalClusterSpec, manifestPath string) field.ErrorList { +func validateCIDRBlocks(cluster *clusterv1.Cluster, _ *existinginfrav1.ExistingInfraClusterSpec, manifestPath string) field.ErrorList { var errors field.ErrorList const ( services = 0 @@ -104,7 +104,7 @@ func validateCIDRBlocks(cluster *clusterv1.Cluster, _ *baremetalspecv1.BareMetal return field.ErrorList{} } -func validateServiceDomain(cluster *clusterv1.Cluster, _ *baremetalspecv1.BareMetalClusterSpec, manifestPath string) field.ErrorList { +func validateServiceDomain(cluster *clusterv1.Cluster, _ *existinginfrav1.ExistingInfraClusterSpec, manifestPath string) field.ErrorList { f := cluster.Spec.ClusterNetwork.ServiceDomain if f != "cluster.local" { return field.ErrorList{ @@ -117,7 +117,7 @@ func validateServiceDomain(cluster *clusterv1.Cluster, _ *baremetalspecv1.BareMe return field.ErrorList{} } -func validateSSHKeyEmpty(_ *clusterv1.Cluster, spec *baremetalspecv1.BareMetalClusterSpec, manifestPath string) field.ErrorList { +func validateSSHKeyEmpty(_ *clusterv1.Cluster, spec *existinginfrav1.ExistingInfraClusterSpec, manifestPath string) field.ErrorList { if spec.DeprecatedSSHKeyPath != "" { return field.ErrorList{ field.Invalid( @@ -136,7 +136,7 @@ func addonPath(i int, args ...string) *field.Path { return clusterProviderPath(allArgs...) } -func validateAddons(_ *clusterv1.Cluster, spec *baremetalspecv1.BareMetalClusterSpec, manifestPath string) field.ErrorList { +func validateAddons(_ *clusterv1.Cluster, spec *existinginfrav1.ExistingInfraClusterSpec, manifestPath string) field.ErrorList { // Addons require kubectl for their manifests to be applied. kubectl := kubectl.LocalClient{} if len(spec.Addons) > 0 && !kubectl.IsPresent() { @@ -178,7 +178,7 @@ func populateCluster(cluster *clusterv1.Cluster) { populateNetwork(cluster) } -func validateCluster(cluster *clusterv1.Cluster, bmc *baremetalspecv1.BareMetalCluster, manifestPath string) field.ErrorList { +func validateCluster(cluster *clusterv1.Cluster, bmc *existinginfrav1.ExistingInfraCluster, manifestPath string) field.ErrorList { var errors field.ErrorList for _, f := range []clusterValidationFunc{ diff --git a/pkg/specs/validation_test.go b/pkg/specs/validation_test.go index 3b201024..82809222 100644 --- a/pkg/specs/validation_test.go +++ b/pkg/specs/validation_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/client-go/kubernetes/scheme" clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" @@ -24,11 +24,11 @@ spec: pods: cidrBlocks: ["192.168.0.0/16"] infrastructureRef: - kind: BareMetalCluster + kind: ExistingInfraCluster name: example --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -47,11 +47,11 @@ spec: pods: cidrBlocks: ["192.168.0.0/16"] infrastructureRef: - kind: BareMetalCluster + kind: ExistingInfraCluster name: example --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -73,7 +73,7 @@ spec: serviceDomain: "foo.bar" --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -93,7 +93,7 @@ spec: cidrBlocks: ["192.168.0.0/72"] --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -113,7 +113,7 @@ spec: cidrBlocks: ["10.96.0.0/16"] --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -134,7 +134,7 @@ spec: cidrBlocks: ["192.168.0.0/16"] --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -159,7 +159,7 @@ spec: cidrBlocks: ["192.168.0.0/16"] --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -184,7 +184,7 @@ spec: cidrBlocks: ["192.168.0.0/16"] --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -212,7 +212,7 @@ spec: cidrBlocks: ["192.168.0.0/16"] --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -240,7 +240,7 @@ spec: cidrBlocks: ["192.168.0.0/16"] --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -263,7 +263,7 @@ spec: cidrBlocks: ["192.168.0.0/16"] --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -274,7 +274,7 @@ spec: keytab: /foo ` -func clusterFromString(t *testing.T, s string) (*clusterv1.Cluster, *baremetalspecv1.BareMetalCluster) { +func clusterFromString(t *testing.T, s string) (*clusterv1.Cluster, *existinginfrav1.ExistingInfraCluster) { r := ioutil.NopCloser(strings.NewReader(s)) cluster, bmc, err := ParseCluster(r) assert.NoError(t, err) @@ -292,7 +292,7 @@ func fieldsInError(errors field.ErrorList) []string { func TestValidateCluster(t *testing.T) { assert.NoError(t, clusterv1.AddToScheme(scheme.Scheme)) - assert.NoError(t, baremetalspecv1.AddToScheme(scheme.Scheme)) + assert.NoError(t, existinginfrav1.AddToScheme(scheme.Scheme)) tests := []struct { input string errors []string diff --git a/pkg/utilities/manifest/manifest.go b/pkg/utilities/manifest/manifest.go index 495de054..8bb15fb9 100644 --- a/pkg/utilities/manifest/manifest.go +++ b/pkg/utilities/manifest/manifest.go @@ -8,7 +8,7 @@ import ( "strings" "github.com/pkg/errors" - bmv1alpha3 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" + bmv1alpha3 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "gopkg.in/oleiade/reflections.v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -41,8 +41,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &clusterv1alpha3.MachineList{}, ) scheme.AddKnownTypes(bmv1alpha3.SchemeGroupVersion, - &bmv1alpha3.BareMetalCluster{}, - &bmv1alpha3.BareMetalMachine{}, + &bmv1alpha3.ExistingInfraCluster{}, + &bmv1alpha3.ExistingInfraMachine{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/pkg/utilities/manifest/manifest_test.go b/pkg/utilities/manifest/manifest_test.go index 8f44f32b..c7ce7c41 100644 --- a/pkg/utilities/manifest/manifest_test.go +++ b/pkg/utilities/manifest/manifest_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - baremetalv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" "k8s.io/client-go/kubernetes/scheme" clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" ) @@ -144,11 +144,11 @@ spec: cidrBlocks: [192.168.0.0/16] serviceDomain: cluster.local infrastructureRef: - kind: BareMetalCluster + kind: ExistingInfraCluster name: example --- apiVersion: cluster.weave.works/v1alpha3 -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: example spec: @@ -182,11 +182,11 @@ spec: set: master spec: infrastructureRef: - kind: BareMetalMachine + kind: ExistingInfraMachine name: master-0 --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: master-0 spec: @@ -205,11 +205,11 @@ spec: set: node spec: infrastructureRef: - kind: BareMetalMachine + kind: ExistingInfraMachine name: node-0 --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: node-0 spec: @@ -251,7 +251,7 @@ var nstests = []struct { func TestManifestWithNamespace(t *testing.T) { assert.NoError(t, clusterv1.AddToScheme(scheme.Scheme)) - assert.NoError(t, baremetalv1.AddToScheme(scheme.Scheme)) + assert.NoError(t, existinginfrav1.AddToScheme(scheme.Scheme)) for _, tt := range nstests { t.Run(tt.name, func(t *testing.T) { fname := createFile(t, tt.content, tt.fileName).Name() diff --git a/test/integration/container/multimaster_test.go b/test/integration/container/multimaster_test.go index 60975cf1..0abf8061 100644 --- a/test/integration/container/multimaster_test.go +++ b/test/integration/container/multimaster_test.go @@ -32,11 +32,11 @@ spec: serviceDomain: cluster.local infrastructureRef: apiVersion: "cluster.weave.works/v1alpha3" - kind: BareMetalCluster + kind: ExistingInfraCluster name: test-multimaster --- apiVersion: cluster.weave.works/v1alpha3 -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: test-multimaster spec: @@ -82,12 +82,12 @@ const machinesYAML = ` clusterName: test-multimaster infrastructureRef: apiVersion: "cluster.weave.works/v1alpha3" - kind: BareMetalMachine + kind: ExistingInfraMachine name: master-1 bootstrap: {} --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: master-1 spec: @@ -108,12 +108,12 @@ const machinesYAML = ` clusterName: test-multimaster infrastructureRef: apiVersion: "cluster.weave.works/v1alpha3" - kind: BareMetalMachine + kind: ExistingInfraMachine name: master-2 bootstrap: {} --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: master-2 spec: @@ -134,12 +134,12 @@ const machinesYAML = ` clusterName: test-multimaster infrastructureRef: apiVersion: "cluster.weave.works/v1alpha3" - kind: BareMetalMachine + kind: ExistingInfraMachine name: master-3 bootstrap: {} --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: master-3 spec: @@ -160,12 +160,12 @@ const machinesYAML = ` clusterName: test-multimaster infrastructureRef: apiVersion: "cluster.weave.works/v1alpha3" - kind: BareMetalMachine + kind: ExistingInfraMachine name: worker-1 bootstrap: {} --- apiVersion: "cluster.weave.works/v1alpha3" - kind: "BareMetalMachine" + kind: "ExistingInfraMachine" metadata: name: worker-1 spec: diff --git a/test/integration/test/apply_test.go b/test/integration/test/apply_test.go index 41c7a9ae..9e82ded0 100644 --- a/test/integration/test/apply_test.go +++ b/test/integration/test/apply_test.go @@ -19,7 +19,7 @@ import ( "github.com/weaveworks/wksctl/pkg/plan/runners/ssh" "github.com/weaveworks/wksctl/pkg/specs" - baremetalspecv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" + existinginfrav1 "github.com/weaveworks/wksctl/pkg/existinginfra/v1alpha3" spawn "github.com/weaveworks/wksctl/test/integration/spawn" "github.com/stretchr/testify/assert" @@ -67,22 +67,22 @@ func setLabel(role role) string { } } -func appendMachine(t *testing.T, ordinal int, ml *[]*clusterv1.Machine, bl *[]*baremetalspecv1.BareMetalMachine, clusterName, role role, publicIP, privateIP string) { +func appendMachine(t *testing.T, ordinal int, ml *[]*clusterv1.Machine, bl *[]*existinginfrav1.ExistingInfraMachine, clusterName, role role, publicIP, privateIP string) { name := generateName(role, ordinal) - spec := baremetalspecv1.BareMetalMachine{ + spec := existinginfrav1.ExistingInfraMachine{ TypeMeta: metav1.TypeMeta{ APIVersion: "cluster.weave.works/v1alpha3", - Kind: "BareMetalMachine", + Kind: "ExistingInfraMachine", }, ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Spec: baremetalspecv1.BareMetalMachineSpec{ - Public: baremetalspecv1.EndPoint{ + Spec: existinginfrav1.ExistingInfraMachineSpec{ + Public: existinginfrav1.EndPoint{ Address: publicIP, Port: 22, }, - Private: baremetalspecv1.EndPoint{ + Private: existinginfrav1.EndPoint{ Address: privateIP, Port: 22, }}, @@ -122,7 +122,7 @@ func appendMachine(t *testing.T, ordinal int, ml *[]*clusterv1.Machine, bl *[]*b // numMachines is the number of machines to use. It can be less than the number // of provisionned terraform machines. -1 means use all machines setup by // terraform. The minimum number of machines to use is 2. -func makeMachinesFromTerraform(t *testing.T, clusterName string, terraform *terraformOutput, numMachines int) (ml []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine) { +func makeMachinesFromTerraform(t *testing.T, clusterName string, terraform *terraformOutput, numMachines int) (ml []*clusterv1.Machine, bl []*existinginfrav1.ExistingInfraMachine) { publicIPs := terraform.stringArrayVar(keyPublicIPs) privateIPs := terraform.stringArrayVar(keyPrivateIPs) assert.True(t, len(publicIPs) >= 2) // One master and at least one node @@ -149,7 +149,7 @@ func makeMachinesFromTerraform(t *testing.T, clusterName string, terraform *terr return ml, bl } -func writeYamlManifests(t *testing.T, path string, machines []*clusterv1.Machine, bml []*baremetalspecv1.BareMetalMachine) { +func writeYamlManifests(t *testing.T, path string, machines []*clusterv1.Machine, bml []*existinginfrav1.ExistingInfraMachine) { var buf bytes.Buffer err := machine.WriteMachines(&buf, machines, bml) assert.NoError(t, err) @@ -183,7 +183,7 @@ func setKubernetesVersion(l []*clusterv1.Machine, version string) { } } -func parseClusterManifest(t *testing.T, file string) (*clusterv1.Cluster, *baremetalspecv1.BareMetalCluster) { +func parseClusterManifest(t *testing.T, file string) (*clusterv1.Cluster, *existinginfrav1.ExistingInfraCluster) { f, err := os.Open(file) assert.NoError(t, err) cluster, bmCluster, err := specs.ParseCluster(f) @@ -364,7 +364,7 @@ func writeTmpFile(runner *ssh.Client, inputFilename, outputFilename string) erro func TestApply(t *testing.T) { assert.NoError(t, clusterv1.AddToScheme(scheme.Scheme)) - assert.NoError(t, baremetalspecv1.AddToScheme(scheme.Scheme)) + assert.NoError(t, existinginfrav1.AddToScheme(scheme.Scheme)) clusterManifestPath := configPath("cluster.yaml") _, c := parseClusterManifest(t, clusterManifestPath) diff --git a/test/integration/test/assets/cluster.yaml b/test/integration/test/assets/cluster.yaml index cd9cc94c..b8498e97 100644 --- a/test/integration/test/assets/cluster.yaml +++ b/test/integration/test/assets/cluster.yaml @@ -11,11 +11,11 @@ spec: serviceDomain: "cluster.local" infrastructureRef: apiVersion: "cluster.weave.works/v1alpha3" - kind: BareMetalCluster + kind: ExistingInfraCluster name: integration-tests --- apiVersion: "cluster.weave.works/v1alpha3" -kind: "BareMetalCluster" +kind: "ExistingInfraCluster" metadata: name: integration-tests spec: