Fixup storage activation

This commit is contained in:
2021-11-30 17:29:42 +01:00
parent b586b1eac8
commit 34bd64f4b3
4 changed files with 120 additions and 11 deletions

View File

@@ -38,11 +38,12 @@ type ContainerPort struct {
}
type Container struct {
Name string `yaml:"name,omitempty"`
Image string `yaml:"image"`
Ports []*ContainerPort `yaml:"ports,omitempty"`
Env []Value `yaml:"env,omitempty"`
Command []string `yaml:"command,omitempty"`
Name string `yaml:"name,omitempty"`
Image string `yaml:"image"`
Ports []*ContainerPort `yaml:"ports,omitempty"`
Env []Value `yaml:"env,omitempty"`
Command []string `yaml:"command,omitempty"`
VolumeMounts []interface{} `yaml:"volumeMounts,omitempty"`
}
func NewContainer(name, image string, environment, labels map[string]string) *Container {
@@ -71,8 +72,9 @@ func NewContainer(name, image string, environment, labels map[string]string) *Co
}
type PodSpec struct {
InitContainers []*Container `yaml:"initContainers,omitempty"`
Containers []*Container `yaml:"containers"`
InitContainers []*Container `yaml:"initContainers,omitempty"`
Containers []*Container `yaml:"containers"`
Volumes []map[string]interface{} `yaml:"volumes,omitempty"`
}
type PodTemplate struct {

29
helm/storage.go Normal file
View File

@@ -0,0 +1,29 @@
package helm
type Storage struct {
*K8sBase `yaml:",inline"`
Spec *PVCSpec
}
func NewPVC(name, storageName string) *Storage {
pvc := &Storage{}
pvc.K8sBase = NewBase()
pvc.K8sBase.Kind = "PersistentVolumeClaim"
pvc.K8sBase.Metadata.Labels[K+"/pvc-name"] = storageName
pvc.K8sBase.ApiVersion = "v1"
pvc.K8sBase.Metadata.Name = "{{ .Release.Name }}-" + storageName
pvc.Spec = &PVCSpec{
Resouces: map[string]interface{}{
"requests": map[string]string{
"capacity": "{{ .Values." + name + ".persistence." + storageName + ".capacity }}",
},
},
AccessModes: []string{"ReadWriteOnce"},
}
return pvc
}
type PVCSpec struct {
Resouces map[string]interface{} `yaml:"resources"`
AccessModes []string `yaml:"accessModes"`
}