From 611552ecabb8ddedacbfaad36d2b325f3c0a5438 Mon Sep 17 00:00:00 2001 From: Jason DeTiberus Date: Thu, 28 Feb 2019 15:33:28 -0500 Subject: [PATCH] Fix machineClass migration --- cmd/clusterctl/cmd/BUILD.bazel | 1 + cmd/clusterctl/phases/pivot.go | 10 +++++----- cmd/clusterctl/validation/BUILD.bazel | 2 -- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/clusterctl/cmd/BUILD.bazel b/cmd/clusterctl/cmd/BUILD.bazel index df57a5c4f6bf..5756ee05e71a 100644 --- a/cmd/clusterctl/cmd/BUILD.bazel +++ b/cmd/clusterctl/cmd/BUILD.bazel @@ -39,6 +39,7 @@ go_library( "//vendor/github.com/spf13/cobra:go_default_library", "//vendor/github.com/spf13/pflag:go_default_library", "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library", "//vendor/k8s.io/client-go/tools/clientcmd:go_default_library", "//vendor/k8s.io/klog:go_default_library", diff --git a/cmd/clusterctl/phases/pivot.go b/cmd/clusterctl/phases/pivot.go index 1ca23b409938..e54e6de48980 100644 --- a/cmd/clusterctl/phases/pivot.go +++ b/cmd/clusterctl/phases/pivot.go @@ -122,7 +122,7 @@ func pivot(from, to clusterclient.Client, providerComponents string) error { return err } - if err := deleteMachineClasses(from, to, machineClasses); err != nil { + if err := deleteMachineClasses(from, machineClasses); err != nil { return err } @@ -149,7 +149,7 @@ func moveClusters(from, to clusterclient.Client, clusters []*clusterv1.Cluster) return nil } -func deleteMachineClasses(from, to clusterclient.Client, machineClasses []*clusterv1.MachineClass) error { +func deleteMachineClasses(client clusterclient.Client, machineClasses []*clusterv1.MachineClass) error { machineClassNames := make([]string, 0, len(machineClasses)) for _, mc := range machineClasses { machineClassNames = append(machineClassNames, mc.Name) @@ -157,17 +157,17 @@ func deleteMachineClasses(from, to clusterclient.Client, machineClasses []*clust klog.V(4).Infof("Preparing to delete MachineClasses: %v", machineClassNames) for _, mc := range machineClasses { - if err := deleteMachineClass(from, to, mc); err != nil { + if err := deleteMachineClass(client, mc); err != nil { return errors.Wrapf(err, "failed to delete MachineClass %s:%s", mc.Namespace, mc.Name) } } return nil } -func deleteMachineClass(from, to clusterclient.Client, machineClass *clusterv1.MachineClass) error { +func deleteMachineClass(client clusterclient.Client, machineClass *clusterv1.MachineClass) error { // New objects cannot have a specified resource version. Clear it out. machineClass.SetResourceVersion("") - if err := to.DeleteMachineClass(machineClass.Namespace, machineClass.Name); err != nil { + if err := client.DeleteMachineClass(machineClass.Namespace, machineClass.Name); err != nil { return errors.Wrapf(err, "error deleting MachineClass %s/%s from source cluster", machineClass.Namespace, machineClass.Name) } diff --git a/cmd/clusterctl/validation/BUILD.bazel b/cmd/clusterctl/validation/BUILD.bazel index 6077c3a80da5..20bc2c589f49 100644 --- a/cmd/clusterctl/validation/BUILD.bazel +++ b/cmd/clusterctl/validation/BUILD.bazel @@ -13,7 +13,6 @@ go_library( "//pkg/apis/cluster/v1alpha1:go_default_library", "//pkg/controller/noderefutil:go_default_library", "//vendor/github.com/pkg/errors:go_default_library", - "//vendor/golang.org/x/net/context:go_default_library", "//vendor/k8s.io/api/core/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", @@ -34,7 +33,6 @@ go_test( "//pkg/apis/cluster/common:go_default_library", "//pkg/apis/cluster/v1alpha1:go_default_library", "//pkg/apis/cluster/v1alpha1/testutil:go_default_library", - "//vendor/golang.org/x/net/context:go_default_library", "//vendor/k8s.io/api/core/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/types:go_default_library",