From 9c7bd08da187ad706fe94e748325eb2ea3b95824 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Jul 2025 22:59:41 +0000 Subject: [PATCH 1/2] chore(deps): bump sigs.k8s.io/yaml from 1.5.0 to 1.6.0 Bumps [sigs.k8s.io/yaml](https://github.com/kubernetes-sigs/yaml) from 1.5.0 to 1.6.0. - [Release notes](https://github.com/kubernetes-sigs/yaml/releases) - [Changelog](https://github.com/kubernetes-sigs/yaml/blob/master/RELEASE.md) - [Commits](https://github.com/kubernetes-sigs/yaml/compare/v1.5.0...v1.6.0) --- updated-dependencies: - dependency-name: sigs.k8s.io/yaml dependency-version: 1.6.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 54a12c0..969e07c 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.33.2 k8s.io/apimachinery v0.33.2 - sigs.k8s.io/yaml v1.5.0 + sigs.k8s.io/yaml v1.6.0 ) require ( diff --git a/go.sum b/go.sum index c896504..b8ee299 100644 --- a/go.sum +++ b/go.sum @@ -163,5 +163,5 @@ sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxO sigs.k8s.io/structured-merge-diff/v4 v4.7.0 h1:qPeWmscJcXP0snki5IYF79Z8xrl8ETFxgMd7wez1XkI= sigs.k8s.io/structured-merge-diff/v4 v4.7.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= -sigs.k8s.io/yaml v1.5.0 h1:M10b2U7aEUY6hRtU870n2VTPgR5RZiL/I6Lcc2F4NUQ= -sigs.k8s.io/yaml v1.5.0/go.mod h1:wZs27Rbxoai4C0f8/9urLZtZtF3avA3gKvGyPdDqTO4= +sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= +sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= -- 2.49.1 From 136478aff7cc8e07e832572a3bc24940afd15e51 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Sun, 3 Aug 2025 10:12:24 +0200 Subject: [PATCH 2/2] fix(configmap): File from the root of project ends by a dash fixes #150 If we mount a file from the root of project, the names ends by a dash. That makes helm failing to install the package. --- generator/configMap_test.go | 40 +++++++++++++++++++++++++++++++++++++ generator/deployment.go | 6 +++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/generator/configMap_test.go b/generator/configMap_test.go index 6e880e6..47d5680 100644 --- a/generator/configMap_test.go +++ b/generator/configMap_test.go @@ -2,8 +2,10 @@ package generator import ( "fmt" + "io" "katenary/generator/labels" "os" + "regexp" "testing" "github.com/compose-spec/compose-go/types" @@ -90,3 +92,41 @@ func TestAppendBadDir(t *testing.T) { t.Errorf("Expected error, got nil") } } + +func TestRootConfigmapfile(t *testing.T) { + composeFile := ` +services: + web: + image: nginx + volumes: + - ./foo.txt:/etc/foo.txt + labels: + %[1]s/configmap-files: |- + - ./foo.txt +` + composeFile = fmt.Sprintf(composeFile, labels.KatenaryLabelPrefix) + tmpDir := setup(composeFile) + defer teardown(tmpDir) + + currentDir, _ := os.Getwd() + os.Chdir(tmpDir) + defer os.Chdir(currentDir) + fooTxt := "foo content" + fooFp, _ := os.Create("foo.txt") + io.WriteString(fooFp, fooTxt) + fooFp.Close() + + output := internalCompileTest(t, "-s", "templates/web/statics/configmap.yaml") + configMap := v1.ConfigMap{} + if err := yaml.Unmarshal([]byte(output), &configMap); err != nil { + t.Errorf(unmarshalError, err) + } + if configMap.Data == nil { + t.Error("Expected configmap data to not be nil") + } + // if the configmap.Name ends by anything that is not alphanumeric, there is a problem + valid := regexp.MustCompile(`.*[a-zA-Z0-9]+$`) + if !valid.MatchString(configMap.Name) { + t.Errorf("ConfigMap name %s is not valid", configMap.Name) + } +} diff --git a/generator/deployment.go b/generator/deployment.go index 0e8fafb..37abd0e 100644 --- a/generator/deployment.go +++ b/generator/deployment.go @@ -635,12 +635,16 @@ func (d *Deployment) appendFileToConfigMap(service types.ServiceConfig, appName // in generate.go dirname := filepath.Dir(volume.Source) pathname := utils.PathToName(dirname) + pathname = strings.TrimSpace(pathname) + if len(pathname) != 0 { + pathname += "-" + pathname + } var cm *ConfigMap if v, ok := d.configMaps[pathname]; !ok { cm = NewConfigMap(*d.service, appName, true) cm.usage = FileMapUsageFiles cm.path = dirname - cm.Name = utils.TplName(service.Name, appName) + "-" + pathname + cm.Name = utils.TplName(service.Name, appName) + pathname d.configMaps[pathname] = &ConfigMapMount{ configMap: cm, mountPath: []mountPathConfig{{ -- 2.49.1