From 8ce0e24b964c886ced979885725cf9845b93748c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Jul 2025 22:24:48 +0000 Subject: [PATCH 1/2] chore(deps): bump k8s.io/apimachinery from 0.33.2 to 0.33.3 Bumps [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) from 0.33.2 to 0.33.3. - [Commits](https://github.com/kubernetes/apimachinery/compare/v0.33.2...v0.33.3) --- updated-dependencies: - dependency-name: k8s.io/apimachinery dependency-version: 0.33.3 dependency-type: direct:production update-type: version-update:semver-patch ... 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..f9fb7f9 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/thediveo/netdb v1.1.2 gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.33.2 - k8s.io/apimachinery v0.33.2 + k8s.io/apimachinery v0.33.3 sigs.k8s.io/yaml v1.5.0 ) diff --git a/go.sum b/go.sum index c896504..23c055b 100644 --- a/go.sum +++ b/go.sum @@ -149,8 +149,8 @@ gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g= k8s.io/api v0.33.2 h1:YgwIS5jKfA+BZg//OQhkJNIfie/kmRsO0BmNaVSimvY= k8s.io/api v0.33.2/go.mod h1:fhrbphQJSM2cXzCWgqU29xLDuks4mu7ti9vveEnpSXs= -k8s.io/apimachinery v0.33.2 h1:IHFVhqg59mb8PJWTLi8m1mAoepkUNYmptHsV+Z1m5jY= -k8s.io/apimachinery v0.33.2/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM= +k8s.io/apimachinery v0.33.3 h1:4ZSrmNa0c/ZpZJhAgRdcsFcZOw1PQU1bALVQ0B3I5LA= +k8s.io/apimachinery v0.33.3/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8tmbZBHi4zVsl1Y= -- 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