From 15f67308f0bdbd52a4565deff8923d67a4c4c755 Mon Sep 17 00:00:00 2001 From: Gerard de Leeuw Date: Sat, 26 Mar 2022 17:05:38 +0100 Subject: [PATCH] chore: use consistent naming for imports Imports should be consistently named so future changes are more readable and easier to understand. Signed-off-by: Gerard de Leeuw Signed-off-by: Andrey Smirnov --- .../controllers/metalmachine_controller.go | 14 ++-- .../controllers/serverbinding_controller.go | 6 +- .../cmd/agent/main.go | 10 +-- .../controllers/environment_controller.go | 24 +++--- .../controllers/server_controller.go | 20 ++--- .../controllers/serverclass_controller.go | 28 +++---- .../controllers/suite_test.go | 6 +- .../internal/ipxe/ipxe_server.go | 48 +++++------ .../internal/metadata/metadata_server.go | 26 +++--- .../internal/power/api/api.go | 4 +- .../internal/power/factory.go | 4 +- .../internal/power/ipmi/ipmi.go | 4 +- .../internal/server/server.go | 44 +++++----- app/sidero-controller-manager/main.go | 4 +- internal/client/client.go | 8 +- sfyra/pkg/capi/cluster.go | 8 +- sfyra/pkg/capi/metalclient.go | 8 +- sfyra/pkg/loadbalancer/loadbalancer.go | 8 +- sfyra/pkg/tests/compatibility.go | 10 +-- sfyra/pkg/tests/environment.go | 12 +-- sfyra/pkg/tests/match.go | 4 +- sfyra/pkg/tests/reconcile.go | 14 ++-- sfyra/pkg/tests/reset.go | 8 +- sfyra/pkg/tests/server.go | 80 +++++++++---------- sfyra/pkg/tests/server_class.go | 34 ++++---- 25 files changed, 218 insertions(+), 218 deletions(-) diff --git a/app/caps-controller-manager/controllers/metalmachine_controller.go b/app/caps-controller-manager/controllers/metalmachine_controller.go index 8e53e3703..a6b4ce47c 100644 --- a/app/caps-controller-manager/controllers/metalmachine_controller.go +++ b/app/caps-controller-manager/controllers/metalmachine_controller.go @@ -35,7 +35,7 @@ import ( infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" "github.com/talos-systems/sidero/app/caps-controller-manager/pkg/constants" - metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" ) var ErrNoServersInServerClass = errors.New("no servers available in serverclass") @@ -265,7 +265,7 @@ func (r *MetalMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl. Complete(r) } -func (r *MetalMachineReconciler) fetchServerFromClass(ctx context.Context, logger logr.Logger, classRef *corev1.ObjectReference, metalMachine *infrav1.MetalMachine) (*metalv1alpha1.Server, error) { +func (r *MetalMachineReconciler) fetchServerFromClass(ctx context.Context, logger logr.Logger, classRef *corev1.ObjectReference, metalMachine *infrav1.MetalMachine) (*metalv1.Server, error) { // First, check if there is already existing serverBinding for this metalmachine var serverBindingList infrav1.ServerBindingList @@ -276,7 +276,7 @@ func (r *MetalMachineReconciler) fetchServerFromClass(ctx context.Context, logge for _, serverBinding := range serverBindingList.Items { if serverBinding.Spec.MetalMachineRef.Namespace == metalMachine.Namespace && serverBinding.Spec.MetalMachineRef.Name == metalMachine.Name { // found existing serverBinding for this metalMachine - var server metalv1alpha1.Server + var server metalv1.Server if err := r.Get(ctx, types.NamespacedName{Namespace: serverBinding.Namespace, Name: serverBinding.Name}, &server); err != nil { return nil, err @@ -302,7 +302,7 @@ func (r *MetalMachineReconciler) fetchServerFromClass(ctx context.Context, logge // NB: we added this loop to double check that an available server isn't "in use" because // we saw raciness between server selection and it being removed from the ServersAvailable list. for _, availServer := range serverClassResource.Status.ServersAvailable { - serverObj := &metalv1alpha1.Server{} + serverObj := &metalv1.Server{} namespacedName := types.NamespacedName{ Namespace: "", @@ -408,7 +408,7 @@ func (r *MetalMachineReconciler) patchProviderID(ctx context.Context, cluster *c } // createServerBinding updates a server to mark it as "in use" via ServerBinding resource. -func (r *MetalMachineReconciler) createServerBinding(ctx context.Context, serverClass *metalv1alpha1.ServerClass, serverObj *metalv1alpha1.Server, metalMachine *infrav1.MetalMachine) error { +func (r *MetalMachineReconciler) createServerBinding(ctx context.Context, serverClass *metalv1.ServerClass, serverObj *metalv1.Server, metalMachine *infrav1.MetalMachine) error { serverRef, err := reference.GetReference(r.Scheme, serverObj) if err != nil { return err @@ -445,8 +445,8 @@ func (r *MetalMachineReconciler) createServerBinding(ctx context.Context, server return err } -func (r *MetalMachineReconciler) fetchServerClass(ctx context.Context, classRef *corev1.ObjectReference) (*metalv1alpha1.ServerClass, error) { - serverClassResource := &metalv1alpha1.ServerClass{} +func (r *MetalMachineReconciler) fetchServerClass(ctx context.Context, classRef *corev1.ObjectReference) (*metalv1.ServerClass, error) { + serverClassResource := &metalv1.ServerClass{} namespacedName := types.NamespacedName{ Namespace: classRef.Namespace, diff --git a/app/caps-controller-manager/controllers/serverbinding_controller.go b/app/caps-controller-manager/controllers/serverbinding_controller.go index 0917bf6c2..12031b0ff 100644 --- a/app/caps-controller-manager/controllers/serverbinding_controller.go +++ b/app/caps-controller-manager/controllers/serverbinding_controller.go @@ -23,7 +23,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/source" infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" - metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" ) // ServerBindingReconciler reconciles a ServerBinding object. @@ -75,7 +75,7 @@ func (r *ServerBindingReconciler) Reconcile(ctx context.Context, req ctrl.Reques } }() - var server metalv1alpha1.Server + var server metalv1.Server err = r.Get(ctx, req.NamespacedName, &server) if err != nil { @@ -190,7 +190,7 @@ func (r *ServerBindingReconciler) reconcileTransition(ctx context.Context, logge return ctrl.Result{}, nil } - var server metalv1alpha1.Server + var server metalv1.Server if err = r.Get(ctx, req.NamespacedName, &server); err != nil { if apierrors.IsNotFound(err) { diff --git a/app/sidero-controller-manager/cmd/agent/main.go b/app/sidero-controller-manager/cmd/agent/main.go index 55ac3bd9b..5513afe6c 100644 --- a/app/sidero-controller-manager/cmd/agent/main.go +++ b/app/sidero-controller-manager/cmd/agent/main.go @@ -19,8 +19,8 @@ import ( "github.com/talos-systems/go-blockdevice/blockdevice" "github.com/talos-systems/go-blockdevice/blockdevice/util/disk" - debug "github.com/talos-systems/go-debug" - kmsg "github.com/talos-systems/go-kmsg" + "github.com/talos-systems/go-debug" + "github.com/talos-systems/go-kmsg" "github.com/talos-systems/go-procfs/procfs" "github.com/talos-systems/go-retry/retry" "github.com/talos-systems/go-smbios/smbios" @@ -30,7 +30,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/api" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/power/ipmi" "github.com/talos-systems/sidero/app/sidero-controller-manager/pkg/constants" @@ -404,7 +404,7 @@ func attemptBMCIP(ctx context.Context, client api.AgentClient, s *smbios.SMBIOS) bmcInfo := &api.BMCInfo{} // Create "open" client - bmcSpec := v1alpha1.BMC{ + bmcSpec := metalv1.BMC{ Interface: "open", } @@ -466,7 +466,7 @@ func attemptBMCUserSetup(ctx context.Context, client api.AgentClient, s *smbios. bmcInfo := &api.BMCInfo{} // Create "open" client - bmcSpec := v1alpha1.BMC{ + bmcSpec := metalv1.BMC{ Interface: "open", } diff --git a/app/sidero-controller-manager/controllers/environment_controller.go b/app/sidero-controller-manager/controllers/environment_controller.go index a42ea5814..32ea581bc 100644 --- a/app/sidero-controller-manager/controllers/environment_controller.go +++ b/app/sidero-controller-manager/controllers/environment_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" - metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/app/sidero-controller-manager/pkg/constants" ) @@ -48,7 +48,7 @@ func (r *EnvironmentReconciler) Reconcile(ctx context.Context, req ctrl.Request) //nolint:godox // TODO: We probably should use admission webhooks instead (or in additional) to prevent // unwanted edits instead of "fixing" the resource after the fact. - if req.Name == metalv1alpha1.EnvironmentDefault { + if req.Name == metalv1.EnvironmentDefault { if err := ReconcileEnvironmentDefault(ctx, r.Client, r.TalosRelease, r.APIEndpoint, r.APIPort); err != nil { return ctrl.Result{}, err } @@ -56,7 +56,7 @@ func (r *EnvironmentReconciler) Reconcile(ctx context.Context, req ctrl.Request) // do not return; re-reconcile it to update status } //nolint:wsl - var env metalv1alpha1.Environment + var env metalv1.Environment if err := r.Get(ctx, req.NamespacedName, &env); err != nil { l.Error(err, "failed fetching resource") @@ -72,7 +72,7 @@ func (r *EnvironmentReconciler) Reconcile(ctx context.Context, req ctrl.Request) } var ( - conditions = []metalv1alpha1.AssetCondition{} + conditions = []metalv1.AssetCondition{} wg sync.WaitGroup mu sync.Mutex result *multierror.Error @@ -80,7 +80,7 @@ func (r *EnvironmentReconciler) Reconcile(ctx context.Context, req ctrl.Request) for _, assetTask := range []struct { BaseName string - Asset metalv1alpha1.Asset + Asset metalv1.Asset }{ { BaseName: constants.KernelAsset, @@ -101,7 +101,7 @@ func (r *EnvironmentReconciler) Reconcile(ctx context.Context, req ctrl.Request) status = "True" } - condition := metalv1alpha1.AssetCondition{ + condition := metalv1.AssetCondition{ Asset: assetTask.Asset, Status: status, Type: "Ready", @@ -183,15 +183,15 @@ func (r *EnvironmentReconciler) Reconcile(ctx context.Context, req ctrl.Request) // ReconcileEnvironmentDefault ensures that Environment "default" exist. func ReconcileEnvironmentDefault(ctx context.Context, c client.Client, talosRelease, apiEndpoint string, apiPort uint16) error { key := types.NamespacedName{ - Name: metalv1alpha1.EnvironmentDefault, + Name: metalv1.EnvironmentDefault, } - env := metalv1alpha1.Environment{} + env := metalv1.Environment{} err := c.Get(ctx, key, &env) if apierrors.IsNotFound(err) { - env.Name = metalv1alpha1.EnvironmentDefault - env.Spec = *metalv1alpha1.EnvironmentDefaultSpec(talosRelease, apiEndpoint, apiPort) + env.Name = metalv1.EnvironmentDefault + env.Spec = *metalv1.EnvironmentDefaultSpec(talosRelease, apiEndpoint, apiPort) err = c.Create(ctx, &env) } @@ -206,11 +206,11 @@ func (r *EnvironmentReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M return ctrl.NewControllerManagedBy(mgr). WithOptions(options). - For(&metalv1alpha1.Environment{}). + For(&metalv1.Environment{}). Complete(r) } -func save(ctx context.Context, asset metalv1alpha1.Asset, file string) error { +func save(ctx context.Context, asset metalv1.Asset, file string) error { url := asset.URL if url == "" { diff --git a/app/sidero-controller-manager/controllers/server_controller.go b/app/sidero-controller-manager/controllers/server_controller.go index 9733f8283..053ebe2cf 100644 --- a/app/sidero-controller-manager/controllers/server_controller.go +++ b/app/sidero-controller-manager/controllers/server_controller.go @@ -31,7 +31,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/source" infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" - metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/power" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/power/metal" "github.com/talos-systems/sidero/app/sidero-controller-manager/pkg/constants" @@ -65,7 +65,7 @@ type ServerReconciler struct { func (r *ServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := r.Log.WithValues("server", req.NamespacedName) - s := metalv1alpha1.Server{} + s := metalv1.Server{} if err := r.APIReader.Get(ctx, req.NamespacedName, &s); err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) @@ -106,7 +106,7 @@ func (r *ServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr s.Status.Ready = ready if err := patchHelper.Patch(ctx, &s, patch.WithOwnedConditions{ - Conditions: []clusterv1.ConditionType{metalv1alpha1.ConditionPowerCycle, metalv1alpha1.ConditionPXEBooted}, + Conditions: []clusterv1.ConditionType{metalv1.ConditionPowerCycle, metalv1.ConditionPXEBooted}, }); err != nil { return result, errors.WithStack(err) } @@ -127,7 +127,7 @@ func (r *ServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr s.Status.InUse = false - conditions.Delete(&s, metalv1alpha1.ConditionPXEBooted) + conditions.Delete(&s, metalv1.ConditionPXEBooted) } else { s.Status.InUse = true s.Status.IsClean = false @@ -138,7 +138,7 @@ func (r *ServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr // Talos installation was successful, so mark the server as PXE booted. if conditions.IsTrue(serverBinding, infrav1.TalosInstalledCondition) { - conditions.MarkTrue(serverBinding, metalv1alpha1.ConditionPXEBooted) + conditions.MarkTrue(serverBinding, metalv1.ConditionPXEBooted) } } } @@ -232,9 +232,9 @@ func (r *ServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr // // we check LastTransitionTime to see if the server is in the wiping state for too long and // it's time to retry the IPMI sequence - if conditions.Has(&s, metalv1alpha1.ConditionPowerCycle) && - conditions.IsFalse(&s, metalv1alpha1.ConditionPowerCycle) && - time.Since(conditions.GetLastTransitionTime(&s, metalv1alpha1.ConditionPowerCycle).Time) < r.RebootTimeout { + if conditions.Has(&s, metalv1.ConditionPowerCycle) && + conditions.IsFalse(&s, metalv1.ConditionPowerCycle) && + time.Since(conditions.GetLastTransitionTime(&s, metalv1.ConditionPowerCycle).Time) < r.RebootTimeout { // already powercycled, reboot/heartbeat timeout not elapsed, wait more return f(false, ctrl.Result{RequeueAfter: r.RebootTimeout / 3}) } @@ -280,7 +280,7 @@ func (r *ServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr } // make sure message is updated in case condition was already set to make sure LastTransitionTime will be updated - conditions.MarkFalse(&s, metalv1alpha1.ConditionPowerCycle, "InProgress", clusterv1.ConditionSeverityInfo, fmt.Sprintf("Server power cycled for wiping at %s.", time.Now().Format(time.RFC3339))) + conditions.MarkFalse(&s, metalv1.ConditionPowerCycle, "InProgress", clusterv1.ConditionSeverityInfo, fmt.Sprintf("Server power cycled for wiping at %s.", time.Now().Format(time.RFC3339))) } // requeue to check for wipe timeout @@ -354,7 +354,7 @@ func (r *ServerReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manage return ctrl.NewControllerManagedBy(mgr). WithOptions(options). - For(&metalv1alpha1.Server{}). + For(&metalv1.Server{}). Watches( &source.Kind{Type: &infrav1.ServerBinding{}}, handler.EnqueueRequestsFromMapFunc(mapRequests), diff --git a/app/sidero-controller-manager/controllers/serverclass_controller.go b/app/sidero-controller-manager/controllers/serverclass_controller.go index f523c5dd2..47c8733da 100644 --- a/app/sidero-controller-manager/controllers/serverclass_controller.go +++ b/app/sidero-controller-manager/controllers/serverclass_controller.go @@ -20,7 +20,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" ) // ServerClassReconciler reconciles a ServerClass object. @@ -42,7 +42,7 @@ func (r *ServerClassReconciler) Reconcile(ctx context.Context, req ctrl.Request) //nolint:godox // TODO: We probably should use admission webhooks instead (or in additional) to prevent // unwanted edits instead of "fixing" the resource after the fact. - if req.Name == metalv1alpha1.ServerClassAny { + if req.Name == metalv1.ServerClassAny { if err := ReconcileServerClassAny(ctx, r.Client); err != nil { return ctrl.Result{}, err } @@ -50,7 +50,7 @@ func (r *ServerClassReconciler) Reconcile(ctx context.Context, req ctrl.Request) // do not return; re-reconcile it to update status } //nolint:wsl - sc := metalv1alpha1.ServerClass{} + sc := metalv1.ServerClass{} if err := r.Get(ctx, req.NamespacedName, &sc); err != nil { l.Error(err, "failed fetching resource") @@ -62,15 +62,15 @@ func (r *ServerClassReconciler) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, err } - sl := &metalv1alpha1.ServerList{} + sl := &metalv1.ServerList{} if err := r.List(ctx, sl); err != nil { return ctrl.Result{}, fmt.Errorf("unable to get serverclass: %w", err) } - results, err := metalv1alpha1.FilterServers(sl.Items, - metalv1alpha1.AcceptedServerFilter, - metalv1alpha1.NotCordonedServerFilter, + results, err := metalv1.FilterServers(sl.Items, + metalv1.AcceptedServerFilter, + metalv1.NotCordonedServerFilter, sc.SelectorFilter(), sc.QualifiersFilter(), ) @@ -103,15 +103,15 @@ func (r *ServerClassReconciler) Reconcile(ctx context.Context, req ctrl.Request) // ReconcileServerClassAny ensures that ServerClass "any" exist and is in desired state. func ReconcileServerClassAny(ctx context.Context, c client.Client) error { key := types.NamespacedName{ - Name: metalv1alpha1.ServerClassAny, + Name: metalv1.ServerClassAny, } - sc := metalv1alpha1.ServerClass{} + sc := metalv1.ServerClass{} err := c.Get(ctx, key, &sc) switch { case apierrors.IsNotFound(err): - sc.Name = metalv1alpha1.ServerClassAny + sc.Name = metalv1.ServerClassAny return c.Create(ctx, &sc) @@ -121,7 +121,7 @@ func ReconcileServerClassAny(ctx context.Context, c client.Client) error { return err } - sc.Spec.Qualifiers = metalv1alpha1.Qualifiers{} + sc.Spec.Qualifiers = metalv1.Qualifiers{} return patchHelper.Patch(ctx, &sc) @@ -137,7 +137,7 @@ func (r *ServerClassReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M mapRequests := func(a client.Object) []reconcile.Request { reqList := []reconcile.Request{} - scList := &metalv1alpha1.ServerClassList{} + scList := &metalv1.ServerClassList{} if err := r.List(ctx, scList); err != nil { return reqList @@ -160,9 +160,9 @@ func (r *ServerClassReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M return ctrl.NewControllerManagedBy(mgr). WithOptions(options). - For(&metalv1alpha1.ServerClass{}). + For(&metalv1.ServerClass{}). Watches( - &source.Kind{Type: &metalv1alpha1.Server{}}, + &source.Kind{Type: &metalv1.Server{}}, handler.EnqueueRequestsFromMapFunc(mapRequests), ). Complete(r) diff --git a/app/sidero-controller-manager/controllers/suite_test.go b/app/sidero-controller-manager/controllers/suite_test.go index 2a7f40d38..142d78fc1 100644 --- a/app/sidero-controller-manager/controllers/suite_test.go +++ b/app/sidero-controller-manager/controllers/suite_test.go @@ -18,7 +18,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" // +kubebuilder:scaffold:imports ) @@ -54,10 +54,10 @@ var _ = BeforeSuite(func(done Done) { Expect(err).ToNot(HaveOccurred()) Expect(cfg).ToNot(BeNil()) - err = metalv1alpha1.AddToScheme(scheme.Scheme) + err = metalv1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) - err = metalv1alpha1.AddToScheme(scheme.Scheme) + err = metalv1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) // +kubebuilder:scaffold:scheme diff --git a/app/sidero-controller-manager/internal/ipxe/ipxe_server.go b/app/sidero-controller-manager/internal/ipxe/ipxe_server.go index 8fd9e3f36..ea290f0fb 100644 --- a/app/sidero-controller-manager/internal/ipxe/ipxe_server.go +++ b/app/sidero-controller-manager/internal/ipxe/ipxe_server.go @@ -32,7 +32,7 @@ import ( "github.com/talos-systems/talos/pkg/machinery/kernel" infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" - metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/siderolink" "github.com/talos-systems/sidero/app/sidero-controller-manager/pkg/constants" siderotypes "github.com/talos-systems/sidero/app/sidero-controller-manager/pkg/types" @@ -208,7 +208,7 @@ func ipxeHandler(w http.ResponseWriter, r *http.Request) { } args := struct { - Env *metalv1alpha1.Environment + Env *metalv1.Environment KernelAsset string InitrdAsset string }{ @@ -249,13 +249,13 @@ func ipxeHandler(w http.ResponseWriter, r *http.Request) { } } -func getBootFromDiskMethod(server *metalv1alpha1.Server, serverBinding *infrav1.ServerBinding) (siderotypes.BootFromDisk, error) { +func getBootFromDiskMethod(server *metalv1.Server, serverBinding *infrav1.ServerBinding) (siderotypes.BootFromDisk, error) { method := defaultBootFromDiskMethod if server.Spec.BootFromDiskMethod != "" { method = server.Spec.BootFromDiskMethod } else if serverBinding.Spec.ServerClassRef != nil { - var serverClass metalv1alpha1.ServerClass + var serverClass metalv1.ServerClass if err := c.Get( context.TODO(), @@ -343,12 +343,12 @@ func parseMAC(s string) (net.HardwareAddr, error) { return macAddr, err } -func lookupServer(uuid string) (*metalv1alpha1.Server, *infrav1.ServerBinding, error) { +func lookupServer(uuid string) (*metalv1.Server, *infrav1.ServerBinding, error) { key := client.ObjectKey{ Name: uuid, } - s := &metalv1alpha1.Server{} + s := &metalv1.Server{} if err := c.Get(context.Background(), key, s); err != nil { if apierrors.IsNotFound(err) { @@ -373,7 +373,7 @@ func lookupServer(uuid string) (*metalv1alpha1.Server, *infrav1.ServerBinding, e // newEnvironment handles which env CRD we'll respect for a given server. // specied in the server spec overrides everything, specified in the server class overrides default, default is default :). -func newEnvironment(server *metalv1alpha1.Server, serverBinding *infrav1.ServerBinding, arch string) (env *metalv1alpha1.Environment, err error) { +func newEnvironment(server *metalv1.Server, serverBinding *infrav1.ServerBinding, arch string) (env *metalv1.Environment, err error) { // NB: The order of this switch statement is important. It defines the // precedence of which environment to boot. switch { @@ -381,7 +381,7 @@ func newEnvironment(server *metalv1alpha1.Server, serverBinding *infrav1.ServerB return newAgentEnvironment(arch), nil case serverBinding == nil: return newAgentEnvironment(arch), nil - case conditions.Has(server, metalv1alpha1.ConditionPXEBooted) && !server.Spec.PXEBootAlways: + case conditions.Has(server, metalv1.ConditionPXEBooted) && !server.Spec.PXEBootAlways: return nil, ErrBootFromDisk case server.Spec.EnvironmentRef != nil: env, err = newEnvironmentFromServer(server) @@ -409,7 +409,7 @@ func newEnvironment(server *metalv1alpha1.Server, serverBinding *infrav1.ServerB return env, nil } -func newAgentEnvironment(arch string) *metalv1alpha1.Environment { +func newAgentEnvironment(arch string) *metalv1.Environment { args := append([]string(nil), kernel.DefaultArgs...) args = append(args, "console=tty0", @@ -428,12 +428,12 @@ func newAgentEnvironment(arch string) *metalv1alpha1.Environment { cmdline.Set(p.Key(), p) } - env := &metalv1alpha1.Environment{ + env := &metalv1.Environment{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("agent-%s", arch), }, - Spec: metalv1alpha1.EnvironmentSpec{ - Kernel: metalv1alpha1.Kernel{ + Spec: metalv1.EnvironmentSpec{ + Kernel: metalv1.Kernel{ Args: cmdline.Strings(), }, }, @@ -442,10 +442,10 @@ func newAgentEnvironment(arch string) *metalv1alpha1.Environment { return env } -func newDefaultEnvironment() (env *metalv1alpha1.Environment, err error) { - env = &metalv1alpha1.Environment{} +func newDefaultEnvironment() (env *metalv1.Environment, err error) { + env = &metalv1.Environment{} - if err := c.Get(context.Background(), types.NamespacedName{Namespace: "", Name: metalv1alpha1.EnvironmentDefault}, env); err != nil { + if err := c.Get(context.Background(), types.NamespacedName{Namespace: "", Name: metalv1.EnvironmentDefault}, env); err != nil { return nil, err } @@ -454,8 +454,8 @@ func newDefaultEnvironment() (env *metalv1alpha1.Environment, err error) { return env, nil } -func newEnvironmentFromServer(server *metalv1alpha1.Server) (env *metalv1alpha1.Environment, err error) { - env = &metalv1alpha1.Environment{} +func newEnvironmentFromServer(server *metalv1.Server) (env *metalv1.Environment, err error) { + env = &metalv1.Environment{} if err := c.Get(context.Background(), types.NamespacedName{Namespace: "", Name: server.Spec.EnvironmentRef.Name}, env); err != nil { return nil, err @@ -466,8 +466,8 @@ func newEnvironmentFromServer(server *metalv1alpha1.Server) (env *metalv1alpha1. return env, nil } -func newEnvironmentFromServerClass(serverBinding *infrav1.ServerBinding) (env *metalv1alpha1.Environment, err error) { - serverClassResource := &metalv1alpha1.ServerClass{} +func newEnvironmentFromServerClass(serverBinding *infrav1.ServerBinding) (env *metalv1.Environment, err error) { + serverClassResource := &metalv1.ServerClass{} if err := c.Get(context.Background(), types.NamespacedName{Namespace: serverBinding.Spec.ServerClassRef.Namespace, Name: serverBinding.Spec.ServerClassRef.Name}, serverClassResource); err != nil { return nil, err @@ -477,7 +477,7 @@ func newEnvironmentFromServerClass(serverBinding *infrav1.ServerBinding) (env *m return env, nil } - env = &metalv1alpha1.Environment{} + env = &metalv1.Environment{} if err := c.Get(context.Background(), types.NamespacedName{Namespace: "", Name: serverClassResource.Spec.EnvironmentRef.Name}, env); err != nil { return nil, err @@ -488,7 +488,7 @@ func newEnvironmentFromServerClass(serverBinding *infrav1.ServerBinding) (env *m return env, nil } -func appendTalosArguments(env *metalv1alpha1.Environment) { +func appendTalosArguments(env *metalv1.Environment) { args := env.Spec.Kernel.Args talosConfigPrefix := talosconstants.KernelParamConfig + "=" @@ -534,16 +534,16 @@ func appendTalosArguments(env *metalv1alpha1.Environment) { } } -func markAsPXEBooted(server *metalv1alpha1.Server) error { +func markAsPXEBooted(server *metalv1.Server) error { patchHelper, err := patch.NewHelper(server, c) if err != nil { return err } - conditions.MarkTrue(server, metalv1alpha1.ConditionPXEBooted) + conditions.MarkTrue(server, metalv1.ConditionPXEBooted) return patchHelper.Patch(context.Background(), server, patch.WithOwnedConditions{ - Conditions: []clusterv1.ConditionType{metalv1alpha1.ConditionPXEBooted}, + Conditions: []clusterv1.ConditionType{metalv1.ConditionPXEBooted}, }) } diff --git a/app/sidero-controller-manager/internal/metadata/metadata_server.go b/app/sidero-controller-manager/internal/metadata/metadata_server.go index d82e5dc15..db976cae3 100644 --- a/app/sidero-controller-manager/internal/metadata/metadata_server.go +++ b/app/sidero-controller-manager/internal/metadata/metadata_server.go @@ -21,8 +21,8 @@ import ( "sigs.k8s.io/cluster-api/util" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" - metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" ) type errorWithCode struct { @@ -141,7 +141,7 @@ func (m *metadataConfigs) FetchConfig(w http.ResponseWriter, r *http.Request) { // Get the server resource by the UUID that was passed in. // We do this to fetch serverclass and any configPatches in the server resource that we need to handle. - serverObj := &metalv1alpha1.Server{} + serverObj := &metalv1.Server{} err = m.client.Get( ctx, @@ -169,7 +169,7 @@ func (m *metadataConfigs) FetchConfig(w http.ResponseWriter, r *http.Request) { // Given a server object, see if it came from a serverclass (it will have an ownerref) // If so, fetch the serverclass so we can use configPatches from it. - serverClassObj := &metalv1alpha1.ServerClass{} + serverClassObj := &metalv1.ServerClass{} if serverBinding.Spec.ServerClassRef != nil { err = m.client.Get( @@ -245,7 +245,7 @@ func (m *metadataConfigs) FetchConfig(w http.ResponseWriter, r *http.Request) { } // patchConfigs is responsible for applying a set of configPatches to the bootstrap data. -func patchConfigs(decodedData []byte, patches []metalv1alpha1.ConfigPatches) ([]byte, errorWithCode) { +func patchConfigs(decodedData []byte, patches []metalv1.ConfigPatches) ([]byte, errorWithCode) { marshalledPatches, err := json.Marshal(patches) if err != nil { return nil, errorWithCode{http.StatusInternalServerError, fmt.Errorf("failure marshaling config patches from server: %s", err)} @@ -289,7 +289,7 @@ func labelNodes(decodedData []byte, serverName string) ([]byte, errorWithCode) { return nil, errorWithCode{http.StatusInternalServerError, fmt.Errorf("unable to case config")} } - patch := metalv1alpha1.ConfigPatches{ + patch := metalv1.ConfigPatches{ Path: "/machine/kubelet/extraArgs", Op: "replace", } @@ -313,33 +313,33 @@ func labelNodes(decodedData []byte, serverName string) ([]byte, errorWithCode) { patch.Value.Raw = value - return patchConfigs(decodedData, []metalv1alpha1.ConfigPatches{patch}) + return patchConfigs(decodedData, []metalv1.ConfigPatches{patch}) default: return nil, errorWithCode{http.StatusInternalServerError, fmt.Errorf("unknown config type")} } } // findMetalMachineServerBinding is responsible for looking up ServerBinding and MetalMachine. -func (m *metadataConfigs) findMetalMachineServerBinding(ctx context.Context, serverName string) (v1alpha3.MetalMachine, v1alpha3.ServerBinding, errorWithCode) { - var serverBinding v1alpha3.ServerBinding +func (m *metadataConfigs) findMetalMachineServerBinding(ctx context.Context, serverName string) (infrav1.MetalMachine, infrav1.ServerBinding, errorWithCode) { + var serverBinding infrav1.ServerBinding err := m.client.Get(ctx, types.NamespacedName{Name: serverName}, &serverBinding) if err != nil { if apierrors.IsNotFound(err) { - return v1alpha3.MetalMachine{}, v1alpha3.ServerBinding{}, errorWithCode{http.StatusNotFound, fmt.Errorf("server is not allocated (missing serverbinding): %w", err)} + return infrav1.MetalMachine{}, infrav1.ServerBinding{}, errorWithCode{http.StatusNotFound, fmt.Errorf("server is not allocated (missing serverbinding): %w", err)} } - return v1alpha3.MetalMachine{}, v1alpha3.ServerBinding{}, errorWithCode{http.StatusInternalServerError, fmt.Errorf("failure getting server binding: %w", err)} + return infrav1.MetalMachine{}, infrav1.ServerBinding{}, errorWithCode{http.StatusInternalServerError, fmt.Errorf("failure getting server binding: %w", err)} } - var metalMachine v1alpha3.MetalMachine + var metalMachine infrav1.MetalMachine if err = m.client.Get(ctx, types.NamespacedName{ // XXX: where is the namespace in owner refs? Namespace: serverBinding.Spec.MetalMachineRef.Namespace, Name: serverBinding.Spec.MetalMachineRef.Name, }, &metalMachine); err != nil { - return v1alpha3.MetalMachine{}, v1alpha3.ServerBinding{}, errorWithCode{http.StatusInternalServerError, fmt.Errorf("failure getting metalmachine: %w", err)} + return infrav1.MetalMachine{}, infrav1.ServerBinding{}, errorWithCode{http.StatusInternalServerError, fmt.Errorf("failure getting metalmachine: %w", err)} } return metalMachine, serverBinding, errorWithCode{} diff --git a/app/sidero-controller-manager/internal/power/api/api.go b/app/sidero-controller-manager/internal/power/api/api.go index f90ebe602..2a45b0f87 100644 --- a/app/sidero-controller-manager/internal/power/api/api.go +++ b/app/sidero-controller-manager/internal/power/api/api.go @@ -14,7 +14,7 @@ import ( "net/http" "time" - metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/power/metal" ) @@ -24,7 +24,7 @@ type Client struct { } // NewClient returns new API client to manage metal machine. -func NewClient(spec metalv1alpha1.ManagementAPI) (*Client, error) { +func NewClient(spec metalv1.ManagementAPI) (*Client, error) { return &Client{ endpoint: spec.Endpoint, }, nil diff --git a/app/sidero-controller-manager/internal/power/factory.go b/app/sidero-controller-manager/internal/power/factory.go index 7aa3091f5..840395b20 100644 --- a/app/sidero-controller-manager/internal/power/factory.go +++ b/app/sidero-controller-manager/internal/power/factory.go @@ -10,7 +10,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/power/api" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/power/ipmi" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/power/metal" @@ -18,7 +18,7 @@ import ( ) // NewManagementClient builds ManagementClient from the server spec. -func NewManagementClient(ctx context.Context, client client.Client, spec *v1alpha1.ServerSpec) (metal.ManagementClient, error) { +func NewManagementClient(ctx context.Context, client client.Client, spec *metalv1.ServerSpec) (metal.ManagementClient, error) { switch { case spec.BMC != nil: var err error diff --git a/app/sidero-controller-manager/internal/power/ipmi/ipmi.go b/app/sidero-controller-manager/internal/power/ipmi/ipmi.go index d1dcec343..bfacf3b75 100644 --- a/app/sidero-controller-manager/internal/power/ipmi/ipmi.go +++ b/app/sidero-controller-manager/internal/power/ipmi/ipmi.go @@ -9,7 +9,7 @@ import ( goipmi "github.com/pensando/goipmi" - metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/power/metal" ) @@ -23,7 +23,7 @@ type Client struct { } // NewClient creates an ipmi client to use. -func NewClient(bmcInfo metalv1alpha1.BMC) (*Client, error) { +func NewClient(bmcInfo metalv1.BMC) (*Client, error) { conn := &goipmi.Connection{ Hostname: bmcInfo.Endpoint, Port: int(bmcInfo.Port), diff --git a/app/sidero-controller-manager/internal/server/server.go b/app/sidero-controller-manager/internal/server/server.go index d3a69aff5..b21fef9e8 100644 --- a/app/sidero-controller-manager/internal/server/server.go +++ b/app/sidero-controller-manager/internal/server/server.go @@ -25,7 +25,7 @@ import ( "sigs.k8s.io/cluster-api/util/patch" controllerclient "sigs.k8s.io/controller-runtime/pkg/client" - metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/api" "github.com/talos-systems/sidero/app/sidero-controller-manager/pkg/constants" ) @@ -45,24 +45,24 @@ type server struct { // CreateServer implements api.AgentServer. func (s *server) CreateServer(ctx context.Context, in *api.CreateServerRequest) (*api.CreateServerResponse, error) { - obj := &metalv1alpha1.Server{} + obj := &metalv1.Server{} if err := s.c.Get(ctx, types.NamespacedName{Name: in.GetSystemInformation().GetUuid()}, obj); err != nil { if !apierrors.IsNotFound(err) { return nil, err } - obj = &metalv1alpha1.Server{ + obj = &metalv1.Server{ TypeMeta: metav1.TypeMeta{ Kind: "Server", - APIVersion: metalv1alpha1.GroupVersion.Version, + APIVersion: metalv1.GroupVersion.Version, }, ObjectMeta: metav1.ObjectMeta{ Name: in.GetSystemInformation().GetUuid(), }, - Spec: metalv1alpha1.ServerSpec{ + Spec: metalv1.ServerSpec{ Hostname: in.GetHostname(), - SystemInformation: &metalv1alpha1.SystemInformation{ + SystemInformation: &metalv1.SystemInformation{ Manufacturer: in.GetSystemInformation().GetManufacturer(), ProductName: in.GetSystemInformation().GetProductName(), Version: in.GetSystemInformation().GetVersion(), @@ -70,7 +70,7 @@ func (s *server) CreateServer(ctx context.Context, in *api.CreateServerRequest) SKUNumber: in.GetSystemInformation().GetSkuNumber(), Family: in.GetSystemInformation().GetFamily(), }, - CPU: &metalv1alpha1.CPUInformation{ + CPU: &metalv1.CPUInformation{ Manufacturer: in.GetCpu().GetManufacturer(), Version: in.GetCpu().GetVersion(), }, @@ -121,7 +121,7 @@ func (s *server) CreateServer(ctx context.Context, in *api.CreateServerRequest) // MarkServerAsWiped implements api.AgentServer. func (s *server) MarkServerAsWiped(ctx context.Context, in *api.MarkServerAsWipedRequest) (*api.MarkServerAsWipedResponse, error) { - obj := &metalv1alpha1.Server{} + obj := &metalv1.Server{} if err := s.c.Get(ctx, types.NamespacedName{Name: in.GetUuid()}, obj); err != nil { return nil, err @@ -134,10 +134,10 @@ func (s *server) MarkServerAsWiped(ctx context.Context, in *api.MarkServerAsWipe obj.Status.IsClean = true - conditions.MarkTrue(obj, metalv1alpha1.ConditionPowerCycle) + conditions.MarkTrue(obj, metalv1.ConditionPowerCycle) if err := patchHelper.Patch(ctx, obj, patch.WithOwnedConditions{ - Conditions: []clusterv1.ConditionType{metalv1alpha1.ConditionPowerCycle}, + Conditions: []clusterv1.ConditionType{metalv1.ConditionPowerCycle}, }); err != nil { return nil, err } @@ -156,7 +156,7 @@ func (s *server) MarkServerAsWiped(ctx context.Context, in *api.MarkServerAsWipe // ReconcileServerAddresses implements api.AgentServer. func (s *server) ReconcileServerAddresses(ctx context.Context, in *api.ReconcileServerAddressesRequest) (*api.ReconcileServerAddressesResponse, error) { - obj := &metalv1alpha1.Server{} + obj := &metalv1.Server{} if err := s.c.Get(ctx, types.NamespacedName{Name: in.GetUuid()}, obj); err != nil { return nil, err @@ -242,7 +242,7 @@ func (s *server) ReconcileServerAddresses(ctx context.Context, in *api.Reconcile // Heartbeat implements api.AgentServer. func (s *server) Heartbeat(ctx context.Context, in *api.HeartbeatRequest) (*api.HeartbeatResponse, error) { - obj := &metalv1alpha1.Server{} + obj := &metalv1.Server{} if err := s.c.Get(ctx, types.NamespacedName{Name: in.GetUuid()}, obj); err != nil { return nil, err @@ -254,11 +254,11 @@ func (s *server) Heartbeat(ctx context.Context, in *api.HeartbeatRequest) (*api. } // remove the condition in case it was already set to make sure LastTransitionTime will be updated - conditions.Delete(obj, metalv1alpha1.ConditionPowerCycle) - conditions.MarkFalse(obj, metalv1alpha1.ConditionPowerCycle, "InProgress", clusterv1.ConditionSeverityInfo, "Server wipe in progress.") + conditions.Delete(obj, metalv1.ConditionPowerCycle) + conditions.MarkFalse(obj, metalv1.ConditionPowerCycle, "InProgress", clusterv1.ConditionSeverityInfo, "Server wipe in progress.") if err := patchHelper.Patch(ctx, obj, patch.WithOwnedConditions{ - Conditions: []clusterv1.ConditionType{metalv1alpha1.ConditionPowerCycle}, + Conditions: []clusterv1.ConditionType{metalv1.ConditionPowerCycle}, }); err != nil { return nil, err } @@ -272,7 +272,7 @@ func (s *server) UpdateBMCInfo(ctx context.Context, in *api.UpdateBMCInfoRequest bmcInfo := in.GetBmcInfo() // Fetch corresponding server - obj := &metalv1alpha1.Server{} + obj := &metalv1.Server{} if err := s.c.Get(ctx, types.NamespacedName{Name: in.GetUuid()}, obj); err != nil { return nil, err @@ -280,7 +280,7 @@ func (s *server) UpdateBMCInfo(ctx context.Context, in *api.UpdateBMCInfoRequest // Create a BMC struct if non-existent if obj.Spec.BMC == nil { - obj.Spec.BMC = &metalv1alpha1.BMC{} + obj.Spec.BMC = &metalv1.BMC{} } // Update bmc info with IP if we've got it. @@ -317,7 +317,7 @@ func (s *server) UpdateBMCInfo(ctx context.Context, in *api.UpdateBMCInfoRequest Namespace: corev1.NamespaceDefault, Name: bmcSecretName, OwnerReferences: []metav1.OwnerReference{ - *metav1.NewControllerRef(obj, metalv1alpha1.GroupVersion.WithKind("Server")), + *metav1.NewControllerRef(obj, metalv1.GroupVersion.WithKind("Server")), }, Labels: map[string]string{ clusterctl.ClusterctlMoveLabelName: "", @@ -343,16 +343,16 @@ func (s *server) UpdateBMCInfo(ctx context.Context, in *api.UpdateBMCInfoRequest } // Update server spec with pointers to endpoint and creds secret - obj.Spec.BMC.UserFrom = &metalv1alpha1.CredentialSource{ - SecretKeyRef: &metalv1alpha1.SecretKeyRef{ + obj.Spec.BMC.UserFrom = &metalv1.CredentialSource{ + SecretKeyRef: &metalv1.SecretKeyRef{ Namespace: corev1.NamespaceDefault, Name: bmcSecretName, Key: "user", }, } - obj.Spec.BMC.PassFrom = &metalv1alpha1.CredentialSource{ - SecretKeyRef: &metalv1alpha1.SecretKeyRef{ + obj.Spec.BMC.PassFrom = &metalv1.CredentialSource{ + SecretKeyRef: &metalv1.SecretKeyRef{ Namespace: corev1.NamespaceDefault, Name: bmcSecretName, Key: "pass", diff --git a/app/sidero-controller-manager/main.go b/app/sidero-controller-manager/main.go index 524d05e6e..950ad064f 100644 --- a/app/sidero-controller-manager/main.go +++ b/app/sidero-controller-manager/main.go @@ -29,7 +29,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" "sigs.k8s.io/controller-runtime/pkg/manager" - infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" + infrav1alpha3 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" metalv1alpha1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/app/sidero-controller-manager/controllers" "github.com/talos-systems/sidero/app/sidero-controller-manager/internal/ipxe" @@ -64,7 +64,7 @@ func init() { _ = capi.AddToScheme(scheme) _ = metalv1alpha1.AddToScheme(scheme) - _ = infrav1.AddToScheme(scheme) + _ = infrav1alpha3.AddToScheme(scheme) // +kubebuilder:scaffold:scheme } diff --git a/internal/client/client.go b/internal/client/client.go index 378634310..833ac58f4 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -13,8 +13,8 @@ import ( capi "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" - caps "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" - scm "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" ) // NewClient is responsible for creating a controller-runtime k8s client with all schemas. @@ -48,11 +48,11 @@ func NewClient(kubeconfig *string) (client.Client, error) { return nil, err } - if err = caps.AddToScheme(scheme); err != nil { + if err = infrav1.AddToScheme(scheme); err != nil { return nil, err } - if err = scm.AddToScheme(scheme); err != nil { + if err = metalv1.AddToScheme(scheme); err != nil { return nil, err } diff --git a/sfyra/pkg/capi/cluster.go b/sfyra/pkg/capi/cluster.go index dd4b68931..d59cf0804 100644 --- a/sfyra/pkg/capi/cluster.go +++ b/sfyra/pkg/capi/cluster.go @@ -27,8 +27,8 @@ import ( capiv1 "sigs.k8s.io/cluster-api/api/v1beta1" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" - sidero "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" - metal "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" ) // Cluster attaches to the provisioned CAPI cluster and provides talos.Cluster. @@ -100,7 +100,7 @@ func NewCluster(ctx context.Context, metalClient runtimeclient.Reader, clusterNa continue } - var metalMachine sidero.MetalMachine + var metalMachine infrav1.MetalMachine if err = metalClient.Get(ctx, types.NamespacedName{Namespace: machine.Spec.InfrastructureRef.Namespace, Name: machine.Spec.InfrastructureRef.Name}, @@ -116,7 +116,7 @@ func NewCluster(ctx context.Context, metalClient runtimeclient.Reader, clusterNa continue } - var server metal.Server + var server metalv1.Server if err := metalClient.Get(ctx, types.NamespacedName{Namespace: metalMachine.Spec.ServerRef.Namespace, Name: metalMachine.Spec.ServerRef.Name}, &server); err != nil { return nil, err diff --git a/sfyra/pkg/capi/metalclient.go b/sfyra/pkg/capi/metalclient.go index 7c67d65f8..67a0be6e1 100644 --- a/sfyra/pkg/capi/metalclient.go +++ b/sfyra/pkg/capi/metalclient.go @@ -12,8 +12,8 @@ import ( capiv1 "sigs.k8s.io/cluster-api/api/v1beta1" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" - sidero "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" - metal "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" ) // GetMetalClient builds k8s client with schemes required to access all the CAPI/Sidero/Talos components. @@ -32,11 +32,11 @@ func GetMetalClient(config *rest.Config) (runtimeclient.Client, error) { return nil, err } - if err := sidero.AddToScheme(scheme); err != nil { + if err := infrav1.AddToScheme(scheme); err != nil { return nil, err } - if err := metal.AddToScheme(scheme); err != nil { + if err := metalv1.AddToScheme(scheme); err != nil { return nil, err } diff --git a/sfyra/pkg/loadbalancer/loadbalancer.go b/sfyra/pkg/loadbalancer/loadbalancer.go index b27ec3861..36621c603 100644 --- a/sfyra/pkg/loadbalancer/loadbalancer.go +++ b/sfyra/pkg/loadbalancer/loadbalancer.go @@ -25,8 +25,8 @@ import ( capiv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" - sidero "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" - metal "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" ) // ControlPlane implements dynamic loadbalancer for the control plane. @@ -153,13 +153,13 @@ func (cp *ControlPlane) reconcile() error { var upstreams []string for _, machine := range machines.Items { - var metalMachine sidero.MetalMachine + var metalMachine infrav1.MetalMachine if err := cp.client.Get(cp.ctx, types.NamespacedName{Namespace: machine.Spec.InfrastructureRef.Namespace, Name: machine.Spec.InfrastructureRef.Name}, &metalMachine); err != nil { continue } - var server metal.Server + var server metalv1.Server if metalMachine.Spec.ServerRef == nil { continue diff --git a/sfyra/pkg/tests/compatibility.go b/sfyra/pkg/tests/compatibility.go index dbb45b189..532cb7807 100644 --- a/sfyra/pkg/tests/compatibility.go +++ b/sfyra/pkg/tests/compatibility.go @@ -23,7 +23,7 @@ import ( "github.com/talos-systems/go-retry/retry" "github.com/talos-systems/talos/pkg/machinery/kernel" - "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/sfyra/pkg/capi" "github.com/talos-systems/sidero/sfyra/pkg/constants" "github.com/talos-systems/sidero/sfyra/pkg/talos" @@ -42,7 +42,7 @@ func TestCompatibilityCluster(ctx context.Context, metalClient client.Client, cl t.Skip("--prev-talos-release is not set, skipped compatibility check") } - var environment v1alpha1.Environment + var environment metalv1.Environment envName := fmt.Sprintf("talos-%s", strings.ReplaceAll(talosRelease, ".", "-")) @@ -82,9 +82,9 @@ func TestCompatibilityCluster(ctx context.Context, metalClient client.Client, cl })) serverClassName := envName - classSpec := v1alpha1.ServerClassSpec{ - Qualifiers: v1alpha1.Qualifiers{ - CPU: []v1alpha1.CPUInformation{ + classSpec := metalv1.ServerClassSpec{ + Qualifiers: metalv1.Qualifiers{ + CPU: []metalv1.CPUInformation{ { Manufacturer: "QEMU", }, diff --git a/sfyra/pkg/tests/environment.go b/sfyra/pkg/tests/environment.go index cd9dcbcf4..63b5dc04d 100644 --- a/sfyra/pkg/tests/environment.go +++ b/sfyra/pkg/tests/environment.go @@ -18,7 +18,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/sfyra/pkg/constants" "github.com/talos-systems/sidero/sfyra/pkg/talos" ) @@ -28,8 +28,8 @@ const environmentName = "sfyra" // TestEnvironmentDefault verifies environment "default". func TestEnvironmentDefault(ctx context.Context, metalClient client.Client, cluster talos.Cluster, kernelURL, initrdURL string) TestFunc { return func(t *testing.T) { - var environment v1alpha1.Environment - err := metalClient.Get(ctx, types.NamespacedName{Name: v1alpha1.EnvironmentDefault}, &environment) + var environment metalv1.Environment + err := metalClient.Get(ctx, types.NamespacedName{Name: metalv1.EnvironmentDefault}, &environment) require.NoError(t, err) assert.True(t, environment.IsReady()) @@ -37,9 +37,9 @@ func TestEnvironmentDefault(ctx context.Context, metalClient client.Client, clus err = metalClient.Delete(ctx, &environment) require.NoError(t, err) - environment = v1alpha1.Environment{} + environment = metalv1.Environment{} err = retry.Constant(60 * time.Second).Retry(func() error { - if err := metalClient.Get(ctx, types.NamespacedName{Name: v1alpha1.EnvironmentDefault}, &environment); err != nil { + if err := metalClient.Get(ctx, types.NamespacedName{Name: metalv1.EnvironmentDefault}, &environment); err != nil { if apierrors.IsNotFound(err) { return retry.ExpectedError(err) } @@ -60,7 +60,7 @@ func TestEnvironmentDefault(ctx context.Context, metalClient client.Client, clus // TestEnvironmentCreate verifies environment creation. func TestEnvironmentCreate(ctx context.Context, metalClient client.Client, cluster talos.Cluster, kernelURL, initrdURL string) TestFunc { return func(t *testing.T) { - var environment v1alpha1.Environment + var environment metalv1.Environment if err := metalClient.Get(ctx, types.NamespacedName{Name: environmentName}, &environment); err != nil { if !apierrors.IsNotFound(err) { diff --git a/sfyra/pkg/tests/match.go b/sfyra/pkg/tests/match.go index 63fcc6d28..13d8db2ed 100644 --- a/sfyra/pkg/tests/match.go +++ b/sfyra/pkg/tests/match.go @@ -13,7 +13,7 @@ import ( capiv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" - metal "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" ) // TestMatchServersMetalMachines verifies that number of metal machines and servers match. @@ -23,7 +23,7 @@ func TestMatchServersMetalMachines(ctx context.Context, metalClient client.Clien require.NoError(t, metalClient.List(ctx, &machines)) - var servers metal.ServerList + var servers metalv1.ServerList require.NoError(t, metalClient.List(ctx, &servers)) diff --git a/sfyra/pkg/tests/reconcile.go b/sfyra/pkg/tests/reconcile.go index 9387e02a2..ab4b65209 100644 --- a/sfyra/pkg/tests/reconcile.go +++ b/sfyra/pkg/tests/reconcile.go @@ -19,8 +19,8 @@ import ( "sigs.k8s.io/cluster-api/util/patch" "sigs.k8s.io/controller-runtime/pkg/client" - sidero "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" - metal "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" ) // TestMachineDeploymentReconcile verifies that machine deployment can reconcile delete machines. @@ -95,7 +95,7 @@ func TestMachineDeploymentReconcile(ctx context.Context, metalClient client.Clie // TestServerBindingReconcile verifies that server binding controller can reconcile missing ServerBindings. func TestServerBindingReconcile(ctx context.Context, metalClient client.Client) TestFunc { return func(t *testing.T) { - var serverBindingList sidero.ServerBindingList + var serverBindingList infrav1.ServerBindingList require.NoError(t, metalClient.List(ctx, &serverBindingList)) @@ -112,7 +112,7 @@ func TestServerBindingReconcile(ctx context.Context, metalClient client.Client) start := time.Now() for time.Since(start) < time.Minute { - var server metal.Server + var server metalv1.Server require.NoError(t, metalClient.Get(ctx, types.NamespacedName{Name: serverBindingToDelete.Name}, &server)) @@ -120,7 +120,7 @@ func TestServerBindingReconcile(ctx context.Context, metalClient client.Client) } // server binding should have been re-created - var serverBinding sidero.ServerBinding + var serverBinding infrav1.ServerBinding require.NoError(t, metalClient.Get(ctx, types.NamespacedName{Name: serverBindingToDelete.Name}, &serverBinding)) @@ -141,7 +141,7 @@ func TestServerBindingReconcile(ctx context.Context, metalClient client.Client) // ref wasn't set. func TestMetalMachineServerRefReconcile(ctx context.Context, metalClient client.Client) TestFunc { return func(t *testing.T) { - var serverBindingList sidero.ServerBindingList + var serverBindingList infrav1.ServerBindingList require.NoError(t, metalClient.List(ctx, &serverBindingList)) @@ -153,7 +153,7 @@ func TestMetalMachineServerRefReconcile(ctx context.Context, metalClient client. serverBinding := serverBindingList.Items[0] // get matching metalmachine - var metalMachine sidero.MetalMachine + var metalMachine infrav1.MetalMachine require.NoError(t, metalClient.Get(ctx, types.NamespacedName{Namespace: serverBinding.Spec.MetalMachineRef.Namespace, Name: serverBinding.Spec.MetalMachineRef.Name}, &metalMachine)) diff --git a/sfyra/pkg/tests/reset.go b/sfyra/pkg/tests/reset.go index 68eeac88f..5cb3597d3 100644 --- a/sfyra/pkg/tests/reset.go +++ b/sfyra/pkg/tests/reset.go @@ -15,14 +15,14 @@ import ( "k8s.io/apimachinery/pkg/labels" "sigs.k8s.io/controller-runtime/pkg/client" - metal "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" - sidero "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" ) // TestServerReset verifies that all the servers got reset. func TestServerReset(ctx context.Context, metalClient client.Client) TestFunc { return func(t *testing.T) { - var machines metal.MetalMachineList + var machines infrav1.MetalMachineList labelSelector, err := labels.Parse("cluster.x-k8s.io/cluster-name=management-cluster,cluster.x-k8s.io/deployment-name=management-cluster-workers") require.NoError(t, err) @@ -44,7 +44,7 @@ func TestServerReset(ctx context.Context, metalClient client.Client) TestFunc { require.NoError(t, err) err = retry.Constant(5*time.Minute, retry.WithUnits(10*time.Second)).Retry(func() error { - var servers sidero.ServerList + var servers metalv1.ServerList err = metalClient.List(ctx, &servers) if err != nil { diff --git a/sfyra/pkg/tests/server.go b/sfyra/pkg/tests/server.go index c21467d05..43ee11949 100644 --- a/sfyra/pkg/tests/server.go +++ b/sfyra/pkg/tests/server.go @@ -29,8 +29,8 @@ import ( "sigs.k8s.io/cluster-api/util/patch" "sigs.k8s.io/controller-runtime/pkg/client" - metalv1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" - "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + infrav1 "github.com/talos-systems/sidero/app/caps-controller-manager/api/v1alpha3" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/sfyra/pkg/capi" "github.com/talos-systems/sidero/sfyra/pkg/constants" "github.com/talos-systems/sidero/sfyra/pkg/talos" @@ -42,11 +42,11 @@ func TestServerRegistration(ctx context.Context, metalClient client.Client, vmSe return func(t *testing.T) { numNodes := len(vmSet.Nodes()) - var servers *v1alpha1.ServerList + var servers *metalv1.ServerList // wait for all the servers to be registered require.NoError(t, retry.Constant(5*time.Minute, retry.WithUnits(10*time.Second)).Retry(func() error { - servers = &v1alpha1.ServerList{} + servers = &metalv1.ServerList{} if err := metalClient.List(ctx, servers); err != nil { return err @@ -101,14 +101,14 @@ func TestServerMgmtAPI(ctx context.Context, metalClient client.Client, vmSet *vm bridgeIP := vmSet.BridgeIP() for _, vm := range vmSet.Nodes() { - server := v1alpha1.Server{} + server := metalv1.Server{} require.NoError(t, metalClient.Get(ctx, types.NamespacedName{Name: vm.UUID.String()}, &server)) patchHelper, err := patch.NewHelper(&server, metalClient) require.NoError(t, err) - server.Spec.ManagementAPI = &v1alpha1.ManagementAPI{ + server.Spec.ManagementAPI = &metalv1.ManagementAPI{ Endpoint: net.JoinHostPort(bridgeIP.String(), strconv.Itoa(vm.APIPort)), } @@ -120,7 +120,7 @@ func TestServerMgmtAPI(ctx context.Context, metalClient client.Client, vmSet *vm // TestServerPatch patches all the servers for the config. func TestServerPatch(ctx context.Context, metalClient client.Client, registryMirrors []string) TestFunc { return func(t *testing.T) { - servers := &v1alpha1.ServerList{} + servers := &metalv1.ServerList{} require.NoError(t, metalClient.List(ctx, servers)) @@ -165,14 +165,14 @@ func TestServerPatch(ctx context.Context, metalClient client.Client, registryMir patchHelper, err := patch.NewHelper(&server, metalClient) require.NoError(t, err) - server.Spec.ConfigPatches = append(server.Spec.ConfigPatches, v1alpha1.ConfigPatches{ + server.Spec.ConfigPatches = append(server.Spec.ConfigPatches, metalv1.ConfigPatches{ Op: "replace", Path: "/machine/install", Value: apiextensions.JSON{Raw: installPatch}, }) if mirrorsPatch != nil { - server.Spec.ConfigPatches = append(server.Spec.ConfigPatches, v1alpha1.ConfigPatches{ + server.Spec.ConfigPatches = append(server.Spec.ConfigPatches, metalv1.ConfigPatches{ Op: "add", Path: "/machine/registries", Value: apiextensions.JSON{Raw: mirrorsPatch}, @@ -190,8 +190,8 @@ func TestServerAcceptance(ctx context.Context, metalClient client.Client, vmSet const numDummies = 3 // create dummy servers to test with - dummySpec := v1alpha1.ServerSpec{ - CPU: &v1alpha1.CPUInformation{ + dummySpec := metalv1.ServerSpec{ + CPU: &metalv1.CPUInformation{ Manufacturer: "DummyCPU", }, } @@ -202,7 +202,7 @@ func TestServerAcceptance(ctx context.Context, metalClient client.Client, vmSet require.NoError(t, err) } - dummyServers := &v1alpha1.ServerList{} + dummyServers := &metalv1.ServerList{} labelSelector, err := labels.Parse("dummy-server=") require.NoError(t, err) @@ -222,7 +222,7 @@ func TestServerAcceptance(ctx context.Context, metalClient client.Client, vmSet })) // verify servers originally registered as non-accepted - acceptedServers := []v1alpha1.Server{} + acceptedServers := []metalv1.Server{} for _, server := range dummyServers.Items { if server.Spec.Accepted { @@ -246,7 +246,7 @@ func TestServerAcceptance(ctx context.Context, metalClient client.Client, vmSet // verify all servers are now accepted require.NoError(t, metalClient.List(ctx, dummyServers, client.MatchingLabelsSelector{Selector: labelSelector})) - acceptedServers = []v1alpha1.Server{} + acceptedServers = []metalv1.Server{} for _, server := range dummyServers.Items { if server.Spec.Accepted { @@ -270,8 +270,8 @@ func TestServerCordoned(ctx context.Context, metalClient client.Client, vmSet *v const numDummies = 3 // create dummy servers to test with - dummySpec := v1alpha1.ServerSpec{ - CPU: &v1alpha1.CPUInformation{ + dummySpec := metalv1.ServerSpec{ + CPU: &metalv1.CPUInformation{ Manufacturer: "DummyManufacturer", }, } @@ -282,7 +282,7 @@ func TestServerCordoned(ctx context.Context, metalClient client.Client, vmSet *v require.NoError(t, err) } - dummyServers := &v1alpha1.ServerList{} + dummyServers := &metalv1.ServerList{} labelSelector, err := labels.Parse("dummy-server=") require.NoError(t, err) @@ -310,8 +310,8 @@ func TestServerCordoned(ctx context.Context, metalClient client.Client, vmSet *v // verify that all servers shows up as available in `any` serverclass require.NoError(t, retry.Constant(30*time.Second, retry.WithUnits(5*time.Second)).Retry(func() error { - var serverClass v1alpha1.ServerClass - err := metalClient.Get(ctx, types.NamespacedName{Name: v1alpha1.ServerClassAny}, &serverClass) + var serverClass metalv1.ServerClass + err := metalClient.Get(ctx, types.NamespacedName{Name: metalv1.ServerClassAny}, &serverClass) if err != nil { return err } @@ -327,7 +327,7 @@ func TestServerCordoned(ctx context.Context, metalClient client.Client, vmSet *v // // cordon a single server and marked as paused serverName := dummyServers.Items[0].Name - var server v1alpha1.Server + var server metalv1.Server require.NoError(t, metalClient.Get(ctx, types.NamespacedName{Name: serverName}, &server)) patchHelper, err := patch.NewHelper(&server, metalClient) @@ -338,8 +338,8 @@ func TestServerCordoned(ctx context.Context, metalClient client.Client, vmSet *v require.NoError(t, patchHelper.Patch(ctx, &server)) require.NoError(t, retry.Constant(30*time.Second, retry.WithUnits(5*time.Second)).Retry(func() error { - var serverClass v1alpha1.ServerClass - err := metalClient.Get(ctx, types.NamespacedName{Name: v1alpha1.ServerClassAny}, &serverClass) + var serverClass metalv1.ServerClass + err := metalClient.Get(ctx, types.NamespacedName{Name: metalv1.ServerClassAny}, &serverClass) if err != nil { return err } @@ -353,7 +353,7 @@ func TestServerCordoned(ctx context.Context, metalClient client.Client, vmSet *v })) // patch the server and marked as not cordoned - var pausedServer v1alpha1.Server + var pausedServer metalv1.Server require.NoError(t, metalClient.Get(ctx, types.NamespacedName{Name: serverName}, &pausedServer)) patchHelperPausedServer, err := patch.NewHelper(&pausedServer, metalClient) @@ -364,8 +364,8 @@ func TestServerCordoned(ctx context.Context, metalClient client.Client, vmSet *v require.NoError(t, patchHelperPausedServer.Patch(ctx, &pausedServer)) require.NoError(t, retry.Constant(30*time.Second, retry.WithUnits(5*time.Second)).Retry(func() error { - var serverClass v1alpha1.ServerClass - err := metalClient.Get(ctx, types.NamespacedName{Name: v1alpha1.ServerClassAny}, &serverClass) + var serverClass metalv1.ServerClass + err := metalClient.Get(ctx, types.NamespacedName{Name: metalv1.ServerClassAny}, &serverClass) if err != nil { return err } @@ -383,12 +383,12 @@ func TestServerCordoned(ctx context.Context, metalClient client.Client, vmSet *v // TestServerResetOnAcceptance tests that servers are reset when accepted. func TestServerResetOnAcceptance(ctx context.Context, metalClient client.Client) TestFunc { return func(t *testing.T) { - serverList := &v1alpha1.ServerList{} + serverList := &metalv1.ServerList{} err := metalClient.List(ctx, serverList) require.NoError(t, err) - servers := []v1alpha1.Server{} + servers := []metalv1.Server{} for _, server := range serverList.Items { server := server @@ -412,7 +412,7 @@ func TestServerResetOnAcceptance(ctx context.Context, metalClient client.Client) require.NoError(t, retry.Constant(5*time.Minute, retry.WithUnits(10*time.Second)).Retry(func() error { for _, server := range servers { - var s v1alpha1.Server + var s metalv1.Server if err := metalClient.Get(ctx, types.NamespacedName{Name: server.Name, Namespace: server.Namespace}, &s); err != nil { return err @@ -434,7 +434,7 @@ func TestServerResetOnAcceptance(ctx context.Context, metalClient client.Client) func TestServersReady(ctx context.Context, metalClient client.Client) TestFunc { return func(t *testing.T) { require.NoError(t, retry.Constant(time.Minute, retry.WithUnits(10*time.Second)).Retry(func() error { - servers := v1alpha1.ServerList{} + servers := metalv1.ServerList{} if err := metalClient.List(ctx, &servers); err != nil { return err @@ -455,7 +455,7 @@ func TestServersReady(ctx context.Context, metalClient client.Client) TestFunc { func TestServersDiscoveredIPs(ctx context.Context, metalClient client.Client) TestFunc { return func(t *testing.T) { require.NoError(t, retry.Constant(time.Minute, retry.WithUnits(10*time.Second)).Retry(func() error { - servers := v1alpha1.ServerList{} + servers := metalv1.ServerList{} if err := metalClient.List(ctx, &servers); err != nil { return err @@ -492,9 +492,9 @@ func TestServerPXEBoot(ctx context.Context, metalClient client.Client, cluster t return func(t *testing.T) { pxeTestServerClass := "pxe-test-server" - classSpec := v1alpha1.ServerClassSpec{ - Qualifiers: v1alpha1.Qualifiers{ - CPU: []v1alpha1.CPUInformation{ + classSpec := metalv1.ServerClassSpec{ + Qualifiers: metalv1.Qualifiers{ + CPU: []metalv1.CPUInformation{ { Manufacturer: "QEMU", }, @@ -503,7 +503,7 @@ func TestServerPXEBoot(ctx context.Context, metalClient client.Client, cluster t EnvironmentRef: &v1.ObjectReference{ Name: environmentName, }, - ConfigPatches: []v1alpha1.ConfigPatches{ + ConfigPatches: []metalv1.ConfigPatches{ { Op: "add", Path: "/fake", @@ -518,7 +518,7 @@ func TestServerPXEBoot(ctx context.Context, metalClient client.Client, cluster t loadbalancer := createCluster(ctx, t, metalClient, cluster, vmSet, capiManager, pxeTestClusterName, pxeTestServerClass, pxeTestClusterLBPort, 1, 0, talosRelease, kubernetesVersion) retry.Constant(time.Minute, retry.WithUnits(10*time.Second)).Retry(func() error { - var machines metalv1.MetalMachineList + var machines infrav1.MetalMachineList labelSelector, err := labels.Parse(fmt.Sprintf("cluster.x-k8s.io/cluster-name=%s", pxeTestClusterName)) require.NoError(t, err) @@ -532,7 +532,7 @@ func TestServerPXEBoot(ctx context.Context, metalClient client.Client, cluster t return retry.ExpectedErrorf("no metal machines detected yet") } - if !conditions.IsFalse(&machines.Items[0], metalv1.TalosConfigLoadedCondition) || !conditions.IsFalse(&machines.Items[0], metalv1.TalosConfigValidatedCondition) { + if !conditions.IsFalse(&machines.Items[0], infrav1.TalosConfigLoadedCondition) || !conditions.IsFalse(&machines.Items[0], infrav1.TalosConfigValidatedCondition) { return retry.ExpectedErrorf("the machine doesn't have any config failure conditions yet") } @@ -557,8 +557,8 @@ func TestServerPXEBoot(ctx context.Context, metalClient client.Client, cluster t // createDummyServers will submit servers with dummy info that are not tied to QEMU VMs. // These can be targeted by the spec passed in or the label "dummy-server". // Dummy servers are patched after creation to ensure they're marked as clean. -func createDummyServer(ctx context.Context, metalClient client.Client, name string, spec v1alpha1.ServerSpec) (v1alpha1.Server, error) { - var server v1alpha1.Server +func createDummyServer(ctx context.Context, metalClient client.Client, name string, spec metalv1.ServerSpec) (metalv1.Server, error) { + var server metalv1.Server server.APIVersion = constants.SideroAPIVersion server.Name = name @@ -572,7 +572,7 @@ func createDummyServer(ctx context.Context, metalClient client.Client, name stri return server, retry.Constant(time.Minute, retry.WithUnits(10*time.Second)).Retry(func() error { // refetch dummy server to make sure we're synced up before patching - server = v1alpha1.Server{} + server = metalv1.Server{} err = metalClient.Get(ctx, types.NamespacedName{Name: name}, &server) if err != nil { @@ -598,7 +598,7 @@ func createDummyServer(ctx context.Context, metalClient client.Client, name stri } // getAvailableServersFromServerClass returns a list of servers that are available as part of a serverclass. -func getAvailableServersFromServerClass(serverClass v1alpha1.ServerClass, serverList *v1alpha1.ServerList) []string { +func getAvailableServersFromServerClass(serverClass metalv1.ServerClass, serverList *metalv1.ServerList) []string { var foundServers []string for _, server := range serverList.Items { diff --git a/sfyra/pkg/tests/server_class.go b/sfyra/pkg/tests/server_class.go index 19267dca7..690fafb7e 100644 --- a/sfyra/pkg/tests/server_class.go +++ b/sfyra/pkg/tests/server_class.go @@ -31,7 +31,7 @@ import ( capiclient "sigs.k8s.io/cluster-api/cmd/clusterctl/client" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" + metalv1 "github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/sfyra/pkg/capi" "github.com/talos-systems/sidero/sfyra/pkg/constants" "github.com/talos-systems/sidero/sfyra/pkg/talos" @@ -48,8 +48,8 @@ func TestServerClassAny(ctx context.Context, metalClient client.Client, vmSet *v return func(t *testing.T) { numNodes := len(vmSet.Nodes()) - var serverClass v1alpha1.ServerClass - err := metalClient.Get(ctx, types.NamespacedName{Name: v1alpha1.ServerClassAny}, &serverClass) + var serverClass metalv1.ServerClass + err := metalClient.Get(ctx, types.NamespacedName{Name: metalv1.ServerClassAny}, &serverClass) require.NoError(t, err) assert.Empty(t, serverClass.Spec.Qualifiers) assert.Len(t, append(serverClass.Status.ServersAvailable, serverClass.Status.ServersInUse...), numNodes) @@ -58,9 +58,9 @@ func TestServerClassAny(ctx context.Context, metalClient client.Client, vmSet *v err = metalClient.Delete(ctx, &serverClass) require.NoError(t, err) - serverClass = v1alpha1.ServerClass{} + serverClass = metalv1.ServerClass{} err = retry.Constant(10 * time.Second).Retry(func() error { - if err := metalClient.Get(ctx, types.NamespacedName{Name: v1alpha1.ServerClassAny}, &serverClass); err != nil { + if err := metalClient.Get(ctx, types.NamespacedName{Name: metalv1.ServerClassAny}, &serverClass); err != nil { if apierrors.IsNotFound(err) { return retry.ExpectedError(err) } @@ -82,9 +82,9 @@ func TestServerClassAny(ctx context.Context, metalClient client.Client, vmSet *v // TestServerClassCreate verifies server class creation. func TestServerClassCreate(ctx context.Context, metalClient client.Client, vmSet *vm.Set) TestFunc { return func(t *testing.T) { - classSpec := v1alpha1.ServerClassSpec{ - Qualifiers: v1alpha1.Qualifiers{ - CPU: []v1alpha1.CPUInformation{ + classSpec := metalv1.ServerClassSpec{ + Qualifiers: metalv1.Qualifiers{ + CPU: []metalv1.CPUInformation{ { Manufacturer: "QEMU", }, @@ -138,8 +138,8 @@ func TestServerClassCreate(ctx context.Context, metalClient client.Client, vmSet func TestServerClassPatch(ctx context.Context, metalClient client.Client, cluster talos.Cluster, capiManager *capi.Manager) TestFunc { return func(t *testing.T) { // Create dummy serverclass + a server - dummySpec := v1alpha1.ServerSpec{ - CPU: &v1alpha1.CPUInformation{ + dummySpec := metalv1.ServerSpec{ + CPU: &metalv1.CPUInformation{ Manufacturer: "DummyCPU", }, Accepted: true, @@ -159,16 +159,16 @@ func TestServerClassPatch(ctx context.Context, metalClient client.Client, cluste installPatch := configPatchToJSON(t, &installConfig) - classSpec := v1alpha1.ServerClassSpec{ - ConfigPatches: []v1alpha1.ConfigPatches{ + classSpec := metalv1.ServerClassSpec{ + ConfigPatches: []metalv1.ConfigPatches{ { Op: "replace", Path: "/machine/install", Value: apiextensions.JSON{Raw: installPatch}, }, }, - Qualifiers: v1alpha1.Qualifiers{ - CPU: []v1alpha1.CPUInformation{ + Qualifiers: metalv1.Qualifiers{ + CPU: []metalv1.CPUInformation{ { Manufacturer: "DummyCPU", }, @@ -279,7 +279,7 @@ func TestServerClassPatch(ctx context.Context, metalClient client.Client, cluste time.Sleep(time.Second * 10) - response := &v1alpha1.Server{} + response := &metalv1.Server{} require.NoError(t, metalClient.Get(ctx, types.NamespacedName{Name: dummyServer.Name}, response)) require.Greater(t, len(response.Finalizers), 0) @@ -303,8 +303,8 @@ func TestServerClassPatch(ctx context.Context, metalClient client.Client, cluste } } -func createServerClass(ctx context.Context, metalClient client.Client, name string, spec v1alpha1.ServerClassSpec) (v1alpha1.ServerClass, error) { - var retClass v1alpha1.ServerClass +func createServerClass(ctx context.Context, metalClient client.Client, name string, spec metalv1.ServerClassSpec) (metalv1.ServerClass, error) { + var retClass metalv1.ServerClass if err := metalClient.Get(ctx, types.NamespacedName{Name: name}, &retClass); err != nil { if !apierrors.IsNotFound(err) {