From a0bf36c83c9de0662426e9de67d38fadfb1ef996 Mon Sep 17 00:00:00 2001 From: rmweir Date: Tue, 11 Feb 2020 11:51:27 -0700 Subject: [PATCH 1/2] Add dynamic field to feature type Added dynamic field to feature type. A value of false indicates that changed feature values will not go into effect until rancher restarts. Switched feature type to use spec and status convention. --- apis/management.cattle.io/v3/global_types.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apis/management.cattle.io/v3/global_types.go b/apis/management.cattle.io/v3/global_types.go index 6413139b..e0fc5194 100644 --- a/apis/management.cattle.io/v3/global_types.go +++ b/apis/management.cattle.io/v3/global_types.go @@ -18,6 +18,15 @@ type Feature struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Value *bool `json:"value" norman:"required"` - Default bool `json:"default" norman:"nocreate,noupdate"` + Spec FeatureSpec `json:"spec"` + Status FeatureStatus `json:"status"` +} + +type FeatureSpec struct { + Value *bool `json:"value" norman:"required"` +} + +type FeatureStatus struct { + Dynamic bool `json:"dynamic"` + Default bool `json:"default"` } From 8da85e8d3e06522e4a20bbd340c2195aad78df53 Mon Sep 17 00:00:00 2001 From: rmweir Date: Tue, 11 Feb 2020 13:18:39 -0700 Subject: [PATCH 2/2] go generate --- .../v3/zz_generated_deepcopy.go | 44 +++++++++++++++-- client/management/v3/zz_generated_feature.go | 48 +++++++++++-------- .../v3/zz_generated_feature_spec.go | 10 ++++ .../v3/zz_generated_feature_status.go | 12 +++++ 4 files changed, 88 insertions(+), 26 deletions(-) create mode 100644 client/management/v3/zz_generated_feature_spec.go create mode 100644 client/management/v3/zz_generated_feature_status.go diff --git a/apis/management.cattle.io/v3/zz_generated_deepcopy.go b/apis/management.cattle.io/v3/zz_generated_deepcopy.go index c614c648..1e3bf860 100644 --- a/apis/management.cattle.io/v3/zz_generated_deepcopy.go +++ b/apis/management.cattle.io/v3/zz_generated_deepcopy.go @@ -3358,11 +3358,8 @@ func (in *Feature) DeepCopyInto(out *Feature) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - if in.Value != nil { - in, out := &in.Value, &out.Value - *out = new(bool) - **out = **in - } + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status return } @@ -3417,6 +3414,43 @@ func (in *FeatureList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FeatureSpec) DeepCopyInto(out *FeatureSpec) { + *out = *in + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeatureSpec. +func (in *FeatureSpec) DeepCopy() *FeatureSpec { + if in == nil { + return nil + } + out := new(FeatureSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FeatureStatus) DeepCopyInto(out *FeatureStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeatureStatus. +func (in *FeatureStatus) DeepCopy() *FeatureStatus { + if in == nil { + return nil + } + out := new(FeatureStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Field) DeepCopyInto(out *Field) { *out = *in diff --git a/client/management/v3/zz_generated_feature.go b/client/management/v3/zz_generated_feature.go index 93bc5d5e..a8d17862 100644 --- a/client/management/v3/zz_generated_feature.go +++ b/client/management/v3/zz_generated_feature.go @@ -5,31 +5,37 @@ import ( ) const ( - FeatureType = "feature" - FeatureFieldAnnotations = "annotations" - FeatureFieldCreated = "created" - FeatureFieldCreatorID = "creatorId" - FeatureFieldDefault = "default" - FeatureFieldLabels = "labels" - FeatureFieldName = "name" - FeatureFieldOwnerReferences = "ownerReferences" - FeatureFieldRemoved = "removed" - FeatureFieldUUID = "uuid" - FeatureFieldValue = "value" + FeatureType = "feature" + FeatureFieldAnnotations = "annotations" + FeatureFieldCreated = "created" + FeatureFieldCreatorID = "creatorId" + FeatureFieldLabels = "labels" + FeatureFieldName = "name" + FeatureFieldOwnerReferences = "ownerReferences" + FeatureFieldRemoved = "removed" + FeatureFieldState = "state" + FeatureFieldStatus = "status" + FeatureFieldTransitioning = "transitioning" + FeatureFieldTransitioningMessage = "transitioningMessage" + FeatureFieldUUID = "uuid" + FeatureFieldValue = "value" ) type Feature struct { types.Resource - Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"` - Created string `json:"created,omitempty" yaml:"created,omitempty"` - CreatorID string `json:"creatorId,omitempty" yaml:"creatorId,omitempty"` - Default bool `json:"default,omitempty" yaml:"default,omitempty"` - Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` - Name string `json:"name,omitempty" yaml:"name,omitempty"` - OwnerReferences []OwnerReference `json:"ownerReferences,omitempty" yaml:"ownerReferences,omitempty"` - Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` - UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"` - Value *bool `json:"value,omitempty" yaml:"value,omitempty"` + Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"` + Created string `json:"created,omitempty" yaml:"created,omitempty"` + CreatorID string `json:"creatorId,omitempty" yaml:"creatorId,omitempty"` + Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` + Name string `json:"name,omitempty" yaml:"name,omitempty"` + OwnerReferences []OwnerReference `json:"ownerReferences,omitempty" yaml:"ownerReferences,omitempty"` + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + State string `json:"state,omitempty" yaml:"state,omitempty"` + Status *FeatureStatus `json:"status,omitempty" yaml:"status,omitempty"` + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioningMessage,omitempty"` + UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + Value *bool `json:"value,omitempty" yaml:"value,omitempty"` } type FeatureCollection struct { diff --git a/client/management/v3/zz_generated_feature_spec.go b/client/management/v3/zz_generated_feature_spec.go new file mode 100644 index 00000000..95c50292 --- /dev/null +++ b/client/management/v3/zz_generated_feature_spec.go @@ -0,0 +1,10 @@ +package client + +const ( + FeatureSpecType = "featureSpec" + FeatureSpecFieldValue = "value" +) + +type FeatureSpec struct { + Value *bool `json:"value,omitempty" yaml:"value,omitempty"` +} diff --git a/client/management/v3/zz_generated_feature_status.go b/client/management/v3/zz_generated_feature_status.go new file mode 100644 index 00000000..44ca220d --- /dev/null +++ b/client/management/v3/zz_generated_feature_status.go @@ -0,0 +1,12 @@ +package client + +const ( + FeatureStatusType = "featureStatus" + FeatureStatusFieldDefault = "default" + FeatureStatusFieldDynamic = "dynamic" +) + +type FeatureStatus struct { + Default bool `json:"default,omitempty" yaml:"default,omitempty"` + Dynamic bool `json:"dynamic,omitempty" yaml:"dynamic,omitempty"` +}