These unit tests go over all the possible pods using the mount feature and make sure they are all listed in the runtime and priority class, which will make sure we don't miss any. Skip-Release-Notes Change-Id: Iba2e24bebd70f0d99f44566a1b0f115e4faa8f5b
93 lines
2.3 KiB
Go
93 lines
2.3 KiB
Go
package openstack_helm
|
|
|
|
import (
|
|
"gopkg.in/yaml.v2"
|
|
"helm.sh/helm/v3/pkg/chart/loader"
|
|
"helm.sh/helm/v3/pkg/chartutil"
|
|
)
|
|
|
|
type HelmValues struct {
|
|
Pod `yaml:"pod"`
|
|
Conf `yaml:"conf"`
|
|
}
|
|
|
|
type PodPriorityClassConfig map[string]string
|
|
type PodRuntimeClassConfig map[string]string
|
|
|
|
type PodMount map[string]interface{}
|
|
|
|
type Pod struct {
|
|
PriorityClass PodPriorityClassConfig `yaml:"priorityClassName,omitempty"`
|
|
RuntimeClass PodRuntimeClassConfig `yaml:"runtimeClassName,omitempty"`
|
|
Mounts map[string]PodMount `yaml:"mounts,omitempty"`
|
|
}
|
|
|
|
type Conf struct {
|
|
Barbican *BarbicanConf `yaml:"barbican,omitempty"`
|
|
Cinder *CinderConf `yaml:"cinder,omitempty"`
|
|
Designate *DesignateConf `yaml:"designate,omitempty"`
|
|
Glance *GlanceConf `yaml:"glance,omitempty"`
|
|
Heat *HeatConf `yaml:"heat,omitempty"`
|
|
Ironic *IronicConf `yaml:"ironic,omitempty"`
|
|
Keystone *KeystoneConf `yaml:"keystone,omitempty"`
|
|
Magnum *MagnumConf `yaml:"magnum,omitempty"`
|
|
Manila *ManilaConf `yaml:"manila,omitempty"`
|
|
Memcached *MemcachedConf `yaml:"memcached,omitempty"`
|
|
Neutron *NeutronConf `yaml:"neutron,omitempty"`
|
|
Nova *NovaConf `yaml:"nova,omitempty"`
|
|
Octavia *OctaviaConf `yaml:"octavia,omitempty"`
|
|
Placement *PlacementConf `yaml:"placement,omitempty"`
|
|
Staffeln *StaffelnConf `yaml:"staffeln,omitempty"`
|
|
}
|
|
|
|
func (h *HelmValues) YAML() ([]byte, error) {
|
|
return yaml.Marshal(h)
|
|
}
|
|
|
|
func (h *HelmValues) NativeHelmValues() (chartutil.Values, error) {
|
|
yamlData, err := h.YAML()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return chartutil.ReadValues(yamlData)
|
|
}
|
|
|
|
func FromYAML(yamlData []byte) (*HelmValues, error) {
|
|
var helmValues HelmValues
|
|
err := yaml.Unmarshal(yamlData, &helmValues)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &helmValues, nil
|
|
}
|
|
|
|
func FromYAMLString(yamlString string) (*HelmValues, error) {
|
|
return FromYAML([]byte(yamlString))
|
|
}
|
|
|
|
func CoalescedHelmValues(name string, values *HelmValues) (*HelmValues, error) {
|
|
chart, err := loader.Load(name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
releaseValues, err := values.NativeHelmValues()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
mergedValues, err := chartutil.CoalesceValues(chart, releaseValues)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
yamlData, err := mergedValues.YAML()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return FromYAMLString(yamlData)
|
|
}
|