Refactorisation and improvements
- image of container is now splitted in repository and tag (in values and deployment). The "tag" is tested in deployment - add "chart-version" option Code: - globalize the PVC generation - ensure types for environment values - refactored to make generic the container creation in a deployment - avoiding race condition on ServiceConfig by using a copy (then a pointer of this copy)
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
)
|
||||
|
||||
type EnvValue interface{}
|
||||
|
||||
// ContainerPort represent a port mapping.
|
||||
type ContainerPort struct {
|
||||
Name string
|
||||
@@ -15,8 +17,8 @@ type ContainerPort struct {
|
||||
|
||||
// Value represent a environment variable with name and value.
|
||||
type Value struct {
|
||||
Name string `yaml:"name"`
|
||||
Value interface{} `yaml:"value"`
|
||||
Name string `yaml:"name"`
|
||||
Value EnvValue `yaml:"value"`
|
||||
}
|
||||
|
||||
// Container represent a container with name, image, and environment variables. It is used in Deployment.
|
||||
|
@@ -47,10 +47,12 @@ func (k *K8sBase) BuildSHA(filename string) {
|
||||
k.Metadata.Annotations[K+"/docker-compose-sha1"] = fmt.Sprintf("%x", string(sum[:]))
|
||||
}
|
||||
|
||||
// Get returns the Kind.
|
||||
func (k *K8sBase) Get() string {
|
||||
return k.Kind
|
||||
}
|
||||
|
||||
// Name returns the name of the object from Metadata.
|
||||
func (k *K8sBase) Name() string {
|
||||
return k.Metadata.Name
|
||||
}
|
||||
|
@@ -1,5 +1,20 @@
|
||||
package helm
|
||||
|
||||
import "sync"
|
||||
|
||||
var (
|
||||
made = make(map[string]bool)
|
||||
locker = sync.Mutex{}
|
||||
)
|
||||
|
||||
// ResetMadePVC resets the cache of made PVCs.
|
||||
// Useful in tests only.
|
||||
func ResetMadePVC() {
|
||||
locker.Lock()
|
||||
defer locker.Unlock()
|
||||
made = make(map[string]bool)
|
||||
}
|
||||
|
||||
// Storage is a struct for a PersistentVolumeClaim.
|
||||
type Storage struct {
|
||||
*K8sBase `yaml:",inline"`
|
||||
@@ -8,6 +23,12 @@ type Storage struct {
|
||||
|
||||
// NewPVC creates a new PersistentVolumeClaim object.
|
||||
func NewPVC(name, storageName string) *Storage {
|
||||
locker.Lock()
|
||||
defer locker.Unlock()
|
||||
if _, ok := made[name+storageName]; ok {
|
||||
return nil
|
||||
}
|
||||
made[name+storageName] = true
|
||||
pvc := &Storage{}
|
||||
pvc.K8sBase = NewBase()
|
||||
pvc.K8sBase.Kind = "PersistentVolumeClaim"
|
||||
|
Reference in New Issue
Block a user