From d8958b539e331bf5ebb056b7f872541e13fb8e01 Mon Sep 17 00:00:00 2001 From: Enxebre Date: Mon, 29 Apr 2019 11:19:34 +0200 Subject: [PATCH] UPSTREAM: : openshift: Drop ProviderSpec.ValueFrom field --- config/crds/machine_v1beta1_cluster.yaml | 14 ------ config/crds/machine_v1beta1_machine.yaml | 14 ------ .../machine_v1beta1_machinedeployment.yaml | 14 ------ config/crds/machine_v1beta1_machineset.yaml | 14 ------ pkg/apis/machine/v1beta1/common_types.go | 26 +--------- pkg/apis/machine/v1beta1/machine_types.go | 4 +- .../machine/v1beta1/zz_generated.deepcopy.go | 47 ------------------- pkg/controller/machine/BUILD.bazel | 1 + pkg/controller/machine/controller_test.go | 20 ++++---- 9 files changed, 12 insertions(+), 142 deletions(-) diff --git a/config/crds/machine_v1beta1_cluster.yaml b/config/crds/machine_v1beta1_cluster.yaml index 253ebd0d3c40..507760d978a7 100644 --- a/config/crds/machine_v1beta1_cluster.yaml +++ b/config/crds/machine_v1beta1_cluster.yaml @@ -73,20 +73,6 @@ spec: their own versioned API types that should be serialized/deserialized from this field, akin to component config. type: object - valueFrom: - description: Source for the provider configuration. Cannot be used - if value is not empty. - properties: - machineClass: - description: The machine class from which the provider config - should be sourced. - properties: - provider: - description: Provider is the name of the cloud-provider - which MachineClass is intended for. - type: string - type: object - type: object type: object required: - clusterNetwork diff --git a/config/crds/machine_v1beta1_machine.yaml b/config/crds/machine_v1beta1_machine.yaml index 791c3d75e62b..e4944fbe7f2b 100644 --- a/config/crds/machine_v1beta1_machine.yaml +++ b/config/crds/machine_v1beta1_machine.yaml @@ -61,20 +61,6 @@ spec: their own versioned API types that should be serialized/deserialized from this field, akin to component config. type: object - valueFrom: - description: Source for the provider configuration. Cannot be used - if value is not empty. - properties: - machineClass: - description: The machine class from which the provider config - should be sourced. - properties: - provider: - description: Provider is the name of the cloud-provider - which MachineClass is intended for. - type: string - type: object - type: object type: object taints: description: Taints is the full, authoritative list of taints to apply diff --git a/config/crds/machine_v1beta1_machinedeployment.yaml b/config/crds/machine_v1beta1_machinedeployment.yaml index f89fcf3614e7..00cd0bdf9b43 100644 --- a/config/crds/machine_v1beta1_machinedeployment.yaml +++ b/config/crds/machine_v1beta1_machinedeployment.yaml @@ -157,20 +157,6 @@ spec: should be serialized/deserialized from this field, akin to component config. type: object - valueFrom: - description: Source for the provider configuration. Cannot - be used if value is not empty. - properties: - machineClass: - description: The machine class from which the provider - config should be sourced. - properties: - provider: - description: Provider is the name of the cloud-provider - which MachineClass is intended for. - type: string - type: object - type: object type: object taints: description: Taints is the full, authoritative list of taints diff --git a/config/crds/machine_v1beta1_machineset.yaml b/config/crds/machine_v1beta1_machineset.yaml index 1aa1de74d6bc..689896305960 100644 --- a/config/crds/machine_v1beta1_machineset.yaml +++ b/config/crds/machine_v1beta1_machineset.yaml @@ -97,20 +97,6 @@ spec: should be serialized/deserialized from this field, akin to component config. type: object - valueFrom: - description: Source for the provider configuration. Cannot - be used if value is not empty. - properties: - machineClass: - description: The machine class from which the provider - config should be sourced. - properties: - provider: - description: Provider is the name of the cloud-provider - which MachineClass is intended for. - type: string - type: object - type: object type: object taints: description: Taints is the full, authoritative list of taints diff --git a/pkg/apis/machine/v1beta1/common_types.go b/pkg/apis/machine/v1beta1/common_types.go index 7884754101dd..5ee990c9f21a 100644 --- a/pkg/apis/machine/v1beta1/common_types.go +++ b/pkg/apis/machine/v1beta1/common_types.go @@ -17,8 +17,7 @@ limitations under the License. package v1beta1 import ( - corev1 "k8s.io/api/core/v1" - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime" ) // ProviderSpec defines the configuration to use during node creation. @@ -32,27 +31,4 @@ type ProviderSpec struct { // field, akin to component config. // +optional Value *runtime.RawExtension `json:"value,omitempty"` - - // Source for the provider configuration. Cannot be used if value is - // not empty. - // +optional - ValueFrom *ProviderSpecSource `json:"valueFrom,omitempty"` -} - -// ProviderSpecSource represents a source for the provider-specific -// resource configuration. -type ProviderSpecSource struct { - // The machine class from which the provider config should be sourced. - // +optional - MachineClass *MachineClassRef `json:"machineClass,omitempty"` -} - -// MachineClassRef is a reference to the MachineClass object. Controllers should find the right MachineClass using this reference. -type MachineClassRef struct { - // +optional - *corev1.ObjectReference `json:",inline"` - - // Provider is the name of the cloud-provider which MachineClass is intended for. - // +optional - Provider string `json:"provider,omitempty"` } diff --git a/pkg/apis/machine/v1beta1/machine_types.go b/pkg/apis/machine/v1beta1/machine_types.go index 926c6915195c..cab20ee0952e 100644 --- a/pkg/apis/machine/v1beta1/machine_types.go +++ b/pkg/apis/machine/v1beta1/machine_types.go @@ -193,8 +193,8 @@ func (m *Machine) Validate() field.ErrorList { } // validate provider config is set - if m.Spec.ProviderSpec.Value == nil && m.Spec.ProviderSpec.ValueFrom == nil { - errors = append(errors, field.Invalid(fldPath.Child("spec").Child("providerspec"), m.Spec.ProviderSpec, "at least one of value or valueFrom fields must be set")) + if m.Spec.ProviderSpec.Value == nil { + errors = append(errors, field.Invalid(fldPath.Child("spec").Child("providerspec"), m.Spec.ProviderSpec, "value field must be set")) } return errors diff --git a/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go b/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go index 67a6eff0d21b..ec66da125674 100644 --- a/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go @@ -289,27 +289,6 @@ func (in *MachineClassList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MachineClassRef) DeepCopyInto(out *MachineClassRef) { - *out = *in - if in.ObjectReference != nil { - in, out := &in.ObjectReference, &out.ObjectReference - *out = new(v1.ObjectReference) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineClassRef. -func (in *MachineClassRef) DeepCopy() *MachineClassRef { - if in == nil { - return nil - } - out := new(MachineClassRef) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineDeployment) DeepCopyInto(out *MachineDeployment) { *out = *in @@ -752,11 +731,6 @@ func (in *ProviderSpec) DeepCopyInto(out *ProviderSpec) { *out = new(runtime.RawExtension) (*in).DeepCopyInto(*out) } - if in.ValueFrom != nil { - in, out := &in.ValueFrom, &out.ValueFrom - *out = new(ProviderSpecSource) - (*in).DeepCopyInto(*out) - } return } @@ -769,24 +743,3 @@ func (in *ProviderSpec) DeepCopy() *ProviderSpec { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ProviderSpecSource) DeepCopyInto(out *ProviderSpecSource) { - *out = *in - if in.MachineClass != nil { - in, out := &in.MachineClass, &out.MachineClass - *out = new(MachineClassRef) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderSpecSource. -func (in *ProviderSpecSource) DeepCopy() *ProviderSpecSource { - if in == nil { - return nil - } - out := new(ProviderSpecSource) - in.DeepCopyInto(out) - return out -} diff --git a/pkg/controller/machine/BUILD.bazel b/pkg/controller/machine/BUILD.bazel index ce06c7775344..006b431d2b43 100644 --- a/pkg/controller/machine/BUILD.bazel +++ b/pkg/controller/machine/BUILD.bazel @@ -48,6 +48,7 @@ go_test( "//pkg/controller/error:go_default_library", "//vendor/golang.org/x/net/context:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", "//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library", "//vendor/k8s.io/client-go/rest:go_default_library", diff --git a/pkg/controller/machine/controller_test.go b/pkg/controller/machine/controller_test.go index 7dcf9a985a92..18f76f6e1fb1 100644 --- a/pkg/controller/machine/controller_test.go +++ b/pkg/controller/machine/controller_test.go @@ -20,6 +20,8 @@ import ( "reflect" "testing" + "k8s.io/apimachinery/pkg/runtime" + "github.com/openshift/cluster-api/pkg/apis/cluster/v1alpha1" "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -49,10 +51,8 @@ func TestReconcileRequest(t *testing.T) { }, Spec: v1beta1.MachineSpec{ ProviderSpec: v1beta1.ProviderSpec{ - ValueFrom: &v1beta1.ProviderSpecSource{ - MachineClass: &v1beta1.MachineClassRef{ - Provider: "no-provider", - }, + Value: &runtime.RawExtension{ + Raw: []byte("{}"), }, }, }, @@ -72,10 +72,8 @@ func TestReconcileRequest(t *testing.T) { }, Spec: v1beta1.MachineSpec{ ProviderSpec: v1beta1.ProviderSpec{ - ValueFrom: &v1beta1.ProviderSpecSource{ - MachineClass: &v1beta1.MachineClassRef{ - Provider: "no-provider", - }, + Value: &runtime.RawExtension{ + Raw: []byte("{}"), }, }, }, @@ -97,10 +95,8 @@ func TestReconcileRequest(t *testing.T) { }, Spec: v1beta1.MachineSpec{ ProviderSpec: v1beta1.ProviderSpec{ - ValueFrom: &v1beta1.ProviderSpecSource{ - MachineClass: &v1beta1.MachineClassRef{ - Provider: "no-provider", - }, + Value: &runtime.RawExtension{ + Raw: []byte("{}"), }, }, },