diff --git a/doc/docs/packages/generator.md b/doc/docs/packages/generator.md index a761861..9b029da 100644 --- a/doc/docs/packages/generator.md +++ b/doc/docs/packages/generator.md @@ -465,7 +465,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"` // contains filtered or unexported fields } ``` diff --git a/doc/docs/packages/generator/katenaryfile.md b/doc/docs/packages/generator/katenaryfile.md index 3e1d02e..a2a1824 100644 --- a/doc/docs/packages/generator/katenaryfile.md +++ b/doc/docs/packages/generator/katenaryfile.md @@ -38,20 +38,20 @@ Service is a struct that contains the service configuration for katenary 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)"` } ``` diff --git a/doc/docs/packages/generator/labels.md b/doc/docs/packages/generator/labels.md index 9368cea..9728333 100644 --- a/doc/docs/packages/generator/labels.md +++ b/doc/docs/packages/generator/labels.md @@ -23,7 +23,7 @@ const KatenaryLabelPrefix = "katenary.v3" func GetLabelHelp(asMarkdown bool) string ``` -Generate the help for the labels. +GetLabelHelp return the help for the labels. ## func [GetLabelHelpFor]() diff --git a/doc/docs/packages/generator/labels/labelstructs.md b/doc/docs/packages/generator/labels/labelstructs.md new file mode 100644 index 0000000..9170aa6 --- /dev/null +++ b/doc/docs/packages/generator/labels/labelstructs.md @@ -0,0 +1,246 @@ + + +# labelstructs + +```go +import "katenary/generator/labels/labelstructs" +``` + +Package labelstructs is a package that contains the structs used to represent the labels in the yaml files. + +## type [ConfigMapFile]() + + + +```go +type ConfigMapFile []string +``` + + +### func [ConfigMapFileFrom]() + +```go +func ConfigMapFileFrom(data string) (ConfigMapFile, error) +``` + + + + +## type [CronJob]() + + + +```go +type CronJob struct { + Image string `yaml:"image,omitempty" json:"image,omitempty"` + Command string `yaml:"command" json:"command,omitempty"` + Schedule string `yaml:"schedule" json:"schedule,omitempty"` + Rbac bool `yaml:"rbac" json:"rbac,omitempty"` +} +``` + + +### func [CronJobFrom]() + +```go +func CronJobFrom(data string) (*CronJob, error) +``` + + + + +## type [Dependency]() + +Dependency is a dependency of a chart to other charts. + +```go +type Dependency struct { + Values map[string]any `yaml:"-" json:"values,omitempty"` + Name string `yaml:"name" json:"name"` + Version string `yaml:"version" json:"version"` + Repository string `yaml:"repository" json:"repository"` + Alias string `yaml:"alias,omitempty" json:"alias,omitempty"` +} +``` + + +### func [DependenciesFrom]() + +```go +func DependenciesFrom(data string) ([]Dependency, error) +``` + +DependenciesFrom returns a slice of dependencies from the given string. + + +## type [EnvFrom]() + + + +```go +type EnvFrom []string +``` + + +### func [EnvFromFrom]() + +```go +func EnvFromFrom(data string) (EnvFrom, error) +``` + +EnvFromFrom returns a EnvFrom from the given string. + + +## type [ExchangeVolume]() + + + +```go +type ExchangeVolume struct { + Name string `yaml:"name" json:"name"` + MountPath string `yaml:"mountPath" json:"mountPath"` + Type string `yaml:"type,omitempty" json:"type,omitempty"` + Init string `yaml:"init,omitempty" json:"init,omitempty"` +} +``` + + +### func [NewExchangeVolumes]() + +```go +func NewExchangeVolumes(data string) ([]*ExchangeVolume, error) +``` + + + + +## type [HealthCheck]() + + + +```go +type HealthCheck struct { + LivenessProbe *corev1.Probe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"` + ReadinessProbe *corev1.Probe `yaml:"readinessProbe,omitempty" json:"readinessProbe,omitempty"` +} +``` + + +### func [ProbeFrom]() + +```go +func ProbeFrom(data string) (*HealthCheck, error) +``` + + + + +## type [Ingress]() + + + +```go +type Ingress struct { + Port *int32 `yaml:"port,omitempty" json:"port,omitempty"` + Annotations map[string]string `yaml:"annotations,omitempty" jsonschema:"nullable" json:"annotations,omitempty"` + Hostname string `yaml:"hostname,omitempty" json:"hostname,omitempty"` + Path *string `yaml:"path,omitempty" json:"path,omitempty"` + Class *string `yaml:"class,omitempty" json:"class,omitempty" jsonschema:"default:-"` + Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"` + TLS *TLS `yaml:"tls,omitempty" json:"tls,omitempty"` +} +``` + + +### func [IngressFrom]() + +```go +func IngressFrom(data string) (*Ingress, error) +``` + +IngressFrom creates a new Ingress from a compose service. + + +## type [MapEnv]() + + + +```go +type MapEnv map[string]string +``` + + +### func [MapEnvFrom]() + +```go +func MapEnvFrom(data string) (MapEnv, error) +``` + +MapEnvFrom returns a MapEnv from the given string. + + +## type [Ports]() + + + +```go +type Ports []uint32 +``` + + +### func [PortsFrom]() + +```go +func PortsFrom(data string) (Ports, error) +``` + +PortsFrom returns a Ports from the given string. + + +## type [Secrets]() + + + +```go +type Secrets []string +``` + + +### func [SecretsFrom]() + +```go +func SecretsFrom(data string) (Secrets, error) +``` + + + + +## type [TLS]() + + + +```go +type TLS struct { + Enabled bool `yaml:"enabled" json:"enabled,omitempty"` +} +``` + + +## type [ValueFrom]() + + + +```go +type ValueFrom map[string]string +``` + + +### func [GetValueFrom]() + +```go +func GetValueFrom(data string) (*ValueFrom, error) +``` + + + +Generated by [gomarkdoc]() diff --git a/doc/docs/packages/utils.md b/doc/docs/packages/utils.md index b512f96..78a6551 100644 --- a/doc/docs/packages/utils.md +++ b/doc/docs/packages/utils.md @@ -8,7 +8,16 @@ import "katenary/utils" Package utils provides some utility functions used in katenary. It defines some constants and functions used in the whole project. -## func [AsResourceName]() +## Constants + +DirectoryPermission is the default values for permissions apply to created directories. + +```go +const DirectoryPermission = 0o755 +``` + + +## func [AsResourceName]() ```go func AsResourceName(name string) string @@ -17,7 +26,7 @@ func AsResourceName(name string) string AsResourceName returns a resource name with underscores to respect the kubernetes naming convention. It's the opposite of FixedResourceName. -## func [Confirm]() +## func [Confirm]() ```go func Confirm(question string, icon ...Icon) bool @@ -26,7 +35,7 @@ func Confirm(question string, icon ...Icon) bool Confirm asks a question and returns true if the answer is y. -## func [CountStartingSpaces]() +## func [CountStartingSpaces]() ```go func CountStartingSpaces(line string) int @@ -35,7 +44,7 @@ func CountStartingSpaces(line string) int CountStartingSpaces counts the number of spaces at the beginning of a string. -## func [EncodeBasicYaml]() +## func [EncodeBasicYaml]() ```go func EncodeBasicYaml(data any) ([]byte, error) @@ -44,7 +53,7 @@ func EncodeBasicYaml(data any) ([]byte, error) EncodeBasicYaml encodes a basic yaml from an interface. -## func [FixedResourceName]() +## func [FixedResourceName]() ```go func FixedResourceName(name string) string @@ -53,7 +62,7 @@ func FixedResourceName(name string) string FixedResourceName returns a resource name without underscores to respect the kubernetes naming convention. -## func [GetContainerByName]() +## func [GetContainerByName]() ```go func GetContainerByName(name string, containers []corev1.Container) (*corev1.Container, int) @@ -62,7 +71,7 @@ func GetContainerByName(name string, containers []corev1.Container) (*corev1.Con GetContainerByName returns a container by name and its index in the array. It returns nil, \-1 if not found. -## func [GetKind]() +## func [GetKind]() ```go func GetKind(path string) (kind string) @@ -71,7 +80,7 @@ func GetKind(path string) (kind string) GetKind returns the kind of the resource from the file path. -## func [GetServiceNameByPort]() +## func [GetServiceNameByPort]() ```go func GetServiceNameByPort(port int) string @@ -80,7 +89,7 @@ func GetServiceNameByPort(port int) string GetServiceNameByPort returns the service name for a port. It the service name is not found, it returns an empty string. -## func [GetValuesFromLabel]() +## func [GetValuesFromLabel]() ```go func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[string]*EnvConfig @@ -98,7 +107,7 @@ func HashComposefiles(files []string) (string, error) HashComposefiles returns a hash of the compose files. -## func [Int32Ptr]() +## func [Int32Ptr]() ```go func Int32Ptr(i int32) *int32 @@ -107,7 +116,7 @@ func Int32Ptr(i int32) *int32 Int32Ptr returns a pointer to an int32. -## func [PathToName]() +## func [PathToName]() ```go func PathToName(path string) string @@ -116,7 +125,7 @@ func PathToName(path string) string PathToName converts a path to a kubernetes complient name. -## func [StrPtr]() +## func [StrPtr]() ```go func StrPtr(s string) *string @@ -125,7 +134,7 @@ func StrPtr(s string) *string StrPtr returns a pointer to a string. -## func [TplName]() +## func [TplName]() ```go func TplName(serviceName, appname string, suffix ...string) string @@ -134,7 +143,7 @@ func TplName(serviceName, appname string, suffix ...string) string TplName returns the name of the kubernetes resource as a template string. It is used in the templates and defined in \_helper.tpl file. -## func [TplValue]() +## func [TplValue]() ```go func TplValue(serviceName, variable string, pipes ...string) string @@ -152,7 +161,7 @@ func Warn(msg ...any) Warn prints a warning message -## func [WordWrap]() +## func [WordWrap]() ```go func WordWrap(text string, lineWidth int) string @@ -161,7 +170,7 @@ func WordWrap(text string, lineWidth int) string WordWrap wraps a string to a given line width. Warning: it may break the string. You need to check the result. -## func [Wrap]() +## func [Wrap]() ```go func Wrap(src, above, below string) string @@ -170,7 +179,7 @@ func Wrap(src, above, below string) string Wrap wraps a string with a string above and below. It will respect the indentation of the src string. -## type [EnvConfig]() +## type [EnvConfig]() EnvConfig is a struct to hold the description of an environment variable.