Skip to content

Commit 635642c

Browse files
authored
[fix] inject module registry to values (#667)
Signed-off-by: Stepan Paksashvili <stepan.paksashvili@flant.com>
1 parent bb1f505 commit 635642c

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

pkg/module_manager/models/modules/values_storage.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type ValuesStorage struct {
4444
// result of the merging all input values
4545
resultValues utils.Values
4646
}
47+
4748
type Registry struct {
4849
Base string `json:"base" yaml:"base"`
4950
DockerCfg string `json:"dockercfg" yaml:"dockercfg"`
@@ -183,9 +184,18 @@ func (vs *ValuesStorage) InjectRegistryValue(registry *Registry) {
183184
vs.lock.Lock()
184185
defer vs.lock.Unlock()
185186

186-
vs.schemaStorage.InjectRegistrySpec()
187+
// inject spec to values schema
188+
vs.schemaStorage.InjectRegistrySpec(validation.ValuesSchema)
189+
// inject spec to helm schema
190+
vs.schemaStorage.InjectRegistrySpec(validation.HelmValuesSchema)
191+
192+
if vs.staticValues == nil {
193+
vs.staticValues = utils.Values{}
194+
}
195+
196+
vs.staticValues["registry"] = registry
187197

188-
vs.resultValues["registry"] = registry
198+
_ = vs.calculateResultValues()
189199
}
190200

191201
// GetConfigValues returns only user defined values

pkg/values/validation/schemas.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,16 @@ func validateObject(dataObj interface{}, s *spec.Schema, rootName string) error
161161
}
162162

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

170+
if len(scheme.Properties) == 0 {
171+
scheme.Properties = make(map[string]spec.Schema)
172+
}
173+
170174
scheme.Properties["registry"] = spec.Schema{
171175
SchemaProps: spec.SchemaProps{
172176
Type: spec.StringOrArray{"object"},

0 commit comments

Comments
 (0)