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
4 changes: 4 additions & 0 deletions pkg/module_manager/models/modules/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,10 @@ func (bm *BasicModule) GetConfigValues(withPrefix bool) utils.Values {
return bm.valuesStorage.GetConfigValues(withPrefix)
}

func (bm *BasicModule) InjectRegistryValue(registry *Registry) {
bm.valuesStorage.InjectRegistryValue(registry)
}

// Synchronization xxx
// TODO: don't like this honestly, i think we can remake it
func (bm *BasicModule) Synchronization() *SynchronizationState {
Expand Down
15 changes: 15 additions & 0 deletions pkg/module_manager/models/modules/values_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ 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"`
Scheme string `json:"scheme" yaml:"scheme"`
CA string `json:"ca,omitempty" yaml:"ca,omitempty"`
}

// NewValuesStorage build a new storage for module values
//
Expand Down Expand Up @@ -173,6 +179,15 @@ func (vs *ValuesStorage) GetValues(withPrefix bool) utils.Values {
return vs.resultValues
}

func (vs *ValuesStorage) InjectRegistryValue(registry *Registry) {
vs.lock.Lock()
defer vs.lock.Unlock()

vs.schemaStorage.InjectRegistrySpec()

vs.resultValues["registry"] = registry
}

// GetConfigValues returns only user defined values
func (vs *ValuesStorage) GetConfigValues(withPrefix bool) utils.Values {
vs.lock.Lock()
Expand Down
30 changes: 30 additions & 0 deletions pkg/values/validation/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,36 @@ func validateObject(dataObj interface{}, s *spec.Schema, rootName string) error
return allErrs.ErrorOrNil()
}

// 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 {
return
}

scheme.Properties["registry"] = spec.Schema{
SchemaProps: spec.SchemaProps{
Type: spec.StringOrArray{"object"},
AdditionalProperties: &spec.SchemaOrBool{Allows: false},
Properties: map[string]spec.Schema{
"base": {
SchemaProps: spec.SchemaProps{Type: spec.StringOrArray{"string"}, MinLength: swag.Int64(1)},
},
"dockercfg": {
SchemaProps: spec.SchemaProps{Type: spec.StringOrArray{"string"}},
},
"scheme": {
SchemaProps: spec.SchemaProps{Type: spec.StringOrArray{"string"}},
},
"ca": {
SchemaProps: spec.SchemaProps{Type: spec.StringOrArray{"string"}},
},
},
Required: []string{"base", "scheme"},
},
}
}

// ModuleSchemasDescription describes which schemas are present in storage for the module.
func (st *SchemaStorage) ModuleSchemasDescription() string {
types := availableSchemaTypes(st.Schemas)
Expand Down
Loading