Skip to content

Commit 8f30c82

Browse files
committed
adding generic patch field
Signed-off-by: Hemant Joshi <mail@hjoshi.me>
1 parent 324c696 commit 8f30c82

16 files changed

+1059
-20
lines changed

api/v1alpha2/provider_types.go

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const (
3737
)
3838

3939
// ProviderSpec is the desired state of the Provider.
40+
// +kubebuilder:validation:XValidation:rule="!(has(self.manifestPatches) && has(self.patches))",message="Cannot set both 'patches' and 'manifestPatches'"
41+
4042
type ProviderSpec struct {
4143
// Version indicates the provider version.
4244
// +optional
@@ -79,17 +81,60 @@ type ProviderSpec struct {
7981
// provider manifests. Patches are applied in the order they are specified.
8082
// The `kind` field must match the target object, and
8183
// if `apiVersion` is specified it will only be applied to matching objects.
82-
// This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396
84+
// This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396.
85+
// This will be deprecated in future releases in favor of `patches`.
8386
// +optional
8487
ManifestPatches []string `json:"manifestPatches,omitempty"`
8588

89+
// Patches are applied to the rendered provider manifests to customize the
90+
// provider manifests. Pathces support both strategic merge patch and RFC6902 JSON patches.
91+
// Both `patches` and `manifestPatches` cannot be set at the same time.
92+
// +optional
93+
Patches []*Patch `json:"patches,omitempty"`
94+
8695
// AdditionalDeployments is a map of additional deployments that the provider
8796
// should manage. The key is the name of the deployment and the value is the
8897
// DeploymentSpec.
8998
// +optional
9099
AdditionalDeployments map[string]AdditionalDeployments `json:"additionalDeployments,omitempty"`
91100
}
92101

102+
// Patch defines a generic patch to be applied to provider manifests.
103+
type Patch struct {
104+
// Patch is content of the patch to be applied. It should be an inline yaml blob-string.
105+
// +optional
106+
Patch string `json:"patch,omitempty"`
107+
// Target defines the target object to which the patch should be applied.
108+
Target *PatchSelector `json:"target,omitempty"`
109+
}
110+
111+
type PatchSelector struct {
112+
// Group is the API Group of the target object.
113+
// +optional
114+
Group string `json:"group,omitempty"`
115+
116+
// Version is the API version of the target object.
117+
// +optional
118+
Version string `json:"version,omitempty"`
119+
120+
// Kind is the kind of the target object.
121+
// +optional
122+
Kind string `json:"kind,omitempty"`
123+
124+
// Name is the name of the target object.
125+
// +optional
126+
Name string `json:"name,omitempty"`
127+
128+
// Namespace is the namespace of the target object.
129+
// +optional
130+
Namespace string `json:"namespace,omitempty"`
131+
132+
// LabelSelector is a string that follows the label selection expression
133+
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
134+
// +optional
135+
LabelSelector string `json:"labelSelector,omitempty"`
136+
}
137+
93138
// AdditionalDeployments defines the properties that can be enabled on the controller
94139
// manager and deployment for the provider if the provider is managing additional deployments.
95140
type AdditionalDeployments struct {

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/operator.cluster.x-k8s.io_addonproviders.yaml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3037,14 +3037,58 @@ spec:
30373037
provider manifests. Patches are applied in the order they are specified.
30383038
The `kind` field must match the target object, and
30393039
if `apiVersion` is specified it will only be applied to matching objects.
3040-
This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396
3040+
This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396.
3041+
This will be deprecated in future releases in favor of `patches`.
30413042
items:
30423043
type: string
30433044
type: array
3045+
patches:
3046+
description: |-
3047+
Patches are applied to the rendered provider manifests to customize the
3048+
provider manifests. Pathces support both strategic merge patch and RFC6902 JSON patches.
3049+
Both `patches` and `manifestPatches` cannot be set at the same time.
3050+
items:
3051+
description: Patch defines a generic patch to be applied to provider
3052+
manifests.
3053+
properties:
3054+
patch:
3055+
description: Patch is content of the patch to be applied. It
3056+
should be an inline yaml blob-string.
3057+
type: string
3058+
target:
3059+
description: Target defines the target object to which the patch
3060+
should be applied.
3061+
properties:
3062+
group:
3063+
description: Group is the API Group of the target object.
3064+
type: string
3065+
kind:
3066+
description: Kind is the kind of the target object.
3067+
type: string
3068+
labelSelector:
3069+
description: |-
3070+
LabelSelector is a string that follows the label selection expression
3071+
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
3072+
type: string
3073+
name:
3074+
description: Name is the name of the target object.
3075+
type: string
3076+
namespace:
3077+
description: Namespace is the namespace of the target object.
3078+
type: string
3079+
version:
3080+
description: Version is the API version of the target object.
3081+
type: string
3082+
type: object
3083+
type: object
3084+
type: array
30443085
version:
30453086
description: Version indicates the provider version.
30463087
type: string
30473088
type: object
3089+
x-kubernetes-validations:
3090+
- message: Cannot set both 'patches' and 'manifestPatches'
3091+
rule: '!(has(self.manifestPatches) && has(self.patches))'
30483092
status:
30493093
description: AddonProviderStatus defines the observed state of AddonProvider.
30503094
properties:

config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3037,14 +3037,58 @@ spec:
30373037
provider manifests. Patches are applied in the order they are specified.
30383038
The `kind` field must match the target object, and
30393039
if `apiVersion` is specified it will only be applied to matching objects.
3040-
This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396
3040+
This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396.
3041+
This will be deprecated in future releases in favor of `patches`.
30413042
items:
30423043
type: string
30433044
type: array
3045+
patches:
3046+
description: |-
3047+
Patches are applied to the rendered provider manifests to customize the
3048+
provider manifests. Pathces support both strategic merge patch and RFC6902 JSON patches.
3049+
Both `patches` and `manifestPatches` cannot be set at the same time.
3050+
items:
3051+
description: Patch defines a generic patch to be applied to provider
3052+
manifests.
3053+
properties:
3054+
patch:
3055+
description: Patch is content of the patch to be applied. It
3056+
should be an inline yaml blob-string.
3057+
type: string
3058+
target:
3059+
description: Target defines the target object to which the patch
3060+
should be applied.
3061+
properties:
3062+
group:
3063+
description: Group is the API Group of the target object.
3064+
type: string
3065+
kind:
3066+
description: Kind is the kind of the target object.
3067+
type: string
3068+
labelSelector:
3069+
description: |-
3070+
LabelSelector is a string that follows the label selection expression
3071+
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
3072+
type: string
3073+
name:
3074+
description: Name is the name of the target object.
3075+
type: string
3076+
namespace:
3077+
description: Namespace is the namespace of the target object.
3078+
type: string
3079+
version:
3080+
description: Version is the API version of the target object.
3081+
type: string
3082+
type: object
3083+
type: object
3084+
type: array
30443085
version:
30453086
description: Version indicates the provider version.
30463087
type: string
30473088
type: object
3089+
x-kubernetes-validations:
3090+
- message: Cannot set both 'patches' and 'manifestPatches'
3091+
rule: '!(has(self.manifestPatches) && has(self.patches))'
30483092
status:
30493093
description: BootstrapProviderStatus defines the observed state of BootstrapProvider.
30503094
properties:

config/crd/bases/operator.cluster.x-k8s.io_controlplaneproviders.yaml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3038,14 +3038,58 @@ spec:
30383038
provider manifests. Patches are applied in the order they are specified.
30393039
The `kind` field must match the target object, and
30403040
if `apiVersion` is specified it will only be applied to matching objects.
3041-
This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396
3041+
This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396.
3042+
This will be deprecated in future releases in favor of `patches`.
30423043
items:
30433044
type: string
30443045
type: array
3046+
patches:
3047+
description: |-
3048+
Patches are applied to the rendered provider manifests to customize the
3049+
provider manifests. Pathces support both strategic merge patch and RFC6902 JSON patches.
3050+
Both `patches` and `manifestPatches` cannot be set at the same time.
3051+
items:
3052+
description: Patch defines a generic patch to be applied to provider
3053+
manifests.
3054+
properties:
3055+
patch:
3056+
description: Patch is content of the patch to be applied. It
3057+
should be an inline yaml blob-string.
3058+
type: string
3059+
target:
3060+
description: Target defines the target object to which the patch
3061+
should be applied.
3062+
properties:
3063+
group:
3064+
description: Group is the API Group of the target object.
3065+
type: string
3066+
kind:
3067+
description: Kind is the kind of the target object.
3068+
type: string
3069+
labelSelector:
3070+
description: |-
3071+
LabelSelector is a string that follows the label selection expression
3072+
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
3073+
type: string
3074+
name:
3075+
description: Name is the name of the target object.
3076+
type: string
3077+
namespace:
3078+
description: Namespace is the namespace of the target object.
3079+
type: string
3080+
version:
3081+
description: Version is the API version of the target object.
3082+
type: string
3083+
type: object
3084+
type: object
3085+
type: array
30453086
version:
30463087
description: Version indicates the provider version.
30473088
type: string
30483089
type: object
3090+
x-kubernetes-validations:
3091+
- message: Cannot set both 'patches' and 'manifestPatches'
3092+
rule: '!(has(self.manifestPatches) && has(self.patches))'
30493093
status:
30503094
description: ControlPlaneProviderStatus defines the observed state of
30513095
ControlPlaneProvider.

config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3037,14 +3037,58 @@ spec:
30373037
provider manifests. Patches are applied in the order they are specified.
30383038
The `kind` field must match the target object, and
30393039
if `apiVersion` is specified it will only be applied to matching objects.
3040-
This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396
3040+
This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396.
3041+
This will be deprecated in future releases in favor of `patches`.
30413042
items:
30423043
type: string
30433044
type: array
3045+
patches:
3046+
description: |-
3047+
Patches are applied to the rendered provider manifests to customize the
3048+
provider manifests. Pathces support both strategic merge patch and RFC6902 JSON patches.
3049+
Both `patches` and `manifestPatches` cannot be set at the same time.
3050+
items:
3051+
description: Patch defines a generic patch to be applied to provider
3052+
manifests.
3053+
properties:
3054+
patch:
3055+
description: Patch is content of the patch to be applied. It
3056+
should be an inline yaml blob-string.
3057+
type: string
3058+
target:
3059+
description: Target defines the target object to which the patch
3060+
should be applied.
3061+
properties:
3062+
group:
3063+
description: Group is the API Group of the target object.
3064+
type: string
3065+
kind:
3066+
description: Kind is the kind of the target object.
3067+
type: string
3068+
labelSelector:
3069+
description: |-
3070+
LabelSelector is a string that follows the label selection expression
3071+
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
3072+
type: string
3073+
name:
3074+
description: Name is the name of the target object.
3075+
type: string
3076+
namespace:
3077+
description: Namespace is the namespace of the target object.
3078+
type: string
3079+
version:
3080+
description: Version is the API version of the target object.
3081+
type: string
3082+
type: object
3083+
type: object
3084+
type: array
30443085
version:
30453086
description: Version indicates the provider version.
30463087
type: string
30473088
type: object
3089+
x-kubernetes-validations:
3090+
- message: Cannot set both 'patches' and 'manifestPatches'
3091+
rule: '!(has(self.manifestPatches) && has(self.patches))'
30483092
status:
30493093
description: CoreProviderStatus defines the observed state of CoreProvider.
30503094
properties:

0 commit comments

Comments
 (0)