From 9e4663cc6e5ef1429dc18aa6b676945745034078 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Sun, 6 Jul 2025 14:34:16 +0200 Subject: [PATCH] chore(convention): Respect Go convention, package name should be lowercase --- generator/chart.go | 16 ++++++------ generator/configMap.go | 6 ++--- generator/converter.go | 4 +-- generator/cronJob.go | 4 +-- generator/deployment.go | 12 ++++----- generator/generator.go | 4 +-- generator/ingress.go | 4 +-- generator/katenaryfile/main.go | 26 +++++++++---------- generator/labels/labelStructs/doc.go | 2 -- .../configMap.go | 2 +- .../{labelStructs => labelstructs}/cronJob.go | 2 +- .../dependencies.go | 2 +- generator/labels/labelstructs/doc.go | 2 ++ .../{labelStructs => labelstructs}/envFrom.go | 2 +- .../exchangeVolume.go | 2 +- .../{labelStructs => labelstructs}/ingress.go | 2 +- .../{labelStructs => labelstructs}/mapenv.go | 2 +- .../{labelStructs => labelstructs}/ports.go | 2 +- .../{labelStructs => labelstructs}/probes.go | 2 +- .../{labelStructs => labelstructs}/secrets.go | 2 +- .../valueFrom.go | 2 +- generator/utils.go | 4 +-- 22 files changed, 53 insertions(+), 53 deletions(-) delete mode 100644 generator/labels/labelStructs/doc.go rename generator/labels/{labelStructs => labelstructs}/configMap.go (92%) rename generator/labels/{labelStructs => labelstructs}/cronJob.go (95%) rename generator/labels/{labelStructs => labelstructs}/dependencies.go (97%) create mode 100644 generator/labels/labelstructs/doc.go rename generator/labels/{labelStructs => labelstructs}/envFrom.go (93%) rename generator/labels/{labelStructs => labelstructs}/exchangeVolume.go (95%) rename generator/labels/{labelStructs => labelstructs}/ingress.go (98%) rename generator/labels/{labelStructs => labelstructs}/mapenv.go (93%) rename generator/labels/{labelStructs => labelstructs}/ports.go (92%) rename generator/labels/{labelStructs => labelstructs}/probes.go (98%) rename generator/labels/{labelStructs => labelstructs}/secrets.go (91%) rename generator/labels/{labelStructs => labelstructs}/valueFrom.go (91%) diff --git a/generator/chart.go b/generator/chart.go index c0ff207..25c0f89 100644 --- a/generator/chart.go +++ b/generator/chart.go @@ -3,7 +3,7 @@ package generator import ( "fmt" "katenary/generator/labels" - "katenary/generator/labels/labelStructs" + "katenary/generator/labels/labelstructs" "katenary/utils" "log" "maps" @@ -49,7 +49,7 @@ type HelmChart struct { AppVersion string `yaml:"appVersion"` Description string `yaml:"description"` Helper string `yaml:"-"` - Dependencies []labelStructs.Dependency `yaml:"dependencies,omitempty"` + Dependencies []labelstructs.Dependency `yaml:"dependencies,omitempty"` } // NewChart creates a new empty chart with the given name. @@ -141,7 +141,7 @@ func (chart *HelmChart) generateConfigMapsAndSecrets(project *types.Project) err maps.Copy(originalEnv, s.Environment) if v, ok := s.Labels[labels.LabelSecrets]; ok { - list, err := labelStructs.SecretsFrom(v) + list, err := labelstructs.SecretsFrom(v) if err != nil { log.Fatal("error unmarshaling secrets label:", err) } @@ -214,7 +214,7 @@ func (chart *HelmChart) generateDeployment(service types.ServiceConfig, deployme if exchange, ok := service.Labels[labels.LabelExchangeVolume]; ok { // we need to add a volume and a mount point - ex, err := labelStructs.NewExchangeVolumes(exchange) + ex, err := labelstructs.NewExchangeVolumes(exchange) if err != nil { return err } @@ -298,7 +298,7 @@ func (chart *HelmChart) setCronJob(service types.ServiceConfig, appName string) func (chart *HelmChart) setDependencies(service types.ServiceConfig) (bool, error) { // helm dependency if v, ok := service.Labels[labels.LabelDependencies]; ok { - d, err := labelStructs.DependenciesFrom(v) + d, err := labelstructs.DependenciesFrom(v) if err != nil { return false, err } @@ -326,7 +326,7 @@ func (chart *HelmChart) setSharedConf(service types.ServiceConfig, deployments m if _, ok := service.Labels[labels.LabelEnvFrom]; !ok { return } - fromservices, err := labelStructs.EnvFromFrom(service.Labels[labels.LabelEnvFrom]) + fromservices, err := labelstructs.EnvFromFrom(service.Labels[labels.LabelEnvFrom]) if err != nil { log.Fatal("error unmarshaling env-from label:", err) } @@ -351,7 +351,7 @@ func (chart *HelmChart) setEnvironmentValuesFrom(service types.ServiceConfig, de if _, ok := service.Labels[labels.LabelValueFrom]; !ok { return } - mapping, err := labelStructs.GetValueFrom(service.Labels[labels.LabelValueFrom]) + mapping, err := labelstructs.GetValueFrom(service.Labels[labels.LabelValueFrom]) if err != nil { log.Fatal("error unmarshaling values-from label:", err) } @@ -383,7 +383,7 @@ func (chart *HelmChart) setEnvironmentValuesFrom(service types.ServiceConfig, de // is it a secret? isSecret := false - secrets, err := labelStructs.SecretsFrom(dep.service.Labels[labels.LabelSecrets]) + secrets, err := labelstructs.SecretsFrom(dep.service.Labels[labels.LabelSecrets]) if err == nil { if slices.Contains(secrets, depName[1]) { isSecret = true diff --git a/generator/configMap.go b/generator/configMap.go index 585dee3..d7fedf5 100644 --- a/generator/configMap.go +++ b/generator/configMap.go @@ -3,7 +3,7 @@ package generator import ( "fmt" "katenary/generator/labels" - "katenary/generator/labels/labelStructs" + "katenary/generator/labels/labelstructs" "katenary/utils" "log" "os" @@ -65,7 +65,7 @@ func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *Co } // get the secrets from the labels - secrets, err := labelStructs.SecretsFrom(service.Labels[labels.LabelSecrets]) + secrets, err := labelstructs.SecretsFrom(service.Labels[labels.LabelSecrets]) if err != nil { log.Fatal(err) } @@ -91,7 +91,7 @@ func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *Co // do not bind env variables to the configmap // remove the variables that are already defined in the environment if l, ok := service.Labels[labels.LabelMapEnv]; ok { - envmap, err := labelStructs.MapEnvFrom(l) + envmap, err := labelstructs.MapEnvFrom(l) if err != nil { log.Fatal("Error parsing map-env", err) } diff --git a/generator/converter.go b/generator/converter.go index f44dc7a..52f9451 100644 --- a/generator/converter.go +++ b/generator/converter.go @@ -7,7 +7,7 @@ import ( "katenary/generator/extrafiles" "katenary/generator/katenaryfile" "katenary/generator/labels" - "katenary/generator/labels/labelStructs" + "katenary/generator/labels/labelstructs" "katenary/parser" "katenary/utils" "log" @@ -258,7 +258,7 @@ func addCommentsToValues(values []byte) []byte { return []byte(strings.Join(lines, "\n")) } -func addDependencyDescription(values []byte, dependencies []labelStructs.Dependency) []byte { +func addDependencyDescription(values []byte, dependencies []labelstructs.Dependency) []byte { for _, d := range dependencies { name := d.Name if d.Alias != "" { diff --git a/generator/cronJob.go b/generator/cronJob.go index 9cdf498..0c33c9f 100644 --- a/generator/cronJob.go +++ b/generator/cronJob.go @@ -2,7 +2,7 @@ package generator import ( "katenary/generator/labels" - "katenary/generator/labels/labelStructs" + "katenary/generator/labels/labelstructs" "katenary/utils" "log" "strings" @@ -30,7 +30,7 @@ func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) ( if !ok { return nil, nil } - mapping, err := labelStructs.CronJobFrom(labels) + mapping, err := labelstructs.CronJobFrom(labels) if err != nil { log.Fatalf("Error parsing cronjob labels: %s", err) return nil, nil diff --git a/generator/deployment.go b/generator/deployment.go index 16c6ebd..2345882 100644 --- a/generator/deployment.go +++ b/generator/deployment.go @@ -3,7 +3,7 @@ package generator import ( "fmt" "katenary/generator/labels" - "katenary/generator/labels/labelStructs" + "katenary/generator/labels/labelstructs" "katenary/utils" "log" "os" @@ -39,7 +39,7 @@ type Deployment struct { service *types.ServiceConfig `yaml:"-"` defaultTag string `yaml:"-"` isMainApp bool `yaml:"-"` - exchangesVolumes map[string]*labelStructs.ExchangeVolume `yaml:"-"` + exchangesVolumes map[string]*labelstructs.ExchangeVolume `yaml:"-"` boundEnvVar []string `yaml:"-"` // environement to remove } @@ -94,7 +94,7 @@ func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment { }, configMaps: make(map[string]*ConfigMapMount), volumeMap: make(map[string]string), - exchangesVolumes: map[string]*labelStructs.ExchangeVolume{}, + exchangesVolumes: map[string]*labelstructs.ExchangeVolume{}, boundEnvVar: []string{}, } @@ -160,7 +160,7 @@ func (d *Deployment) AddContainer(service types.ServiceConfig) { func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container) { // get the label for healthcheck if v, ok := service.Labels[labels.LabelHealthCheck]; ok { - probes, err := labelStructs.ProbeFrom(v) + probes, err := labelstructs.ProbeFrom(v) if err != nil { log.Fatal(err) } @@ -195,7 +195,7 @@ func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *In func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string) { tobind := map[string]bool{} if v, ok := service.Labels[labels.LabelConfigMapFiles]; ok { - binds, err := labelStructs.ConfigMapFileFrom(v) + binds, err := labelstructs.ConfigMapFileFrom(v) if err != nil { log.Fatal(err) } @@ -320,7 +320,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, sam }() // secrets from label - labelSecrets, err := labelStructs.SecretsFrom(service.Labels[labels.LabelSecrets]) + labelSecrets, err := labelstructs.SecretsFrom(service.Labels[labels.LabelSecrets]) if err != nil { log.Fatal(err) } diff --git a/generator/generator.go b/generator/generator.go index 21f8559..cbaa288 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -4,7 +4,7 @@ import ( "bytes" "fmt" "katenary/generator/labels" - "katenary/generator/labels/labelStructs" + "katenary/generator/labels/labelstructs" "katenary/utils" "log" "regexp" @@ -227,7 +227,7 @@ func fixResourceNames(project *types.Project) error { } // also, the value-from label should be updated if valuefrom, ok := s.Labels[labels.LabelValueFrom]; ok { - vf, err := labelStructs.GetValueFrom(valuefrom) + vf, err := labelstructs.GetValueFrom(valuefrom) if err != nil { return err } diff --git a/generator/ingress.go b/generator/ingress.go index 7e2d753..31d9ed9 100644 --- a/generator/ingress.go +++ b/generator/ingress.go @@ -2,7 +2,7 @@ package generator import ( "katenary/generator/labels" - "katenary/generator/labels/labelStructs" + "katenary/generator/labels/labelstructs" "katenary/utils" "log" "strings" @@ -33,7 +33,7 @@ func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress { return nil } - mapping, err := labelStructs.IngressFrom(label) + mapping, err := labelstructs.IngressFrom(label) if err != nil { log.Fatalf("Failed to parse ingress label: %s\n", err) } diff --git a/generator/katenaryfile/main.go b/generator/katenaryfile/main.go index b9b938d..47f4624 100644 --- a/generator/katenaryfile/main.go +++ b/generator/katenaryfile/main.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" "katenary/generator/labels" - "katenary/generator/labels/labelStructs" + "katenary/generator/labels/labelstructs" "katenary/utils" "log" "os" @@ -27,20 +27,20 @@ type StringOrMap any type Service struct { MainApp *bool `json:"main-app,omitempty" jsonschema:"title=Is this service the main application"` Values []StringOrMap `json:"values,omitempty" jsonschema:"description=Environment variables to be set in values.yaml with or without a description"` - Secrets *labelStructs.Secrets `json:"secrets,omitempty" jsonschema:"title=Secrets,description=Environment variables to be set as secrets"` - Ports *labelStructs.Ports `json:"ports,omitempty" jsonschema:"title=Ports,description=Ports to be exposed in services"` - Ingress *labelStructs.Ingress `json:"ingress,omitempty" jsonschema:"title=Ingress,description=Ingress configuration"` - HealthCheck *labelStructs.HealthCheck `json:"health-check,omitempty" jsonschema:"title=Health Check,description=Health check configuration that respects the kubernetes api"` + Secrets *labelstructs.Secrets `json:"secrets,omitempty" jsonschema:"title=Secrets,description=Environment variables to be set as secrets"` + Ports *labelstructs.Ports `json:"ports,omitempty" jsonschema:"title=Ports,description=Ports to be exposed in services"` + Ingress *labelstructs.Ingress `json:"ingress,omitempty" jsonschema:"title=Ingress,description=Ingress configuration"` + HealthCheck *labelstructs.HealthCheck `json:"health-check,omitempty" jsonschema:"title=Health Check,description=Health check configuration that respects the kubernetes api"` SamePod *string `json:"same-pod,omitempty" jsonschema:"title=Same Pod,description=Service that should be in the same pod"` Description *string `json:"description,omitempty" jsonschema:"title=Description,description=Description of the service that will be injected in the values.yaml file"` Ignore *bool `json:"ignore,omitempty" jsonschema:"title=Ignore,description=Ignore the service in the conversion"` - Dependencies []labelStructs.Dependency `json:"dependencies,omitempty" jsonschema:"title=Dependencies,description=Services that should be injected in the Chart.yaml file"` - ConfigMapFile *labelStructs.ConfigMapFile `json:"configmap-files,omitempty" jsonschema:"title=ConfigMap Files,description=Files that should be injected as ConfigMap"` - MapEnv *labelStructs.MapEnv `json:"map-env,omitempty" jsonschema:"title=Map Env,description=Map environment variables to another value"` - CronJob *labelStructs.CronJob `json:"cron-job,omitempty" jsonschema:"title=Cron Job,description=Cron Job configuration"` - EnvFrom *labelStructs.EnvFrom `json:"env-from,omitempty" jsonschema:"title=Env From,description=Inject environment variables from another service"` - ExchangeVolumes []*labelStructs.ExchangeVolume `json:"exchange-volumes,omitempty" jsonschema:"title=Exchange Volumes,description=Exchange volumes between services"` - ValuesFrom *labelStructs.ValueFrom `json:"values-from,omitempty" jsonschema:"title=Values From,description=Inject values from another service (secret or configmap environment variables)"` + Dependencies []labelstructs.Dependency `json:"dependencies,omitempty" jsonschema:"title=Dependencies,description=Services that should be injected in the Chart.yaml file"` + ConfigMapFile *labelstructs.ConfigMapFile `json:"configmap-files,omitempty" jsonschema:"title=ConfigMap Files,description=Files that should be injected as ConfigMap"` + MapEnv *labelstructs.MapEnv `json:"map-env,omitempty" jsonschema:"title=Map Env,description=Map environment variables to another value"` + CronJob *labelstructs.CronJob `json:"cron-job,omitempty" jsonschema:"title=Cron Job,description=Cron Job configuration"` + EnvFrom *labelstructs.EnvFrom `json:"env-from,omitempty" jsonschema:"title=Env From,description=Inject environment variables from another service"` + ExchangeVolumes []*labelstructs.ExchangeVolume `json:"exchange-volumes,omitempty" jsonschema:"title=Exchange Volumes,description=Exchange volumes between services"` + ValuesFrom *labelstructs.ValueFrom `json:"values-from,omitempty" jsonschema:"title=Values From,description=Inject values from another service (secret or configmap environment variables)"` } // OverrideWithConfig overrides the project with the katenary.yaml file. It @@ -117,7 +117,7 @@ func getLabelContent(o any, service *types.ServiceConfig, labelName string) erro val := strings.TrimSpace(string(c)) if labelName == labels.LabelIngress { // special case, values must be set from some defaults - ing, err := labelStructs.IngressFrom(val) + ing, err := labelstructs.IngressFrom(val) if err != nil { log.Fatal(err) return err diff --git a/generator/labels/labelStructs/doc.go b/generator/labels/labelStructs/doc.go deleted file mode 100644 index 5373fcf..0000000 --- a/generator/labels/labelStructs/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// labelStructs is a package that contains the structs used to represent the labels in the yaml files. -package labelStructs diff --git a/generator/labels/labelStructs/configMap.go b/generator/labels/labelstructs/configMap.go similarity index 92% rename from generator/labels/labelStructs/configMap.go rename to generator/labels/labelstructs/configMap.go index 2b5112f..a771d7b 100644 --- a/generator/labels/labelStructs/configMap.go +++ b/generator/labels/labelstructs/configMap.go @@ -1,4 +1,4 @@ -package labelStructs +package labelstructs import "gopkg.in/yaml.v3" diff --git a/generator/labels/labelStructs/cronJob.go b/generator/labels/labelstructs/cronJob.go similarity index 95% rename from generator/labels/labelStructs/cronJob.go rename to generator/labels/labelstructs/cronJob.go index 972e456..9c20ecb 100644 --- a/generator/labels/labelStructs/cronJob.go +++ b/generator/labels/labelstructs/cronJob.go @@ -1,4 +1,4 @@ -package labelStructs +package labelstructs import "gopkg.in/yaml.v3" diff --git a/generator/labels/labelStructs/dependencies.go b/generator/labels/labelstructs/dependencies.go similarity index 97% rename from generator/labels/labelStructs/dependencies.go rename to generator/labels/labelstructs/dependencies.go index 90511fe..e82a585 100644 --- a/generator/labels/labelStructs/dependencies.go +++ b/generator/labels/labelstructs/dependencies.go @@ -1,4 +1,4 @@ -package labelStructs +package labelstructs import "gopkg.in/yaml.v3" diff --git a/generator/labels/labelstructs/doc.go b/generator/labels/labelstructs/doc.go new file mode 100644 index 0000000..25fb986 --- /dev/null +++ b/generator/labels/labelstructs/doc.go @@ -0,0 +1,2 @@ +// labelstructs is a package that contains the structs used to represent the labels in the yaml files. +package labelstructs diff --git a/generator/labels/labelStructs/envFrom.go b/generator/labels/labelstructs/envFrom.go similarity index 93% rename from generator/labels/labelStructs/envFrom.go rename to generator/labels/labelstructs/envFrom.go index f2c8f2f..cbc4151 100644 --- a/generator/labels/labelStructs/envFrom.go +++ b/generator/labels/labelstructs/envFrom.go @@ -1,4 +1,4 @@ -package labelStructs +package labelstructs import "gopkg.in/yaml.v3" diff --git a/generator/labels/labelStructs/exchangeVolume.go b/generator/labels/labelstructs/exchangeVolume.go similarity index 95% rename from generator/labels/labelStructs/exchangeVolume.go rename to generator/labels/labelstructs/exchangeVolume.go index 1faa997..2f32894 100644 --- a/generator/labels/labelStructs/exchangeVolume.go +++ b/generator/labels/labelstructs/exchangeVolume.go @@ -1,4 +1,4 @@ -package labelStructs +package labelstructs import "gopkg.in/yaml.v3" diff --git a/generator/labels/labelStructs/ingress.go b/generator/labels/labelstructs/ingress.go similarity index 98% rename from generator/labels/labelStructs/ingress.go rename to generator/labels/labelstructs/ingress.go index df40da3..34e3429 100644 --- a/generator/labels/labelStructs/ingress.go +++ b/generator/labels/labelstructs/ingress.go @@ -1,4 +1,4 @@ -package labelStructs +package labelstructs import ( "fmt" diff --git a/generator/labels/labelStructs/mapenv.go b/generator/labels/labelstructs/mapenv.go similarity index 93% rename from generator/labels/labelStructs/mapenv.go rename to generator/labels/labelstructs/mapenv.go index 6b4cdfa..dfccf4f 100644 --- a/generator/labels/labelStructs/mapenv.go +++ b/generator/labels/labelstructs/mapenv.go @@ -1,4 +1,4 @@ -package labelStructs +package labelstructs import "gopkg.in/yaml.v3" diff --git a/generator/labels/labelStructs/ports.go b/generator/labels/labelstructs/ports.go similarity index 92% rename from generator/labels/labelStructs/ports.go rename to generator/labels/labelstructs/ports.go index 253a075..43253c8 100644 --- a/generator/labels/labelStructs/ports.go +++ b/generator/labels/labelstructs/ports.go @@ -1,4 +1,4 @@ -package labelStructs +package labelstructs import "gopkg.in/yaml.v3" diff --git a/generator/labels/labelStructs/probes.go b/generator/labels/labelstructs/probes.go similarity index 98% rename from generator/labels/labelStructs/probes.go rename to generator/labels/labelstructs/probes.go index bdd3813..1feeeb4 100644 --- a/generator/labels/labelStructs/probes.go +++ b/generator/labels/labelstructs/probes.go @@ -1,4 +1,4 @@ -package labelStructs +package labelstructs import ( "encoding/json" diff --git a/generator/labels/labelStructs/secrets.go b/generator/labels/labelstructs/secrets.go similarity index 91% rename from generator/labels/labelStructs/secrets.go rename to generator/labels/labelstructs/secrets.go index e5cfb36..2ac8d59 100644 --- a/generator/labels/labelStructs/secrets.go +++ b/generator/labels/labelstructs/secrets.go @@ -1,4 +1,4 @@ -package labelStructs +package labelstructs import "gopkg.in/yaml.v3" diff --git a/generator/labels/labelStructs/valueFrom.go b/generator/labels/labelstructs/valueFrom.go similarity index 91% rename from generator/labels/labelStructs/valueFrom.go rename to generator/labels/labelstructs/valueFrom.go index 9ad5712..5d86176 100644 --- a/generator/labels/labelStructs/valueFrom.go +++ b/generator/labels/labelstructs/valueFrom.go @@ -1,4 +1,4 @@ -package labelStructs +package labelstructs import "gopkg.in/yaml.v3" diff --git a/generator/utils.go b/generator/utils.go index f931e73..51feb08 100644 --- a/generator/utils.go +++ b/generator/utils.go @@ -2,7 +2,7 @@ package generator import ( "katenary/generator/labels" - "katenary/generator/labels/labelStructs" + "katenary/generator/labels/labelstructs" "katenary/utils" "regexp" "strconv" @@ -50,7 +50,7 @@ func fixPorts(service *types.ServiceConfig) error { if portsLabel, ok = service.Labels[labels.LabelPorts]; !ok { return nil } - ports, err := labelStructs.PortsFrom(portsLabel) + ports, err := labelstructs.PortsFrom(portsLabel) if err != nil { // maybe it's a string, comma separated parts := strings.SplitSeq(portsLabel, ",")