Feat cronjob #23

Merged
metal3d merged 28 commits from feat-cronjob into master 2022-06-10 14:15:18 +00:00
5 changed files with 14 additions and 12 deletions
Showing only changes of commit 403e7fb7e5 - Show all commits

View File

@@ -6,6 +6,7 @@ import (
"katenary/compose"
"katenary/helm"
"katenary/logger"
"katenary/tools"
"log"
"net/url"
"os"
@@ -272,7 +273,7 @@ func buildConfigMapFromPath(name, path string) *helm.ConfigMap {
files[filename] = string(c)
}
cm := helm.NewConfigMap(name, GetRelPath(path))
cm := helm.NewConfigMap(name, tools.GetRelPath(path))
cm.Data = files
return cm
}
@@ -337,7 +338,7 @@ func prepareVolumes(deployment, name string, s *types.ServiceConfig, container *
isConfigMap := false
for _, cmVol := range configMapsVolumes {
if GetRelPath(volname) == cmVol {
if tools.GetRelPath(volname) == cmVol {
isConfigMap = true
break
}
@@ -366,10 +367,10 @@ func prepareVolumes(deployment, name string, s *types.ServiceConfig, container *
// the volume is a path and it's explicitally asked to be a configmap in labels
cm := buildConfigMapFromPath(name, volname)
cm.K8sBase.Metadata.Name = helm.ReleaseNameTpl + "-" + name + "-" + PathToName(volname)
cm.K8sBase.Metadata.Name = helm.ReleaseNameTpl + "-" + name + "-" + tools.PathToName(volname)
// build a configmapRef for this volume
volname := PathToName(volname)
volname := tools.PathToName(volname)
volumes = append(volumes, map[string]interface{}{
"name": volname,
"configMap": map[string]string{
@@ -586,7 +587,7 @@ func prepareEnvFromFiles(name string, s *types.ServiceConfig, container *helm.Co
// manage environment files (env_file in compose)
for _, envfile := range s.EnvFile {
f := PathToName(envfile)
f := tools.PathToName(envfile)
f = strings.ReplaceAll(f, ".env", "")
isSecret := false
for _, s := range secretsFiles {
@@ -876,7 +877,7 @@ func addVolumeFrom(deployment *helm.Deployment, container *helm.Container, s *ty
for name, volumes := range volumesFrom {
for volumeName := range volumes {
initianame := volumeName
volumeName = PathToName(volumeName)
volumeName = tools.PathToName(volumeName)
// get the volume from the deployment container "name"
var ctn *helm.Container
for _, c := range deployment.Spec.Template.Spec.Containers {

View File

@@ -4,6 +4,7 @@ import (
"katenary/compose"
"katenary/generator/writers"
"katenary/helm"
"katenary/tools"
"log"
"os"
"path/filepath"
@@ -175,7 +176,7 @@ func Generate(p *compose.Parser, katernayVersion, appName, appVersion, chartVers
// there could be several files, so let's force the filename
name := c.(helm.Named).Name() + "-" + c.GetType()
suffix := c.GetPathRessource()
suffix = PathToName(suffix)
suffix = tools.PathToName(suffix)
name += suffix
name = PrefixRE.ReplaceAllString(name, "")
writers.BuildConfigMap(c, kind, n, name, templatesDir)

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"katenary/tools"
"strings"
)
@@ -31,8 +32,7 @@ func NewConfigMap(name, path string) *ConfigMap {
base.Metadata.Name = ReleaseNameTpl + "-" + name
base.Metadata.Labels[K+"/component"] = name
if path != "" {
//base.Metadata.Labels[K+"/path"] = path
base.Metadata.Labels[K+"/path"] = `{{ "` + path + `" | quote }}`
base.Metadata.Labels[K+"/path"] = tools.PathToName(path)
}
return &ConfigMap{
K8sBase: base,
@@ -97,7 +97,7 @@ func NewSecret(name, path string) *Secret {
base.Metadata.Name = ReleaseNameTpl + "-" + name
base.Metadata.Labels[K+"/component"] = name
if path != "" {
base.Metadata.Labels[K+"/path"] = `{{ "` + path + `" | quote }}`
base.Metadata.Labels[K+"/path"] = tools.PathToName(path)
}
return &Secret{
K8sBase: base,

View File

@@ -1,4 +1,4 @@
package generator
package tools
import (
"katenary/compose"

View File

@@ -1,4 +1,4 @@
package generator
package tools
import (
"katenary/compose"