Use compose-go + improvements (#9)
Use compose-go https://github.com/compose-spec/compose-go to make Katenary parsing compose file the official way. Add labels: - `volume-from` (with `same-pod`) to avoid volume repetition - `ignore` to ignore a service - `mapenv` (replaces the `env-to-service`) to map environment to helm variable (as a template string) - `secret-vars` declares variables as secret values More: - Now, environment (as secret vars) are set in values.yaml - Ingress has got annotations in values.yaml - Probes (liveness probe) are improved - fixed code to optimize - many others fixes about path, bad volume check, refactorisation, tests...
This commit is contained in:
@@ -1,17 +1,40 @@
|
||||
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"`
|
||||
Spec *PVCSpec
|
||||
}
|
||||
|
||||
// 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"
|
||||
pvc.K8sBase.Metadata.Labels[K+"/pvc-name"] = storageName
|
||||
pvc.K8sBase.ApiVersion = "v1"
|
||||
pvc.K8sBase.Metadata.Name = RELEASE_NAME + "-" + storageName
|
||||
pvc.K8sBase.Metadata.Name = ReleaseNameTpl + "-" + storageName
|
||||
pvc.K8sBase.Metadata.Labels[K+"/component"] = name
|
||||
pvc.Spec = &PVCSpec{
|
||||
Resouces: map[string]interface{}{
|
||||
@@ -24,6 +47,7 @@ func NewPVC(name, storageName string) *Storage {
|
||||
return pvc
|
||||
}
|
||||
|
||||
// PVCSpec is a struct for a PersistentVolumeClaim spec.
|
||||
type PVCSpec struct {
|
||||
Resouces map[string]interface{} `yaml:"resources"`
|
||||
AccessModes []string `yaml:"accessModes"`
|
||||
|
Reference in New Issue
Block a user