Skip to content

Commit 06a4c41

Browse files
committed
adding generic patch field
Signed-off-by: Hemant Joshi <[email protected]>
1 parent 324c696 commit 06a4c41

18 files changed

+1544
-159
lines changed

api/v1alpha2/provider_types.go

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,61 @@ type ProviderSpec struct {
7979
// provider manifests. Patches are applied in the order they are specified.
8080
// The `kind` field must match the target object, and
8181
// 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
82+
// This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396.
83+
// This will be deprecated in future releases in favor of `patches`.
8384
// +optional
8485
ManifestPatches []string `json:"manifestPatches,omitempty"`
8586

87+
// Patches are applied to the rendered provider manifests to customize the
88+
// provider manifests. Pathces support both strategic merge patch and RFC6902 JSON patches.
89+
// If both `manifestPatches` and `patches` are specified, then `patches` gets the priority
90+
// and `manifestPatches` will be ignored.
91+
// +optional
92+
Patches []*Patch `json:"patches,omitempty"`
93+
8694
// AdditionalDeployments is a map of additional deployments that the provider
8795
// should manage. The key is the name of the deployment and the value is the
8896
// DeploymentSpec.
8997
// +optional
9098
AdditionalDeployments map[string]AdditionalDeployments `json:"additionalDeployments,omitempty"`
9199
}
92100

101+
// Patch defines a generic patch to be applied to provider manifests.
102+
type Patch struct {
103+
// Patch is content of the patch to be applied. It should be an inline yaml blob-string.
104+
// +optional
105+
Patch string `json:"patch,omitempty"`
106+
// Target defines the target object to which the patch should be applied.
107+
Target *PatchSelector `json:"target,omitempty"`
108+
}
109+
110+
type PatchSelector struct {
111+
// Group is the API Group of the target object.
112+
// +optional
113+
Group string `json:"group,omitempty"`
114+
115+
// Version is the API version of the target object.
116+
// +optional
117+
Version string `json:"version,omitempty"`
118+
119+
// Kind is the kind of the target object.
120+
// +optional
121+
Kind string `json:"kind,omitempty"`
122+
123+
// Name is the name of the target object.
124+
// +optional
125+
Name string `json:"name,omitempty"`
126+
127+
// Namespace is the namespace of the target object.
128+
// +optional
129+
Namespace string `json:"namespace,omitempty"`
130+
131+
// LabelSelector is a string that follows the label selection expression
132+
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
133+
// +optional
134+
LabelSelector string `json:"labelSelector,omitempty"`
135+
}
136+
93137
// AdditionalDeployments defines the properties that can be enabled on the controller
94138
// manager and deployment for the provider if the provider is managing additional deployments.
95139
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: 129 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@ spec:
634634
most preferred is the one with the greatest sum of weights, i.e.
635635
for each node that meets all of the scheduling requirements (resource
636636
request, requiredDuringScheduling anti-affinity expressions, etc.),
637-
compute a sum by iterating through the elements of this field and adding
638-
"weight" to the sum if the node has pods which matches the corresponding podAffinityTerm; the
637+
compute a sum by iterating through the elements of this field and subtracting
638+
"weight" from the sum if the node has pods which matches the corresponding podAffinityTerm; the
639639
node(s) with the highest sum are the most preferred.
640640
items:
641641
description: The weights of all of the matched
@@ -1015,8 +1015,9 @@ spec:
10151015
present in a Container.
10161016
properties:
10171017
name:
1018-
description: Name of the environment variable.
1019-
Must be a C_IDENTIFIER.
1018+
description: |-
1019+
Name of the environment variable.
1020+
May consist of any printable ASCII characters except '='.
10201021
type: string
10211022
value:
10221023
description: |-
@@ -1075,6 +1076,43 @@ spec:
10751076
- fieldPath
10761077
type: object
10771078
x-kubernetes-map-type: atomic
1079+
fileKeyRef:
1080+
description: |-
1081+
FileKeyRef selects a key of the env file.
1082+
Requires the EnvFiles feature gate to be enabled.
1083+
properties:
1084+
key:
1085+
description: |-
1086+
The key within the env file. An invalid key will prevent the pod from starting.
1087+
The keys defined within a source may consist of any printable ASCII characters except '='.
1088+
During Alpha stage of the EnvFiles feature gate, the key size is limited to 128 characters.
1089+
type: string
1090+
optional:
1091+
default: false
1092+
description: |-
1093+
Specify whether the file or its key must be defined. If the file or key
1094+
does not exist, then the env var is not published.
1095+
If optional is set to true and the specified key does not exist,
1096+
the environment variable will not be set in the Pod's containers.
1097+
1098+
If optional is set to false and the specified key does not exist,
1099+
an error will be returned during Pod creation.
1100+
type: boolean
1101+
path:
1102+
description: |-
1103+
The path within the volume from which to select the file.
1104+
Must be relative and may not contain the '..' path or start with '..'.
1105+
type: string
1106+
volumeName:
1107+
description: The name of the volume
1108+
mount containing the env file.
1109+
type: string
1110+
required:
1111+
- key
1112+
- path
1113+
- volumeName
1114+
type: object
1115+
x-kubernetes-map-type: atomic
10781116
resourceFieldRef:
10791117
description: |-
10801118
Selects a resource of the container: only resources limits and requests
@@ -1146,7 +1184,7 @@ spec:
11461184
Claims lists the names of resources, defined in spec.resourceClaims,
11471185
that are used by this container.
11481186
1149-
This is an alpha field and requires enabling the
1187+
This field depends on the
11501188
DynamicResourceAllocation feature gate.
11511189
11521190
This field is immutable. It can only be set for containers.
@@ -2108,8 +2146,8 @@ spec:
21082146
most preferred is the one with the greatest sum of weights, i.e.
21092147
for each node that meets all of the scheduling requirements (resource
21102148
request, requiredDuringScheduling anti-affinity expressions, etc.),
2111-
compute a sum by iterating through the elements of this field and adding
2112-
"weight" to the sum if the node has pods which matches the corresponding podAffinityTerm; the
2149+
compute a sum by iterating through the elements of this field and subtracting
2150+
"weight" from the sum if the node has pods which matches the corresponding podAffinityTerm; the
21132151
node(s) with the highest sum are the most preferred.
21142152
items:
21152153
description: The weights of all of the matched WeightedPodAffinityTerm
@@ -2487,8 +2525,9 @@ spec:
24872525
present in a Container.
24882526
properties:
24892527
name:
2490-
description: Name of the environment variable. Must
2491-
be a C_IDENTIFIER.
2528+
description: |-
2529+
Name of the environment variable.
2530+
May consist of any printable ASCII characters except '='.
24922531
type: string
24932532
value:
24942533
description: |-
@@ -2546,6 +2585,43 @@ spec:
25462585
- fieldPath
25472586
type: object
25482587
x-kubernetes-map-type: atomic
2588+
fileKeyRef:
2589+
description: |-
2590+
FileKeyRef selects a key of the env file.
2591+
Requires the EnvFiles feature gate to be enabled.
2592+
properties:
2593+
key:
2594+
description: |-
2595+
The key within the env file. An invalid key will prevent the pod from starting.
2596+
The keys defined within a source may consist of any printable ASCII characters except '='.
2597+
During Alpha stage of the EnvFiles feature gate, the key size is limited to 128 characters.
2598+
type: string
2599+
optional:
2600+
default: false
2601+
description: |-
2602+
Specify whether the file or its key must be defined. If the file or key
2603+
does not exist, then the env var is not published.
2604+
If optional is set to true and the specified key does not exist,
2605+
the environment variable will not be set in the Pod's containers.
2606+
2607+
If optional is set to false and the specified key does not exist,
2608+
an error will be returned during Pod creation.
2609+
type: boolean
2610+
path:
2611+
description: |-
2612+
The path within the volume from which to select the file.
2613+
Must be relative and may not contain the '..' path or start with '..'.
2614+
type: string
2615+
volumeName:
2616+
description: The name of the volume mount
2617+
containing the env file.
2618+
type: string
2619+
required:
2620+
- key
2621+
- path
2622+
- volumeName
2623+
type: object
2624+
x-kubernetes-map-type: atomic
25492625
resourceFieldRef:
25502626
description: |-
25512627
Selects a resource of the container: only resources limits and requests
@@ -2614,7 +2690,7 @@ spec:
26142690
Claims lists the names of resources, defined in spec.resourceClaims,
26152691
that are used by this container.
26162692
2617-
This is an alpha field and requires enabling the
2693+
This field depends on the
26182694
DynamicResourceAllocation feature gate.
26192695
26202696
This field is immutable. It can only be set for containers.
@@ -3037,10 +3113,52 @@ spec:
30373113
provider manifests. Patches are applied in the order they are specified.
30383114
The `kind` field must match the target object, and
30393115
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
3116+
This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396.
3117+
This will be deprecated in future releases in favor of `patches`.
30413118
items:
30423119
type: string
30433120
type: array
3121+
patches:
3122+
description: |-
3123+
Patches are applied to the rendered provider manifests to customize the
3124+
provider manifests. Pathces support both strategic merge patch and RFC6902 JSON patches.
3125+
If both `manifestPatches` and `patches` are specified, then `patches` gets the priority
3126+
and `manifestPatches` will be ignored.
3127+
items:
3128+
description: Patch defines a generic patch to be applied to provider
3129+
manifests.
3130+
properties:
3131+
patch:
3132+
description: Patch is content of the patch to be applied. It
3133+
should be an inline yaml blob-string.
3134+
type: string
3135+
target:
3136+
description: Target defines the target object to which the patch
3137+
should be applied.
3138+
properties:
3139+
group:
3140+
description: Group is the API Group of the target object.
3141+
type: string
3142+
kind:
3143+
description: Kind is the kind of the target object.
3144+
type: string
3145+
labelSelector:
3146+
description: |-
3147+
LabelSelector is a string that follows the label selection expression
3148+
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
3149+
type: string
3150+
name:
3151+
description: Name is the name of the target object.
3152+
type: string
3153+
namespace:
3154+
description: Namespace is the namespace of the target object.
3155+
type: string
3156+
version:
3157+
description: Version is the API version of the target object.
3158+
type: string
3159+
type: object
3160+
type: object
3161+
type: array
30443162
version:
30453163
description: Version indicates the provider version.
30463164
type: string

0 commit comments

Comments
 (0)