Skip to content

Commit

Permalink
fix(harborcluster): don't allow users to switch type between incluste…
Browse files Browse the repository at this point in the history
…r and external (#820)

Signed-off-by: cndoit18 <cndoit18@outlook.com>
  • Loading branch information
cndoit18 committed Nov 26, 2021
1 parent d7f6e61 commit 008767f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions apis/goharbor.io/v1beta1/harborcluster_webhook.go
Expand Up @@ -140,6 +140,24 @@ func (harborcluster *HarborCluster) validate(old *HarborCluster) error {
}
}

if old.Spec.Cache.Kind != harborcluster.Spec.Cache.Kind {
allErrs = append(allErrs, field.Forbidden(
field.NewPath("spec").Child("cache"),
"don't allow to switch cache between incluster and external"))
}

if old.Spec.Database.Kind != harborcluster.Spec.Database.Kind {
allErrs = append(allErrs, field.Forbidden(
field.NewPath("spec").Child("database"),
"don't allow to switch database between incluster and external"))
}

if old.Spec.Storage.Kind != harborcluster.Spec.Storage.Kind {
allErrs = append(allErrs, field.Forbidden(
field.NewPath("spec").Child("storage"),
"don't allow to switch storage between incluster and external"))
}

if len(allErrs) == 0 {
return nil
}
Expand Down

0 comments on commit 008767f

Please sign in to comment.