Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pkg/module_manager/models/modules/values_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type ValuesStorage struct {
// result of the merging all input values
resultValues utils.Values
}

type Registry struct {
Base string `json:"base" yaml:"base"`
DockerCfg string `json:"dockercfg" yaml:"dockercfg"`
Expand Down Expand Up @@ -183,9 +184,18 @@ func (vs *ValuesStorage) InjectRegistryValue(registry *Registry) {
vs.lock.Lock()
defer vs.lock.Unlock()

vs.schemaStorage.InjectRegistrySpec()
// inject spec to values schema
vs.schemaStorage.InjectRegistrySpec(validation.ValuesSchema)
// inject spec to helm schema
vs.schemaStorage.InjectRegistrySpec(validation.HelmValuesSchema)

if vs.staticValues == nil {
vs.staticValues = utils.Values{}
}

vs.staticValues["registry"] = registry

vs.resultValues["registry"] = registry
_ = vs.calculateResultValues()
}

// GetConfigValues returns only user defined values
Expand Down
10 changes: 7 additions & 3 deletions pkg/values/validation/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,16 @@ func validateObject(dataObj interface{}, s *spec.Schema, rootName string) error
}

// InjectRegistrySpec mutates the module schema to add a strict-typed "registry" field
func (st *SchemaStorage) InjectRegistrySpec() {
scheme := st.Schemas[ValuesSchema]
if scheme == nil || len(scheme.Properties) == 0 {
func (st *SchemaStorage) InjectRegistrySpec(schemaType SchemaType) {
scheme := st.Schemas[schemaType]
if scheme == nil {
return
}

if len(scheme.Properties) == 0 {
scheme.Properties = make(map[string]spec.Schema)
}

scheme.Properties["registry"] = spec.Schema{
SchemaProps: spec.SchemaProps{
Type: spec.StringOrArray{"object"},
Expand Down
Loading