diff --git a/Makefile b/Makefile index aeffcf9..104a800 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ BLD_CMD=go build -ldflags="-X 'katenary/generator.Version=$(RELEASE)$(VERSION)'" GOOS=linux GOARCH=amd64 SIGNER=metal3d@gmail.com +UPX_OPTS = +UPX ?= upx $(UPX_OPTS) BUILD_IMAGE=docker.io/golang:$(GOVERSION)-alpine # SHELL=/bin/bash @@ -95,17 +97,17 @@ ifeq ($(GO),local) $(BLD_CMD) else ifeq ($(CTN),podman) @podman run -e CGO_ENABLED=0 -e GOOS=$(GOOS) -e GOARCH=$(GOARCH) \ - --rm -v $(PWD):/go/src/katenary:z -w /go/src/katenary --userns keep-id -it $(BUILD_IMAGE) $(BLD_CMD) + --rm -v $(PWD):/go/src/katenary:z -w /go/src/katenary --userns keep-id $(BUILD_IMAGE) $(BLD_CMD) else @docker run -e CGO_ENABLED=0 -e GOOS=$(GOOS) -e GOARCH=$(GOARCH) \ - --rm -v $(PWD):/go/src/katenary:z -w /go/src/katenary --user $(shell id -u):$(shell id -g) -e HOME=/tmp -it $(BUILD_IMAGE) $(BLD_CMD) + --rm -v $(PWD):/go/src/katenary:z -w /go/src/katenary --user $(shell id -u):$(shell id -g) -e HOME=/tmp $(BUILD_IMAGE) $(BLD_CMD) endif echo "=> Stripping if possible" strip $(OUT) 2>/dev/null || echo "=> No strip available" ## Release build -dist: prepare $(BINARIES) $(ASC_BINARIES) +dist: prepare $(BINARIES) upx $(ASC_BINARIES) prepare: pull mkdir -p dist @@ -147,6 +149,13 @@ gpg-sign: dist/%.asc: dist/% gpg --armor --detach-sign --default-key $(SIGNER) $< &>/dev/null || exit 1 + +upx: + $(UPX) dist/katenary-linux-amd64 + $(UPX) dist/katenary-linux-arm64 + $(UPX) dist/katenary.exe + $(UPX) dist/katenary-darwin-amd64 --force-macos + install: build install -Dm755 katenary $(PREFIX)/bin/katenary diff --git a/generator/chart.go b/generator/chart.go index d8bc0bf..45f3791 100644 --- a/generator/chart.go +++ b/generator/chart.go @@ -6,8 +6,10 @@ import ( "katenary/generator/labels/labelStructs" "katenary/utils" "log" + "maps" "os" "path/filepath" + "slices" "strings" "github.com/compose-spec/compose-go/types" @@ -42,7 +44,7 @@ type HelmChart struct { composeHash *string `yaml:"-"` Name string `yaml:"name"` Icon string `yaml:"icon,omitempty"` - ApiVersion string `yaml:"apiVersion"` + APIVersion string `yaml:"apiVersion"` Version string `yaml:"version"` AppVersion string `yaml:"appVersion"` Description string `yaml:"description"` @@ -56,7 +58,7 @@ func NewChart(name string) *HelmChart { Name: name, Templates: make(map[string]*ChartTemplate, 0), Description: "A Helm chart for " + name, - ApiVersion: "v2", + APIVersion: "v2", Version: "", AppVersion: "", // set to 0.1.0 by default if no "main-app" label is found Values: map[string]any{ @@ -136,9 +138,7 @@ func (chart *HelmChart) generateConfigMapsAndSecrets(project *types.Project) err secretsVar := types.MappingWithEquals{} // copy env to originalEnv - for k, v := range s.Environment { - originalEnv[k] = v - } + maps.Copy(originalEnv, s.Environment) if v, ok := s.Labels[labels.LabelSecrets]; ok { list, err := labelStructs.SecretsFrom(v) @@ -374,7 +374,7 @@ func (chart *HelmChart) setEnvironmentValuesFrom(service types.ServiceConfig, de if dep == nil || target == nil { log.Fatalf("deployment %s or %s not found", depName[0], service.Name) } - container, index := utils.GetContainerByName(target.service.Name, target.Spec.Template.Spec.Containers) + container, index := utils.GetContainerByName(target.service.ContainerName, target.Spec.Template.Spec.Containers) if container == nil { log.Fatalf("Container %s not found", target.GetName()) } @@ -385,11 +385,8 @@ func (chart *HelmChart) setEnvironmentValuesFrom(service types.ServiceConfig, de isSecret := false secrets, err := labelStructs.SecretsFrom(dep.service.Labels[labels.LabelSecrets]) if err == nil { - for _, secret := range secrets { - if secret == depName[1] { - isSecret = true - break - } + if slices.Contains(secrets, depName[1]) { + isSecret = true } } diff --git a/generator/configMap.go b/generator/configMap.go index 777ed82..585dee3 100644 --- a/generator/configMap.go +++ b/generator/configMap.go @@ -161,7 +161,7 @@ func (c *ConfigMap) AddBinaryData(key string, value []byte) { c.BinaryData[key] = value } -// AddFile adds files from given path to the configmap. It is not recursive, to add all files in a directory, +// AppendDir adds files from given path to the configmap. It is not recursive, to add all files in a directory, // you need to call this function for each subdirectory. func (c *ConfigMap) AppendDir(path string) error { // read all files in the path and add them to the configmap diff --git a/generator/deployment.go b/generator/deployment.go index 6421f66..16c6ebd 100644 --- a/generator/deployment.go +++ b/generator/deployment.go @@ -131,7 +131,7 @@ func (d *Deployment) AddContainer(service types.ServiceConfig) { Image: utils.TplValue(service.Name, "repository.image") + ":" + utils.TplValue(service.Name, "repository.tag", d.defaultTag), Ports: ports, - Name: service.Name, + Name: service.ContainerName, ImagePullPolicy: corev1.PullIfNotPresent, Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{}, @@ -253,8 +253,8 @@ func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment) { // get the container } // add volume mount to the container - targetContainer, ti := utils.GetContainerByName(service.Name, d.Spec.Template.Spec.Containers) - sourceContainer, _ := utils.GetContainerByName(service.Name, binded.Spec.Template.Spec.Containers) + targetContainer, ti := utils.GetContainerByName(service.ContainerName, d.Spec.Template.Spec.Containers) + sourceContainer, _ := utils.GetContainerByName(service.ContainerName, binded.Spec.Template.Spec.Containers) for _, bindedMount := range sourceContainer.VolumeMounts { if bindedMount.Name == bindedVolume.Name { targetContainer.VolumeMounts = append(targetContainer.VolumeMounts, bindedMount) @@ -408,7 +408,7 @@ func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secret }) } - container, index := utils.GetContainerByName(service.Name, d.Spec.Template.Spec.Containers) + container, index := utils.GetContainerByName(service.ContainerName, d.Spec.Template.Spec.Containers) if container == nil { utils.Warn("Container not found for service " + service.Name) return nil, -1 @@ -663,7 +663,7 @@ func (d *Deployment) appendFileToConfigMap(service types.ServiceConfig, appName } func (d *Deployment) bindVolumes(volume types.ServiceVolumeConfig, isSamePod bool, tobind map[string]bool, service types.ServiceConfig, appName string) { - container, index := utils.GetContainerByName(service.Name, d.Spec.Template.Spec.Containers) + container, index := utils.GetContainerByName(service.ContainerName, d.Spec.Template.Spec.Containers) defer func(d *Deployment, container *corev1.Container, index int) { d.Spec.Template.Spec.Containers[index] = *container diff --git a/generator/deployment_test.go b/generator/deployment_test.go index aa058ef..d9e3f97 100644 --- a/generator/deployment_test.go +++ b/generator/deployment_test.go @@ -4,6 +4,7 @@ import ( "fmt" "katenary/generator/labels" "os" + "strings" "testing" yaml3 "gopkg.in/yaml.v3" @@ -343,6 +344,38 @@ services: } } +func TestWithUnderscoreInContainerName(t *testing.T) { + composeFile := ` +services: + web-app: + image: nginx:1.29 + container_name: web_app_container + environment: + FOO: BAR + labels: + %s/values: | + - FOO +` + composeFile = fmt.Sprintf(composeFile, labels.Prefix()) + tmpDir := setup(composeFile) + defer teardown(tmpDir) + + currentDir, _ := os.Getwd() + os.Chdir(tmpDir) + defer os.Chdir(currentDir) + + output := internalCompileTest(t, "-s", "templates/web_app/deployment.yaml") + dt := v1.Deployment{} + if err := yaml.Unmarshal([]byte(output), &dt); err != nil { + t.Errorf(unmarshalError, err) + } + // find container.name + containerName := dt.Spec.Template.Spec.Containers[0].Name + if strings.Contains(containerName, "_") { + t.Errorf("Expected container name to not contain underscores, got %s", containerName) + } +} + func TestWithDashes(t *testing.T) { composeFile := ` services: diff --git a/generator/doc.go b/generator/doc.go index 90332ae..ee61f59 100644 --- a/generator/doc.go +++ b/generator/doc.go @@ -1,14 +1,17 @@ /* -The generator package generates kubernetes objects from a "compose" file and transforms them into a helm chart. +Package generator generates kubernetes objects from a "compose" file and transforms them into a helm chart. -The generator package is the core of katenary. It is responsible for generating kubernetes objects from a compose file and transforming them into a helm chart. -Conversion manipulates Yaml representation of kubernetes object to add conditions, labels, annotations, etc. to the objects. It also create the values to be set to -the values.yaml file. +The generator package is the core of katenary. It is responsible for generating kubernetes objects from a compose file +and transforming them into a helm chart. +Conversion manipulates Yaml representation of kubernetes object to add conditions, labels, annotations, etc. to the +objects. It also create the values to be set to the values.yaml file. -The generate.Convert() create an HelmChart object and call "Generate()" method to convert from a compose file to a helm chart. -It saves the helm chart in the given directory. +The generate.Convert() create an HelmChart object and call "Generate()" method to convert from a compose file to a helm +chart. It saves the helm chart in the given directory. -If you want to change or override the write behavior, you can use the HelmChart.Generate() function and implement your own write function. This function returns -the helm chart object containing all kubernetes objects and helm chart ingormation. It does not write the helm chart to the disk. +If you want to change or override the write behavior, you can use the HelmChart.Generate() function and implement your +own write function. This function returns +the helm chart object containing all kubernetes objects and helm chart ingormation. It does not write the helm chart to +the disk. */ package generator diff --git a/generator/extrafiles/doc.go b/generator/extrafiles/doc.go index 5033525..5330c36 100644 --- a/generator/extrafiles/doc.go +++ b/generator/extrafiles/doc.go @@ -1,2 +1,2 @@ -/* extrafiles package provides function to generate the Chart files that are not objects. Like README.md and notes.txt... */ +/* Package extrafiles provides function to generate the Chart files that are not objects. Like README.md and notes.txt... */ package extrafiles diff --git a/generator/generator.go b/generator/generator.go index d3a5113..21f8559 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -48,6 +48,8 @@ func Generate(project *types.Project) (*HelmChart, error) { // drop all services with the "ignore" label dropIngoredServices(project) + fixContainerNames(project) + // rename all services name to remove dashes if err := fixResourceNames(project); err != nil { return nil, err @@ -265,7 +267,7 @@ func addStaticVolumes(deployments map[string]*Deployment, service types.ServiceC return } - container, index := utils.GetContainerByName(service.Name, d.Spec.Template.Spec.Containers) + container, index := utils.GetContainerByName(service.ContainerName, d.Spec.Template.Spec.Containers) if container == nil { // may append for the same-pod services return } @@ -317,7 +319,7 @@ func computeNIndent(b []byte) []byte { startSpaces = spaces[0] } line = []byte(startSpaces + strings.TrimLeft(string(line), " ")) - line = bytes.ReplaceAll(line, []byte("__indent__"), []byte(fmt.Sprintf("%d", len(startSpaces)))) + line = bytes.ReplaceAll(line, []byte("__indent__"), fmt.Appendf(nil, "%d", len(startSpaces))) lines[i] = line } return bytes.Join(lines, []byte("\n")) @@ -416,3 +418,15 @@ func samePodVolume(service types.ServiceConfig, v types.ServiceVolumeConfig, dep } return false } + +func fixContainerNames(project *types.Project) { + // fix container names to be unique + for i, service := range project.Services { + if service.ContainerName == "" { + service.ContainerName = utils.FixedResourceName(service.Name) + } else { + service.ContainerName = utils.FixedResourceName(service.ContainerName) + } + project.Services[i] = service + } +} diff --git a/generator/utils.go b/generator/utils.go index c10cd15..f931e73 100644 --- a/generator/utils.go +++ b/generator/utils.go @@ -53,8 +53,8 @@ func fixPorts(service *types.ServiceConfig) error { ports, err := labelStructs.PortsFrom(portsLabel) if err != nil { // maybe it's a string, comma separated - parts := strings.Split(portsLabel, ",") - for _, part := range parts { + parts := strings.SplitSeq(portsLabel, ",") + for part := range parts { part = strings.TrimSpace(part) if part == "" { continue diff --git a/go.mod b/go.mod index 807b7df..0af6081 100644 --- a/go.mod +++ b/go.mod @@ -11,9 +11,9 @@ require ( github.com/spf13/cobra v1.9.1 github.com/thediveo/netdb v1.1.2 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.33.1 - k8s.io/apimachinery v0.33.1 - sigs.k8s.io/yaml v1.4.0 + k8s.io/api v0.33.2 + k8s.io/apimachinery v0.33.2 + sigs.k8s.io/yaml v1.5.0 ) require ( @@ -44,14 +44,15 @@ require ( github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect - golang.org/x/exp v0.0.0-20250531010427-b6e5de432a8b // indirect - golang.org/x/net v0.40.0 // indirect - golang.org/x/sync v0.14.0 // indirect + go.yaml.in/yaml/v2 v2.4.2 // indirect + golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect + golang.org/x/net v0.41.0 // indirect + golang.org/x/sync v0.15.0 // indirect golang.org/x/sys v0.33.0 // indirect - golang.org/x/text v0.25.0 // indirect + golang.org/x/text v0.26.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/utils v0.0.0-20250502105355-0f33e8f1c979 // indirect + k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.7.0 // indirect diff --git a/go.sum b/go.sum index a1a0b00..c896504 100644 --- a/go.sum +++ b/go.sum @@ -95,24 +95,28 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17 github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI= +go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU= +go.yaml.in/yaml/v3 v3.0.3 h1:bXOww4E/J3f66rav3pX3m8w6jDE4knZjGOw8b5Y6iNE= +go.yaml.in/yaml/v3 v3.0.3/go.mod h1:tBHosrYAkRZjRAOREWbDnBXUf08JOwYq++0QNwQiWzI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20250531010427-b6e5de432a8b h1:QoALfVG9rhQ/M7vYDScfPdWjGL9dlsVVM5VGh7aKoAA= -golang.org/x/exp v0.0.0-20250531010427-b6e5de432a8b/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ= +golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o= +golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= -golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= +golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= -golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= +golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -121,14 +125,14 @@ golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= -golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= +golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= -golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= +golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo= +golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -143,14 +147,14 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g= -k8s.io/api v0.33.1 h1:tA6Cf3bHnLIrUK4IqEgb2v++/GYUtqiu9sRVk3iBXyw= -k8s.io/api v0.33.1/go.mod h1:87esjTn9DRSRTD4fWMXamiXxJhpOIREjWOSjsW1kEHw= -k8s.io/apimachinery v0.33.1 h1:mzqXWV8tW9Rw4VeW9rEkqvnxj59k1ezDUl20tFK/oM4= -k8s.io/apimachinery v0.33.1/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM= +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/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-20250502105355-0f33e8f1c979 h1:jgJW5IePPXLGB8e/1wvd0Ich9QE97RvvF3a8J3fP/Lg= -k8s.io/utils v0.0.0-20250502105355-0f33e8f1c979/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8tmbZBHi4zVsl1Y= +k8s.io/utils v0.0.0-20250604170112-4c0f3b243397/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= @@ -158,5 +162,6 @@ sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= 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 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= 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= diff --git a/parser/main.go b/parser/main.go index b0548dd..c5445b6 100644 --- a/parser/main.go +++ b/parser/main.go @@ -1,4 +1,4 @@ -// Parser package is a wrapper around compose-go to parse compose files. +// Package parser is a wrapper around compose-go to parse compose files. package parser import ( diff --git a/utils/doc.go b/utils/doc.go index b3896e7..031a733 100644 --- a/utils/doc.go +++ b/utils/doc.go @@ -1,2 +1,3 @@ -// Utils package provides some utility functions used in katenary. It defines some constants and functions used in the whole project. +// Package utils provides some utility functions used in katenary. +// It defines some constants and functions used in the whole project. package utils diff --git a/utils/utils.go b/utils/utils.go index ab4ba59..6ebd5ab 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -90,7 +90,7 @@ func GetContainerByName(name string, containers []corev1.Container) (*corev1.Con return nil, -1 } -// GetContainerByName returns a container by name and its index in the array. +// TplValue returns a container by name and its index in the array. func TplValue(serviceName, variable string, pipes ...string) string { if len(pipes) == 0 { return `{{ tpl .Values.` + serviceName + `.` + variable + ` $ }}`