Skip to content

Commit

Permalink
redpanda: remove ImageRepository schema validation
Browse files Browse the repository at this point in the history
Previously, the `image.repository` field had a weak regex associated with it to
prevent invalid values from being passed to Kubernetes. This accidentally
prevented users from leveraging repositories that contained a specified port
due to the `:` character.

Rather than extending the regex or replacing it with an appropriate URL regex,
this commit opts to remove the validation entirely. This string is never parsed
internally within the chart and Kubernetes itself will provide appropriate
error messages if required.

Fixes #1292
  • Loading branch information
chrisseto committed May 22, 2024
1 parent d953e51 commit 112531a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
4 changes: 2 additions & 2 deletions charts/redpanda/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type SecurityContext struct {
}

type Image struct {
Repository ImageRepository `json:"repository" jsonschema:"required,default=docker.redpanda.com/redpandadata/redpanda"`
Repository string `json:"repository" jsonschema:"required,default=docker.redpanda.com/redpandadata/redpanda"`
Tag ImageTag `json:"tag" jsonschema:"default=Chart.appVersion"`
PullPolicy string `json:"pullPolicy" jsonschema:"required,pattern=^(Always|Never|IfNotPresent)$,description=The Kubernetes Pod image pull policy."`
}
Expand Down Expand Up @@ -383,7 +383,7 @@ type Statefulset struct {
Controllers struct {
Image struct {
Tag ImageTag `json:"tag" jsonschema:"required,default=Chart.appVersion"`
Repository ImageRepository `json:"repository" jsonschema:"required,default=docker.redpanda.com/redpandadata/redpanda-operator"`
Repository string `json:"repository" jsonschema:"required,default=docker.redpanda.com/redpandadata/redpanda-operator"`
} `json:"image"`
Enabled bool `json:"enabled"`
Resources any `json:"resources"`
Expand Down
2 changes: 0 additions & 2 deletions charts/redpanda/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@
"repository": {
"default": "docker.redpanda.com/redpandadata/redpanda",
"description": "container image repository",
"pattern": "^[a-z0-9-_/.]+$",
"type": "string"
},
"tag": {
Expand Down Expand Up @@ -1590,7 +1589,6 @@
"properties": {
"repository": {
"default": "docker.redpanda.com/redpandadata/redpanda-operator",
"pattern": "^[a-z0-9-_/.]+$",
"type": "string"
},
"tag": {
Expand Down
10 changes: 5 additions & 5 deletions charts/redpanda/values_partial.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ type PartialSecurityContext struct {
}

type PartialImage struct {
Repository *ImageRepository `json:"repository,omitempty" jsonschema:"required,default=docker.redpanda.com/redpandadata/redpanda"`
Tag *ImageTag `json:"tag,omitempty" jsonschema:"default=Chart.appVersion"`
PullPolicy *string `json:"pullPolicy,omitempty" jsonschema:"required,pattern=^(Always|Never|IfNotPresent)$,description=The Kubernetes Pod image pull policy."`
Repository *string `json:"repository,omitempty" jsonschema:"required,default=docker.redpanda.com/redpandadata/redpanda"`
Tag *ImageTag `json:"tag,omitempty" jsonschema:"default=Chart.appVersion"`
PullPolicy *string `json:"pullPolicy,omitempty" jsonschema:"required,pattern=^(Always|Never|IfNotPresent)$,description=The Kubernetes Pod image pull policy."`
}

type PartialService struct {
Expand Down Expand Up @@ -271,8 +271,8 @@ type PartialStatefulset struct {
} `json:"configWatcher,omitempty"`
Controllers struct {
Image struct {
Tag *ImageTag `json:"tag,omitempty" jsonschema:"required,default=Chart.appVersion"`
Repository *ImageRepository `json:"repository,omitempty" jsonschema:"required,default=docker.redpanda.com/redpandadata/redpanda-operator"`
Tag *ImageTag `json:"tag,omitempty" jsonschema:"required,default=Chart.appVersion"`
Repository *string `json:"repository,omitempty" jsonschema:"required,default=docker.redpanda.com/redpandadata/redpanda-operator"`
} `json:"image,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Resources any `json:"resources,omitempty"`
Expand Down
6 changes: 0 additions & 6 deletions charts/redpanda/values_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ func (ImageTag) JSONSchemaExtend(schema *jsonschema.Schema) {
schema.Pattern = `^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$|^$`
}

type ImageRepository string

func (ImageRepository) JSONSchemaExtend(schema *jsonschema.Schema) {
schema.Pattern = "^[a-z0-9-_/.]+$"
}

type MemoryAmount string

func (MemoryAmount) JSONSchemaExtend(schema *jsonschema.Schema) {
Expand Down

0 comments on commit 112531a

Please sign in to comment.