Update typeconfig OverridePath definition to support multiple overrides
@@ -54,10 +54,9 @@ type FederatedTypeConfigSpec struct {
// provided for the template resource.
// +optional
Override *APIResource `json:"override,omitempty"`
- // The path to the field to override in the target type. The last
- // entry in the path should be the name of the field in the override type.
+ // The list of name:path pairs of the fields to override in target template.
// +optional
- OverridePath []string `json:"overridePath,omitempty"`
+ OverridePaths []OverridePath `json:"overridePaths,omitempty"`
}
// APIResource defines how to configure the dynamic client for an API resource.
@@ -77,6 +76,17 @@ type APIResource struct {
PluralName string `json:"pluralName,omitempty"`
}
+// OverridePath is the name:path pair of the field to override in target template.
+type OverridePath struct {
+ // Name of the override field in the override spec.
+ // If left empty, Defaults to the last (. separated) portion of the
+ // Path string.
+ Name string `json:"name,omitempty"`
+ // The . separated complete path (in target template spec) of the
+ // field to override. For example 'spec.replicas' for ReplicaSets.
+ Path string `json:"path"`
+}
+
// FederatedTypeConfigStatus defines the observed state of FederatedTypeConfig
type FederatedTypeConfigStatus struct {
// ObservedGeneration is the generation as observed by the controller consuming the FederatedTypeConfig.
@@ -126,6 +136,10 @@ func SetFederatedTypeConfigDefaults(obj *FederatedTypeConfig) {
setStringDefault(&obj.Spec.Override.PluralName, PluralName(obj.Spec.Override.Kind))
setStringDefault(&obj.Spec.Override.Group, obj.Spec.Template.Group)
setStringDefault(&obj.Spec.Override.Version, obj.Spec.Template.Version)
+ for index, overridePath := range obj.Spec.OverridePaths {
+ splitPath := strings.Split(overridePath.Path, ".")
+ setStringDefault(&obj.Spec.OverridePaths[index].Name, splitPath[len(splitPath)-1])
+ }
}
}
