2023-12-06 15:24:02 +01:00
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# generator
2024-04-10 04:51:45 +02:00
```go
2025-08-20 12:16:14 +02:00
import "katenary.io/internal/generator"
2023-12-06 15:24:02 +01:00
```
2025-07-04 14:59:49 +02:00
Package generator generates kubernetes objects from a "compose" file and transforms them into a helm chart.
2023-12-06 15:24:02 +01:00
2024-11-26 16:11:46 +01:00
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.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
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.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
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.
2023-12-06 15:24:02 +01:00
## Variables
2024-04-10 04:51:45 +02:00
<a name="Annotations"></a>
```go
2023-12-06 15:24:02 +01:00
var (
// Standard annotationss
Annotations = map[string]string{
2024-11-22 15:12:44 +01:00
labels.LabelName("version"): Version,
2023-12-06 15:24:02 +01:00
}
)
```
2024-04-10 04:51:45 +02:00
<a name="Version"></a>Version is the version of katenary. It is set at compile time.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
var Version = "master" // changed at compile time
```
2024-04-10 04:51:45 +02:00
<a name="Convert"></a>
2026-05-03 21:21:38 +02:00
## func Convert
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2024-12-03 14:45:27 +01:00
func Convert(config ConvertOptions, dockerComposeFile ...string) error
2023-12-06 15:24:02 +01:00
```
2024-04-10 04:51:45 +02:00
Convert a compose \(docker, podman...\) project to a helm chart. It calls Generate\(\) to generate the chart and then write it to the disk.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
<a name="GetLabels"></a>
2026-05-03 21:21:38 +02:00
## func GetLabels
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func GetLabels(serviceName, appName string) map[string]string
```
2024-04-10 04:51:45 +02:00
GetLabels returns the labels for a service. It uses the appName to replace the \_\_replace\_\_ in the labels. This is used to generate the labels in the templates.
<a name="GetMatchLabels"></a>
2026-05-03 21:21:38 +02:00
## func GetMatchLabels
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func GetMatchLabels(serviceName, appName string) map[string]string
```
2024-04-10 04:51:45 +02:00
GetMatchLabels returns the matchLabels for a service. It uses the appName to replace the \_\_replace\_\_ in the labels. This is used to generate the matchLabels in the templates.
2023-12-06 15:24:02 +01:00
2024-11-26 23:42:39 +01:00
<a name="GetVersion"></a>
2026-05-03 21:21:38 +02:00
## func GetVersion
2024-11-26 23:42:39 +01:00
```go
func GetVersion() string
```
GetVersion return the version of katneary. It's important to understand that the version is set at compile time for the github release. But, it the user get katneary using \`go install\`, the version should be different.
2024-04-10 04:51:45 +02:00
<a name="Helper"></a>
2026-05-03 21:21:38 +02:00
## func Helper
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func Helper(name string) string
```
Helper returns the \_helpers.tpl file for a chart.
2024-04-10 04:51:45 +02:00
<a name="NewCronJob"></a>
2026-05-03 21:21:38 +02:00
## func NewCronJob
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (*CronJob, *RBAC)
```
2024-04-10 04:51:45 +02:00
NewCronJob creates a new CronJob from a compose service. The appName is the name of the application taken from the project name.
2023-12-06 15:24:02 +01:00
2024-11-22 15:12:44 +01:00
<a name="ToK8SYaml"></a>
2026-05-03 21:21:38 +02:00
## func ToK8SYaml
2024-04-24 13:59:21 +02:00
```go
2025-06-04 15:18:11 +02:00
func ToK8SYaml(obj any) ([]byte, error)
2024-04-24 13:59:21 +02:00
```
2024-11-08 13:13:27 +01:00
<a name="UnWrapTPL"></a>
2026-05-03 21:21:38 +02:00
## func UnWrapTPL
2024-11-08 13:13:27 +01:00
```go
func UnWrapTPL(in []byte) []byte
```
UnWrapTPL removes the line wrapping from a template.
2024-04-10 04:51:45 +02:00
<a name="ChartTemplate"></a>
2026-05-03 21:21:38 +02:00
## type ChartTemplate
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
ChartTemplate is a template of a chart. It contains the content of the template and the name of the service. This is used internally to generate the templates.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type ChartTemplate struct {
Servicename string
2024-05-06 21:11:36 +02:00
Content []byte
2023-12-06 15:24:02 +01:00
}
```
2024-04-10 04:51:45 +02:00
<a name="ConfigMap"></a>
2026-05-03 21:21:38 +02:00
## type ConfigMap
2023-12-06 15:24:02 +01:00
ConfigMap is a kubernetes ConfigMap. Implements the DataMap interface.
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type ConfigMap struct {
*corev1.ConfigMap
// contains filtered or unexported fields
}
```
2024-04-10 04:51:45 +02:00
<a name="NewConfigMap"></a>
2026-05-03 21:21:38 +02:00
### func NewConfigMap
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2024-10-18 09:34:57 +02:00
func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *ConfigMap
2023-12-06 15:24:02 +01:00
```
2024-04-10 04:51:45 +02:00
NewConfigMap creates a new ConfigMap from a compose service. The appName is the name of the application taken from the project name. The ConfigMap is filled by environment variables and labels "map\-env".
2023-12-06 15:24:02 +01:00
2024-04-19 11:17:54 +02:00
<a name="NewConfigMapFromDirectory"></a>
2026-05-03 21:21:38 +02:00
### func NewConfigMapFromDirectory
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2024-05-06 21:11:36 +02:00
func NewConfigMapFromDirectory(service types.ServiceConfig, appName, path string) *ConfigMap
2023-12-06 15:24:02 +01:00
```
2024-04-19 11:17:54 +02:00
NewConfigMapFromDirectory creates a new ConfigMap from a compose service. This path is the path to the file or directory. If the path is a directory, all files in the directory are added to the ConfigMap. Each subdirectory are ignored. Note that the Generate\(\) function will create the subdirectories ConfigMaps.
2023-12-06 15:24:02 +01:00
2024-12-03 13:52:22 +01:00
<a name="ConfigMap.AddBinaryData"></a>
2026-05-03 21:21:38 +02:00
### func \(\*ConfigMap\) AddBinaryData
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2024-12-03 13:52:22 +01:00
func (c *ConfigMap) AddBinaryData(key string, value []byte)
2023-12-06 15:24:02 +01:00
```
2024-12-03 13:52:22 +01:00
AddBinaryData adds binary data to the configmap. Append or overwrite the value if the key already exists.
2023-12-06 15:24:02 +01:00
2024-12-03 13:52:22 +01:00
<a name="ConfigMap.AddData"></a>
2026-05-03 21:21:38 +02:00
### func \(\*ConfigMap\) AddData
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2024-12-03 13:52:22 +01:00
func (c *ConfigMap) AddData(key, value string)
2023-12-06 15:24:02 +01:00
```
2024-12-03 13:52:22 +01:00
AddData adds a key value pair to the configmap. Append or overwrite the value if the key already exists.
2023-12-06 15:24:02 +01:00
2024-12-03 14:45:27 +01:00
<a name="ConfigMap.AppendDir"></a>
2026-05-03 21:21:38 +02:00
### func \(\*ConfigMap\) AppendDir
2024-04-19 11:17:54 +02:00
```go
2024-12-03 14:45:27 +01:00
func (c *ConfigMap) AppendDir(path string) error
2024-04-19 11:17:54 +02:00
```
2025-07-04 14:59:49 +02:00
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.
2024-04-19 11:17:54 +02:00
2024-12-03 14:45:27 +01:00
<a name="ConfigMap.AppendFile"></a>
2026-05-03 21:21:38 +02:00
### func \(\*ConfigMap\) AppendFile
2024-12-03 13:52:22 +01:00
```go
2024-12-03 14:45:27 +01:00
func (c *ConfigMap) AppendFile(path string) error
2024-12-03 13:52:22 +01:00
```
2024-12-03 14:45:27 +01:00
2024-12-03 13:52:22 +01:00
2024-04-10 04:51:45 +02:00
<a name="ConfigMap.Filename"></a>
2026-05-03 21:21:38 +02:00
### func \(\*ConfigMap\) Filename
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (c *ConfigMap) Filename() string
```
2024-04-10 04:51:45 +02:00
Filename returns the filename of the configmap. If the configmap is used for files, the filename contains the path.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
<a name="ConfigMap.SetData"></a>
2026-05-03 21:21:38 +02:00
### func \(\*ConfigMap\) SetData
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (c *ConfigMap) SetData(data map[string]string)
```
SetData sets the data of the configmap. It replaces the entire data.
2024-04-10 04:51:45 +02:00
<a name="ConfigMap.Yaml"></a>
2026-05-03 21:21:38 +02:00
### func \(\*ConfigMap\) Yaml
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (c *ConfigMap) Yaml() ([]byte, error)
```
Yaml returns the yaml representation of the configmap
2024-04-19 11:17:54 +02:00
<a name="ConfigMapMount"></a>
2026-05-03 21:21:38 +02:00
## type ConfigMapMount
2024-04-19 11:17:54 +02:00
```go
type ConfigMapMount struct {
// contains filtered or unexported fields
}
```
2024-04-10 04:51:45 +02:00
<a name="ConvertOptions"></a>
2026-05-03 21:21:38 +02:00
## type ConvertOptions
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
ConvertOptions are the options to convert a compose project to a helm chart.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type ConvertOptions struct {
2024-05-06 21:11:36 +02:00
AppVersion *string
OutputDir string
ChartVersion string
2024-10-18 09:34:57 +02:00
Icon string
2024-05-06 21:11:36 +02:00
Profiles []string
2024-11-08 13:13:27 +01:00
EnvFiles []string
2024-05-06 21:11:36 +02:00
Force bool
HelmUpdate bool
2023-12-06 15:24:02 +01:00
}
```
2024-04-10 04:51:45 +02:00
<a name="CronJob"></a>
2026-05-03 21:21:38 +02:00
## type CronJob
2023-12-06 15:24:02 +01:00
CronJob is a kubernetes CronJob.
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type CronJob struct {
*batchv1.CronJob
// contains filtered or unexported fields
}
```
2024-04-10 04:51:45 +02:00
<a name="CronJob.Filename"></a>
2026-05-03 21:21:38 +02:00
### func \(\*CronJob\) Filename
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (c *CronJob) Filename() string
```
Filename returns the filename of the cronjob.
Implements the Yaml interface.
2024-04-10 04:51:45 +02:00
<a name="CronJob.Yaml"></a>
2026-05-03 21:21:38 +02:00
### func \(\*CronJob\) Yaml
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (c *CronJob) Yaml() ([]byte, error)
```
Yaml returns the yaml representation of the cronjob.
Implements the Yaml interface.
2024-04-10 04:51:45 +02:00
<a name="CronJobValue"></a>
2026-05-03 21:21:38 +02:00
## type CronJobValue
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
CronJobValue is a cronjob configuration that will be saved in values.yaml.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type CronJobValue struct {
Repository *RepositoryValue `yaml:"repository,omitempty"`
Environment map[string]any `yaml:"environment,omitempty"`
ImagePullPolicy string `yaml:"imagePullPolicy,omitempty"`
Schedule string `yaml:"schedule"`
}
```
2024-04-10 04:51:45 +02:00
<a name="DataMap"></a>
2026-05-03 21:21:38 +02:00
## type DataMap
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
DataMap is a kubernetes ConfigMap or Secret. It can be used to add data to the ConfigMap or Secret.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type DataMap interface {
SetData(map[string]string)
AddData(string, string)
}
```
2024-04-10 04:51:45 +02:00
<a name="Deployment"></a>
2026-05-03 21:21:38 +02:00
## type Deployment
2023-12-06 15:24:02 +01:00
Deployment is a kubernetes Deployment.
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type Deployment struct {
*appsv1.Deployment `yaml:",inline"`
// contains filtered or unexported fields
}
```
2024-04-10 04:51:45 +02:00
<a name="NewDeployment"></a>
2026-05-03 21:21:38 +02:00
### func NewDeployment
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment
```
2024-04-10 04:51:45 +02:00
NewDeployment creates a new Deployment from a compose service. The appName is the name of the application taken from the project name. It also creates the Values map that will be used to create the values.yaml file.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
<a name="Deployment.AddContainer"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) AddContainer
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (d *Deployment) AddContainer(service types.ServiceConfig)
```
AddContainer adds a container to the deployment.
2024-04-10 04:51:45 +02:00
<a name="Deployment.AddHealthCheck"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) AddHealthCheck
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container)
```
2024-04-10 04:51:45 +02:00
<a name="Deployment.AddIngress"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) AddIngress
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *Ingress
```
2024-04-10 04:51:45 +02:00
AddIngress adds an ingress to the deployment. It creates the ingress object.
2023-12-06 15:24:02 +01:00
2026-05-03 21:21:38 +02:00
<a name="Deployment.AddIngressRoute"></a>
### func \(\*Deployment\) AddIngressRoute
```go
func (d *Deployment) AddIngressRoute(service types.ServiceConfig, appName string) Yaml
```
AddIngressRoute adds an IngressRoute to the deployment if type is "ingressroute".
2024-11-22 15:12:44 +01:00
<a name="Deployment.AddLegacyVolume"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) AddLegacyVolume
2024-11-22 15:12:44 +01:00
```go
func (d *Deployment) AddLegacyVolume(name, kind string)
```
2024-04-10 04:51:45 +02:00
<a name="Deployment.AddVolumes"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) AddVolumes
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string)
```
2024-04-10 04:51:45 +02:00
AddVolumes adds a volume to the deployment. It does not create the PVC, it only adds the volumes to the deployment. If the volume is a bind volume it will warn the user that it is not supported yet.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
<a name="Deployment.BindFrom"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) BindFrom
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment)
```
2024-04-10 04:51:45 +02:00
2024-11-22 15:12:44 +01:00
<a name="Deployment.BindMapFilesToContainer"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) BindMapFilesToContainer
2024-11-22 15:12:44 +01:00
```go
func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secrets []string, appName string) (*corev1.Container, int)
```
2024-04-10 04:51:45 +02:00
<a name="Deployment.DependsOn"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) DependsOn
2024-04-10 04:51:45 +02:00
```go
2024-04-03 23:26:54 +02:00
func (d *Deployment) DependsOn(to *Deployment, servicename string) error
2023-12-06 15:24:02 +01:00
```
2024-04-10 04:51:45 +02:00
DependsOn adds a initContainer to the deployment that will wait for the service to be up.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
<a name="Deployment.Filename"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) Filename
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (d *Deployment) Filename() string
```
2024-04-10 04:51:45 +02:00
Filename returns the filename of the deployment.
2023-12-06 15:24:02 +01:00
2024-11-22 15:12:44 +01:00
<a name="Deployment.MountExchangeVolumes"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) MountExchangeVolumes
2024-11-22 15:12:44 +01:00
```go
func (d *Deployment) MountExchangeVolumes()
```
2024-04-10 04:51:45 +02:00
<a name="Deployment.SetEnvFrom"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) SetEnvFrom
2024-04-10 04:51:45 +02:00
```go
2024-11-22 15:12:44 +01:00
func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, samePod ...bool)
2023-12-06 15:24:02 +01:00
```
2024-04-10 04:51:45 +02:00
SetEnvFrom sets the environment variables to a configmap. The configmap is created.
2023-12-06 15:24:02 +01:00
2026-03-16 22:20:24 +01:00
<a name="Deployment.SetServiceAccountName"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) SetServiceAccountName
2026-03-16 22:20:24 +01:00
```go
func (d *Deployment) SetServiceAccountName()
```
2024-04-10 04:51:45 +02:00
<a name="Deployment.Yaml"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Deployment\) Yaml
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (d *Deployment) Yaml() ([]byte, error)
```
Yaml returns the yaml representation of the deployment.
2024-04-10 04:51:45 +02:00
<a name="FileMapUsage"></a>
2026-05-03 21:21:38 +02:00
## type FileMapUsage
2023-12-06 15:24:02 +01:00
FileMapUsage is the usage of the filemap.
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type FileMapUsage uint8
```
2024-04-10 04:51:45 +02:00
<a name="FileMapUsageConfigMap"></a>FileMapUsage constants.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
const (
FileMapUsageConfigMap FileMapUsage = iota // pure configmap for key:values.
FileMapUsageFiles // files in a configmap.
)
```
2024-04-10 04:51:45 +02:00
<a name="HelmChart"></a>
2026-05-03 21:21:38 +02:00
## type HelmChart
2023-12-06 15:24:02 +01:00
2024-11-26 16:11:46 +01:00
HelmChart is a Helm Chart representation. It contains all the templates, values, versions, helpers...
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type HelmChart struct {
2024-05-06 21:11:36 +02:00
Templates map[string]*ChartTemplate `yaml:"-"`
Values map[string]any `yaml:"-"`
VolumeMounts map[string]any `yaml:"-"`
2023-12-06 15:24:02 +01:00
Name string `yaml:"name"`
2024-10-18 09:34:57 +02:00
Icon string `yaml:"icon,omitempty"`
2025-07-04 14:59:49 +02:00
APIVersion string `yaml:"apiVersion"`
2023-12-06 15:24:02 +01:00
Version string `yaml:"version"`
AppVersion string `yaml:"appVersion"`
Description string `yaml:"description"`
2024-05-06 21:11:36 +02:00
Helper string `yaml:"-"`
2025-07-06 15:36:43 +02:00
Dependencies []labelstructs.Dependency `yaml:"dependencies,omitempty"`
2023-12-06 15:24:02 +01:00
// contains filtered or unexported fields
}
```
2024-04-10 04:51:45 +02:00
<a name="Generate"></a>
2026-05-03 21:21:38 +02:00
### func Generate
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func Generate(project *types.Project) (*HelmChart, error)
```
2024-04-10 04:51:45 +02:00
Generate a chart from a compose project. This does not write files to disk, it only creates the HelmChart object.
2023-12-06 15:24:02 +01:00
The Generate function will create the HelmChart object this way:
2024-04-10 04:51:45 +02:00
- Detect the service port name or leave the port number if not found.
2026-03-16 22:20:24 +01:00
- Create a deployment for each service that are not ingore.
2024-04-10 04:51:45 +02:00
- Create a service and ingresses for each service that has ports and/or declared ingresses.
- Create a PVC or Configmap volumes for each volume.
- Create init containers for each service which has dependencies to other services.
- Create a chart dependencies.
- Create a configmap and secrets from the environment variables.
- Merge the same\-pod services.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
<a name="NewChart"></a>
2026-05-03 21:21:38 +02:00
### func NewChart
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func NewChart(name string) *HelmChart
```
NewChart creates a new empty chart with the given name.
2024-05-06 21:11:36 +02:00
<a name="HelmChart.SaveTemplates"></a>
2026-05-03 21:21:38 +02:00
### func \(\*HelmChart\) SaveTemplates
2024-05-06 21:11:36 +02:00
```go
func (chart *HelmChart) SaveTemplates(templateDir string)
```
SaveTemplates the templates of the chart to the given directory.
2024-04-10 04:51:45 +02:00
<a name="Ingress"></a>
2026-05-03 21:21:38 +02:00
## type Ingress
2024-04-10 04:51:45 +02:00
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type Ingress struct {
*networkv1.Ingress
// contains filtered or unexported fields
}
```
2024-04-10 04:51:45 +02:00
<a name="NewIngress"></a>
2026-05-03 21:21:38 +02:00
### func NewIngress
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress
```
2026-05-03 21:21:38 +02:00
NewIngress creates a new standard Kubernetes Ingress from a compose service.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
<a name="Ingress.Filename"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Ingress\) Filename
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (ingress *Ingress) Filename() string
```
2024-04-10 04:51:45 +02:00
<a name="Ingress.Yaml"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Ingress\) Yaml
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (ingress *Ingress) Yaml() ([]byte, error)
```
2026-05-03 21:21:38 +02:00
<a name="IngressRoute"></a>
## type IngressRoute
IngressRoute represents a Traefik IngressRoute CRD
```go
type IngressRoute struct {
metav1.TypeMeta `yaml:",inline"`
metav1.ObjectMeta `yaml:"metadata"`
Spec IngressRouteSpec `yaml:"spec"`
// contains filtered or unexported fields
}
```
<a name="NewIngressRoute"></a>
### func NewIngressRoute
```go
func NewIngressRoute(service types.ServiceConfig, Chart *HelmChart, mapping *labelstructs.Ingress, serviceName, appName string) *IngressRoute
```
NewIngressRoute creates a new Traefik IngressRoute from a compose service.
<a name="IngressRoute.Filename"></a>
### func \(\*IngressRoute\) Filename
```go
func (ir *IngressRoute) Filename() string
```
<a name="IngressRoute.Yaml"></a>
### func \(\*IngressRoute\) Yaml
```go
func (ir *IngressRoute) Yaml() ([]byte, error)
```
<a name="IngressRouteRoute"></a>
## type IngressRouteRoute
IngressRouteRoute defines a route in the IngressRoute
```go
type IngressRouteRoute struct {
Match string `json:"match" yaml:"match"`
Kind string `json:"kind" yaml:"kind"`
Services []IngressRouteService `json:"services" yaml:"services"`
}
```
<a name="IngressRouteService"></a>
## type IngressRouteService
IngressRouteService defines a service backend in IngressRoute
```go
type IngressRouteService struct {
Name string `json:"name" yaml:"name"`
Port int `json:"port" yaml:"port"`
}
```
<a name="IngressRouteSpec"></a>
## type IngressRouteSpec
IngressRouteSpec defines the spec for Traefik IngressRoute
```go
type IngressRouteSpec struct {
EntryPoints []string `json:"entryPoints,omitempty" yaml:"entryPoints,omitempty"`
Routes []IngressRouteRoute `json:"routes" yaml:"routes"`
TLS *IngressRouteTLS `json:"tls,omitempty" yaml:"tls,omitempty"`
}
```
<a name="IngressRouteTLS"></a>
## type IngressRouteTLS
IngressRouteTLS defines TLS configuration for IngressRoute
```go
type IngressRouteTLS struct {
SecretName string `json:"secretName,omitempty" yaml:"secretName,omitempty"`
Domains []IngressRouteTLSDomain `json:"domains,omitempty" yaml:"domains,omitempty"`
}
```
<a name="IngressRouteTLSDomain"></a>
## type IngressRouteTLSDomain
IngressRouteTLSDomain defines a domain for TLS
```go
type IngressRouteTLSDomain struct {
Main string `json:"main" yaml:"main"`
}
```
2024-04-10 04:51:45 +02:00
<a name="IngressValue"></a>
2026-05-03 21:21:38 +02:00
## type IngressValue
2024-04-10 04:51:45 +02:00
IngressValue is a ingress configuration that will be saved in values.yaml.
```go
2023-12-06 15:24:02 +01:00
type IngressValue struct {
2026-05-03 21:21:38 +02:00
Annotations map[string]string `yaml:"annotations"`
Host string `yaml:"host"`
Path string `yaml:"path"`
Class string `yaml:"class"`
Type string `yaml:"type"`
Enabled bool `yaml:"enabled"`
IngressRouteEnabled bool `yaml:"ingressRouteEnabled"`
TLS TLS `yaml:"tls"`
2023-12-06 15:24:02 +01:00
}
```
2024-04-10 04:51:45 +02:00
<a name="PersistenceValue"></a>
2026-05-03 21:21:38 +02:00
## type PersistenceValue
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
PersistenceValue is a persistence configuration that will be saved in values.yaml.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type PersistenceValue struct {
StorageClass string `yaml:"storageClass"`
Size string `yaml:"size"`
AccessMode []string `yaml:"accessMode"`
2024-05-06 21:11:36 +02:00
Enabled bool `yaml:"enabled"`
2023-12-06 15:24:02 +01:00
}
```
2024-04-10 04:51:45 +02:00
<a name="RBAC"></a>
2026-05-03 21:21:38 +02:00
## type RBAC
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
RBAC is a kubernetes RBAC containing a role, a rolebinding and an associated serviceaccount.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type RBAC struct {
RoleBinding *RoleBinding
Role *Role
ServiceAccount *ServiceAccount
}
```
2024-04-10 04:51:45 +02:00
<a name="NewRBAC"></a>
2026-05-03 21:21:38 +02:00
### func NewRBAC
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func NewRBAC(service types.ServiceConfig, appName string) *RBAC
```
2024-04-10 04:51:45 +02:00
NewRBAC creates a new RBAC from a compose service. The appName is the name of the application taken from the project name.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
<a name="RepositoryValue"></a>
2026-05-03 21:21:38 +02:00
## type RepositoryValue
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
RepositoryValue is a docker repository image and tag that will be saved in values.yaml.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type RepositoryValue struct {
Image string `yaml:"image"`
Tag string `yaml:"tag"`
}
```
2024-04-10 04:51:45 +02:00
<a name="Role"></a>
2026-05-03 21:21:38 +02:00
## type Role
2023-12-06 15:24:02 +01:00
Role is a kubernetes Role.
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type Role struct {
*rbacv1.Role
// contains filtered or unexported fields
}
```
2026-03-16 22:20:24 +01:00
<a name="NewRestrictedRole"></a>
2026-05-03 21:21:38 +02:00
### func NewRestrictedRole
2026-03-16 22:20:24 +01:00
```go
func NewRestrictedRole(service types.ServiceConfig, appName string) *Role
```
NewRestrictedRole creates a Role with minimal permissions for init containers.
2024-04-10 04:51:45 +02:00
<a name="Role.Filename"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Role\) Filename
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (r *Role) Filename() string
```
2024-04-10 04:51:45 +02:00
<a name="Role.Yaml"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Role\) Yaml
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (r *Role) Yaml() ([]byte, error)
```
2024-04-10 04:51:45 +02:00
<a name="RoleBinding"></a>
2026-05-03 21:21:38 +02:00
## type RoleBinding
2023-12-06 15:24:02 +01:00
RoleBinding is a kubernetes RoleBinding.
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type RoleBinding struct {
*rbacv1.RoleBinding
// contains filtered or unexported fields
}
```
2026-03-16 22:20:24 +01:00
<a name="NewRestrictedRoleBinding"></a>
2026-05-03 21:21:38 +02:00
### func NewRestrictedRoleBinding
2026-03-16 22:20:24 +01:00
```go
func NewRestrictedRoleBinding(service types.ServiceConfig, appName string) *RoleBinding
```
NewRestrictedRoleBinding creates a RoleBinding that binds the restricted role to the ServiceAccount.
2024-04-10 04:51:45 +02:00
<a name="RoleBinding.Filename"></a>
2026-05-03 21:21:38 +02:00
### func \(\*RoleBinding\) Filename
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (r *RoleBinding) Filename() string
```
2024-04-10 04:51:45 +02:00
<a name="RoleBinding.Yaml"></a>
2026-05-03 21:21:38 +02:00
### func \(\*RoleBinding\) Yaml
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (r *RoleBinding) Yaml() ([]byte, error)
```
2024-04-10 04:51:45 +02:00
<a name="Secret"></a>
2026-05-03 21:21:38 +02:00
## type Secret
2023-12-06 15:24:02 +01:00
Secret is a kubernetes Secret.
Implements the DataMap interface.
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type Secret struct {
*corev1.Secret
// contains filtered or unexported fields
}
```
2024-04-10 04:51:45 +02:00
<a name="NewSecret"></a>
2026-05-03 21:21:38 +02:00
### func NewSecret
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func NewSecret(service types.ServiceConfig, appName string) *Secret
```
NewSecret creates a new Secret from a compose service
2024-04-10 04:51:45 +02:00
<a name="Secret.AddData"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Secret\) AddData
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2024-05-06 21:11:36 +02:00
func (s *Secret) AddData(key, value string)
2023-12-06 15:24:02 +01:00
```
AddData adds a key value pair to the secret.
2024-04-10 04:51:45 +02:00
<a name="Secret.Filename"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Secret\) Filename
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (s *Secret) Filename() string
```
Filename returns the filename of the secret.
2024-04-10 04:51:45 +02:00
<a name="Secret.SetData"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Secret\) SetData
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (s *Secret) SetData(data map[string]string)
```
SetData sets the data of the secret.
2024-04-10 04:51:45 +02:00
<a name="Secret.Yaml"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Secret\) Yaml
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (s *Secret) Yaml() ([]byte, error)
```
Yaml returns the yaml representation of the secret.
2024-04-10 04:51:45 +02:00
<a name="Service"></a>
2026-05-03 21:21:38 +02:00
## type Service
2023-12-06 15:24:02 +01:00
Service is a kubernetes Service.
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type Service struct {
*v1.Service `yaml:",inline"`
// contains filtered or unexported fields
}
```
2024-04-10 04:51:45 +02:00
<a name="NewService"></a>
2026-05-03 21:21:38 +02:00
### func NewService
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func NewService(service types.ServiceConfig, appName string) *Service
```
NewService creates a new Service from a compose service.
2024-04-10 04:51:45 +02:00
<a name="Service.AddPort"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Service\) AddPort
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
```
AddPort adds a port to the service.
2024-04-10 04:51:45 +02:00
<a name="Service.Filename"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Service\) Filename
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (s *Service) Filename() string
```
Filename returns the filename of the service.
2024-04-10 04:51:45 +02:00
<a name="Service.Yaml"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Service\) Yaml
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (s *Service) Yaml() ([]byte, error)
```
Yaml returns the yaml representation of the service.
2024-04-10 04:51:45 +02:00
<a name="ServiceAccount"></a>
2026-05-03 21:21:38 +02:00
## type ServiceAccount
2023-12-06 15:24:02 +01:00
ServiceAccount is a kubernetes ServiceAccount.
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type ServiceAccount struct {
*corev1.ServiceAccount
// contains filtered or unexported fields
}
```
2026-03-16 22:20:24 +01:00
<a name="NewServiceAccount"></a>
2026-05-03 21:21:38 +02:00
### func NewServiceAccount
2026-03-16 22:20:24 +01:00
```go
func NewServiceAccount(service types.ServiceConfig, appName string) *ServiceAccount
```
NewServiceAccount creates a new ServiceAccount from a compose service.
2024-04-10 04:51:45 +02:00
<a name="ServiceAccount.Filename"></a>
2026-05-03 21:21:38 +02:00
### func \(\*ServiceAccount\) Filename
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (r *ServiceAccount) Filename() string
```
2024-04-10 04:51:45 +02:00
<a name="ServiceAccount.Yaml"></a>
2026-05-03 21:21:38 +02:00
### func \(\*ServiceAccount\) Yaml
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (r *ServiceAccount) Yaml() ([]byte, error)
```
2024-11-22 15:12:44 +01:00
<a name="TLS"></a>
2026-05-03 21:21:38 +02:00
## type TLS
2024-11-22 15:12:44 +01:00
```go
type TLS struct {
2025-06-04 15:18:11 +02:00
Enabled bool `yaml:"enabled"`
SecretName string `yaml:"secretName"`
2024-11-22 15:12:44 +01:00
}
```
2024-04-10 04:51:45 +02:00
<a name="Value"></a>
2026-05-03 21:21:38 +02:00
## type Value
2023-12-06 15:24:02 +01:00
2024-11-26 16:11:46 +01:00
Value will be saved in values.yaml. It contains configuration for all deployment and services.
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type Value struct {
Repository *RepositoryValue `yaml:"repository,omitempty"`
Persistence map[string]*PersistenceValue `yaml:"persistence,omitempty"`
Ingress *IngressValue `yaml:"ingress,omitempty"`
Environment map[string]any `yaml:"environment,omitempty"`
Replicas *uint32 `yaml:"replicas,omitempty"`
CronJob *CronJobValue `yaml:"cronjob,omitempty"`
2024-04-21 16:37:20 +02:00
NodeSelector map[string]string `yaml:"nodeSelector"`
2024-04-22 13:31:30 +02:00
Resources map[string]any `yaml:"resources"`
2024-05-06 21:11:36 +02:00
ImagePullPolicy string `yaml:"imagePullPolicy,omitempty"`
ServiceAccount string `yaml:"serviceAccount"`
2023-12-06 15:24:02 +01:00
}
```
2024-04-10 04:51:45 +02:00
<a name="NewValue"></a>
2026-05-03 21:21:38 +02:00
### func NewValue
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func NewValue(service types.ServiceConfig, main ...bool) *Value
```
2024-04-10 04:51:45 +02:00
NewValue creates a new Value from a compose service. The value contains the necessary information to deploy the service \(image, tag, replicas, etc.\).
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
If \`main\` is true, the tag will be empty because it will be set in the helm chart appVersion.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
<a name="Value.AddIngress"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Value\) AddIngress
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (v *Value) AddIngress(host, path string)
```
2024-04-10 04:51:45 +02:00
<a name="Value.AddPersistence"></a>
2026-05-03 21:21:38 +02:00
### func \(\*Value\) AddPersistence
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (v *Value) AddPersistence(volumeName string)
```
AddPersistence adds persistence configuration to the Value.
2024-04-10 04:51:45 +02:00
<a name="VolumeClaim"></a>
2026-05-03 21:21:38 +02:00
## type VolumeClaim
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
VolumeClaim is a kubernetes VolumeClaim. This is a PersistentVolumeClaim.
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type VolumeClaim struct {
*v1.PersistentVolumeClaim
// contains filtered or unexported fields
}
```
2024-04-10 04:51:45 +02:00
<a name="NewVolumeClaim"></a>
2026-05-03 21:21:38 +02:00
### func NewVolumeClaim
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func NewVolumeClaim(service types.ServiceConfig, volumeName, appName string) *VolumeClaim
```
NewVolumeClaim creates a new VolumeClaim from a compose service.
2024-04-10 04:51:45 +02:00
<a name="VolumeClaim.Filename"></a>
2026-05-03 21:21:38 +02:00
### func \(\*VolumeClaim\) Filename
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (v *VolumeClaim) Filename() string
```
Filename returns the suggested filename for a VolumeClaim.
2024-04-10 04:51:45 +02:00
<a name="VolumeClaim.Yaml"></a>
2026-05-03 21:21:38 +02:00
### func \(\*VolumeClaim\) Yaml
2023-12-06 15:24:02 +01:00
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
func (v *VolumeClaim) Yaml() ([]byte, error)
```
Yaml marshals a VolumeClaim into yaml.
2024-04-10 04:51:45 +02:00
<a name="Yaml"></a>
2026-05-03 21:21:38 +02:00
## type Yaml
2023-12-06 15:24:02 +01:00
Yaml is a kubernetes object that can be converted to yaml.
2024-04-10 04:51:45 +02:00
```go
2023-12-06 15:24:02 +01:00
type Yaml interface {
Yaml() ([]byte, error)
Filename() string
}
```
2026-05-03 21:21:38 +02:00
<a name="NewIngressRouteFromService"></a>
### func NewIngressRouteFromService
```go
func NewIngressRouteFromService(service types.ServiceConfig, Chart *HelmChart) Yaml
```
NewIngressRouteFromService creates a Traefik IngressRoute from the same service config. This is called separately to generate the IngressRoute file in addition to Ingress.
2024-04-10 04:51:45 +02:00
Generated by [gomarkdoc ](<https://github.com/princjef/gomarkdoc> )