Skip to content

Commit 91b2c9a

Browse files
authored
Merge pull request #1547 from gianlucam76/take-ownership
(feat) add takeOwnership
2 parents e583b1e + 22b4f5d commit 91b2c9a

File tree

8 files changed

+123
-1
lines changed

8 files changed

+123
-1
lines changed

api/v1beta1/spec.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ type HelmInstallOptions struct {
254254
// +kubebuilder:default:=false
255255
// +optional
256256
DisableHooks bool `json:"disableHooks,omitempty"`
257+
258+
// if set, install will ignore the check for helm annotations
259+
// and take ownership of the existing resources
260+
// +kubebuilder:default:=false
261+
// +optional
262+
TakeOwnership bool `json:"takeOwnership,omitempty"`
257263
}
258264

259265
type HelmUpgradeOptions struct {
@@ -317,6 +323,12 @@ type HelmUpgradeOptions struct {
317323
// +kubebuilder:default:=false
318324
// +optional
319325
DisableHooks bool `json:"disableHooks,omitempty"`
326+
327+
// if set, upgrade will ignore the check for helm annotations
328+
// and take ownership of the existing resources
329+
// +kubebuilder:default:=false
330+
// +optional
331+
TakeOwnership bool `json:"takeOwnership,omitempty"`
320332
}
321333

322334
type HelmUninstallOptions struct {

config/crd/bases/config.projectsveltos.io_clusterprofiles.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,12 @@ spec:
323323
description: Replaces if set indicates to replace an
324324
older release with this one
325325
type: boolean
326+
takeOwnership:
327+
default: false
328+
description: |-
329+
if set, install will ignore the check for helm annotations
330+
and take ownership of the existing resources
331+
type: boolean
326332
type: object
327333
labels:
328334
additionalProperties:
@@ -434,6 +440,12 @@ spec:
434440
description: SubNotes determines whether sub-notes are
435441
rendered in the chart.
436442
type: boolean
443+
takeOwnership:
444+
default: false
445+
description: |-
446+
if set, upgrade will ignore the check for helm annotations
447+
and take ownership of the existing resources
448+
type: boolean
437449
upgradeCRDs:
438450
default: false
439451
description: |-

config/crd/bases/config.projectsveltos.io_clusterpromotions.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ spec:
223223
description: Replaces if set indicates to replace
224224
an older release with this one
225225
type: boolean
226+
takeOwnership:
227+
default: false
228+
description: |-
229+
if set, install will ignore the check for helm annotations
230+
and take ownership of the existing resources
231+
type: boolean
226232
type: object
227233
labels:
228234
additionalProperties:
@@ -335,6 +341,12 @@ spec:
335341
description: SubNotes determines whether sub-notes
336342
are rendered in the chart.
337343
type: boolean
344+
takeOwnership:
345+
default: false
346+
description: |-
347+
if set, upgrade will ignore the check for helm annotations
348+
and take ownership of the existing resources
349+
type: boolean
338350
upgradeCRDs:
339351
default: false
340352
description: |-

config/crd/bases/config.projectsveltos.io_clustersummaries.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ spec:
360360
description: Replaces if set indicates to replace
361361
an older release with this one
362362
type: boolean
363+
takeOwnership:
364+
default: false
365+
description: |-
366+
if set, install will ignore the check for helm annotations
367+
and take ownership of the existing resources
368+
type: boolean
363369
type: object
364370
labels:
365371
additionalProperties:
@@ -472,6 +478,12 @@ spec:
472478
description: SubNotes determines whether sub-notes
473479
are rendered in the chart.
474480
type: boolean
481+
takeOwnership:
482+
default: false
483+
description: |-
484+
if set, upgrade will ignore the check for helm annotations
485+
and take ownership of the existing resources
486+
type: boolean
475487
upgradeCRDs:
476488
default: false
477489
description: |-

config/crd/bases/config.projectsveltos.io_profiles.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,12 @@ spec:
323323
description: Replaces if set indicates to replace an
324324
older release with this one
325325
type: boolean
326+
takeOwnership:
327+
default: false
328+
description: |-
329+
if set, install will ignore the check for helm annotations
330+
and take ownership of the existing resources
331+
type: boolean
326332
type: object
327333
labels:
328334
additionalProperties:
@@ -434,6 +440,12 @@ spec:
434440
description: SubNotes determines whether sub-notes are
435441
rendered in the chart.
436442
type: boolean
443+
takeOwnership:
444+
default: false
445+
description: |-
446+
if set, upgrade will ignore the check for helm annotations
447+
and take ownership of the existing resources
448+
type: boolean
437449
upgradeCRDs:
438450
default: false
439451
description: |-

controllers/handlers_helm.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,6 +3126,18 @@ func getWaitForJobsHelmValue(options *configv1beta1.HelmOptions) bool {
31263126
return false
31273127
}
31283128

3129+
func getTakeOwnershipHelmValue(options *configv1beta1.HelmOptions, isUpgrade bool) bool {
3130+
if options == nil {
3131+
return false
3132+
}
3133+
3134+
if isUpgrade {
3135+
return options.UpgradeOptions.TakeOwnership
3136+
}
3137+
3138+
return options.InstallOptions.TakeOwnership
3139+
}
3140+
31293141
func getCreateNamespaceHelmValue(options *configv1beta1.HelmOptions) bool {
31303142
if options != nil {
31313143
return options.InstallOptions.CreateNamespace
@@ -3363,6 +3375,7 @@ func getHelmInstallClient(ctx context.Context, requestedChart *configv1beta1.Hel
33633375
installClient.Labels = getLabelsValue(requestedChart.Options)
33643376
installClient.Description = getDescriptionValue(requestedChart.Options)
33653377
installClient.PassCredentialsAll = getPassCredentialsToAllValue(requestedChart.Options)
3378+
installClient.TakeOwnership = getTakeOwnershipHelmValue(requestedChart.Options, false)
33663379
if actionConfig.RegistryClient != nil {
33673380
installClient.SetRegistryClient(actionConfig.RegistryClient)
33683381
}
@@ -3423,6 +3436,7 @@ func getHelmUpgradeClient(requestedChart *configv1beta1.HelmChart, actionConfig
34233436
upgradeClient.PlainHTTP = registryOptions.plainHTTP
34243437
upgradeClient.CaFile = registryOptions.caPath
34253438
upgradeClient.PassCredentialsAll = getPassCredentialsToAllValue(requestedChart.Options)
3439+
upgradeClient.TakeOwnership = getTakeOwnershipHelmValue(requestedChart.Options, true)
34263440

34273441
if actionConfig.RegistryClient != nil {
34283442
upgradeClient.SetRegistryClient(actionConfig.RegistryClient)

manifest/manifest.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,12 @@ spec:
632632
description: Replaces if set indicates to replace an
633633
older release with this one
634634
type: boolean
635+
takeOwnership:
636+
default: false
637+
description: |-
638+
if set, install will ignore the check for helm annotations
639+
and take ownership of the existing resources
640+
type: boolean
635641
type: object
636642
labels:
637643
additionalProperties:
@@ -743,6 +749,12 @@ spec:
743749
description: SubNotes determines whether sub-notes are
744750
rendered in the chart.
745751
type: boolean
752+
takeOwnership:
753+
default: false
754+
description: |-
755+
if set, upgrade will ignore the check for helm annotations
756+
and take ownership of the existing resources
757+
type: boolean
746758
upgradeCRDs:
747759
default: false
748760
description: |-
@@ -1931,6 +1943,12 @@ spec:
19311943
description: Replaces if set indicates to replace
19321944
an older release with this one
19331945
type: boolean
1946+
takeOwnership:
1947+
default: false
1948+
description: |-
1949+
if set, install will ignore the check for helm annotations
1950+
and take ownership of the existing resources
1951+
type: boolean
19341952
type: object
19351953
labels:
19361954
additionalProperties:
@@ -2043,6 +2061,12 @@ spec:
20432061
description: SubNotes determines whether sub-notes
20442062
are rendered in the chart.
20452063
type: boolean
2064+
takeOwnership:
2065+
default: false
2066+
description: |-
2067+
if set, upgrade will ignore the check for helm annotations
2068+
and take ownership of the existing resources
2069+
type: boolean
20462070
upgradeCRDs:
20472071
default: false
20482072
description: |-
@@ -3866,6 +3890,12 @@ spec:
38663890
description: Replaces if set indicates to replace
38673891
an older release with this one
38683892
type: boolean
3893+
takeOwnership:
3894+
default: false
3895+
description: |-
3896+
if set, install will ignore the check for helm annotations
3897+
and take ownership of the existing resources
3898+
type: boolean
38693899
type: object
38703900
labels:
38713901
additionalProperties:
@@ -3978,6 +4008,12 @@ spec:
39784008
description: SubNotes determines whether sub-notes
39794009
are rendered in the chart.
39804010
type: boolean
4011+
takeOwnership:
4012+
default: false
4013+
description: |-
4014+
if set, upgrade will ignore the check for helm annotations
4015+
and take ownership of the existing resources
4016+
type: boolean
39814017
upgradeCRDs:
39824018
default: false
39834019
description: |-
@@ -5249,6 +5285,12 @@ spec:
52495285
description: Replaces if set indicates to replace an
52505286
older release with this one
52515287
type: boolean
5288+
takeOwnership:
5289+
default: false
5290+
description: |-
5291+
if set, install will ignore the check for helm annotations
5292+
and take ownership of the existing resources
5293+
type: boolean
52525294
type: object
52535295
labels:
52545296
additionalProperties:
@@ -5360,6 +5402,12 @@ spec:
53605402
description: SubNotes determines whether sub-notes are
53615403
rendered in the chart.
53625404
type: boolean
5405+
takeOwnership:
5406+
default: false
5407+
description: |-
5408+
if set, upgrade will ignore the check for helm annotations
5409+
and take ownership of the existing resources
5410+
type: boolean
53635411
upgradeCRDs:
53645412
default: false
53655413
description: |-

test/pullmode-sveltosapplier.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ spec:
9999
valueFrom:
100100
fieldRef:
101101
fieldPath: metadata.namespace
102-
image: docker.io/projectsveltos/sveltos-applier@sha256:036caed08715f4636080721d5009388aa65d71e8a617be45ca8178ebd838d0c2
102+
image: docker.io/projectsveltos/sveltos-applier@sha256:939d489585c1bb3c4e9770f125c4416166a516a3af289816e8f333e0fa42f7fb
103103
livenessProbe:
104104
failureThreshold: 3
105105
httpGet:

0 commit comments

Comments
 (0)