chore(convention): Respect Go convention, package name should be lowercase

This commit is contained in:
2025-07-06 14:34:16 +02:00
parent 1a5c95d240
commit 9e4663cc6e
22 changed files with 53 additions and 53 deletions

View File

@@ -3,7 +3,7 @@ package generator
import ( import (
"fmt" "fmt"
"katenary/generator/labels" "katenary/generator/labels"
"katenary/generator/labels/labelStructs" "katenary/generator/labels/labelstructs"
"katenary/utils" "katenary/utils"
"log" "log"
"maps" "maps"
@@ -49,7 +49,7 @@ type HelmChart struct {
AppVersion string `yaml:"appVersion"` AppVersion string `yaml:"appVersion"`
Description string `yaml:"description"` Description string `yaml:"description"`
Helper string `yaml:"-"` 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. // 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) maps.Copy(originalEnv, s.Environment)
if v, ok := s.Labels[labels.LabelSecrets]; ok { if v, ok := s.Labels[labels.LabelSecrets]; ok {
list, err := labelStructs.SecretsFrom(v) list, err := labelstructs.SecretsFrom(v)
if err != nil { if err != nil {
log.Fatal("error unmarshaling secrets label:", err) 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 { if exchange, ok := service.Labels[labels.LabelExchangeVolume]; ok {
// we need to add a volume and a mount point // we need to add a volume and a mount point
ex, err := labelStructs.NewExchangeVolumes(exchange) ex, err := labelstructs.NewExchangeVolumes(exchange)
if err != nil { if err != nil {
return err return err
} }
@@ -298,7 +298,7 @@ func (chart *HelmChart) setCronJob(service types.ServiceConfig, appName string)
func (chart *HelmChart) setDependencies(service types.ServiceConfig) (bool, error) { func (chart *HelmChart) setDependencies(service types.ServiceConfig) (bool, error) {
// helm dependency // helm dependency
if v, ok := service.Labels[labels.LabelDependencies]; ok { if v, ok := service.Labels[labels.LabelDependencies]; ok {
d, err := labelStructs.DependenciesFrom(v) d, err := labelstructs.DependenciesFrom(v)
if err != nil { if err != nil {
return false, err return false, err
} }
@@ -326,7 +326,7 @@ func (chart *HelmChart) setSharedConf(service types.ServiceConfig, deployments m
if _, ok := service.Labels[labels.LabelEnvFrom]; !ok { if _, ok := service.Labels[labels.LabelEnvFrom]; !ok {
return return
} }
fromservices, err := labelStructs.EnvFromFrom(service.Labels[labels.LabelEnvFrom]) fromservices, err := labelstructs.EnvFromFrom(service.Labels[labels.LabelEnvFrom])
if err != nil { if err != nil {
log.Fatal("error unmarshaling env-from label:", err) 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 { if _, ok := service.Labels[labels.LabelValueFrom]; !ok {
return return
} }
mapping, err := labelStructs.GetValueFrom(service.Labels[labels.LabelValueFrom]) mapping, err := labelstructs.GetValueFrom(service.Labels[labels.LabelValueFrom])
if err != nil { if err != nil {
log.Fatal("error unmarshaling values-from label:", err) log.Fatal("error unmarshaling values-from label:", err)
} }
@@ -383,7 +383,7 @@ func (chart *HelmChart) setEnvironmentValuesFrom(service types.ServiceConfig, de
// is it a secret? // is it a secret?
isSecret := false isSecret := false
secrets, err := labelStructs.SecretsFrom(dep.service.Labels[labels.LabelSecrets]) secrets, err := labelstructs.SecretsFrom(dep.service.Labels[labels.LabelSecrets])
if err == nil { if err == nil {
if slices.Contains(secrets, depName[1]) { if slices.Contains(secrets, depName[1]) {
isSecret = true isSecret = true

View File

@@ -3,7 +3,7 @@ package generator
import ( import (
"fmt" "fmt"
"katenary/generator/labels" "katenary/generator/labels"
"katenary/generator/labels/labelStructs" "katenary/generator/labels/labelstructs"
"katenary/utils" "katenary/utils"
"log" "log"
"os" "os"
@@ -65,7 +65,7 @@ func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *Co
} }
// get the secrets from the labels // 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 { if err != nil {
log.Fatal(err) 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 // do not bind env variables to the configmap
// remove the variables that are already defined in the environment // remove the variables that are already defined in the environment
if l, ok := service.Labels[labels.LabelMapEnv]; ok { if l, ok := service.Labels[labels.LabelMapEnv]; ok {
envmap, err := labelStructs.MapEnvFrom(l) envmap, err := labelstructs.MapEnvFrom(l)
if err != nil { if err != nil {
log.Fatal("Error parsing map-env", err) log.Fatal("Error parsing map-env", err)
} }

View File

@@ -7,7 +7,7 @@ import (
"katenary/generator/extrafiles" "katenary/generator/extrafiles"
"katenary/generator/katenaryfile" "katenary/generator/katenaryfile"
"katenary/generator/labels" "katenary/generator/labels"
"katenary/generator/labels/labelStructs" "katenary/generator/labels/labelstructs"
"katenary/parser" "katenary/parser"
"katenary/utils" "katenary/utils"
"log" "log"
@@ -258,7 +258,7 @@ func addCommentsToValues(values []byte) []byte {
return []byte(strings.Join(lines, "\n")) 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 { for _, d := range dependencies {
name := d.Name name := d.Name
if d.Alias != "" { if d.Alias != "" {

View File

@@ -2,7 +2,7 @@ package generator
import ( import (
"katenary/generator/labels" "katenary/generator/labels"
"katenary/generator/labels/labelStructs" "katenary/generator/labels/labelstructs"
"katenary/utils" "katenary/utils"
"log" "log"
"strings" "strings"
@@ -30,7 +30,7 @@ func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (
if !ok { if !ok {
return nil, nil return nil, nil
} }
mapping, err := labelStructs.CronJobFrom(labels) mapping, err := labelstructs.CronJobFrom(labels)
if err != nil { if err != nil {
log.Fatalf("Error parsing cronjob labels: %s", err) log.Fatalf("Error parsing cronjob labels: %s", err)
return nil, nil return nil, nil

View File

@@ -3,7 +3,7 @@ package generator
import ( import (
"fmt" "fmt"
"katenary/generator/labels" "katenary/generator/labels"
"katenary/generator/labels/labelStructs" "katenary/generator/labels/labelstructs"
"katenary/utils" "katenary/utils"
"log" "log"
"os" "os"
@@ -39,7 +39,7 @@ type Deployment struct {
service *types.ServiceConfig `yaml:"-"` service *types.ServiceConfig `yaml:"-"`
defaultTag string `yaml:"-"` defaultTag string `yaml:"-"`
isMainApp bool `yaml:"-"` isMainApp bool `yaml:"-"`
exchangesVolumes map[string]*labelStructs.ExchangeVolume `yaml:"-"` exchangesVolumes map[string]*labelstructs.ExchangeVolume `yaml:"-"`
boundEnvVar []string `yaml:"-"` // environement to remove boundEnvVar []string `yaml:"-"` // environement to remove
} }
@@ -94,7 +94,7 @@ func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment {
}, },
configMaps: make(map[string]*ConfigMapMount), configMaps: make(map[string]*ConfigMapMount),
volumeMap: make(map[string]string), volumeMap: make(map[string]string),
exchangesVolumes: map[string]*labelStructs.ExchangeVolume{}, exchangesVolumes: map[string]*labelstructs.ExchangeVolume{},
boundEnvVar: []string{}, boundEnvVar: []string{},
} }
@@ -160,7 +160,7 @@ func (d *Deployment) AddContainer(service types.ServiceConfig) {
func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container) { func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container) {
// get the label for healthcheck // get the label for healthcheck
if v, ok := service.Labels[labels.LabelHealthCheck]; ok { if v, ok := service.Labels[labels.LabelHealthCheck]; ok {
probes, err := labelStructs.ProbeFrom(v) probes, err := labelstructs.ProbeFrom(v)
if err != nil { if err != nil {
log.Fatal(err) 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) { func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string) {
tobind := map[string]bool{} tobind := map[string]bool{}
if v, ok := service.Labels[labels.LabelConfigMapFiles]; ok { if v, ok := service.Labels[labels.LabelConfigMapFiles]; ok {
binds, err := labelStructs.ConfigMapFileFrom(v) binds, err := labelstructs.ConfigMapFileFrom(v)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@@ -320,7 +320,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, sam
}() }()
// secrets from label // secrets from label
labelSecrets, err := labelStructs.SecretsFrom(service.Labels[labels.LabelSecrets]) labelSecrets, err := labelstructs.SecretsFrom(service.Labels[labels.LabelSecrets])
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"katenary/generator/labels" "katenary/generator/labels"
"katenary/generator/labels/labelStructs" "katenary/generator/labels/labelstructs"
"katenary/utils" "katenary/utils"
"log" "log"
"regexp" "regexp"
@@ -227,7 +227,7 @@ func fixResourceNames(project *types.Project) error {
} }
// also, the value-from label should be updated // also, the value-from label should be updated
if valuefrom, ok := s.Labels[labels.LabelValueFrom]; ok { if valuefrom, ok := s.Labels[labels.LabelValueFrom]; ok {
vf, err := labelStructs.GetValueFrom(valuefrom) vf, err := labelstructs.GetValueFrom(valuefrom)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -2,7 +2,7 @@ package generator
import ( import (
"katenary/generator/labels" "katenary/generator/labels"
"katenary/generator/labels/labelStructs" "katenary/generator/labels/labelstructs"
"katenary/utils" "katenary/utils"
"log" "log"
"strings" "strings"
@@ -33,7 +33,7 @@ func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress {
return nil return nil
} }
mapping, err := labelStructs.IngressFrom(label) mapping, err := labelstructs.IngressFrom(label)
if err != nil { if err != nil {
log.Fatalf("Failed to parse ingress label: %s\n", err) log.Fatalf("Failed to parse ingress label: %s\n", err)
} }

View File

@@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"katenary/generator/labels" "katenary/generator/labels"
"katenary/generator/labels/labelStructs" "katenary/generator/labels/labelstructs"
"katenary/utils" "katenary/utils"
"log" "log"
"os" "os"
@@ -27,20 +27,20 @@ type StringOrMap any
type Service struct { type Service struct {
MainApp *bool `json:"main-app,omitempty" jsonschema:"title=Is this service the main application"` 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"` 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"` 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"` 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"` 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"` 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"` 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"` 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"` 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"` 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"` 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"` 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"` 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"` 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"` 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)"` 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 // 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)) val := strings.TrimSpace(string(c))
if labelName == labels.LabelIngress { if labelName == labels.LabelIngress {
// special case, values must be set from some defaults // special case, values must be set from some defaults
ing, err := labelStructs.IngressFrom(val) ing, err := labelstructs.IngressFrom(val)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
return err return err

View File

@@ -1,2 +0,0 @@
// labelStructs is a package that contains the structs used to represent the labels in the yaml files.
package labelStructs

View File

@@ -1,4 +1,4 @@
package labelStructs package labelstructs
import "gopkg.in/yaml.v3" import "gopkg.in/yaml.v3"

View File

@@ -1,4 +1,4 @@
package labelStructs package labelstructs
import "gopkg.in/yaml.v3" import "gopkg.in/yaml.v3"

View File

@@ -1,4 +1,4 @@
package labelStructs package labelstructs
import "gopkg.in/yaml.v3" import "gopkg.in/yaml.v3"

View File

@@ -0,0 +1,2 @@
// labelstructs is a package that contains the structs used to represent the labels in the yaml files.
package labelstructs

View File

@@ -1,4 +1,4 @@
package labelStructs package labelstructs
import "gopkg.in/yaml.v3" import "gopkg.in/yaml.v3"

View File

@@ -1,4 +1,4 @@
package labelStructs package labelstructs
import "gopkg.in/yaml.v3" import "gopkg.in/yaml.v3"

View File

@@ -1,4 +1,4 @@
package labelStructs package labelstructs
import ( import (
"fmt" "fmt"

View File

@@ -1,4 +1,4 @@
package labelStructs package labelstructs
import "gopkg.in/yaml.v3" import "gopkg.in/yaml.v3"

View File

@@ -1,4 +1,4 @@
package labelStructs package labelstructs
import "gopkg.in/yaml.v3" import "gopkg.in/yaml.v3"

View File

@@ -1,4 +1,4 @@
package labelStructs package labelstructs
import ( import (
"encoding/json" "encoding/json"

View File

@@ -1,4 +1,4 @@
package labelStructs package labelstructs
import "gopkg.in/yaml.v3" import "gopkg.in/yaml.v3"

View File

@@ -1,4 +1,4 @@
package labelStructs package labelstructs
import "gopkg.in/yaml.v3" import "gopkg.in/yaml.v3"

View File

@@ -2,7 +2,7 @@ package generator
import ( import (
"katenary/generator/labels" "katenary/generator/labels"
"katenary/generator/labels/labelStructs" "katenary/generator/labels/labelstructs"
"katenary/utils" "katenary/utils"
"regexp" "regexp"
"strconv" "strconv"
@@ -50,7 +50,7 @@ func fixPorts(service *types.ServiceConfig) error {
if portsLabel, ok = service.Labels[labels.LabelPorts]; !ok { if portsLabel, ok = service.Labels[labels.LabelPorts]; !ok {
return nil return nil
} }
ports, err := labelStructs.PortsFrom(portsLabel) ports, err := labelstructs.PortsFrom(portsLabel)
if err != nil { if err != nil {
// maybe it's a string, comma separated // maybe it's a string, comma separated
parts := strings.SplitSeq(portsLabel, ",") parts := strings.SplitSeq(portsLabel, ",")