Fixup documentation

- better gomarkdown generation that now fixed the escaped strings, no
  need to use pandoc anymore
- added workflow image
- upgraded versions of mkdocs requirements
This commit is contained in:
2024-04-10 04:51:45 +02:00
parent 2f53638f82
commit c7c18f01cd
11 changed files with 538 additions and 443 deletions

View File

@@ -4,7 +4,7 @@ VERSION=$(shell git describe --exact-match --tags $(CUR_SHA) 2>/dev/null || echo
CTN:=$(shell which podman 2>&1 1>/dev/null && echo "podman" || echo "docker") CTN:=$(shell which podman 2>&1 1>/dev/null && echo "podman" || echo "docker")
PREFIX=~/.local PREFIX=~/.local
GOVERSION=1.21 GOVERSION=1.22
GO=container GO=container
OUT=katenary OUT=katenary
BLD_CMD=go build -ldflags="-X 'katenary/generator.Version=$(VERSION)'" -o $(OUT) ./cmd/katenary BLD_CMD=go build -ldflags="-X 'katenary/generator.Version=$(VERSION)'" -o $(OUT) ./cmd/katenary
@@ -154,6 +154,15 @@ clean:
rm -rf katenary dist/* release.id rm -rf katenary dist/* release.id
serve-doc: __label_doc
@cd doc && \
[ -d venv ] || python -m venv venv; \
source venv/bin/activate && \
echo "==> Installing requirements in the virtual env..."
pip install -qq -r requirements.txt && \
echo "==> Serving doc with mkdocs..." && \
mkdocs serve
tests: test tests: test
test: test:
@echo -e "\033[1;33mTesting katenary $(VERSION)...\033[0m" @echo -e "\033[1;33mTesting katenary $(VERSION)...\033[0m"
@@ -183,6 +192,8 @@ push-release: build-all
__label_doc: __label_doc:
@command -v gomarkdoc || (echo "==> We need to install gomarkdoc..." && \
go install github.com/princjef/gomarkdoc/cmd/gomarkdoc@latest)
@echo "=> Generating labels doc..." @echo "=> Generating labels doc..."
# short label doc # short label doc
go run ./cmd/katenary help-labels -m | \ go run ./cmd/katenary help-labels -m | \
@@ -201,16 +212,6 @@ __label_doc:
PACKAGES=$$(for f in $$(find . -name "*.go" -type f); do dirname $$f; done | sort -u) PACKAGES=$$(for f in $$(find . -name "*.go" -type f); do dirname $$f; done | sort -u)
for pack in $$PACKAGES; do for pack in $$PACKAGES; do
echo "-> Generating doc for $$pack" echo "-> Generating doc for $$pack"
#gomarkdoc -o doc/docs/packages/$$pack.md $$pack gomarkdoc --repository.default-branch $(shell git branch --show-current) -o doc/docs/packages/$$pack.md $$pack
gomarkdoc -f azure-devops $$pack | pandoc -t gfm -o doc/docs/packages/$$pack.md
# drop the Index section without removing the title
# - remove the Index section, but keep the following heading
sed -i '/^## Index/,/^##/ { /## Index/d; /^##/! d }' doc/docs/packages/$$pack.md sed -i '/^## Index/,/^##/ { /## Index/d; /^##/! d }' doc/docs/packages/$$pack.md
# fixes for markdown problem
# - there are \* on heading, replace to *
sed -i 's/\\\*/\*/g' doc/docs/packages/$$pack.md
## parenthis in heading are escaped, replace to unescaped
sed -i 's/\\(/\(/g' doc/docs/packages/$$pack.md
sed -i 's/\\)/\)/g' doc/docs/packages/$$pack.md
## list are badly formatted with 2 spaces, replace to 4
done done

View File

@@ -1,20 +1,3 @@
<style>
#logo{
background-image: url('statics/logo-dark.svg');
background-repeat: no-repeat;
background-position: center;
background-size: contain;
height: 8em;
width: 100%;
margin: 0 auto;
}
[data-md-color-scheme=slate] #logo {
background-image: url('statics/logo-bright.svg');
}
</style>
<div class="md-center" id="logo"></div> <div class="md-center" id="logo"></div>
# Welcome to Katenary documentation # Welcome to Katenary documentation
@@ -29,6 +12,11 @@ and Helm Chart creation.
💡 Effortless Efficiency: You only need to add labels when it's necessary to precise things. Then call `katenary convert` and let the magic happen. 💡 Effortless Efficiency: You only need to add labels when it's necessary to precise things. Then call `katenary convert` and let the magic happen.
<div style="margin: auto" class="zoomable">
<img src="statics/workflow.png" id="workflow-image"/>
</div>
# What ? # What ?
Katenary is a tool made to help you to transform "compose" files (`docker-compose.yml`, `podman-compose.yml`...) to Katenary is a tool made to help you to transform "compose" files (`docker-compose.yml`, `podman-compose.yml`...) to

View File

@@ -6,3 +6,7 @@
import "katenary/cmd/katenary" import "katenary/cmd/katenary"
``` ```
Katenary CLI, main package.
This package is not intended to be imported. It contains the main function that build the command line with \`cobra\` package.

View File

@@ -6,35 +6,28 @@
import "katenary/generator" import "katenary/generator"
``` ```
The generator package generates kubernetes objects from a compose file The generator package generates kubernetes objects from a compose file and transforms them into a helm chart.
and transforms them into a helm chart.
The generator package is the core of katenary. It is responsible for 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. Convertion 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.
generating kubernetes objects from a compose file and transforming them
into a helm chart. Convertion manipulates Yaml representation of
kubernetes object to add conditions, labels, annotations, etc. to the
objects. It also create the values to be set to the values.yaml file.
The generate.Convert() create an HelmChart object and call Generate()” 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.
method to convert from a compose file to a helm chart. It saves the helm
chart in the given directory.
If you want to change or override the write behavior, you can use the 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.
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.
TODO: Manage cronjob + rbac TODO: create note.txt TODO: manage emptyDirs TODO: Manage cronjob \+ rbac TODO: create note.txt TODO: manage emptyDirs
## Constants ## Constants
<a name="KATENARY_PREFIX"></a>
```go ```go
const KATENARY_PREFIX = "katenary.v3/" const KATENARY_PREFIX = "katenary.v3/"
``` ```
## Variables ## Variables
<a name="Annotations"></a>
```go ```go
var ( var (
@@ -45,22 +38,23 @@ var (
) )
``` ```
Version is the version of katenary. It is set at compile time. <a name="Version"></a>Version is the version of katenary. It is set at compile time.
```go ```go
var Version = "master" // changed at compile time var Version = "master" // changed at compile time
``` ```
## func Convert <a name="Convert"></a>
## func [Convert](<https://github.com/metal3d/katenary/blob/develop/generator/converter.go#L37>)
```go ```go
func Convert(config ConvertOptions, dockerComposeFile ...string) func Convert(config ConvertOptions, dockerComposeFile ...string)
``` ```
Convert a compose (docker, podman) project to a helm chart. It calls Convert a compose \(docker, podman...\) project to a helm chart. It calls Generate\(\) to generate the chart and then write it to the disk.
Generate() to generate the chart and then write it to the disk.
## func GetLabelHelp <a name="GetLabelHelp"></a>
## func [GetLabelHelp](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryLabels.go#L66>)
```go ```go
func GetLabelHelp(asMarkdown bool) string func GetLabelHelp(asMarkdown bool) string
@@ -68,7 +62,8 @@ func GetLabelHelp(asMarkdown bool) string
Generate the help for the labels. Generate the help for the labels.
## func GetLabelHelpFor <a name="GetLabelHelpFor"></a>
## func [GetLabelHelpFor](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryLabels.go#L142>)
```go ```go
func GetLabelHelpFor(labelname string, asMarkdown bool) string func GetLabelHelpFor(labelname string, asMarkdown bool) string
@@ -76,7 +71,8 @@ func GetLabelHelpFor(labelname string, asMarkdown bool) string
GetLabelHelpFor returns the help for a specific label. GetLabelHelpFor returns the help for a specific label.
## func GetLabelNames <a name="GetLabelNames"></a>
## func [GetLabelNames](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryLabels.go#L198>)
```go ```go
func GetLabelNames() []string func GetLabelNames() []string
@@ -84,19 +80,26 @@ func GetLabelNames() []string
GetLabelNames returns a sorted list of all katenary label names. GetLabelNames returns a sorted list of all katenary label names.
## func GetLabels <a name="GetLabels"></a>
## func [GetLabels](<https://github.com/metal3d/katenary/blob/develop/generator/labels.go#L18>)
```go ```go
func GetLabels(serviceName, appName string) map[string]string func GetLabels(serviceName, appName string) map[string]string
``` ```
## func GetMatchLabels 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>
## func [GetMatchLabels](<https://github.com/metal3d/katenary/blob/develop/generator/labels.go#L31>)
```go ```go
func GetMatchLabels(serviceName, appName string) map[string]string func GetMatchLabels(serviceName, appName string) map[string]string
``` ```
## func Helper 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.
<a name="Helper"></a>
## func [Helper](<https://github.com/metal3d/katenary/blob/develop/generator/helper.go#L14>)
```go ```go
func Helper(name string) string func Helper(name string) string
@@ -104,20 +107,19 @@ func Helper(name string) string
Helper returns the \_helpers.tpl file for a chart. Helper returns the \_helpers.tpl file for a chart.
## func NewCronJob <a name="NewCronJob"></a>
## func [NewCronJob](<https://github.com/metal3d/katenary/blob/develop/generator/cronJob.go#L29>)
```go ```go
func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (*CronJob, *RBAC) func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (*CronJob, *RBAC)
``` ```
NewCronJob creates a new CronJob from a compose service. The appName is NewCronJob creates a new CronJob from a compose service. The appName is the name of the application taken from the project name.
the name of the application taken from the project name.
## type ChartTemplate <a name="ChartTemplate"></a>
## type [ChartTemplate](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L16-L19>)
ChartTemplate is a template of a chart. It contains the content of the 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.
template and the name of the service. This is used internally to
generate the templates.
TODO: maybe we can set it private. TODO: maybe we can set it private.
@@ -128,7 +130,8 @@ type ChartTemplate struct {
} }
``` ```
## type ConfigMap <a name="ConfigMap"></a>
## type [ConfigMap](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L47-L52>)
ConfigMap is a kubernetes ConfigMap. Implements the DataMap interface. ConfigMap is a kubernetes ConfigMap. Implements the DataMap interface.
@@ -139,57 +142,53 @@ type ConfigMap struct {
} }
``` ```
### func NewConfigMap <a name="NewConfigMap"></a>
### func [NewConfigMap](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L56>)
```go ```go
func NewConfigMap(service types.ServiceConfig, appName string) *ConfigMap func NewConfigMap(service types.ServiceConfig, appName string) *ConfigMap
``` ```
NewConfigMap creates a new ConfigMap from a compose service. The appName 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".
is the name of the application taken from the project name. The
ConfigMap is filled by environment variables and labels “map-env”.
### func NewConfigMapFromFiles <a name="NewConfigMapFromFiles"></a>
### func [NewConfigMapFromFiles](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L133>)
```go ```go
func NewConfigMapFromFiles(service types.ServiceConfig, appName string, path string) *ConfigMap func NewConfigMapFromFiles(service types.ServiceConfig, appName string, path string) *ConfigMap
``` ```
NewConfigMapFromFiles creates a new ConfigMap from a compose service. NewConfigMapFromFiles 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.
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.
### func (*ConfigMap) AddData <a name="ConfigMap.AddData"></a>
### func \(\*ConfigMap\) [AddData](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L169>)
```go ```go
func (c *ConfigMap) AddData(key string, value string) func (c *ConfigMap) AddData(key string, value string)
``` ```
AddData adds a key value pair to the configmap. Append or overwrite the AddData adds a key value pair to the configmap. Append or overwrite the value if the key already exists.
value if the key already exists.
### func (*ConfigMap) AppendDir <a name="ConfigMap.AppendDir"></a>
### func \(\*ConfigMap\) [AppendDir](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L175>)
```go ```go
func (c *ConfigMap) AppendDir(path string) func (c *ConfigMap) AppendDir(path string)
``` ```
AddFile adds files from given path to the configmap. It is not AddFile 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.
recursive, to add all files in a directory, you need to call this
function for each subdirectory.
### func (*ConfigMap) Filename <a name="ConfigMap.Filename"></a>
### func \(\*ConfigMap\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L211>)
```go ```go
func (c *ConfigMap) Filename() string func (c *ConfigMap) Filename() string
``` ```
Filename returns the filename of the configmap. If the configmap is used Filename returns the filename of the configmap. If the configmap is used for files, the filename contains the path.
for files, the filename contains the path.
### func (*ConfigMap) SetData <a name="ConfigMap.SetData"></a>
### func \(\*ConfigMap\) [SetData](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L164>)
```go ```go
func (c *ConfigMap) SetData(data map[string]string) func (c *ConfigMap) SetData(data map[string]string)
@@ -197,7 +196,8 @@ func (c *ConfigMap) SetData(data map[string]string)
SetData sets the data of the configmap. It replaces the entire data. SetData sets the data of the configmap. It replaces the entire data.
### func (*ConfigMap) Yaml <a name="ConfigMap.Yaml"></a>
### func \(\*ConfigMap\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L221>)
```go ```go
func (c *ConfigMap) Yaml() ([]byte, error) func (c *ConfigMap) Yaml() ([]byte, error)
@@ -205,10 +205,10 @@ func (c *ConfigMap) Yaml() ([]byte, error)
Yaml returns the yaml representation of the configmap Yaml returns the yaml representation of the configmap
## type ConvertOptions <a name="ConvertOptions"></a>
## type [ConvertOptions](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L53-L60>)
ConvertOptions are the options to convert a compose project to a helm ConvertOptions are the options to convert a compose project to a helm chart.
chart.
```go ```go
type ConvertOptions struct { type ConvertOptions struct {
@@ -221,7 +221,8 @@ type ConvertOptions struct {
} }
``` ```
## type CronJob <a name="CronJob"></a>
## type [CronJob](<https://github.com/metal3d/katenary/blob/develop/generator/cronJob.go#L23-L26>)
CronJob is a kubernetes CronJob. CronJob is a kubernetes CronJob.
@@ -232,7 +233,8 @@ type CronJob struct {
} }
``` ```
### func (*CronJob) Filename <a name="CronJob.Filename"></a>
### func \(\*CronJob\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/cronJob.go#L125>)
```go ```go
func (c *CronJob) Filename() string func (c *CronJob) Filename() string
@@ -242,7 +244,8 @@ Filename returns the filename of the cronjob.
Implements the Yaml interface. Implements the Yaml interface.
### func (*CronJob) Yaml <a name="CronJob.Yaml"></a>
### func \(\*CronJob\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/cronJob.go#L132>)
```go ```go
func (c *CronJob) Yaml() ([]byte, error) func (c *CronJob) Yaml() ([]byte, error)
@@ -252,10 +255,10 @@ Yaml returns the yaml representation of the cronjob.
Implements the Yaml interface. Implements the Yaml interface.
## type CronJobValue <a name="CronJobValue"></a>
## type [CronJobValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L63-L68>)
CronJobValue is a cronjob configuration that will be saved in CronJobValue is a cronjob configuration that will be saved in values.yaml.
values.yaml.
```go ```go
type CronJobValue struct { type CronJobValue struct {
@@ -266,10 +269,10 @@ type CronJobValue struct {
} }
``` ```
## type DataMap <a name="DataMap"></a>
## type [DataMap](<https://github.com/metal3d/katenary/blob/develop/generator/types.go#L4-L7>)
DataMap is a kubernetes ConfigMap or Secret. It can be used to add data DataMap is a kubernetes ConfigMap or Secret. It can be used to add data to the ConfigMap or Secret.
to the ConfigMap or Secret.
```go ```go
type DataMap interface { type DataMap interface {
@@ -278,16 +281,17 @@ type DataMap interface {
} }
``` ```
### func NewFileMap <a name="NewFileMap"></a>
### func [NewFileMap](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L26>)
```go ```go
func NewFileMap(service types.ServiceConfig, appName string, kind string) DataMap func NewFileMap(service types.ServiceConfig, appName string, kind string) DataMap
``` ```
NewFileMap creates a new DataMap from a compose service. The appName is NewFileMap creates a new DataMap from a compose service. The appName is the name of the application taken from the project name.
the name of the application taken from the project name.
## type Dependency <a name="Dependency"></a>
## type [Dependency](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L4-L10>)
Dependency is a dependency of a chart to other charts. Dependency is a dependency of a chart to other charts.
@@ -301,7 +305,8 @@ type Dependency struct {
} }
``` ```
## type Deployment <a name="Deployment"></a>
## type [Deployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L24-L31>)
Deployment is a kubernetes Deployment. Deployment is a kubernetes Deployment.
@@ -312,18 +317,17 @@ type Deployment struct {
} }
``` ```
### func NewDeployment <a name="NewDeployment"></a>
### func [NewDeployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L35>)
```go ```go
func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment
``` ```
NewDeployment creates a new Deployment from a compose service. The 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.
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.
### func (*Deployment) AddContainer <a name="Deployment.AddContainer"></a>
### func \(\*Deployment\) [AddContainer](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L120>)
```go ```go
func (d *Deployment) AddContainer(service types.ServiceConfig) func (d *Deployment) AddContainer(service types.ServiceConfig)
@@ -331,62 +335,71 @@ func (d *Deployment) AddContainer(service types.ServiceConfig)
AddContainer adds a container to the deployment. AddContainer adds a container to the deployment.
### func (*Deployment) AddHealthCheck <a name="Deployment.AddHealthCheck"></a>
### func \(\*Deployment\) [AddHealthCheck](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L414>)
```go ```go
func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container) func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container)
``` ```
### func (*Deployment) AddIngress
<a name="Deployment.AddIngress"></a>
### func \(\*Deployment\) [AddIngress](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L160>)
```go ```go
func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *Ingress func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *Ingress
``` ```
AddIngress adds an ingress to the deployment. It creates the ingress AddIngress adds an ingress to the deployment. It creates the ingress object.
object.
### func (*Deployment) AddVolumes <a name="Deployment.AddVolumes"></a>
### func \(\*Deployment\) [AddVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L166>)
```go ```go
func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string) func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string)
``` ```
AddVolumes adds a volume to the deployment. It does not create the PVC, 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.
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.
### func (*Deployment) BindFrom <a name="Deployment.BindFrom"></a>
### func \(\*Deployment\) [BindFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L291>)
```go ```go
func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment) func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment)
``` ```
### func (*Deployment) DependsOn
<a name="Deployment.DependsOn"></a>
### func \(\*Deployment\) [DependsOn](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L94>)
```go ```go
func (d *Deployment) DependsOn(to *Deployment, servicename string) error func (d *Deployment) DependsOn(to *Deployment, servicename string) error
``` ```
DependsOn adds a initContainer to the deployment that will wait for the DependsOn adds a initContainer to the deployment that will wait for the service to be up.
service to be up.
### func (*Deployment) Filename <a name="Deployment.Filename"></a>
### func \(\*Deployment\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L556>)
```go ```go
func (d *Deployment) Filename() string func (d *Deployment) Filename() string
``` ```
### func (*Deployment) SetEnvFrom Filename returns the filename of the deployment.
<a name="Deployment.SetEnvFrom"></a>
### func \(\*Deployment\) [SetEnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L319>)
```go ```go
func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string) func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string)
``` ```
SetEnvFrom sets the environment variables to a configmap. The configmap SetEnvFrom sets the environment variables to a configmap. The configmap is created.
is created.
### func (*Deployment) Yaml <a name="Deployment.Yaml"></a>
### func \(\*Deployment\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L447>)
```go ```go
func (d *Deployment) Yaml() ([]byte, error) func (d *Deployment) Yaml() ([]byte, error)
@@ -394,7 +407,8 @@ func (d *Deployment) Yaml() ([]byte, error)
Yaml returns the yaml representation of the deployment. Yaml returns the yaml representation of the deployment.
## type FileMapUsage <a name="FileMapUsage"></a>
## type [FileMapUsage](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L37>)
FileMapUsage is the usage of the filemap. FileMapUsage is the usage of the filemap.
@@ -402,7 +416,7 @@ FileMapUsage is the usage of the filemap.
type FileMapUsage uint8 type FileMapUsage uint8
``` ```
FileMapUsage constants. <a name="FileMapUsageConfigMap"></a>FileMapUsage constants.
```go ```go
const ( const (
@@ -411,10 +425,10 @@ const (
) )
``` ```
## type HelmChart <a name="HelmChart"></a>
## type [HelmChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L23-L35>)
HelmChart is a Helm Chart representation. It contains all the tempaltes, HelmChart is a Helm Chart representation. It contains all the tempaltes, values, versions, helpers...
values, versions, helpers…
```go ```go
type HelmChart struct { type HelmChart struct {
@@ -432,36 +446,28 @@ type HelmChart struct {
} }
``` ```
### func Generate <a name="Generate"></a>
### func [Generate](<https://github.com/metal3d/katenary/blob/develop/generator/generator.go#L36>)
```go ```go
func Generate(project *types.Project) (*HelmChart, error) func Generate(project *types.Project) (*HelmChart, error)
``` ```
Generate a chart from a compose project. This does not write files to Generate a chart from a compose project. This does not write files to disk, it only creates the HelmChart object.
disk, it only creates the HelmChart object.
The Generate function will create the HelmChart object this way: The Generate function will create the HelmChart object this way:
1. Detect the service port name or leave the port number if not found. - Detect the service port name or leave the port number if not found.
- Create a deployment for each service that are not ingnore.
- 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.
2. Create a deployment for each service that are not ingnore. <a name="NewChart"></a>
### func [NewChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L38>)
3. Create a service and ingresses for each service that has ports
and/or declared ingresses.
4. Create a PVC or Configmap volumes for each volume.
5. Create init containers for each service which has dependencies to
other services.
6. Create a chart dependencies.
7. Create a configmap and secrets from the environment variables.
8. Merge the same-pod services.
### func NewChart
```go ```go
func NewChart(name string) *HelmChart func NewChart(name string) *HelmChart
@@ -469,7 +475,8 @@ func NewChart(name string) *HelmChart
NewChart creates a new empty chart with the given name. NewChart creates a new empty chart with the given name.
## type Help <a name="Help"></a>
## type [Help](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryLabels.go#L32-L37>)
Help is the documentation of a label. Help is the documentation of a label.
@@ -482,7 +489,10 @@ type Help struct {
} }
``` ```
## type Ingress <a name="Ingress"></a>
## type [Ingress](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L18-L21>)
```go ```go
type Ingress struct { type Ingress struct {
@@ -491,7 +501,8 @@ type Ingress struct {
} }
``` ```
### func NewIngress <a name="NewIngress"></a>
### func [NewIngress](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L24>)
```go ```go
func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress
@@ -499,22 +510,28 @@ func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress
NewIngress creates a new Ingress from a compose service. NewIngress creates a new Ingress from a compose service.
### func (*Ingress) Filename <a name="Ingress.Filename"></a>
### func \(\*Ingress\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L178>)
```go ```go
func (ingress *Ingress) Filename() string func (ingress *Ingress) Filename() string
``` ```
### func (*Ingress) Yaml
<a name="Ingress.Yaml"></a>
### func \(\*Ingress\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L137>)
```go ```go
func (ingress *Ingress) Yaml() ([]byte, error) func (ingress *Ingress) Yaml() ([]byte, error)
``` ```
## type IngressValue
IngressValue is a ingress configuration that will be saved in
values.yaml. <a name="IngressValue"></a>
## type [IngressValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L27-L33>)
IngressValue is a ingress configuration that will be saved in values.yaml.
```go ```go
type IngressValue struct { type IngressValue struct {
@@ -526,7 +543,8 @@ type IngressValue struct {
} }
``` ```
## type Label <a name="Label"></a>
## type [Label](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryLabels.go#L29>)
Label is a katenary label to find in compose files. Label is a katenary label to find in compose files.
@@ -534,7 +552,7 @@ Label is a katenary label to find in compose files.
type Label = string type Label = string
``` ```
Known labels. <a name="LABEL_MAIN_APP"></a>Known labels.
```go ```go
const ( const (
@@ -555,15 +573,17 @@ const (
) )
``` ```
## type LabelType <a name="LabelType"></a>
## type [LabelType](<https://github.com/metal3d/katenary/blob/develop/generator/labels.go#L9>)
LabelType identifies the type of label to generate in objects. TODO: is LabelType identifies the type of label to generate in objects. TODO: is this still needed?
this still needed?
```go ```go
type LabelType uint8 type LabelType uint8
``` ```
<a name="DeploymentLabel"></a>
```go ```go
const ( const (
DeploymentLabel LabelType = iota DeploymentLabel LabelType = iota
@@ -571,10 +591,10 @@ const (
) )
``` ```
## type PersistenceValue <a name="PersistenceValue"></a>
## type [PersistenceValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L19-L24>)
PersistenceValue is a persistence configuration that will be saved in PersistenceValue is a persistence configuration that will be saved in values.yaml.
values.yaml.
```go ```go
type PersistenceValue struct { type PersistenceValue struct {
@@ -585,10 +605,10 @@ type PersistenceValue struct {
} }
``` ```
## type RBAC <a name="RBAC"></a>
## type [RBAC](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L20-L24>)
RBAC is a kubernetes RBAC containing a role, a rolebinding and an RBAC is a kubernetes RBAC containing a role, a rolebinding and an associated serviceaccount.
associated serviceaccount.
```go ```go
type RBAC struct { type RBAC struct {
@@ -598,19 +618,19 @@ type RBAC struct {
} }
``` ```
### func NewRBAC <a name="NewRBAC"></a>
### func [NewRBAC](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L27>)
```go ```go
func NewRBAC(service types.ServiceConfig, appName string) *RBAC func NewRBAC(service types.ServiceConfig, appName string) *RBAC
``` ```
NewRBAC creates a new RBAC from a compose service. The appName is the NewRBAC creates a new RBAC from a compose service. The appName is the name of the application taken from the project name.
name of the application taken from the project name.
## type RepositoryValue <a name="RepositoryValue"></a>
## type [RepositoryValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L13-L16>)
RepositoryValue is a docker repository image and tag that will be saved RepositoryValue is a docker repository image and tag that will be saved in values.yaml.
in values.yaml.
```go ```go
type RepositoryValue struct { type RepositoryValue struct {
@@ -619,7 +639,8 @@ type RepositoryValue struct {
} }
``` ```
## type Role <a name="Role"></a>
## type [Role](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L114-L117>)
Role is a kubernetes Role. Role is a kubernetes Role.
@@ -630,19 +651,26 @@ type Role struct {
} }
``` ```
### func (*Role) Filename <a name="Role.Filename"></a>
### func \(\*Role\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L123>)
```go ```go
func (r *Role) Filename() string func (r *Role) Filename() string
``` ```
### func (*Role) Yaml
<a name="Role.Yaml"></a>
### func \(\*Role\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L119>)
```go ```go
func (r *Role) Yaml() ([]byte, error) func (r *Role) Yaml() ([]byte, error)
``` ```
## type RoleBinding
<a name="RoleBinding"></a>
## type [RoleBinding](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L100-L103>)
RoleBinding is a kubernetes RoleBinding. RoleBinding is a kubernetes RoleBinding.
@@ -653,19 +681,26 @@ type RoleBinding struct {
} }
``` ```
### func (*RoleBinding) Filename <a name="RoleBinding.Filename"></a>
### func \(\*RoleBinding\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L109>)
```go ```go
func (r *RoleBinding) Filename() string func (r *RoleBinding) Filename() string
``` ```
### func (*RoleBinding) Yaml
<a name="RoleBinding.Yaml"></a>
### func \(\*RoleBinding\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L105>)
```go ```go
func (r *RoleBinding) Yaml() ([]byte, error) func (r *RoleBinding) Yaml() ([]byte, error)
``` ```
## type Secret
<a name="Secret"></a>
## type [Secret](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L24-L27>)
Secret is a kubernetes Secret. Secret is a kubernetes Secret.
@@ -678,7 +713,8 @@ type Secret struct {
} }
``` ```
### func NewSecret <a name="NewSecret"></a>
### func [NewSecret](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L30>)
```go ```go
func NewSecret(service types.ServiceConfig, appName string) *Secret func NewSecret(service types.ServiceConfig, appName string) *Secret
@@ -686,7 +722,8 @@ func NewSecret(service types.ServiceConfig, appName string) *Secret
NewSecret creates a new Secret from a compose service NewSecret creates a new Secret from a compose service
### func (*Secret) AddData <a name="Secret.AddData"></a>
### func \(\*Secret\) [AddData](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L87>)
```go ```go
func (s *Secret) AddData(key string, value string) func (s *Secret) AddData(key string, value string)
@@ -694,7 +731,8 @@ func (s *Secret) AddData(key string, value string)
AddData adds a key value pair to the secret. AddData adds a key value pair to the secret.
### func (*Secret) Filename <a name="Secret.Filename"></a>
### func \(\*Secret\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L111>)
```go ```go
func (s *Secret) Filename() string func (s *Secret) Filename() string
@@ -702,7 +740,8 @@ func (s *Secret) Filename() string
Filename returns the filename of the secret. Filename returns the filename of the secret.
### func (*Secret) SetData <a name="Secret.SetData"></a>
### func \(\*Secret\) [SetData](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L80>)
```go ```go
func (s *Secret) SetData(data map[string]string) func (s *Secret) SetData(data map[string]string)
@@ -710,7 +749,8 @@ func (s *Secret) SetData(data map[string]string)
SetData sets the data of the secret. SetData sets the data of the secret.
### func (*Secret) Yaml <a name="Secret.Yaml"></a>
### func \(\*Secret\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L95>)
```go ```go
func (s *Secret) Yaml() ([]byte, error) func (s *Secret) Yaml() ([]byte, error)
@@ -718,7 +758,8 @@ func (s *Secret) Yaml() ([]byte, error)
Yaml returns the yaml representation of the secret. Yaml returns the yaml representation of the secret.
## type Service <a name="Service"></a>
## type [Service](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L19-L22>)
Service is a kubernetes Service. Service is a kubernetes Service.
@@ -729,7 +770,8 @@ type Service struct {
} }
``` ```
### func NewService <a name="NewService"></a>
### func [NewService](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L25>)
```go ```go
func NewService(service types.ServiceConfig, appName string) *Service func NewService(service types.ServiceConfig, appName string) *Service
@@ -737,7 +779,8 @@ func NewService(service types.ServiceConfig, appName string) *Service
NewService creates a new Service from a compose service. NewService creates a new Service from a compose service.
### func (*Service) AddPort <a name="Service.AddPort"></a>
### func \(\*Service\) [AddPort](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L54>)
```go ```go
func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string) func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
@@ -745,7 +788,8 @@ func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
AddPort adds a port to the service. AddPort adds a port to the service.
### func (*Service) Filename <a name="Service.Filename"></a>
### func \(\*Service\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L93>)
```go ```go
func (s *Service) Filename() string func (s *Service) Filename() string
@@ -753,7 +797,8 @@ func (s *Service) Filename() string
Filename returns the filename of the service. Filename returns the filename of the service.
### func (*Service) Yaml <a name="Service.Yaml"></a>
### func \(\*Service\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L78>)
```go ```go
func (s *Service) Yaml() ([]byte, error) func (s *Service) Yaml() ([]byte, error)
@@ -761,7 +806,8 @@ func (s *Service) Yaml() ([]byte, error)
Yaml returns the yaml representation of the service. Yaml returns the yaml representation of the service.
## type ServiceAccount <a name="ServiceAccount"></a>
## type [ServiceAccount](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L128-L131>)
ServiceAccount is a kubernetes ServiceAccount. ServiceAccount is a kubernetes ServiceAccount.
@@ -772,23 +818,30 @@ type ServiceAccount struct {
} }
``` ```
### func (*ServiceAccount) Filename <a name="ServiceAccount.Filename"></a>
### func \(\*ServiceAccount\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L137>)
```go ```go
func (r *ServiceAccount) Filename() string func (r *ServiceAccount) Filename() string
``` ```
### func (*ServiceAccount) Yaml
<a name="ServiceAccount.Yaml"></a>
### func \(\*ServiceAccount\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L133>)
```go ```go
func (r *ServiceAccount) Yaml() ([]byte, error) func (r *ServiceAccount) Yaml() ([]byte, error)
``` ```
## type Value
Value will be saved in values.yaml. It contains configuraiton for all
deployment and services. The content will be lile:
<a name="Value"></a>
## type [Value](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L52-L60>)
Value will be saved in values.yaml. It contains configuraiton for all deployment and services. The content will be lile:
```
name_of_component: name_of_component:
repository: repository:
image: image_name image: image_name
@@ -803,6 +856,7 @@ deployment and services. The content will be lile:
environment: environment:
ENV_VAR_1: value_1 ENV_VAR_1: value_1
ENV_VAR_2: value_2 ENV_VAR_2: value_2
```
```go ```go
type Value struct { type Value struct {
@@ -816,26 +870,28 @@ type Value struct {
} }
``` ```
### func NewValue <a name="NewValue"></a>
### func [NewValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L75>)
```go ```go
func NewValue(service types.ServiceConfig, main ...bool) *Value func NewValue(service types.ServiceConfig, main ...bool) *Value
``` ```
NewValue creates a new Value from a compose service. The value contains NewValue creates a new Value from a compose service. The value contains the necessary information to deploy the service \(image, tag, replicas, etc.\).
the necessary information to deploy the service (image, tag, replicas,
etc.).
If \`main\` is true, the tag will be empty because it will be set in the If \`main\` is true, the tag will be empty because it will be set in the helm chart appVersion.
helm chart appVersion.
### func (*Value) AddIngress <a name="Value.AddIngress"></a>
### func \(\*Value\) [AddIngress](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L114>)
```go ```go
func (v *Value) AddIngress(host, path string) func (v *Value) AddIngress(host, path string)
``` ```
### func (*Value) AddPersistence
<a name="Value.AddPersistence"></a>
### func \(\*Value\) [AddPersistence](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L102>)
```go ```go
func (v *Value) AddPersistence(volumeName string) func (v *Value) AddPersistence(volumeName string)
@@ -843,10 +899,10 @@ func (v *Value) AddPersistence(volumeName string)
AddPersistence adds persistence configuration to the Value. AddPersistence adds persistence configuration to the Value.
## type VolumeClaim <a name="VolumeClaim"></a>
## type [VolumeClaim](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L18-L23>)
VolumeClaim is a kubernetes VolumeClaim. This is a VolumeClaim is a kubernetes VolumeClaim. This is a PersistentVolumeClaim.
PersistentVolumeClaim.
```go ```go
type VolumeClaim struct { type VolumeClaim struct {
@@ -855,7 +911,8 @@ type VolumeClaim struct {
} }
``` ```
### func NewVolumeClaim <a name="NewVolumeClaim"></a>
### func [NewVolumeClaim](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L26>)
```go ```go
func NewVolumeClaim(service types.ServiceConfig, volumeName, appName string) *VolumeClaim func NewVolumeClaim(service types.ServiceConfig, volumeName, appName string) *VolumeClaim
@@ -863,7 +920,8 @@ func NewVolumeClaim(service types.ServiceConfig, volumeName, appName string) *Vo
NewVolumeClaim creates a new VolumeClaim from a compose service. NewVolumeClaim creates a new VolumeClaim from a compose service.
### func (*VolumeClaim) Filename <a name="VolumeClaim.Filename"></a>
### func \(\*VolumeClaim\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L117>)
```go ```go
func (v *VolumeClaim) Filename() string func (v *VolumeClaim) Filename() string
@@ -871,7 +929,8 @@ func (v *VolumeClaim) Filename() string
Filename returns the suggested filename for a VolumeClaim. Filename returns the suggested filename for a VolumeClaim.
### func (*VolumeClaim) Yaml <a name="VolumeClaim.Yaml"></a>
### func \(\*VolumeClaim\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L56>)
```go ```go
func (v *VolumeClaim) Yaml() ([]byte, error) func (v *VolumeClaim) Yaml() ([]byte, error)
@@ -879,7 +938,8 @@ func (v *VolumeClaim) Yaml() ([]byte, error)
Yaml marshals a VolumeClaim into yaml. Yaml marshals a VolumeClaim into yaml.
## type Yaml <a name="Yaml"></a>
## type [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/types.go#L10-L13>)
Yaml is a kubernetes object that can be converted to yaml. Yaml is a kubernetes object that can be converted to yaml.
@@ -890,4 +950,4 @@ type Yaml interface {
} }
``` ```
Generated by [gomarkdoc](https://github.com/princjef/gomarkdoc) Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

View File

@@ -6,10 +6,9 @@
import "katenary/generator/extrafiles" import "katenary/generator/extrafiles"
``` ```
extrafiles package provides function to generate the Chart files that extrafiles package provides function to generate the Chart files that are not objects. Like README.md and notes.txt...
are not objects. Like README.md and notes.txt…
## func NotesFile ## func [NotesFile](<https://github.com/metal3d/katenary/blob/develop/generator/extrafiles/notes.go#L9>)
```go ```go
func NotesFile() string func NotesFile() string
@@ -17,7 +16,8 @@ func NotesFile() string
NoteTXTFile returns the content of the note.txt file. NoteTXTFile returns the content of the note.txt file.
## func ReadMeFile <a name="ReadMeFile"></a>
## func [ReadMeFile](<https://github.com/metal3d/katenary/blob/develop/generator/extrafiles/readme.go#L25>)
```go ```go
func ReadMeFile(charname, description string, values map[string]any) string func ReadMeFile(charname, description string, values map[string]any) string
@@ -25,4 +25,4 @@ func ReadMeFile(charname, description string, values map[string]any) string
ReadMeFile returns the content of the README.md file. ReadMeFile returns the content of the README.md file.
Generated by [gomarkdoc](https://github.com/princjef/gomarkdoc) Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

View File

@@ -6,15 +6,14 @@
import "katenary/parser" import "katenary/parser"
``` ```
Parser package is a wrapper around compose-go to parse compose files. Parser package is a wrapper around compose\-go to parse compose files.
## func Parse ## func [Parse](<https://github.com/metal3d/katenary/blob/develop/parser/main.go#L10>)
```go ```go
func Parse(profiles []string, dockerComposeFile ...string) (*types.Project, error) func Parse(profiles []string, dockerComposeFile ...string) (*types.Project, error)
``` ```
Parse compose files and return a project. The project is parsed with Parse compose files and return a project. The project is parsed with dotenv, osenv and profiles.
dotenv, osenv and profiles.
Generated by [gomarkdoc](https://github.com/princjef/gomarkdoc) Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

View File

@@ -6,25 +6,29 @@
import "katenary/update" import "katenary/update"
``` ```
Update package is used to check if a new version of katenary is Update package is used to check if a new version of katenary is available.
available.
## Variables ## Variables
<a name="Version"></a>
```go ```go
var Version = "master" // reset by cmd/main.go var (
Version = "master" // reset by cmd/main.go
)
``` ```
## func DownloadFile <a name="DownloadFile"></a>
## func [DownloadFile](<https://github.com/metal3d/katenary/blob/develop/update/main.go#L134>)
```go ```go
func DownloadFile(url, exe string) error func DownloadFile(url, exe string) error
``` ```
DownloadFile will download a url to a local file. It also ensure that DownloadFile will download a url to a local file. It also ensure that the file is executable.
the file is executable.
## func DownloadLatestVersion <a name="DownloadLatestVersion"></a>
## func [DownloadLatestVersion](<https://github.com/metal3d/katenary/blob/develop/update/main.go#L80>)
```go ```go
func DownloadLatestVersion(assets []Asset) error func DownloadLatestVersion(assets []Asset) error
@@ -32,7 +36,8 @@ func DownloadLatestVersion(assets []Asset) error
DownloadLatestVersion will download the latest version of katenary. DownloadLatestVersion will download the latest version of katenary.
## type Asset <a name="Asset"></a>
## type [Asset](<https://github.com/metal3d/katenary/blob/develop/update/main.go#L23-L26>)
Asset is a github asset from release url. Asset is a github asset from release url.
@@ -43,13 +48,13 @@ type Asset struct {
} }
``` ```
### func CheckLatestVersion <a name="CheckLatestVersion"></a>
### func [CheckLatestVersion](<https://github.com/metal3d/katenary/blob/develop/update/main.go#L29>)
```go ```go
func CheckLatestVersion() (string, []Asset, error) func CheckLatestVersion() (string, []Asset, error)
``` ```
CheckLatestVersion check katenary latest version from release and CheckLatestVersion check katenary latest version from release and propose to download it
propose to download it
Generated by [gomarkdoc](https://github.com/princjef/gomarkdoc) Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

View File

@@ -6,49 +6,27 @@
import "katenary/utils" import "katenary/utils"
``` ```
Utils package provides some utility functions used in katenary. It Utils package provides some utility functions used in katenary. It defines some constants and functions used in the whole project.
defines some constants and functions used in the whole project.
## Constants ## func [CountStartingSpaces](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L31>)
Icons used in katenary.
``` go
const (
IconSuccess Icon = "✅"
IconFailure = "❌"
IconWarning = "⚠️'"
IconNote = "📝"
IconWorld = "🌐"
IconPlug = "🔌"
IconPackage = "📦"
IconCabinet = "🗄️"
IconInfo = "❕"
IconSecret = "🔒"
IconConfig = "🔧"
IconDependency = "🔗"
)
```
## func CountStartingSpaces
```go ```go
func CountStartingSpaces(line string) int func CountStartingSpaces(line string) int
``` ```
CountStartingSpaces counts the number of spaces at the beginning of a CountStartingSpaces counts the number of spaces at the beginning of a string.
string.
## func GetContainerByName <a name="GetContainerByName"></a>
## func [GetContainerByName](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L82>)
```go ```go
func GetContainerByName(name string, containers []corev1.Container) (*corev1.Container, int) func GetContainerByName(name string, containers []corev1.Container) (*corev1.Container, int)
``` ```
GetContainerByName returns a container by name and its index in the GetContainerByName returns a container by name and its index in the array. It returns nil, \-1 if not found.
array. It returns nil, -1 if not found.
## func GetKind <a name="GetKind"></a>
## func [GetKind](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L44>)
```go ```go
func GetKind(path string) (kind string) func GetKind(path string) (kind string)
@@ -56,16 +34,17 @@ func GetKind(path string) (kind string)
GetKind returns the kind of the resource from the file path. GetKind returns the kind of the resource from the file path.
## func GetServiceNameByPort <a name="GetServiceNameByPort"></a>
## func [GetServiceNameByPort](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L72>)
```go ```go
func GetServiceNameByPort(port int) string func GetServiceNameByPort(port int) string
``` ```
GetServiceNameByPort returns the service name for a port. It the service GetServiceNameByPort returns the service name for a port. It the service name is not found, it returns an empty string.
name is not found, it returns an empty string.
## func GetValuesFromLabel <a name="GetValuesFromLabel"></a>
## func [GetValuesFromLabel](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L122>)
```go ```go
func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[string]*EnvConfig func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[string]*EnvConfig
@@ -73,7 +52,8 @@ func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[str
GetValuesFromLabel returns a map of values from a label. GetValuesFromLabel returns a map of values from a label.
## func HashComposefiles <a name="HashComposefiles"></a>
## func [HashComposefiles](<https://github.com/metal3d/katenary/blob/develop/utils/hash.go#L12>)
```go ```go
func HashComposefiles(files []string) (string, error) func HashComposefiles(files []string) (string, error)
@@ -81,7 +61,8 @@ func HashComposefiles(files []string) (string, error)
HashComposefiles returns a hash of the compose files. HashComposefiles returns a hash of the compose files.
## func Int32Ptr <a name="Int32Ptr"></a>
## func [Int32Ptr](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L25>)
```go ```go
func Int32Ptr(i int32) *int32 func Int32Ptr(i int32) *int32
@@ -89,13 +70,17 @@ func Int32Ptr(i int32) *int32
Int32Ptr returns a pointer to an int32. Int32Ptr returns a pointer to an int32.
## func MapKeys <a name="MapKeys"></a>
## func [MapKeys](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L156>)
```go ```go
func MapKeys(m map[string]interface{}) []string func MapKeys(m map[string]interface{}) []string
``` ```
## func PathToName
<a name="PathToName"></a>
## func [PathToName](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L101>)
```go ```go
func PathToName(path string) string func PathToName(path string) string
@@ -103,7 +88,8 @@ func PathToName(path string) string
PathToName converts a path to a kubernetes complient name. PathToName converts a path to a kubernetes complient name.
## func StrPtr <a name="StrPtr"></a>
## func [StrPtr](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L28>)
```go ```go
func StrPtr(s string) *string func StrPtr(s string) *string
@@ -111,25 +97,26 @@ func StrPtr(s string) *string
StrPtr returns a pointer to a string. StrPtr returns a pointer to a string.
## func TplName <a name="TplName"></a>
## func [TplName](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L17>)
```go ```go
func TplName(serviceName, appname string, suffix ...string) string func TplName(serviceName, appname string, suffix ...string) string
``` ```
TplName returns the name of the kubernetes resource as a template TplName returns the name of the kubernetes resource as a template string. It is used in the templates and defined in \_helper.tpl file.
string. It is used in the templates and defined in \_helper.tpl file.
## func TplValue <a name="TplValue"></a>
## func [TplValue](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L92>)
```go ```go
func TplValue(serviceName, variable string, pipes ...string) string func TplValue(serviceName, variable string, pipes ...string) string
``` ```
GetContainerByName returns a container by name and its index in the GetContainerByName returns a container by name and its index in the array.
array.
## func Warn <a name="Warn"></a>
## func [Warn](<https://github.com/metal3d/katenary/blob/develop/utils/icons.go#L25>)
```go ```go
func Warn(msg ...interface{}) func Warn(msg ...interface{})
@@ -137,37 +124,37 @@ func Warn(msg ...interface{})
Warn prints a warning message Warn prints a warning message
## func WordWrap <a name="WordWrap"></a>
## func [WordWrap](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L152>)
```go ```go
func WordWrap(text string, lineWidth int) string func WordWrap(text string, lineWidth int) string
``` ```
WordWrap wraps a string to a given line width. Warning: it may break the WordWrap wraps a string to a given line width. Warning: it may break the string. You need to check the result.
string. You need to check the result.
## func Wrap <a name="Wrap"></a>
## func [Wrap](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L61>)
```go ```go
func Wrap(src, above, below string) string func Wrap(src, above, below string) string
``` ```
Wrap wraps a string with a string above and below. It will respect the Wrap wraps a string with a string above and below. It will respect the indentation of the src string.
indentation of the src string.
## func WrapBytes <a name="WrapBytes"></a>
## func [WrapBytes](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L67>)
```go ```go
func WrapBytes(src, above, below []byte) []byte func WrapBytes(src, above, below []byte) []byte
``` ```
WrapBytes wraps a byte array with a byte array above and below. It will WrapBytes wraps a byte array with a byte array above and below. It will respect the indentation of the src string.
respect the indentation of the src string.
## type EnvConfig <a name="EnvConfig"></a>
## type [EnvConfig](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L116-L119>)
EnvConfig is a struct to hold the description of an environment EnvConfig is a struct to hold the description of an environment variable.
variable.
```go ```go
type EnvConfig struct { type EnvConfig struct {
@@ -176,7 +163,8 @@ type EnvConfig struct {
} }
``` ```
## type Icon <a name="Icon"></a>
## type [Icon](<https://github.com/metal3d/katenary/blob/develop/utils/icons.go#L6>)
Icon is a unicode icon Icon is a unicode icon
@@ -184,4 +172,23 @@ Icon is a unicode icon
type Icon string type Icon string
``` ```
Generated by [gomarkdoc](https://github.com/princjef/gomarkdoc) <a name="IconSuccess"></a>Icons used in katenary.
```go
const (
IconSuccess Icon = "✅"
IconFailure Icon = "❌"
IconWarning Icon = "⚠️'"
IconNote Icon = "📝"
IconWorld Icon = "🌐"
IconPlug Icon = "🔌"
IconPackage Icon = "📦"
IconCabinet Icon = "🗄️"
IconInfo Icon = "❕"
IconSecret Icon = "🔒"
IconConfig Icon = "🔧"
IconDependency Icon = "🔗"
)
```
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

View File

@@ -4,24 +4,56 @@ Basically, you can use `katenary` to transpose a docker-compose file (or any com
`podman-compose` and `docker-compose`) to a configurable Helm Chart. This resulting helm chart can be installed with `podman-compose` and `docker-compose`) to a configurable Helm Chart. This resulting helm chart can be installed with
`helm` command to your Kubernetes cluster. `helm` command to your Kubernetes cluster.
!!! Warning "YAML in multiline label"
Compose only accept text label. So, to put a complete YAML content in the target label, you need to use a pipe char (`|` or `|-`)
and to **indent** your content.
For example :
```yaml
labels:
# your labels
foo: bar
# katenary labels with multiline
katenary.v3/ingress: |-
hostname: my.website.tld
port: 80
katenary.v3/ports: |-
- 1234
```
Katenary transforms compose services this way: Katenary transforms compose services this way:
- Takes the service and create a "Deployment" file - Takes the service and create a "Deployment" file
- if a port is declared, katenary creates a service (ClusterIP) - if a port is declared, katenary creates a service (ClusterIP)
- it a port is exposed, katenary creates a service (NodePort) - if a port is exposed, katenary creates a service (NodePort)
- environment variables will be stored in `values.yaml` file - environment variables will be stored inside a configMap
- image, tags, and ingresses configuration are also stored in `values.yaml` file - image, tags, and ingresses configuration are also stored in `values.yaml` file
- if named volumes are declared, katenary create PersistentVolumeClaims - not enabled in values file (a `emptyDir` is - if named volumes are declared, katenary create PersistentVolumeClaims - not enabled in values file
used by default)
- any other volume (local mount points) are ignored
- `depends_on` needs that the pointed service declared a port. If not, you can use labels to inform katenary - `depends_on` needs that the pointed service declared a port. If not, you can use labels to inform katenary
For any other specific configuration, like binding local files as configMap, bind variables, add values with documentation, etc. You'll need to use labels.
Katenary can also configure containers grouping in pods, declare dependencies, ignore some services, force variables as Katenary can also configure containers grouping in pods, declare dependencies, ignore some services, force variables as
secrets, mount files as `configMap`, and many others things. To adapt the helm chart generation, you will need to use secrets, mount files as `configMap`, and many others things. To adapt the helm chart generation, you will need to use
some specific labels. some specific labels.
For more complete label usage, see [the labels page](labels.md). For more complete label usage, see [the labels page](labels.md).
!!! Info "Overriding file"
It could be sometimes more convinient to separate the
configuration related to Katenary inside a secondary file.
Instead of adding labels inside the `compose.yaml` file,
you can create a file named `compose.katenary.yaml` and
declare your labels inside. Katenary will detect it by
default.
**No need to precise the file in the command line.**
## Make convertion ## Make convertion
After having installed `katenary`, the standard usage is to call: After having installed `katenary`, the standard usage is to call:
@@ -153,8 +185,6 @@ services:
image: mariadb image: mariadb
``` ```
!!! Warning This is a "multiline" label that accepts YAML or JSON content, don't forget to add a pipe char (`|` or `|-`)
and to **indent** your content
This label can be used to map others environment for any others reason. E.g. to change an informational environment This label can be used to map others environment for any others reason. E.g. to change an informational environment
variable. variable.

View File

@@ -42,6 +42,7 @@ nav:
- coding.md - coding.md
- dependencies.md - dependencies.md
- Go Packages: - Go Packages:
- packages/cmd/katenary.md
- packages/generator.md - packages/generator.md
- packages/parser.md - packages/parser.md
- packages/update.md - packages/update.md

View File

@@ -1,6 +1,6 @@
mkdocs>=1.3.0 mkdocs>=1.5.3
Jinja2>=2.10.2 Jinja2>=3.1.3
MarkupSafe>=2.0 MarkupSafe>=2.1.5
pymdown-extensions>=9.5 pymdown-extensions>=10.7.1
mkdocs-material>=8.3.4 mkdocs-material>=9.5.17
mkdocs-material-extensions>=1.0.3 mkdocs-material-extensions>=1.3.1