12 Commits

Author SHA1 Message Date
8c443ba402 chore(doc): regenerate the doc
All checks were successful
Go-Tests / tests (push) Successful in 2m37s
Go-Tests / sonar (push) Successful in 1m2s
2025-09-16 08:59:27 +02:00
a4647aa69a chore(code): Unecessary type checking
Changed how to use the type checking for label content.
2025-09-16 08:58:51 +02:00
f3c1bf39fe chore(doc): Document code
All checks were successful
Go-Tests / tests (push) Successful in 2m13s
Go-Tests / sonar (push) Successful in 48s
2025-09-15 13:36:22 +02:00
e3cad1e561 chore(tests): Test only when it's necessary
All checks were successful
Go-Tests / tests (push) Successful in 2m39s
Go-Tests / sonar (push) Successful in 51s
Pushing documentation, README.md or install.sh should not launch go test
2025-09-15 13:31:31 +02:00
debe43ce34 chore(tests): enhance output
All checks were successful
Go-Tests / tests (push) Successful in 2m18s
Go-Tests / sonar (push) Successful in 55s
- use a better logger separation
- use tags not not overload the CI output
- removed lot of log.Println/Fatal/Error
2025-09-15 13:02:54 +02:00
9472952d65 feat(tests): Verbose test coverage
All checks were successful
Go-Tests / tests (pull_request) Successful in 1m42s
Go-Tests / sonar (pull_request) Successful in 41s
Go-Tests / tests (push) Successful in 1m40s
Go-Tests / sonar (push) Successful in 50s
2025-09-14 23:43:42 +02:00
03b4d5c714 fix(volume) File from project root failed
All checks were successful
Go-Tests / tests (pull_request) Successful in 1m47s
Go-Tests / sonar (pull_request) Successful in 48s
Go-Tests / tests (push) Successful in 1m37s
Go-Tests / sonar (push) Successful in 46s
When mounting one file from the root of the project (e.g. ./file.txt),
the volume name is empty. In this case, we generate the volume name from
the subpath.
2025-09-14 23:23:11 +02:00
8358b068b3 Merge pull request 'fix(build): Version prefix should be "v"' (#167) from fix-build-version into master
All checks were successful
Go-Tests / tests (push) Successful in 1m40s
Go-Tests / sonar (push) Successful in 46s
Reviewed-on: #167
2025-09-05 09:08:11 +00:00
0de7102b2b fix(build): Version prefix should be "v"
All checks were successful
Go-Tests / tests (pull_request) Successful in 3m26s
Go-Tests / sonar (pull_request) Successful in 43s
In version.go, we check the "v" or "release-" prefix. Without this one,
the version is built from "build info".
2025-09-05 10:09:28 +02:00
1f3154e214 feat(actions): Add a name for the "build package" task
All checks were successful
Go-Tests / tests (push) Successful in 1m51s
Go-Tests / sonar (push) Successful in 1m4s
2025-08-29 13:35:51 +02:00
31ff1371d6 feat(doc): regeneration
Line changed after generation
2025-08-29 13:35:31 +02:00
6cd1c92997 feat(doc): Enhancement, cleanup, add package instructions
All checks were successful
Go-Tests / tests (pull_request) Successful in 1m48s
Go-Tests / sonar (pull_request) Successful in 52s
Go-Tests / tests (push) Successful in 3m30s
Go-Tests / sonar (push) Successful in 50s
- remove trailing spaces
- add instruction for packages
- reindent YAML examples
- remove section telling that there is no config files, as
`katenary.yaml` file can now be used
2025-08-29 13:24:32 +02:00
31 changed files with 640 additions and 472 deletions

View File

@@ -1,3 +1,4 @@
name: Build release binaries and packages
on: on:
push: push:
tags: tags:
@@ -66,7 +67,7 @@ jobs:
echo "Building binary version $VERSION" echo "Building binary version $VERSION"
mkdir -p dist mkdir -p dist
GOARCH=${{ matrix.goarch }} GOOS=${{ matrix.goos }}\ GOARCH=${{ matrix.goarch }} GOOS=${{ matrix.goos }}\
go build -ldflags="-X 'repo.katenary.io/katenary/katenary/internal/generator.Version=$VERSION'" \ go build -ldflags="-X 'repo.katenary.io/katenary/katenary/internal/generator.Version=v$VERSION'" \
-trimpath -o dist/katenary-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/katenary -trimpath -o dist/katenary-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/katenary
- name: Package (Linux) - name: Package (Linux)

View File

@@ -5,10 +5,18 @@ on:
types: types:
- opened - opened
- edited - edited
paths-ignore:
- "doc/**"
- "README.md"
- "*.sh"
push: push:
branches: branches:
- "master" - "master"
- "main" - "main"
paths-ignore:
- "doc/**"
- "README.md"
- "*.sh"
env: env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
@@ -33,7 +41,9 @@ jobs:
- name: Launch Test - name: Launch Test
run: | run: |
go vet ./... go vet ./...
go test -coverprofile=coverprofile.out -json -v ./... > gotest.json go test -tags ci -coverprofile=coverprofile.out -v ./...
go test -tags ci -coverprofile=coverprofile.out -json -v ./... > gotest.json
go tool cover -func=coverprofile.out
# - uses: actions/upload-artifact@v4 # - uses: actions/upload-artifact@v4
- name: Upload artifact - name: Upload artifact
uses: christopherhx/gitea-upload-artifact@v4 uses: christopherhx/gitea-upload-artifact@v4

View File

@@ -37,6 +37,24 @@ The main developer is [Patrice FERLET](https://repo.katenary.io/metal3d).
## Install ## Install
### Package from repository and Windows installer
You can find Linux packages repository and Windows installer in the [packages page](https://repo.katenary.io/Katenary/katenary/packages).
> Note for Fedora >= 42, the repository instructions are not up-to-date. You should use:
>
> ```bash
> dnf config-manager addrepo \
> --from-repofile https://repo.katenary.io/Katenary/katenary/fedora/katenary.repo
> dnf install katenary
> ```
- Windows users, go to the "generic" packages page, and download the `setup.exe` file.
- macOS users, please use the "`darwin`" binary. An experimental package is in preparation.
- FreedBSD users, please use the "`freebsd`" package in "generic" packages page.
### Binary installation
You can download the binaries from the [Release](https://repo.katenary.io/Katenary/katenary/releases) section. Copy the binary You can download the binaries from the [Release](https://repo.katenary.io/Katenary/katenary/releases) section. Copy the binary
and rename it to `katenary`. Place the binary inside your `PATH`. You should now be able to call the `katenary` command. and rename it to `katenary`. Place the binary inside your `PATH`. You should now be able to call the `katenary` command.
@@ -54,7 +72,7 @@ go install -u katenary.io/cmd@latest
go install -u katenary.io/cmd@v3.0.0 go install -u katenary.io/cmd@v3.0.0
``` ```
## Or, build yourself ### Or, build yourself
If you've got `podman` or `docker`, you can build `katenary` by using: If you've got `podman` or `docker`, you can build `katenary` by using:
@@ -69,7 +87,7 @@ make install
``` ```
It will use the default PREFIX (`~/.local/`) to install the binary in the `bin` subdirectory. You can force the PREFIX It will use the default PREFIX (`~/.local/`) to install the binary in the `bin` subdirectory. You can force the PREFIX
value at install time, but maybe you need to use "sudo": value at install time, but maybe you need to use "`sudo`":
```bash ```bash
sudo make install PREFIX=/usr/local sudo make install PREFIX=/usr/local

2
doc/.editorconfig Normal file
View File

@@ -0,0 +1,2 @@
[*.md]
indent_size=2

View File

@@ -36,14 +36,14 @@ flowchart TD
Val[Values files]:::outputs@{shape: curv-trap} Val[Values files]:::outputs@{shape: curv-trap}
PVC:::outputs@{shape: curv-trap} PVC:::outputs@{shape: curv-trap}
S[Service]:::outputs@{shape: curv-trap} S[Service]:::outputs@{shape: curv-trap}
A[Compose file]:::inputs --> B[Compose parser] A[Compose file]:::inputs --> B[Compose parser]
B --> G[Generator] B --> G[Generator]
G --> P[Ports exposed to services] ---> S G --> P[Ports exposed to services] ---> S
G ------> H G ------> H
G --> C --> D G --> C --> D
G ------> Val G ------> Val
G ....-> M[Merge Continainers if same-pod] G ....-> M[Merge Continainers if same-pod]
M ..-> C M ..-> C
G --> E[Environment variables] ----> Secrets & ConfigMap G --> E[Environment variables] ----> Secrets & ConfigMap
G--> V[Bind volumes] -------> PVC G--> V[Bind volumes] -------> PVC
@@ -51,7 +51,7 @@ flowchart TD
Secrets & ConfigMap -- create envFrom --> D Secrets & ConfigMap -- create envFrom --> D
V -- bind volumes --> D V -- bind volumes --> D
``` ```
If the declaration of a container is to be integrated into another pod (via the `same-pod` label), this `Deployment` and If the declaration of a container is to be integrated into another pod (via the `same-pod` label), this `Deployment` and
@@ -92,7 +92,7 @@ For each source container linked to the destination:
- we then copy the service port to the destination service - we then copy the service port to the destination service
- we finally remove the source service and deployment - we finally remove the source service and deployment
> The `Configmap`, secrets, variables... are kept. > The `Configmap`, secrets, variables, and so on, are kept.
It finally computes the `helper` file. It finally computes the `helper` file.

View File

@@ -6,9 +6,9 @@ The main author[^1] of Katenary is a big fan of Podman, Docker and makes a huge
daily work. When he started to work with Kubernetes, he wanted to have the same experience as with Docker Compose. daily work. When he started to work with Kubernetes, he wanted to have the same experience as with Docker Compose.
He wanted to have a tool that could convert his `docker-compose` files to Kubernetes manifests, but also to Helm charts. He wanted to have a tool that could convert his `docker-compose` files to Kubernetes manifests, but also to Helm charts.
Kompose was a good option. But the lacks of some options and configuration for the output Helm chart made him think [Kompose](https://kompose.io/) was a good option. But the lacks of some options and configuration for the output Helm
about creating a new tool. He wanted to have a tool that could generate a complete Helm chart, with a lot of options chart made him think about creating a new tool. He wanted to have a tool that could generate a complete Helm chart,
and flexibility. with a lot of options and flexibility.
[^1]: I'm talking about myself :sunglasses: - Patrice FERLET, aka Metal3d, Tech Lead and DevOps Engineer at Klee Group. [^1]: I'm talking about myself :sunglasses: - Patrice FERLET, aka Metal3d, Tech Lead and DevOps Engineer at Klee Group.
@@ -51,15 +51,6 @@ many indentation levels in the YAML file.
It is also more flexible. You can add or remove labels without changing the others. It is also more flexible. You can add or remove labels without changing the others.
## Why not using a configuration file?
The idea was to keep the configuration at a same place, and using the go-compose library to read the labels. It's
easier to have a single file to manage.
By the way, Katenary auto accepts a `compose.katenary.yaml` file in the same directory. It's a way to separate the
configuration from the compose file. It uses
the [overrides' mechanism](https://docs.docker.com/compose/multiple-compose-files/merge/) like "compose" does.
## Why not developing with Rust? ## Why not developing with Rust?
Seriously... Seriously...
@@ -87,7 +78,7 @@ tested some concepts.
You can help us in many ways. You can help us in many ways.
- The first things we really need, more than money, more than anything else, is to have feedback. If you use Katenary, - The first things we really need, more than money, more than anything else, is to have feedback. If you use Katenary,
if you have some issues, if you have some ideas, please open an issue on the [GitHub repository](https://github.com/Katenary/katenary). if you have some issues, if you have some ideas, please open an issue on [our repository](https://repo.katenary.io/Katenary/katenary).
- The second thing is to help us to fix issues. If you're a Go developer, or if you want to fix the documentation, - The second thing is to help us to fix issues. If you're a Go developer, or if you want to fix the documentation,
your help is greatly appreciated. your help is greatly appreciated.
- And then, of course, we need money, or sponsors. - And then, of course, we need money, or sponsors.
@@ -97,10 +88,9 @@ You can help us in many ways.
We will be happy to communicate your help by putting your logo on the website and in the documentation. You can sponsor We will be happy to communicate your help by putting your logo on the website and in the documentation. You can sponsor
us by giving us some money, or by giving us some time of your developers, or leaving us some time to work on the project. us by giving us some money, or by giving us some time of your developers, or leaving us some time to work on the project.
### If you're an individual Please, contact us by email at [contact at katenary dot io](mailto:contact@katenary.io).
All donators will be listed on the website and in the documentation. You can give us some money by using ### If you're an individual
the [GitHub Sponsors]()
All main contributors[^3] will be listed on the website and in the documentation. All main contributors[^3] will be listed on the website and in the documentation.

View File

@@ -44,30 +44,52 @@ The main developer is [Patrice FERLET](https://repo.katenary.io/metal3d).
The project source The project source
code is hosted on the [:fontawesome-brands-git: Katenary Repository](https://repo.katenary.io/Katenary/katenary). code is hosted on the [:fontawesome-brands-git: Katenary Repository](https://repo.katenary.io/Katenary/katenary).
## Install Katenary # Install Katenary
Katenary is developed using the :fontawesome-brands-golang:{ .gopher } [Go](https://go.dev) language. ## Linux / Windows package distribution or setup.exe
The binary is statically linked, so you can simply download it from the [release
page](https://github.com/Katenary/katenary/releases) of the project in GitHub. The simplest way to install Katenary is to install the package or use Windows installer from the page [packages page](https://repo.katenary.io/Katenary/katenary/packages).
You will find packages and instructions to install the repository for your distribution for :
- RPM (Fedora, Rocky, Alma, OpenSUSE...)
- DEB (Debian, Ubuntu, Mint...)
- Arch Linux (AUR)
- Windows (in the "generic" packages page, use the "setup" file)
!!! Note "Fedora >= 42"
The instruction is not updated for newest version of `dnf`. If the command to add the repository doesn't work, you can
try:
```bash
dnf config-manager addrepo \
--from-repofile https://repo.katenary.io/api/packages/Katenary/rpm.repo
```
As Katenary is developed using the :fontawesome-brands-golang:{ .gopher } [Go](https://go.dev) language the binary is statically
linked, so you can simply download it from the [generic package page](https://repo.katenary.io/Katenary/katenary/packages) and get the version
which is compatible with your operating system and architecture.
You need to select the right binary for your operating system and architecture, and copy the binary in a directory You need to select the right binary for your operating system and architecture, and copy the binary in a directory
that is in your `PATH`. that is in your `PATH`.
If you are a Linux user, you can use the "one line installation command" which will download the binary in your ## Linux - one line installation command
If you are a Linux user, you can use the "one line installation command" which will download the **binary** in your
`$HOME/.local/bin` directory if it exists. `$HOME/.local/bin` directory if it exists.
```bash ```bash
sh <(curl -sSL https://repo.katenary.io/Katenary/katenary/raw/branch/master/install.sh) sh <(curl -sSL https://repo.katenary.io/Katenary/katenary/raw/branch/master/install.sh)
``` ```
!!! Info "Upgrading is integrated to the `katenary` command" ## Compile from sources
Katenary propose a `upgrade` sub-command to update the current binary to the latest stable release.
Of course, you need to install Katenary once :smile: You can, of course, compile Katenary from sources.
!!! Note "You prefer to compile it, no need to install Go" !!! Note "You prefer to compile it, no need to install Go"
You can also build and install it yourself, the provided Makefile has got a `build` command that uses `podman` or
`docker` to build the binary. You can also build and install it yourself, the provided Makefile has got a `build` command that uses `podman` or
`docker` to build the binary.
So, you don't need to install Go compiler :+1:. So, you don't need to install Go compiler :+1:.
@@ -107,7 +129,7 @@ source <(katenary completion bash)
Add this line in you `~/.profile`, `~/.bash_aliases` or `~/.bashrc` file to have completion at startup. Add this line in you `~/.profile`, `~/.bash_aliases` or `~/.bashrc` file to have completion at startup.
## What a name # What a name
A catenary is the curve that a hanging chain or cable assumes under its own weight when supported only at its ends. A catenary is the curve that a hanging chain or cable assumes under its own weight when supported only at its ends.
I, the maintainer, decided to name "Katenary" this project because it's like a chain that links a boat to a dock. I, the maintainer, decided to name "Katenary" this project because it's like a chain that links a boat to a dock.
@@ -119,7 +141,7 @@ Anyway, it's too late to change the name now :smile:
I spent time to find it :wink: I spent time to find it :wink:
## Special thanks to # Special thanks to
I really want to thank all the contributors, testers, and of course, the authors of the packages and tools that are used I really want to thank all the contributors, testers, and of course, the authors of the packages and tools that are used
in this project. There is too many to list here. Katenary can work because of all these people. Open source is a great in this project. There is too many to list here. Katenary can work because of all these people. Open source is a great
@@ -157,6 +179,6 @@ thing! :heart:
<a href="https://www.mkdocs.org/" target="_blank">MkDocs</a> using <a <a href="https://www.mkdocs.org/" target="_blank">MkDocs</a> using <a
href="https://squidfunk.github.io/mkdocs-material/" target="_blank">Material for MkDocs</a> theme template. href="https://squidfunk.github.io/mkdocs-material/" target="_blank">Material for MkDocs</a> theme template.
## License # License
Katenary is an open source project under the MIT license. You can use it, modify it, and distribute it as you want. Katenary is an open source project under the MIT license. You can use it, modify it, and distribute it as you want.

View File

@@ -6,9 +6,9 @@ While compose labels are string, we can use _here-doc_ syntax using `|` to use Y
```yaml ```yaml
label-name: |- label-name: |-
# this is actually a multiline string here # this is actually a multiline string here
key1: value1 key1: value1
key2: value2 key2: value2
``` ```
Katenary will try to _Unmarshal_ these labels. Katenary will try to _Unmarshal_ these labels.
@@ -46,17 +46,17 @@ Inject files as Configmap.
**Type**: `[]string` **Type**: `[]string`
It makes a file or directory to be converted to one or more ConfigMaps It makes a file or directory to be converted to one or more ConfigMaps
and mounted in the pod. The file or directory is relative to the and mounted in the pod. The file or directory is relative to the
service directory. service directory.
If it is a directory, all files inside it are added to the ConfigMap. If it is a directory, all files inside it are added to the ConfigMap.
If the directory as subdirectories, so one configmap per subpath are created. If the directory as subdirectories, so one ConfigMap per sub-path are created.
!!! Warning !!! Warning
It is not intended to be used to store an entire project in configmaps. It is not intended to be used to store an entire project in ConfigMaps.
It is intended to be used to store configuration files that are not managed It is intended to be used to store configuration files that are not managed
by the application, like nginx configuration files. Keep in mind that your by the application, like nginx configuration files. Keep in mind that your
project sources should be stored in an application image or in a storage. project sources should be stored in an application image or in a storage.
@@ -80,8 +80,9 @@ Create a cronjob from the service.
This adds a cronjob to the chart. This adds a cronjob to the chart.
The label value is a YAML object with the following attributes: The label value is a YAML object with the following attributes:
- command: the command to be executed
- schedule: the cron schedule (cron format or @every where "every" is a - command: the command to be executed
- schedule: the cron schedule (cron format or @every where "every" is a
duration like 1h30m, daily, hourly...) duration like 1h30m, daily, hourly...)
- rbac: false (optionnal), if true, it will create a role, a rolebinding and - rbac: false (optionnal), if true, it will create a role, a rolebinding and
a serviceaccount to make your cronjob able to connect the Kubernetes API a serviceaccount to make your cronjob able to connect the Kubernetes API
@@ -90,9 +91,9 @@ The label value is a YAML object with the following attributes:
```yaml ```yaml
labels: labels:
katenary.v3/cronjob: |- katenary.v3/cronjob: |-
command: echo "hello world" command: echo "hello world"
schedule: "* */1 * * *" # or @hourly for example schedule: "* */1 * * *" # or @hourly for example
``` ```
@@ -102,8 +103,8 @@ Add Helm dependencies to the service.
**Type**: `[]object` **Type**: `[]object`
Set the service to be, actually, a Helm dependency. This means that the Set the service to be, actually, a Helm dependency. This means that the
service will not be exported as template. The dependencies are added to service will not be exported as template. The dependencies are added to
the Chart.yaml file and the values are added to the values.yaml file. the Chart.yaml file and the values are added to the values.yaml file.
It's a list of objects with the following attributes: It's a list of objects with the following attributes:
@@ -115,12 +116,12 @@ It's a list of objects with the following attributes:
!!! Info !!! Info
Katenary doesn't update the helm depenedencies by default. Katenary doesn't update the helm depenedencies by default.
Use `--helm-update` (or `-u`) flag to update the dependencies. Use `--helm-update` (or `-u`) flag to update the dependencies.
example: <code>katenary convert -u</code> example: <code>katenary convert -u</code>
By setting an alias, it is possible to change the name of the dependency By setting an alias, it is possible to change the name of the dependency
in values.yaml. in values.yaml.
**Example:** **Example:**
@@ -149,7 +150,7 @@ Description of the service
**Type**: `string` **Type**: `string`
This replaces the default comment in values.yaml file to the given description. This replaces the default comment in values.yaml file to the given description.
It is useful to document the service and configuration. It is useful to document the service and configuration.
The value can be set with a documentation in multiline format. The value can be set with a documentation in multiline format.
@@ -178,15 +179,15 @@ It adds environment variables from another service to the current service.
service1: service1:
image: nginx:1.19 image: nginx:1.19
environment: environment:
FOO: bar FOO: bar
service2: service2:
image: php:7.4-fpm image: php:7.4-fpm
labels: labels:
# get the congigMap from service1 where FOO is # get the congigMap from service1 where FOO is
# defined inside this service too # defined inside this service too
katenary.v3/env-from: |- katenary.v3/env-from: |-
- myservice1 - myservice1
``` ```
@@ -196,7 +197,7 @@ Add exchange volumes (empty directory on the node) to share data
**Type**: `[]object` **Type**: `[]object`
This label allows sharing data between containres. The volume is created in This label allows sharing data between containres. The volume is created in
the node and mounted in the pod. It is useful to share data between containers the node and mounted in the pod. It is useful to share data between containers
in a "same pod" logic. For example to let PHP-FPM and Nginx share the same direcotory. in a "same pod" logic. For example to let PHP-FPM and Nginx share the same direcotory.
@@ -207,6 +208,7 @@ This will create:
- a `initContainer` for each definition - a `initContainer` for each definition
Fields: Fields:
- name: the name of the volume (manadatory) - name: the name of the volume (manadatory)
- mountPath: the path where the volume is mounted in the pod (optional, default is `/opt`) - mountPath: the path where the volume is mounted in the pod (optional, default is `/opt`)
- init: a command to run to initialize the volume with data (optional) - init: a command to run to initialize the volume with data (optional)
@@ -275,7 +277,7 @@ Ingress rules to be added to the service.
**Type**: `object` **Type**: `object`
Declare an ingress rule for the service. The port should be exposed or Declare an ingress rule for the service. The port should be exposed or
declared with `katenary.v3/ports`. declared with `katenary.v3/ports`.
**Example:** **Example:**
@@ -294,7 +296,7 @@ Mark the service as the main app.
**Type**: `bool` **Type**: `bool`
This makes the service to be the main application. Its image tag is This makes the service to be the main application. Its image tag is
considered to be the Chart appVersion and to be the defaultvalue in Pod considered to be the Chart appVersion and to be the defaultvalue in Pod
container image attribute. container image attribute.
@@ -309,7 +311,7 @@ ghost:
image: ghost:1.25.5 image: ghost:1.25.5
labels: labels:
# The chart is now named ghost, and the appVersion is 1.25.5. # The chart is now named ghost, and the appVersion is 1.25.5.
# In Deployment, the image attribute is set to ghost:1.25.5 if # In Deployment, the image attribute is set to ghost:1.25.5 if
# you don't change the "tag" attribute in values.yaml # you don't change the "tag" attribute in values.yaml
katenary.v3/main-app: true katenary.v3/main-app: true
``` ```
@@ -322,8 +324,8 @@ Map env vars from the service to the deployment.
**Type**: `map[string]string` **Type**: `map[string]string`
Because you may need to change the variable for Kubernetes, this label Because you may need to change the variable for Kubernetes, this label
forces the value to another. It is also particullary helpful to use a template forces the value to another. It is also particullary helpful to use a template
value instead. For example, you could bind the value to a service name value instead. For example, you could bind the value to a service name
with Helm attributes: with Helm attributes:
`{{ tpl .Release.Name . }}`. `{{ tpl .Release.Name . }}`.
@@ -349,7 +351,7 @@ Ports to be added to the service.
**Type**: `[]uint32` **Type**: `[]uint32`
Only useful for services without exposed port. It is mandatory if the Only useful for services without exposed port. It is mandatory if the
service is a dependency of another service. service is a dependency of another service.
**Example:** **Example:**
@@ -368,10 +370,10 @@ Move the same-pod deployment to the target deployment.
**Type**: `string` **Type**: `string`
This will make the service to be included in another service pod. Some services This will make the service to be included in another service pod. Some services
must work together in the same pod, like a sidecar or a proxy or nginx + php-fpm. must work together in the same pod, like a sidecar or a proxy or nginx + php-fpm.
Note that volume and VolumeMount are copied from the source to the target Note that volume and VolumeMount are copied from the source to the target
deployment. deployment.
**Example:** **Example:**
@@ -393,7 +395,7 @@ Env vars to be set as secrets.
**Type**: `[]string` **Type**: `[]string`
This label allows setting the environment variables as secrets. The variable This label allows setting the environment variables as secrets. The variable
is removed from the environment and added to a secret object. is removed from the environment and added to a secret object.
The variable can be set to the `katenary.v3/values` too, The variable can be set to the `katenary.v3/values` too,
@@ -418,14 +420,14 @@ Environment variables to be added to the values.yaml
**Type**: `[]string or map[string]string` **Type**: `[]string or map[string]string`
By default, all environment variables in the "env" and environment By default, all environment variables in the "env" and environment
files are added to configmaps with the static values set. This label files are added to ConfigMaps with the static values set. This label
allows adding environment variables to the values.yaml file. allows adding environment variables to the values.yaml file.
Note that the value inside the configmap is `{{ tpl vaname . }}`, so Note that the value inside the configmap is `{{ tpl vaname . }}`, so
you can set the value to a template that will be rendered with the you can set the value to a template that will be rendered with the
values.yaml file. values.yaml file.
The value can be set with a documentation. This may help to understand The value can be set with a documentation. This may help to understand
the purpose of the variable. the purpose of the variable.
**Example:** **Example:**
@@ -442,7 +444,7 @@ labels:
- TO_CONFIGURE - TO_CONFIGURE
# complex values, set as a template in values.yaml with a documentation # complex values, set as a template in values.yaml with a documentation
- A_COMPLEX_VALUE: |- - A_COMPLEX_VALUE: |-
This is the documentation for the variable to This is the documentation for the variable to
configure in values.yaml. configure in values.yaml.
It can be, of course, a multiline text. It can be, of course, a multiline text.
``` ```

View File

@@ -35,7 +35,7 @@ var Version = "master" // changed at compile time
``` ```
<a name="Convert"></a> <a name="Convert"></a>
## func [Convert](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/converter.go#L100>) ## func [Convert](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/converter.go#L101>)
```go ```go
func Convert(config ConvertOptions, dockerComposeFile ...string) error func Convert(config ConvertOptions, dockerComposeFile ...string) error
@@ -62,7 +62,7 @@ func GetMatchLabels(serviceName, appName string) map[string]string
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. 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="GetVersion"></a> <a name="GetVersion"></a>
## func [GetVersion](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/version.go#L14>) ## func [GetVersion](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/version.go#L15>)
```go ```go
func GetVersion() string func GetVersion() string
@@ -107,7 +107,7 @@ func UnWrapTPL(in []byte) []byte
UnWrapTPL removes the line wrapping from a template. UnWrapTPL removes the line wrapping from a template.
<a name="ChartTemplate"></a> <a name="ChartTemplate"></a>
## type [ChartTemplate](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L22-L25>) ## type [ChartTemplate](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L23-L26>)
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. 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.
@@ -119,7 +119,7 @@ type ChartTemplate struct {
``` ```
<a name="ConfigMap"></a> <a name="ConfigMap"></a>
## type [ConfigMap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L38-L43>) ## type [ConfigMap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L39-L44>)
ConfigMap is a kubernetes ConfigMap. Implements the DataMap interface. ConfigMap is a kubernetes ConfigMap. Implements the DataMap interface.
@@ -131,7 +131,7 @@ type ConfigMap struct {
``` ```
<a name="NewConfigMap"></a> <a name="NewConfigMap"></a>
### func [NewConfigMap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L47>) ### func [NewConfigMap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L48>)
```go ```go
func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *ConfigMap func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *ConfigMap
@@ -140,7 +140,7 @@ func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *Co
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". 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".
<a name="NewConfigMapFromDirectory"></a> <a name="NewConfigMapFromDirectory"></a>
### func [NewConfigMapFromDirectory](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L120>) ### func [NewConfigMapFromDirectory](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L121>)
```go ```go
func NewConfigMapFromDirectory(service types.ServiceConfig, appName, path string) *ConfigMap func NewConfigMapFromDirectory(service types.ServiceConfig, appName, path string) *ConfigMap
@@ -149,7 +149,7 @@ func NewConfigMapFromDirectory(service types.ServiceConfig, appName, path string
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. 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.
<a name="ConfigMap.AddBinaryData"></a> <a name="ConfigMap.AddBinaryData"></a>
### func \(\*ConfigMap\) [AddBinaryData](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L158>) ### func \(\*ConfigMap\) [AddBinaryData](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L159>)
```go ```go
func (c *ConfigMap) AddBinaryData(key string, value []byte) func (c *ConfigMap) AddBinaryData(key string, value []byte)
@@ -158,7 +158,7 @@ func (c *ConfigMap) AddBinaryData(key string, value []byte)
AddBinaryData adds binary data to the configmap. Append or overwrite the value if the key already exists. AddBinaryData adds binary data to the configmap. Append or overwrite the value if the key already exists.
<a name="ConfigMap.AddData"></a> <a name="ConfigMap.AddData"></a>
### func \(\*ConfigMap\) [AddData](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L153>) ### func \(\*ConfigMap\) [AddData](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L154>)
```go ```go
func (c *ConfigMap) AddData(key, value string) func (c *ConfigMap) AddData(key, value string)
@@ -167,7 +167,7 @@ func (c *ConfigMap) AddData(key, value string)
AddData adds a key value pair to the configmap. Append or overwrite the value if the key already exists. AddData adds a key value pair to the configmap. Append or overwrite the value if the key already exists.
<a name="ConfigMap.AppendDir"></a> <a name="ConfigMap.AppendDir"></a>
### func \(\*ConfigMap\) [AppendDir](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L167>) ### func \(\*ConfigMap\) [AppendDir](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L168>)
```go ```go
func (c *ConfigMap) AppendDir(path string) error func (c *ConfigMap) AppendDir(path string) error
@@ -176,7 +176,7 @@ func (c *ConfigMap) AppendDir(path string) error
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. 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.
<a name="ConfigMap.AppendFile"></a> <a name="ConfigMap.AppendFile"></a>
### func \(\*ConfigMap\) [AppendFile](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L214>) ### func \(\*ConfigMap\) [AppendFile](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L215>)
```go ```go
func (c *ConfigMap) AppendFile(path string) error func (c *ConfigMap) AppendFile(path string) error
@@ -185,7 +185,7 @@ func (c *ConfigMap) AppendFile(path string) error
<a name="ConfigMap.Filename"></a> <a name="ConfigMap.Filename"></a>
### func \(\*ConfigMap\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L238>) ### func \(\*ConfigMap\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L239>)
```go ```go
func (c *ConfigMap) Filename() string func (c *ConfigMap) Filename() string
@@ -194,7 +194,7 @@ func (c *ConfigMap) Filename() string
Filename returns the filename of the configmap. If the configmap is used for files, the filename contains the path. Filename returns the filename of the configmap. If the configmap is used for files, the filename contains the path.
<a name="ConfigMap.SetData"></a> <a name="ConfigMap.SetData"></a>
### func \(\*ConfigMap\) [SetData](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L248>) ### func \(\*ConfigMap\) [SetData](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L249>)
```go ```go
func (c *ConfigMap) SetData(data map[string]string) func (c *ConfigMap) SetData(data map[string]string)
@@ -203,7 +203,7 @@ 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.
<a name="ConfigMap.Yaml"></a> <a name="ConfigMap.Yaml"></a>
### func \(\*ConfigMap\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L253>) ### func \(\*ConfigMap\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L254>)
```go ```go
func (c *ConfigMap) Yaml() ([]byte, error) func (c *ConfigMap) Yaml() ([]byte, error)
@@ -212,7 +212,7 @@ func (c *ConfigMap) Yaml() ([]byte, error)
Yaml returns the yaml representation of the configmap Yaml returns the yaml representation of the configmap
<a name="ConfigMapMount"></a> <a name="ConfigMapMount"></a>
## type [ConfigMapMount](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L29-L32>) ## type [ConfigMapMount](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L30-L33>)
@@ -223,7 +223,7 @@ type ConfigMapMount struct {
``` ```
<a name="ConvertOptions"></a> <a name="ConvertOptions"></a>
## type [ConvertOptions](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L28-L37>) ## type [ConvertOptions](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L29-L38>)
ConvertOptions are the options to convert a compose project to a helm chart. ConvertOptions are the options to convert a compose project to a helm chart.
@@ -301,7 +301,7 @@ type DataMap interface {
``` ```
<a name="Deployment"></a> <a name="Deployment"></a>
## type [Deployment](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L35-L45>) ## type [Deployment](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L36-L46>)
Deployment is a kubernetes Deployment. Deployment is a kubernetes Deployment.
@@ -313,7 +313,7 @@ type Deployment struct {
``` ```
<a name="NewDeployment"></a> <a name="NewDeployment"></a>
### func [NewDeployment](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L49>) ### func [NewDeployment](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L50>)
```go ```go
func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment
@@ -322,7 +322,7 @@ func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment
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. 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.
<a name="Deployment.AddContainer"></a> <a name="Deployment.AddContainer"></a>
### func \(\*Deployment\) [AddContainer](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L116>) ### func \(\*Deployment\) [AddContainer](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L117>)
```go ```go
func (d *Deployment) AddContainer(service types.ServiceConfig) func (d *Deployment) AddContainer(service types.ServiceConfig)
@@ -331,7 +331,7 @@ func (d *Deployment) AddContainer(service types.ServiceConfig)
AddContainer adds a container to the deployment. AddContainer adds a container to the deployment.
<a name="Deployment.AddHealthCheck"></a> <a name="Deployment.AddHealthCheck"></a>
### func \(\*Deployment\) [AddHealthCheck](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L163>) ### func \(\*Deployment\) [AddHealthCheck](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L164>)
```go ```go
func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container) func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container)
@@ -340,7 +340,7 @@ func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *core
<a name="Deployment.AddIngress"></a> <a name="Deployment.AddIngress"></a>
### func \(\*Deployment\) [AddIngress](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L192>) ### func \(\*Deployment\) [AddIngress](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L193>)
```go ```go
func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *Ingress func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *Ingress
@@ -349,7 +349,7 @@ func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *In
AddIngress adds an ingress to the deployment. It creates the ingress object. AddIngress adds an ingress to the deployment. It creates the ingress object.
<a name="Deployment.AddLegacyVolume"></a> <a name="Deployment.AddLegacyVolume"></a>
### func \(\*Deployment\) [AddLegacyVolume](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L222>) ### func \(\*Deployment\) [AddLegacyVolume](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L223>)
```go ```go
func (d *Deployment) AddLegacyVolume(name, kind string) func (d *Deployment) AddLegacyVolume(name, kind string)
@@ -358,7 +358,7 @@ func (d *Deployment) AddLegacyVolume(name, kind string)
<a name="Deployment.AddVolumes"></a> <a name="Deployment.AddVolumes"></a>
### func \(\*Deployment\) [AddVolumes](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L198>) ### func \(\*Deployment\) [AddVolumes](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L199>)
```go ```go
func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string) func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string)
@@ -367,7 +367,7 @@ func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string)
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. 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.
<a name="Deployment.BindFrom"></a> <a name="Deployment.BindFrom"></a>
### func \(\*Deployment\) [BindFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L243>) ### func \(\*Deployment\) [BindFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L244>)
```go ```go
func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment) func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment)
@@ -376,7 +376,7 @@ func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment)
<a name="Deployment.BindMapFilesToContainer"></a> <a name="Deployment.BindMapFilesToContainer"></a>
### func \(\*Deployment\) [BindMapFilesToContainer](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L377>) ### func \(\*Deployment\) [BindMapFilesToContainer](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L378>)
```go ```go
func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secrets []string, appName string) (*corev1.Container, int) func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secrets []string, appName string) (*corev1.Container, int)
@@ -385,7 +385,7 @@ func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secret
<a name="Deployment.DependsOn"></a> <a name="Deployment.DependsOn"></a>
### func \(\*Deployment\) [DependsOn](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L271>) ### func \(\*Deployment\) [DependsOn](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L272>)
```go ```go
func (d *Deployment) DependsOn(to *Deployment, servicename string) error func (d *Deployment) DependsOn(to *Deployment, servicename string) error
@@ -394,7 +394,7 @@ func (d *Deployment) DependsOn(to *Deployment, servicename string) error
DependsOn adds a initContainer to the deployment that will wait for the service to be up. DependsOn adds a initContainer to the deployment that will wait for the service to be up.
<a name="Deployment.Filename"></a> <a name="Deployment.Filename"></a>
### func \(\*Deployment\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L302>) ### func \(\*Deployment\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L303>)
```go ```go
func (d *Deployment) Filename() string func (d *Deployment) Filename() string
@@ -403,7 +403,7 @@ func (d *Deployment) Filename() string
Filename returns the filename of the deployment. Filename returns the filename of the deployment.
<a name="Deployment.MountExchangeVolumes"></a> <a name="Deployment.MountExchangeVolumes"></a>
### func \(\*Deployment\) [MountExchangeVolumes](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L428>) ### func \(\*Deployment\) [MountExchangeVolumes](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L429>)
```go ```go
func (d *Deployment) MountExchangeVolumes() func (d *Deployment) MountExchangeVolumes()
@@ -412,7 +412,7 @@ func (d *Deployment) MountExchangeVolumes()
<a name="Deployment.SetEnvFrom"></a> <a name="Deployment.SetEnvFrom"></a>
### func \(\*Deployment\) [SetEnvFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L307>) ### func \(\*Deployment\) [SetEnvFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L308>)
```go ```go
func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, samePod ...bool) func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, samePod ...bool)
@@ -421,7 +421,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, sam
SetEnvFrom sets the environment variables to a configmap. The configmap is created. SetEnvFrom sets the environment variables to a configmap. The configmap is created.
<a name="Deployment.Yaml"></a> <a name="Deployment.Yaml"></a>
### func \(\*Deployment\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L452>) ### func \(\*Deployment\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L453>)
```go ```go
func (d *Deployment) Yaml() ([]byte, error) func (d *Deployment) Yaml() ([]byte, error)
@@ -430,7 +430,7 @@ func (d *Deployment) Yaml() ([]byte, error)
Yaml returns the yaml representation of the deployment. Yaml returns the yaml representation of the deployment.
<a name="FileMapUsage"></a> <a name="FileMapUsage"></a>
## type [FileMapUsage](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L22>) ## type [FileMapUsage](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L23>)
FileMapUsage is the usage of the filemap. FileMapUsage is the usage of the filemap.
@@ -448,7 +448,7 @@ const (
``` ```
<a name="HelmChart"></a> <a name="HelmChart"></a>
## type [HelmChart](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L41-L54>) ## type [HelmChart](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L42-L55>)
HelmChart is a Helm Chart representation. It contains all the templates, values, versions, helpers... HelmChart is a Helm Chart representation. It contains all the templates, values, versions, helpers...
@@ -491,7 +491,7 @@ The Generate function will create the HelmChart object this way:
- Merge the same\-pod services. - Merge the same\-pod services.
<a name="NewChart"></a> <a name="NewChart"></a>
### func [NewChart](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L57>) ### func [NewChart](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L58>)
```go ```go
func NewChart(name string) *HelmChart func NewChart(name string) *HelmChart
@@ -500,7 +500,7 @@ 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.
<a name="HelmChart.SaveTemplates"></a> <a name="HelmChart.SaveTemplates"></a>
### func \(\*HelmChart\) [SaveTemplates](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L72>) ### func \(\*HelmChart\) [SaveTemplates](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L73>)
```go ```go
func (chart *HelmChart) SaveTemplates(templateDir string) func (chart *HelmChart) SaveTemplates(templateDir string)

View File

@@ -12,7 +12,7 @@ A katenary file, named "katenary.yml" or "katenary.yaml", is a file where you ca
Formely, the file describe the same structure as in labels, and so that can be validated and completed by LSP. It also ease the use of katenary. Formely, the file describe the same structure as in labels, and so that can be validated and completed by LSP. It also ease the use of katenary.
## func [GenerateSchema](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L138>) ## func [GenerateSchema](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L137>)
```go ```go
func GenerateSchema() string func GenerateSchema() string
@@ -21,7 +21,7 @@ func GenerateSchema() string
GenerateSchema generates the schema for the katenary.yaml file. GenerateSchema generates the schema for the katenary.yaml file.
<a name="OverrideWithConfig"></a> <a name="OverrideWithConfig"></a>
## func [OverrideWithConfig](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L50>) ## func [OverrideWithConfig](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L49>)
```go ```go
func OverrideWithConfig(project *types.Project) func OverrideWithConfig(project *types.Project)
@@ -30,7 +30,7 @@ func OverrideWithConfig(project *types.Project)
OverrideWithConfig overrides the project with the katenary.yaml file. It will set the labels of the services with the values from the katenary.yaml file. It work in memory, so it will not modify the original project. OverrideWithConfig overrides the project with the katenary.yaml file. It will set the labels of the services with the values from the katenary.yaml file. It work in memory, so it will not modify the original project.
<a name="Service"></a> <a name="Service"></a>
## type [Service](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L28-L45>) ## type [Service](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L27-L44>)
Service is a struct that contains the service configuration for katenary Service is a struct that contains the service configuration for katenary
@@ -56,7 +56,7 @@ type Service struct {
``` ```
<a name="StringOrMap"></a> <a name="StringOrMap"></a>
## type [StringOrMap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L25>) ## type [StringOrMap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L24>)
StringOrMap is a struct that can be either a string or a map of strings. It's a helper struct to unmarshal the katenary.yaml file and produce the schema StringOrMap is a struct that can be either a string or a map of strings. It's a helper struct to unmarshal the katenary.yaml file and produce the schema

View File

@@ -0,0 +1,83 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# logger
```go
import "katenary.io/internal/logger"
```
Package logger provides simple logging functions with icons and colors.
## func [Failure](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L43>)
```go
func Failure(msg ...any)
```
Failure prints a failure message.
<a name="Info"></a>
## func [Info](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L26>)
```go
func Info(msg ...any)
```
Info prints an informational message.
<a name="Log"></a>
## func [Log](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L49>)
```go
func Log(icon Icon, msg ...any)
```
Log prints a message with a custom icon.
<a name="Success"></a>
## func [Success](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L37>)
```go
func Success(msg ...any)
```
Success prints a success message.
<a name="Warn"></a>
## func [Warn](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L31>)
```go
func Warn(msg ...any)
```
Warn prints a warning message.
<a name="Icon"></a>
## type [Icon](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L5>)
Icon is a unicode icon
```go
type Icon string
```
<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

@@ -17,7 +17,7 @@ const DirectoryPermission = 0o755
``` ```
<a name="AsResourceName"></a> <a name="AsResourceName"></a>
## func [AsResourceName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L196>) ## func [AsResourceName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L198>)
```go ```go
func AsResourceName(name string) string func AsResourceName(name string) string
@@ -26,16 +26,16 @@ func AsResourceName(name string) string
AsResourceName returns a resource name with underscores to respect the kubernetes naming convention. It's the opposite of FixedResourceName. AsResourceName returns a resource name with underscores to respect the kubernetes naming convention. It's the opposite of FixedResourceName.
<a name="Confirm"></a> <a name="Confirm"></a>
## func [Confirm](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L164>) ## func [Confirm](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L166>)
```go ```go
func Confirm(question string, icon ...Icon) bool func Confirm(question string, icon ...logger.Icon) bool
``` ```
Confirm asks a question and returns true if the answer is y. Confirm asks a question and returns true if the answer is y.
<a name="CountStartingSpaces"></a> <a name="CountStartingSpaces"></a>
## func [CountStartingSpaces](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L41>) ## func [CountStartingSpaces](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L42>)
```go ```go
func CountStartingSpaces(line string) int func CountStartingSpaces(line string) int
@@ -44,7 +44,7 @@ func CountStartingSpaces(line string) int
CountStartingSpaces counts the number of spaces at the beginning of a string. CountStartingSpaces counts the number of spaces at the beginning of a string.
<a name="EncodeBasicYaml"></a> <a name="EncodeBasicYaml"></a>
## func [EncodeBasicYaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L178>) ## func [EncodeBasicYaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L180>)
```go ```go
func EncodeBasicYaml(data any) ([]byte, error) func EncodeBasicYaml(data any) ([]byte, error)
@@ -53,7 +53,7 @@ func EncodeBasicYaml(data any) ([]byte, error)
EncodeBasicYaml encodes a basic yaml from an interface. EncodeBasicYaml encodes a basic yaml from an interface.
<a name="FixedResourceName"></a> <a name="FixedResourceName"></a>
## func [FixedResourceName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L190>) ## func [FixedResourceName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L192>)
```go ```go
func FixedResourceName(name string) string func FixedResourceName(name string) string
@@ -62,7 +62,7 @@ func FixedResourceName(name string) string
FixedResourceName returns a resource name without underscores to respect the kubernetes naming convention. FixedResourceName returns a resource name without underscores to respect the kubernetes naming convention.
<a name="GetContainerByName"></a> <a name="GetContainerByName"></a>
## func [GetContainerByName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L87>) ## func [GetContainerByName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L88>)
```go ```go
func GetContainerByName(name string, containers []corev1.Container) (*corev1.Container, int) func GetContainerByName(name string, containers []corev1.Container) (*corev1.Container, int)
@@ -71,7 +71,7 @@ func GetContainerByName(name string, containers []corev1.Container) (*corev1.Con
GetContainerByName returns a container by name and its index in the array. It returns nil, \-1 if not found. GetContainerByName returns a container by name and its index in the array. It returns nil, \-1 if not found.
<a name="GetKind"></a> <a name="GetKind"></a>
## func [GetKind](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L54>) ## func [GetKind](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L55>)
```go ```go
func GetKind(path string) (kind string) func GetKind(path string) (kind string)
@@ -80,7 +80,7 @@ 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.
<a name="GetServiceNameByPort"></a> <a name="GetServiceNameByPort"></a>
## func [GetServiceNameByPort](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L77>) ## func [GetServiceNameByPort](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L78>)
```go ```go
func GetServiceNameByPort(port int) string func GetServiceNameByPort(port int) string
@@ -89,7 +89,7 @@ func GetServiceNameByPort(port int) string
GetServiceNameByPort returns the service name for a port. It the service name is not found, it returns an empty string. GetServiceNameByPort returns the service name for a port. It the service name is not found, it returns an empty string.
<a name="GetValuesFromLabel"></a> <a name="GetValuesFromLabel"></a>
## func [GetValuesFromLabel](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L129>) ## func [GetValuesFromLabel](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L130>)
```go ```go
func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[string]*EnvConfig func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[string]*EnvConfig
@@ -107,7 +107,7 @@ func HashComposefiles(files []string) (string, error)
HashComposefiles returns a hash of the compose files. HashComposefiles returns a hash of the compose files.
<a name="Int32Ptr"></a> <a name="Int32Ptr"></a>
## func [Int32Ptr](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L35>) ## func [Int32Ptr](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L36>)
```go ```go
func Int32Ptr(i int32) *int32 func Int32Ptr(i int32) *int32
@@ -116,7 +116,7 @@ func Int32Ptr(i int32) *int32
Int32Ptr returns a pointer to an int32. Int32Ptr returns a pointer to an int32.
<a name="PathToName"></a> <a name="PathToName"></a>
## func [PathToName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L106>) ## func [PathToName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L107>)
```go ```go
func PathToName(path string) string func PathToName(path string) string
@@ -125,7 +125,7 @@ func PathToName(path string) string
PathToName converts a path to a kubernetes complient name. PathToName converts a path to a kubernetes complient name.
<a name="StrPtr"></a> <a name="StrPtr"></a>
## func [StrPtr](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L38>) ## func [StrPtr](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L39>)
```go ```go
func StrPtr(s string) *string func StrPtr(s string) *string
@@ -134,7 +134,7 @@ func StrPtr(s string) *string
StrPtr returns a pointer to a string. StrPtr returns a pointer to a string.
<a name="TplName"></a> <a name="TplName"></a>
## func [TplName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L22>) ## func [TplName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L23>)
```go ```go
func TplName(serviceName, appname string, suffix ...string) string func TplName(serviceName, appname string, suffix ...string) string
@@ -143,7 +143,7 @@ func TplName(serviceName, appname string, suffix ...string) string
TplName returns the name of the kubernetes resource as a template string. It is used in the templates and defined in \_helper.tpl file. TplName returns the name of the kubernetes resource as a template string. It is used in the templates and defined in \_helper.tpl file.
<a name="TplValue"></a> <a name="TplValue"></a>
## func [TplValue](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L97>) ## func [TplValue](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L98>)
```go ```go
func TplValue(serviceName, variable string, pipes ...string) string func TplValue(serviceName, variable string, pipes ...string) string
@@ -151,17 +151,8 @@ func TplValue(serviceName, variable string, pipes ...string) string
TplValue returns a string that can be used in a template to access a value from the values file. TplValue returns a string that can be used in a template to access a value from the values file.
<a name="Warn"></a>
## func [Warn](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/icons.go#L25>)
```go
func Warn(msg ...any)
```
Warn prints a warning message
<a name="WordWrap"></a> <a name="WordWrap"></a>
## func [WordWrap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L159>) ## func [WordWrap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L161>)
```go ```go
func WordWrap(text string, lineWidth int) string func WordWrap(text string, lineWidth int) string
@@ -170,7 +161,7 @@ func WordWrap(text string, lineWidth int) string
WordWrap wraps a string to a given line width. Warning: it may break the string. You need to check the result. WordWrap wraps a string to a given line width. Warning: it may break the string. You need to check the result.
<a name="Wrap"></a> <a name="Wrap"></a>
## func [Wrap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L71>) ## func [Wrap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L72>)
```go ```go
func Wrap(src, above, below string) string func Wrap(src, above, below string) string
@@ -179,7 +170,7 @@ func Wrap(src, above, below string) string
Wrap wraps a string with a string above and below. It will respect the indentation of the src string. Wrap wraps a string with a string above and below. It will respect the indentation of the src string.
<a name="EnvConfig"></a> <a name="EnvConfig"></a>
## type [EnvConfig](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L123-L126>) ## type [EnvConfig](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L124-L127>)
EnvConfig is a struct to hold the description of an environment variable. EnvConfig is a struct to hold the description of an environment variable.
@@ -190,32 +181,4 @@ type EnvConfig struct {
} }
``` ```
<a name="Icon"></a>
## type [Icon](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/icons.go#L6>)
Icon is a unicode icon
```go
type Icon string
```
<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>) Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

View File

@@ -34,18 +34,18 @@ For example. With "labels", you should do:
```yaml ```yaml
# in compose file # in compose file
services: services:
webapp: webapp:
image: php:7-apache image: php:7-apache
ports: ports:
- 8080:80 - 8080:80
environment: environment:
DB_HOST: database DB_HOST: database
labels: labels:
katenary.v3/ingress: |- katenary.v3/ingress: |-
hostname: myapp.example.com hostname: myapp.example.com
port: 8080 port: 8080
katenary.v3/map-env: |- katenary.v3/map-env: |-
DB_HOST: "{{ .Release.Name }}-database" DB_HOST: "{{ .Release.Name }}-database"
``` ```
Using a Katenary file, you can do: Using a Katenary file, you can do:
@@ -53,21 +53,21 @@ Using a Katenary file, you can do:
```yaml ```yaml
# in compose file, no need to add labels # in compose file, no need to add labels
services: services:
webapp: webapp:
image: php:7-apache image: php:7-apache
ports: ports:
- 8080:80 - 8080:80
environment: environment:
DB_HOST: database DB_HOST: database
# in katenary.yaml # in katenary.yaml
webapp: webapp:
ingress: ingress:
hostname: myapp.example.com hostname: myapp.example.com
port: 8080 port: 8080
map-env: map-env:
DB_HOST: "{{ .Release.Name }}-database" DB_HOST: "{{ .Release.Name }}-database"
``` ```
!!! Warning "YAML in multiline label" !!! Warning "YAML in multiline label"
@@ -129,8 +129,9 @@ After having installed `katenary`, the standard usage is to call:
It will search standard compose files in the current directory and try to create a helm chart in "chart" directory. It will search standard compose files in the current directory and try to create a helm chart in "chart" directory.
!!! Info !!! Info
Katenary uses the compose-go library which respects the Docker and Docker-Compose specification. Keep in mind that
it will find files exactly the same way as `docker-compose` and `podman-compose` do it. Katenary uses the compose-go library which respects the Docker and Docker-Compose specification. Keep in mind that
it will find files exactly the same way as `docker-compose` and `podman-compose` do it.
Of course, you can provide others files than the default with (cumulative) `-c` options: Of course, you can provide others files than the default with (cumulative) `-c` options:
@@ -141,7 +142,8 @@ Of course, you can provide others files than the default with (cumulative) `-c`
Katenary proposes a lot of labels to configure the helm chart generation, but some are very important. Katenary proposes a lot of labels to configure the helm chart generation, but some are very important.
!!! Info !!! Info
For more complete label usage, see [the labels page](labels.md).
For more complete label usage, see [the labels page](labels.md).
### Work with Depends On? ### Work with Depends On?
@@ -154,15 +156,15 @@ See this compose file:
version: "3" version: "3"
services: services:
webapp: webapp:
image: php:8-apache image: php:8-apache
depends_on: depends_on:
- database - database
database: database:
image: mariadb image: mariadb
environment: environment:
MYSQL_ROOT_PASSWORD: foobar MYSQL_ROOT_PASSWORD: foobar
``` ```
In this case, `webapp` needs to know the `database` port because the `depends_on` points on it and Kubernetes has not In this case, `webapp` needs to know the `database` port because the `depends_on` points on it and Kubernetes has not
@@ -173,18 +175,18 @@ So, instead of exposing the port in the compose definition, let's declare this t
version: "3" version: "3"
services: services:
webapp: webapp:
image: php:8-apache image: php:8-apache
depends_on: depends_on:
- database - database
database: database:
image: mariadb image: mariadb
environment: environment:
MYSQL_ROOT_PASSWORD: foobar MYSQL_ROOT_PASSWORD: foobar
labels: labels:
katenary.v3/ports: |- katenary.v3/ports: |-
- 3306 - 3306
``` ```
### Declare ingresses ### Declare ingresses
@@ -196,14 +198,14 @@ Katenary can create this resource for you. You just need to declare the hostname
```yaml ```yaml
services: services:
webapp: webapp:
image: ... image: ...
ports: 8080:5050 ports: 8080:5050
labels: labels:
katenary.v3/ingress: |- katenary.v3/ingress: |-
# the target port is 5050 wich is the "service" port # the target port is 5050 wich is the "service" port
port: 5050 port: 5050
hostname: myapp.example.com hostname: myapp.example.com
``` ```
Note that the port to bind is the one used by the container, not the used locally. This is because Katenary create a Note that the port to bind is the one used by the container, not the used locally. This is because Katenary create a
@@ -218,13 +220,13 @@ With a compose file, there is no problem as Docker/Podman allows resolving the n
```yaml ```yaml
services: services:
webapp: webapp:
image: php:7-apache image: php:7-apache
environment: environment:
DB_HOST: database DB_HOST: database
database: database:
image: mariadb image: mariadb
``` ```
Katenary prefixes the services with `{{ .Release.Name }}` (to make it possible to install the application several times Katenary prefixes the services with `{{ .Release.Name }}` (to make it possible to install the application several times
@@ -232,16 +234,16 @@ in a namespace), so you need to "remap" the environment variable to the right on
```yaml ```yaml
services: services:
webapp: webapp:
image: php:7-apache image: php:7-apache
environment: environment:
DB_HOST: database DB_HOST: database
labels: labels:
katenary.v3/mapenv: |- katenary.v3/mapenv: |-
DB_HOST: "{{ .Release.Name }}-database" DB_HOST: "{{ .Release.Name }}-database"
database: database:
image: mariadb image: mariadb
``` ```
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
@@ -249,13 +251,13 @@ variable.
```yaml ```yaml
services: services:
webapp: webapp:
#... #...
environment: environment:
RUNNING: docker RUNNING: docker
labels: labels:
katenary.v3/mapenv: |- katenary.v3/mapenv: |-
RUNNING: kubernetes RUNNING: kubernetes
``` ```
In the above example, `RUNNING` will be set to `kubernetes` when you'll deploy the application with helm, and it's In the above example, `RUNNING` will be set to `kubernetes` when you'll deploy the application with helm, and it's

View File

@@ -1,7 +1,7 @@
'\" t '\" t
.\" Automatically generated by Pandoc 3.1.11.1 .\" Automatically generated by Pandoc 3.1.11.1
.\" .\"
.TH "Katenary" "1" "2025-08-21" "mkdocs-manpage v2.0.1" "Katenary helm chart generator" .TH "Katenary" "1" "2025-09-15" "mkdocs-manpage v2.0.1" "Katenary helm chart generator"
.SH Basic Usage .SH Basic Usage
Basically, you can use \f[CR]katenary\f[R] to transpose a docker\-compose file (or any compose file compatible with \f[CR]podman\-compose\f[R] and \f[CR]docker\-compose\f[R]) to a configurable Helm Chart. Basically, you can use \f[CR]katenary\f[R] to transpose a docker\-compose file (or any compose file compatible with \f[CR]podman\-compose\f[R] and \f[CR]docker\-compose\f[R]) to a configurable Helm Chart.
This resulting helm chart can be installed with \f[CR]helm\f[R] command to your Kubernetes cluster. This resulting helm chart can be installed with \f[CR]helm\f[R] command to your Kubernetes cluster.
@@ -38,18 +38,18 @@ With \[dq]labels\[dq], you should do:
.EX .EX
# in compose file # in compose file
services: services:
webapp: webapp:
image: php:7\-apache image: php:7\-apache
ports: ports:
\- 8080:80 \- 8080:80
environment: environment:
DB_HOST: database DB_HOST: database
labels: labels:
katenary.v3/ingress: |\- katenary.v3/ingress: |\-
hostname: myapp.example.com hostname: myapp.example.com
port: 8080 port: 8080
katenary.v3/map\-env: |\- katenary.v3/map\-env: |\-
DB_HOST: \[dq]{{ .Release.Name }}\-database\[dq] DB_HOST: \[dq]{{ .Release.Name }}\-database\[dq]
.EE .EE
.PP .PP
Using a Katenary file, you can do: Using a Katenary file, you can do:
@@ -57,21 +57,21 @@ Using a Katenary file, you can do:
.EX .EX
# in compose file, no need to add labels # in compose file, no need to add labels
services: services:
webapp: webapp:
image: php:7\-apache image: php:7\-apache
ports: ports:
\- 8080:80 \- 8080:80
environment: environment:
DB_HOST: database DB_HOST: database
# in katenary.yaml # in katenary.yaml
webapp: webapp:
ingress: ingress:
hostname: myapp.example.com hostname: myapp.example.com
port: 8080 port: 8080
map\-env: map\-env:
DB_HOST: \[dq]{{ .Release.Name }}\-database\[dq] DB_HOST: \[dq]{{ .Release.Name }}\-database\[dq]
.EE .EE
.PP .PP
YAML in multiline label YAML in multiline label
@@ -162,15 +162,15 @@ See this compose file:
version: \[dq]3\[dq] version: \[dq]3\[dq]
services: services:
webapp: webapp:
image: php:8\-apache image: php:8\-apache
depends_on: depends_on:
\- database \- database
database: database:
image: mariadb image: mariadb
environment: environment:
MYSQL_ROOT_PASSWORD: foobar MYSQL_ROOT_PASSWORD: foobar
.EE .EE
.PP .PP
In this case, \f[CR]webapp\f[R] needs to know the \f[CR]database\f[R] port because the \f[CR]depends_on\f[R] points on it and Kubernetes has not (yet) solution to check the database startup. In this case, \f[CR]webapp\f[R] needs to know the \f[CR]database\f[R] port because the \f[CR]depends_on\f[R] points on it and Kubernetes has not (yet) solution to check the database startup.
@@ -181,18 +181,18 @@ So, instead of exposing the port in the compose definition, let\[aq]s declare th
version: \[dq]3\[dq] version: \[dq]3\[dq]
services: services:
webapp: webapp:
image: php:8\-apache image: php:8\-apache
depends_on: depends_on:
\- database \- database
database: database:
image: mariadb image: mariadb
environment: environment:
MYSQL_ROOT_PASSWORD: foobar MYSQL_ROOT_PASSWORD: foobar
labels: labels:
katenary.v3/ports: |\- katenary.v3/ports: |\-
\- 3306 \- 3306
.EE .EE
.SS Declare ingresses .SS Declare ingresses
It\[aq]s very common to have an Ingress resource on web application to deploy on Kubernetes. It\[aq]s very common to have an Ingress resource on web application to deploy on Kubernetes.
@@ -203,14 +203,14 @@ You just need to declare the hostname and the port to bind.
.IP .IP
.EX .EX
services: services:
webapp: webapp:
image: ... image: ...
ports: 8080:5050 ports: 8080:5050
labels: labels:
katenary.v3/ingress: |\- katenary.v3/ingress: |\-
# the target port is 5050 wich is the \[dq]service\[dq] port # the target port is 5050 wich is the \[dq]service\[dq] port
port: 5050 port: 5050
hostname: myapp.example.com hostname: myapp.example.com
.EE .EE
.PP .PP
Note that the port to bind is the one used by the container, not the used locally. Note that the port to bind is the one used by the container, not the used locally.
@@ -223,29 +223,29 @@ With a compose file, there is no problem as Docker/Podman allows resolving the n
.IP .IP
.EX .EX
services: services:
webapp: webapp:
image: php:7\-apache image: php:7\-apache
environment: environment:
DB_HOST: database DB_HOST: database
database: database:
image: mariadb image: mariadb
.EE .EE
.PP .PP
Katenary prefixes the services with \f[CR]{{ .Release.Name }}\f[R] (to make it possible to install the application several times in a namespace), so you need to \[dq]remap\[dq] the environment variable to the right one. Katenary prefixes the services with \f[CR]{{ .Release.Name }}\f[R] (to make it possible to install the application several times in a namespace), so you need to \[dq]remap\[dq] the environment variable to the right one.
.IP .IP
.EX .EX
services: services:
webapp: webapp:
image: php:7\-apache image: php:7\-apache
environment: environment:
DB_HOST: database DB_HOST: database
labels: labels:
katenary.v3/mapenv: |\- katenary.v3/mapenv: |\-
DB_HOST: \[dq]{{ .Release.Name }}\-database\[dq] DB_HOST: \[dq]{{ .Release.Name }}\-database\[dq]
database: database:
image: mariadb image: mariadb
.EE .EE
.PP .PP
This label can be used to map others environment for any others reason. This label can be used to map others environment for any others reason.
@@ -254,13 +254,13 @@ to change an informational environment variable.
.IP .IP
.EX .EX
services: services:
webapp: webapp:
#... #...
environment: environment:
RUNNING: docker RUNNING: docker
labels: labels:
katenary.v3/mapenv: |\- katenary.v3/mapenv: |\-
RUNNING: kubernetes RUNNING: kubernetes
.EE .EE
.PP .PP
In the above example, \f[CR]RUNNING\f[R] will be set to \f[CR]kubernetes\f[R] when you\[aq]ll deploy the application with helm, and it\[aq]s \f[CR]docker\f[R] for \[dq]Podman\[dq] and \[dq]Docker\[dq] executions. In the above example, \f[CR]RUNNING\f[R] will be set to \f[CR]kubernetes\f[R] when you\[aq]ll deploy the application with helm, and it\[aq]s \f[CR]docker\f[R] for \[dq]Podman\[dq] and \[dq]Docker\[dq] executions.
@@ -271,9 +271,9 @@ While compose labels are string, we can use \f[I]here\-doc\f[R] syntax using \f[
.IP .IP
.EX .EX
label\-name: |\- label\-name: |\-
# this is actually a multiline string here # this is actually a multiline string here
key1: value1 key1: value1
key2: value2 key2: value2
.EE .EE
.PP .PP
Katenary will try to \f[I]Unmarshal\f[R] these labels. Katenary will try to \f[I]Unmarshal\f[R] these labels.
@@ -414,11 +414,11 @@ The file or directory is relative to the service directory.
.PP .PP
If it is a directory, all files inside it are added to the ConfigMap. If it is a directory, all files inside it are added to the ConfigMap.
.PP .PP
If the directory as subdirectories, so one configmap per subpath are created. If the directory as subdirectories, so one ConfigMap per sub\-path are created.
.PP .PP
Warning Warning
.PP .PP
It is not intended to be used to store an entire project in configmaps. It is not intended to be used to store an entire project in ConfigMaps.
It is intended to be used to store configuration files that are not managed by the application, like nginx configuration files. It is intended to be used to store configuration files that are not managed by the application, like nginx configuration files.
Keep in mind that your project sources should be stored in an application image or in a storage. Keep in mind that your project sources should be stored in an application image or in a storage.
.PP .PP
@@ -438,16 +438,21 @@ Create a cronjob from the service.
.PP .PP
This adds a cronjob to the chart. This adds a cronjob to the chart.
.PP .PP
The label value is a YAML object with the following attributes: \- command: the command to be executed \- schedule: the cron schedule (cron format or \[at]every where \[dq]every\[dq] is a duration like 1h30m, daily, hourly...) The label value is a YAML object with the following attributes:
\- rbac: false (optionnal), if true, it will create a role, a rolebinding and a serviceaccount to make your cronjob able to connect the Kubernetes API .IP \[bu] 2
command: the command to be executed
.IP \[bu] 2
schedule: the cron schedule (cron format or \[at]every where \[dq]every\[dq] is a duration like 1h30m, daily, hourly...)
.IP \[bu] 2
rbac: false (optionnal), if true, it will create a role, a rolebinding and a serviceaccount to make your cronjob able to connect the Kubernetes API
.PP .PP
\f[B]Example:\f[R] \f[B]Example:\f[R]
.IP .IP
.EX .EX
labels: labels:
katenary.v3/cronjob: |\- katenary.v3/cronjob: |\-
command: echo \[dq]hello world\[dq] command: echo \[dq]hello world\[dq]
schedule: \[dq]* */1 * * *\[dq] # or \[at]hourly for example schedule: \[dq]* */1 * * *\[dq] # or \[at]hourly for example
.EE .EE
.SS katenary.v3/dependencies .SS katenary.v3/dependencies
Add Helm dependencies to the service. Add Helm dependencies to the service.
@@ -527,15 +532,15 @@ It adds environment variables from another service to the current service.
service1: service1:
image: nginx:1.19 image: nginx:1.19
environment: environment:
FOO: bar FOO: bar
service2: service2:
image: php:7.4\-fpm image: php:7.4\-fpm
labels: labels:
# get the congigMap from service1 where FOO is # get the congigMap from service1 where FOO is
# defined inside this service too # defined inside this service too
katenary.v3/env\-from: |\- katenary.v3/env\-from: |\-
\- myservice1 \- myservice1
.EE .EE
.SS katenary.v3/exchange\-volumes .SS katenary.v3/exchange\-volumes
Add exchange volumes (empty directory on the node) to share data Add exchange volumes (empty directory on the node) to share data
@@ -555,7 +560,13 @@ a \f[CR]voumeMount\f[R] in the pod for \f[B]each container\f[R]
.IP \[bu] 2 .IP \[bu] 2
a \f[CR]initContainer\f[R] for each definition a \f[CR]initContainer\f[R] for each definition
.PP .PP
Fields: \- name: the name of the volume (manadatory) \- mountPath: the path where the volume is mounted in the pod (optional, default is \f[CR]/opt\f[R]) \- init: a command to run to initialize the volume with data (optional) Fields:
.IP \[bu] 2
name: the name of the volume (manadatory)
.IP \[bu] 2
mountPath: the path where the volume is mounted in the pod (optional, default is \f[CR]/opt\f[R])
.IP \[bu] 2
init: a command to run to initialize the volume with data (optional)
.PP .PP
Warning Warning
.PP .PP
@@ -645,7 +656,7 @@ ghost:
image: ghost:1.25.5 image: ghost:1.25.5
labels: labels:
# The chart is now named ghost, and the appVersion is 1.25.5. # The chart is now named ghost, and the appVersion is 1.25.5.
# In Deployment, the image attribute is set to ghost:1.25.5 if # In Deployment, the image attribute is set to ghost:1.25.5 if
# you don\[aq]t change the \[dq]tag\[dq] attribute in values.yaml # you don\[aq]t change the \[dq]tag\[dq] attribute in values.yaml
katenary.v3/main\-app: true katenary.v3/main\-app: true
.EE .EE
@@ -734,7 +745,7 @@ Environment variables to be added to the values.yaml
.PP .PP
\f[B]Type\f[R]: \f[CR][]string or map[string]string\f[R] \f[B]Type\f[R]: \f[CR][]string or map[string]string\f[R]
.PP .PP
By default, all environment variables in the \[dq]env\[dq] and environment files are added to configmaps with the static values set. By default, all environment variables in the \[dq]env\[dq] and environment files are added to ConfigMaps with the static values set.
This label allows adding environment variables to the values.yaml file. This label allows adding environment variables to the values.yaml file.
.PP .PP
Note that the value inside the configmap is \f[CR]{{ tpl vaname . }}\f[R], so you can set the value to a template that will be rendered with the values.yaml file. Note that the value inside the configmap is \f[CR]{{ tpl vaname . }}\f[R], so you can set the value to a template that will be rendered with the values.yaml file.
@@ -756,7 +767,7 @@ labels:
\- TO_CONFIGURE \- TO_CONFIGURE
# complex values, set as a template in values.yaml with a documentation # complex values, set as a template in values.yaml with a documentation
\- A_COMPLEX_VALUE: |\- \- A_COMPLEX_VALUE: |\-
This is the documentation for the variable to This is the documentation for the variable to
configure in values.yaml. configure in values.yaml.
It can be, of course, a multiline text. It can be, of course, a multiline text.
.EE .EE

View File

@@ -11,6 +11,7 @@ import (
"katenary.io/internal/generator/labels" "katenary.io/internal/generator/labels"
"katenary.io/internal/generator/labels/labelstructs" "katenary.io/internal/generator/labels/labelstructs"
"katenary.io/internal/logger"
"katenary.io/internal/utils" "katenary.io/internal/utils"
"github.com/compose-spec/compose-go/types" "github.com/compose-spec/compose-go/types"
@@ -77,36 +78,36 @@ func (chart *HelmChart) SaveTemplates(templateDir string) {
// t = addModeline(t) // t = addModeline(t)
kind := utils.GetKind(name) kind := utils.GetKind(name)
var icon utils.Icon var icon logger.Icon
switch kind { switch kind {
case "deployment": case "deployment":
icon = utils.IconPackage icon = logger.IconPackage
case "service": case "service":
icon = utils.IconPlug icon = logger.IconPlug
case "ingress": case "ingress":
icon = utils.IconWorld icon = logger.IconWorld
case "volumeclaim": case "volumeclaim":
icon = utils.IconCabinet icon = logger.IconCabinet
case "configmap": case "configmap":
icon = utils.IconConfig icon = logger.IconConfig
case "secret": case "secret":
icon = utils.IconSecret icon = logger.IconSecret
default: default:
icon = utils.IconInfo icon = logger.IconInfo
} }
servicename := template.Servicename servicename := template.Servicename
if err := os.MkdirAll(filepath.Join(templateDir, servicename), utils.DirectoryPermission); err != nil { if err := os.MkdirAll(filepath.Join(templateDir, servicename), utils.DirectoryPermission); err != nil {
fmt.Println(utils.IconFailure, err) logger.Failure(err.Error())
os.Exit(1) os.Exit(1)
} }
fmt.Println(icon, "Creating", kind, servicename) logger.Log(icon, "Creating ", kind, " ", name)
// if the name is a path, create the directory // if the name is a path, create the directory
if strings.Contains(name, string(filepath.Separator)) { if strings.Contains(name, string(filepath.Separator)) {
name = filepath.Join(templateDir, name) name = filepath.Join(templateDir, name)
err := os.MkdirAll(filepath.Dir(name), utils.DirectoryPermission) err := os.MkdirAll(filepath.Dir(name), utils.DirectoryPermission)
if err != nil { if err != nil {
fmt.Println(utils.IconFailure, err) logger.Failure(err.Error())
os.Exit(1) os.Exit(1)
} }
} else { } else {
@@ -116,14 +117,14 @@ func (chart *HelmChart) SaveTemplates(templateDir string) {
} }
f, err := os.Create(name) f, err := os.Create(name)
if err != nil { if err != nil {
fmt.Println(utils.IconFailure, err) fmt.Println(logger.IconFailure, err)
os.Exit(1) os.Exit(1)
} }
defer f.Close() defer f.Close()
if _, err := f.Write(t); err != nil { if _, err := f.Write(t); err != nil {
log.Fatal("error writing template file:", err) logger.Failure("error wrting template file: ", err.Error())
os.Exit(1)
} }
} }
} }
@@ -144,14 +145,15 @@ func (chart *HelmChart) generateConfigMapsAndSecrets(project *types.Project) err
if v, ok := s.Labels[labels.LabelSecrets]; ok { if v, ok := s.Labels[labels.LabelSecrets]; ok {
list, err := labelstructs.SecretsFrom(v) list, err := labelstructs.SecretsFrom(v)
if err != nil { if err != nil {
log.Fatal("error unmarshaling secrets label:", err) logger.Failure("error unmarshaling secrets label:", err)
os.Exit(1)
} }
for _, secret := range list { for _, secret := range list {
if secret == "" { if secret == "" {
continue continue
} }
if _, ok := s.Environment[secret]; !ok { if _, ok := s.Environment[secret]; !ok {
fmt.Printf("%s secret %s not found in environment", utils.IconWarning, secret) fmt.Printf("%s secret %s not found in environment", logger.IconWarning, secret)
continue continue
} }
secretsVar[secret] = s.Environment[secret] secretsVar[secret] = s.Environment[secret]
@@ -195,7 +197,7 @@ func (chart *HelmChart) generateDeployment(service types.ServiceConfig, deployme
// isgnored service // isgnored service
if isIgnored(service) { if isIgnored(service) {
fmt.Printf("%s Ignoring service %s\n", utils.IconInfo, service.Name) logger.Info("Ignoring service ", service.Name)
return nil return nil
} }
@@ -305,7 +307,7 @@ func (chart *HelmChart) setDependencies(service types.ServiceConfig) (bool, erro
} }
for _, dep := range d { for _, dep := range d {
fmt.Printf("%s Adding dependency to %s\n", utils.IconDependency, dep.Name) logger.Log(logger.IconDependency, "Adding dependency to ", dep.Name)
chart.Dependencies = append(chart.Dependencies, dep) chart.Dependencies = append(chart.Dependencies, dep)
name := dep.Name name := dep.Name
if dep.Alias != "" { if dep.Alias != "" {

View File

@@ -11,6 +11,7 @@ import (
"katenary.io/internal/generator/labels" "katenary.io/internal/generator/labels"
"katenary.io/internal/generator/labels/labelstructs" "katenary.io/internal/generator/labels/labelstructs"
"katenary.io/internal/logger"
"katenary.io/internal/utils" "katenary.io/internal/utils"
"github.com/compose-spec/compose-go/types" "github.com/compose-spec/compose-go/types"
@@ -178,7 +179,7 @@ func (c *ConfigMap) AppendDir(path string) error {
} }
for _, file := range files { for _, file := range files {
if file.IsDir() { if file.IsDir() {
utils.Warn("Subdirectories are ignored for the moment, skipping", filepath.Join(path, file.Name())) logger.Warn("Subdirectories are ignored for the moment, skipping", filepath.Join(path, file.Name()))
continue continue
} }
path := filepath.Join(path, file.Name()) path := filepath.Join(path, file.Name())

View File

@@ -10,6 +10,7 @@ import (
"katenary.io/internal/generator/labels" "katenary.io/internal/generator/labels"
"github.com/compose-spec/compose-go/types" "github.com/compose-spec/compose-go/types"
appv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
) )
@@ -117,9 +118,15 @@ services:
io.WriteString(fooFp, fooTxt) io.WriteString(fooFp, fooTxt)
fooFp.Close() fooFp.Close()
output := internalCompileTest(t, "-s", "templates/web/statics/configmap.yaml") cmOutput := internalCompileTestForce(t, "-s", "templates/web/statics/configmap.yaml")
depOutput := internalCompileTestForce(t, "-s", "templates/web/deployment.yaml")
configMap := v1.ConfigMap{} configMap := v1.ConfigMap{}
if err := yaml.Unmarshal([]byte(output), &configMap); err != nil { if err := yaml.Unmarshal([]byte(cmOutput), &configMap); err != nil {
t.Errorf(unmarshalError, err)
}
deployment := appv1.Deployment{}
if err := yaml.Unmarshal([]byte(depOutput), &deployment); err != nil {
t.Errorf(unmarshalError, err) t.Errorf(unmarshalError, err)
} }
if configMap.Data == nil { if configMap.Data == nil {
@@ -130,4 +137,12 @@ services:
if !valid.MatchString(configMap.Name) { if !valid.MatchString(configMap.Name) {
t.Errorf("ConfigMap name %s is not valid", configMap.Name) t.Errorf("ConfigMap name %s is not valid", configMap.Name)
} }
// the volume mount should be named "configmap-<configmap name>"
if deployment.Spec.Template.Spec.Volumes[0].Name != deployment.Spec.Template.Spec.Containers[0].VolumeMounts[0].Name {
t.Errorf("Expected volume name to be %s, got %s",
deployment.Spec.Template.Spec.Containers[0].VolumeMounts[0].Name,
deployment.Spec.Template.Spec.Volumes[0].Name,
)
}
} }

View File

@@ -16,6 +16,7 @@ import (
"katenary.io/internal/generator/katenaryfile" "katenary.io/internal/generator/katenaryfile"
"katenary.io/internal/generator/labels" "katenary.io/internal/generator/labels"
"katenary.io/internal/generator/labels/labelstructs" "katenary.io/internal/generator/labels/labelstructs"
"katenary.io/internal/logger"
"katenary.io/internal/parser" "katenary.io/internal/parser"
"katenary.io/internal/utils" "katenary.io/internal/utils"
@@ -111,12 +112,13 @@ func Convert(config ConvertOptions, dockerComposeFile ...string) error {
currentDir, _ := os.Getwd() currentDir, _ := os.Getwd()
// go to the root of the project // go to the root of the project
if err := os.Chdir(filepath.Dir(dockerComposeFile[0])); err != nil { if err := os.Chdir(filepath.Dir(dockerComposeFile[0])); err != nil {
fmt.Println(utils.IconFailure, err) logger.Failure(err.Error())
return err return err
} }
defer func() { defer func() {
if err := os.Chdir(currentDir); err != nil { // after the generation, go back to the original directory if err := os.Chdir(currentDir); err != nil { // after the generation, go back to the original directory
log.Fatal(err) logger.Failure(err.Error())
os.Exit(1)
} }
}() }()
@@ -134,7 +136,7 @@ func Convert(config ConvertOptions, dockerComposeFile ...string) error {
// check older version of labels // check older version of labels
if err := checkOldLabels(project); err != nil { if err := checkOldLabels(project); err != nil {
fmt.Println(utils.IconFailure, err) logger.Failure(err.Error())
return err return err
} }
@@ -147,7 +149,7 @@ func Convert(config ConvertOptions, dockerComposeFile ...string) error {
if _, err := os.Stat(config.OutputDir); err == nil { if _, err := os.Stat(config.OutputDir); err == nil {
overwrite := utils.Confirm( overwrite := utils.Confirm(
"The chart directory "+config.OutputDir+" already exists, do you want to overwrite it?", "The chart directory "+config.OutputDir+" already exists, do you want to overwrite it?",
utils.IconWarning, logger.IconWarning,
) )
if !overwrite { if !overwrite {
fmt.Println("Aborting") fmt.Println("Aborting")
@@ -399,7 +401,7 @@ func addMainTagAppDoc(values []byte, project *types.Project) []byte {
} else if v == "false" || v == "no" || v == "0" { } else if v == "false" || v == "no" || v == "0" {
continue continue
} else { } else {
fmt.Printf("%s Adding main tag app doc %s\n", utils.IconConfig, service.Name) logger.Log(logger.IconConfig, "Adding main tag app doc for service", service.Name)
} }
lines = addMainAppDoc(lines, service) lines = addMainAppDoc(lines, service)
@@ -579,15 +581,15 @@ func buildValues(chart *HelmChart, project *types.Project, valuesPath string) {
func callHelmUpdate(config ConvertOptions) { func callHelmUpdate(config ConvertOptions) {
executeAndHandleError := func(fn func(ConvertOptions) error, config ConvertOptions, message string) { executeAndHandleError := func(fn func(ConvertOptions) error, config ConvertOptions, message string) {
if err := fn(config); err != nil { if err := fn(config); err != nil {
fmt.Println(utils.IconFailure, err) logger.Failure("Helm command failed, please check the output above", err.Error())
os.Exit(1) os.Exit(1)
} }
fmt.Println(utils.IconSuccess, message) logger.Success(message)
} }
if config.HelmUpdate { if config.HelmUpdate {
executeAndHandleError(helmUpdate, config, "Helm dependencies updated") executeAndHandleError(helmUpdate, config, "Helm dependencies updated")
executeAndHandleError(helmLint, config, "Helm chart linted") executeAndHandleError(helmLint, config, "Helm chart linted")
fmt.Println(utils.IconSuccess, "Helm chart created successfully") logger.Success("Helm chart created successfully")
} }
} }
@@ -627,7 +629,7 @@ func removeUnwantedLines(values []byte) []byte {
func writeContent(path string, content []byte) { func writeContent(path string, content []byte) {
f, err := os.Create(path) f, err := os.Create(path)
if err != nil { if err != nil {
fmt.Println(utils.IconFailure, err) logger.Failure("Cannot create file "+path, err.Error())
os.Exit(1) os.Exit(1)
} }
defer f.Close() defer f.Close()
@@ -640,10 +642,10 @@ func writeContent(path string, content []byte) {
// helmLint runs "helm lint" on the output directory. // helmLint runs "helm lint" on the output directory.
func helmLint(config ConvertOptions) error { func helmLint(config ConvertOptions) error {
fmt.Println(utils.IconInfo, "Linting...") logger.Info("Linting...")
helm, err := exec.LookPath("helm") helm, err := exec.LookPath("helm")
if err != nil { if err != nil {
fmt.Println(utils.IconFailure, err) logger.Failure("Helm is not installed or not in your PATH", err.Error())
os.Exit(1) os.Exit(1)
} }
cmd := exec.Command(helm, "lint", config.OutputDir) cmd := exec.Command(helm, "lint", config.OutputDir)
@@ -655,10 +657,10 @@ func helmLint(config ConvertOptions) error {
// helmUpdate runs "helm dependency update" on the output directory. // helmUpdate runs "helm dependency update" on the output directory.
func helmUpdate(config ConvertOptions) error { func helmUpdate(config ConvertOptions) error {
// lookup for "helm" binary // lookup for "helm" binary
fmt.Println(utils.IconInfo, "Updating helm dependencies...") logger.Info("Updating helm dependencies...")
helm, err := exec.LookPath("helm") helm, err := exec.LookPath("helm")
if err != nil { if err != nil {
fmt.Println(utils.IconFailure, err) fmt.Println(logger.IconFailure, err)
os.Exit(1) os.Exit(1)
} }
// run "helm dependency update" // run "helm dependency update"

View File

@@ -11,6 +11,7 @@ import (
"katenary.io/internal/generator/labels" "katenary.io/internal/generator/labels"
"katenary.io/internal/generator/labels/labelstructs" "katenary.io/internal/generator/labels/labelstructs"
"katenary.io/internal/logger"
"katenary.io/internal/utils" "katenary.io/internal/utils"
"github.com/compose-spec/compose-go/types" "github.com/compose-spec/compose-go/types"
@@ -119,7 +120,7 @@ func (d *Deployment) AddContainer(service types.ServiceConfig) {
for _, port := range service.Ports { for _, port := range service.Ports {
name := utils.GetServiceNameByPort(int(port.Target)) name := utils.GetServiceNameByPort(int(port.Target))
if name == "" { if name == "" {
utils.Warn("Port name not found for port ", port.Target, " in service ", service.Name, ". Using port number instead") logger.Warn("Port name not found for port ", port.Target, " in service ", service.Name, ". Using port number instead")
name = fmt.Sprintf("port-%d", port.Target) name = fmt.Sprintf("port-%d", port.Target)
} }
ports = append(ports, corev1.ContainerPort{ ports = append(ports, corev1.ContainerPort{
@@ -274,7 +275,7 @@ func (d *Deployment) DependsOn(to *Deployment, servicename string) error {
for _, container := range to.Spec.Template.Spec.Containers { for _, container := range to.Spec.Template.Spec.Containers {
commands := []string{} commands := []string{}
if len(container.Ports) == 0 { if len(container.Ports) == 0 {
utils.Warn("No ports found for service ", logger.Warn("No ports found for service ",
servicename, servicename,
". You should declare a port in the service or use "+ ". You should declare a port in the service or use "+
labels.LabelPorts+ labels.LabelPorts+
@@ -340,7 +341,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, sam
_, ok := service.Environment[secret] _, ok := service.Environment[secret]
if !ok { if !ok {
drop = append(drop, secret) drop = append(drop, secret)
utils.Warn("Secret " + secret + " not found in service " + service.Name + " - skpped") logger.Warn("Secret " + secret + " not found in service " + service.Name + " - skpped")
continue continue
} }
secrets = append(secrets, secret) secrets = append(secrets, secret)
@@ -357,7 +358,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, sam
val, ok := service.Environment[value] val, ok := service.Environment[value]
if !ok { if !ok {
drop = append(drop, value) drop = append(drop, value)
utils.Warn("Environment variable " + value + " not found in service " + service.Name + " - skpped") logger.Warn("Environment variable " + value + " not found in service " + service.Name + " - skpped")
continue continue
} }
if d.chart.Values[service.Name].(*Value).Environment == nil { if d.chart.Values[service.Name].(*Value).Environment == nil {
@@ -413,7 +414,7 @@ func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secret
container, index := utils.GetContainerByName(service.ContainerName, d.Spec.Template.Spec.Containers) container, index := utils.GetContainerByName(service.ContainerName, d.Spec.Template.Spec.Containers)
if container == nil { if container == nil {
utils.Warn("Container not found for service " + service.Name) logger.Warn("Container not found for service " + service.Name)
return nil, -1 return nil, -1
} }
@@ -677,7 +678,7 @@ func (d *Deployment) bindVolumes(volume types.ServiceVolumeConfig, isSamePod boo
}(d, container, index) }(d, container, index)
if _, found := tobind[volume.Source]; !isSamePod && volume.Type == "bind" && !found { if _, found := tobind[volume.Source]; !isSamePod && volume.Type == "bind" && !found {
utils.Warn( logger.Warn(
"Bind volumes are not supported yet, " + "Bind volumes are not supported yet, " +
"excepting for those declared as " + "excepting for those declared as " +
labels.LabelConfigMapFiles + labels.LabelConfigMapFiles +
@@ -688,7 +689,7 @@ func (d *Deployment) bindVolumes(volume types.ServiceVolumeConfig, isSamePod boo
} }
if container == nil { if container == nil {
utils.Warn("Container not found for volume", volume.Source) logger.Warn("Container not found for volume", volume.Source)
return return
} }

View File

@@ -15,7 +15,6 @@ func TestReadMeFile_Basic(t *testing.T) {
} }
result := ReadMeFile("testchart", "A test chart", values) result := ReadMeFile("testchart", "A test chart", values)
t.Logf("Generated README content:\n%s", result)
paramerRegExp := regexp.MustCompile(`\|\s+` + "`" + `(.*?)` + "`" + `\s+\|\s+` + "`" + `(.*?)` + "`" + `\s+\|`) paramerRegExp := regexp.MustCompile(`\|\s+` + "`" + `(.*?)` + "`" + `\s+\|\s+` + "`" + `(.*?)` + "`" + `\s+\|`)
matches := paramerRegExp.FindAllStringSubmatch(result, -1) matches := paramerRegExp.FindAllStringSubmatch(result, -1)
if len(matches) != 3 { if len(matches) != 3 {

View File

@@ -233,7 +233,6 @@ func fixResourceNames(project *types.Project) error {
return err return err
} }
for varname, bind := range *vf { for varname, bind := range *vf {
log.Printf("service %s, varname %s, bind %s", service.Name, varname, bind)
bind := strings.ReplaceAll(bind, service.Name, fixed) bind := strings.ReplaceAll(bind, service.Name, fixed)
(*vf)[varname] = bind (*vf)[varname] = bind
} }
@@ -278,6 +277,7 @@ func addStaticVolumes(deployments map[string]*Deployment, service types.ServiceC
if y, err = config.configMap.Yaml(); err != nil { if y, err = config.configMap.Yaml(); err != nil {
log.Fatal(err) log.Fatal(err)
} }
// add the configmap to the chart // add the configmap to the chart
d.chart.Templates[config.configMap.Filename()] = &ChartTemplate{ d.chart.Templates[config.configMap.Filename()] = &ChartTemplate{
Content: y, Content: y,
@@ -285,6 +285,10 @@ func addStaticVolumes(deployments map[string]*Deployment, service types.ServiceC
} }
// add the moint path to the container // add the moint path to the container
for _, m := range config.mountPath { for _, m := range config.mountPath {
// volumeName can be empty, in this case we generate a name
if volumeName == "" {
volumeName = utils.PathToName(m.subPath)
}
container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{ container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{
Name: utils.PathToName(volumeName), Name: utils.PathToName(volumeName),
MountPath: m.mountPath, MountPath: m.mountPath,

View File

@@ -3,7 +3,6 @@ package katenaryfile
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"log" "log"
"os" "os"
"reflect" "reflect"
@@ -11,7 +10,7 @@ import (
"katenary.io/internal/generator/labels" "katenary.io/internal/generator/labels"
"katenary.io/internal/generator/labels/labelstructs" "katenary.io/internal/generator/labels/labelstructs"
"katenary.io/internal/utils" "katenary.io/internal/logger"
"github.com/compose-spec/compose-go/types" "github.com/compose-spec/compose-go/types"
"github.com/invopop/jsonschema" "github.com/invopop/jsonschema"
@@ -60,7 +59,7 @@ func OverrideWithConfig(project *types.Project) {
// no katenary file found // no katenary file found
return return
} }
fmt.Println(utils.IconInfo, "Using katenary file", yamlFile) logger.Info("Using katenary file", yamlFile)
services := make(map[string]Service) services := make(map[string]Service)
fp, err := os.Open(yamlFile) fp, err := os.Open(yamlFile)
@@ -102,7 +101,7 @@ func OverrideWithConfig(project *types.Project) {
mustGetLabelContent(s.ValuesFrom, &project.Services[i], labels.LabelValuesFrom) mustGetLabelContent(s.ValuesFrom, &project.Services[i], labels.LabelValuesFrom)
} }
} }
fmt.Println(utils.IconInfo, "Katenary file loaded successfully, the services are now configured.") logger.Info("Katenary file loaded successfully, the services are now configured.")
} }
func getLabelContent(o any, service *types.ServiceConfig, labelName string) error { func getLabelContent(o any, service *types.ServiceConfig, labelName string) error {

View File

@@ -1,7 +1,6 @@
package katenaryfile package katenaryfile
import ( import (
"log"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@@ -39,18 +38,15 @@ webapp:
composeFile := filepath.Join(tmpDir, "compose.yaml") composeFile := filepath.Join(tmpDir, "compose.yaml")
katenaryFile := filepath.Join(tmpDir, "katenary.yaml") katenaryFile := filepath.Join(tmpDir, "katenary.yaml")
os.MkdirAll(tmpDir, 0755) os.MkdirAll(tmpDir, 0o755)
if err := os.WriteFile(composeFile, []byte(composeContent), 0644); err != nil { if err := os.WriteFile(composeFile, []byte(composeContent), 0o644); err != nil {
t.Log(err) t.Log(err)
} }
if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0644); err != nil { if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0o644); err != nil {
t.Log(err) t.Log(err)
} }
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
c, _ := os.ReadFile(composeFile)
log.Println(string(c))
// chand dir to this directory // chand dir to this directory
os.Chdir(tmpDir) os.Chdir(tmpDir)
options, _ := cli.NewProjectOptions(nil, options, _ := cli.NewProjectOptions(nil,
@@ -92,18 +88,15 @@ webapp:
composeFile := filepath.Join(tmpDir, "compose.yaml") composeFile := filepath.Join(tmpDir, "compose.yaml")
katenaryFile := filepath.Join(tmpDir, "katenary.yaml") katenaryFile := filepath.Join(tmpDir, "katenary.yaml")
os.MkdirAll(tmpDir, 0755) os.MkdirAll(tmpDir, 0o755)
if err := os.WriteFile(composeFile, []byte(composeContent), 0644); err != nil { if err := os.WriteFile(composeFile, []byte(composeContent), 0o644); err != nil {
t.Log(err) t.Log(err)
} }
if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0644); err != nil { if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0o644); err != nil {
t.Log(err) t.Log(err)
} }
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
c, _ := os.ReadFile(composeFile)
log.Println(string(c))
// chand dir to this directory // chand dir to this directory
os.Chdir(tmpDir) os.Chdir(tmpDir)
options, _ := cli.NewProjectOptions(nil, options, _ := cli.NewProjectOptions(nil,
@@ -150,18 +143,15 @@ webapp:
composeFile := filepath.Join(tmpDir, "compose.yaml") composeFile := filepath.Join(tmpDir, "compose.yaml")
katenaryFile := filepath.Join(tmpDir, "katenary.yaml") katenaryFile := filepath.Join(tmpDir, "katenary.yaml")
os.MkdirAll(tmpDir, 0755) os.MkdirAll(tmpDir, 0o755)
if err := os.WriteFile(composeFile, []byte(composeContent), 0644); err != nil { if err := os.WriteFile(composeFile, []byte(composeContent), 0o644); err != nil {
t.Log(err) t.Log(err)
} }
if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0644); err != nil { if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0o644); err != nil {
t.Log(err) t.Log(err)
} }
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
c, _ := os.ReadFile(composeFile)
log.Println(string(c))
// chand dir to this directory // chand dir to this directory
os.Chdir(tmpDir) os.Chdir(tmpDir)
options, _ := cli.NewProjectOptions(nil, options, _ := cli.NewProjectOptions(nil,

View File

@@ -24,7 +24,7 @@
"main-app": "main-app":
short: "Mark the service as the main app." short: "Mark the service as the main app."
long: |- long: |-
This makes the service to be the main application. Its image tag is This makes the service to be the main application. Its image tag is
considered to be the Chart appVersion and to be the defaultvalue in Pod considered to be the Chart appVersion and to be the defaultvalue in Pod
container image attribute. container image attribute.
@@ -36,7 +36,7 @@
image: ghost:1.25.5 image: ghost:1.25.5
labels: labels:
# The chart is now named ghost, and the appVersion is 1.25.5. # The chart is now named ghost, and the appVersion is 1.25.5.
# In Deployment, the image attribute is set to ghost:1.25.5 if # In Deployment, the image attribute is set to ghost:1.25.5 if
# you don't change the "tag" attribute in values.yaml # you don't change the "tag" attribute in values.yaml
{{ .KatenaryPrefix }}/main-app: true {{ .KatenaryPrefix }}/main-app: true
type: "bool" type: "bool"
@@ -45,14 +45,14 @@
short: "Environment variables to be added to the values.yaml" short: "Environment variables to be added to the values.yaml"
long: |- long: |-
By default, all environment variables in the "env" and environment By default, all environment variables in the "env" and environment
files are added to configmaps with the static values set. This label files are added to ConfigMaps with the static values set. This label
allows adding environment variables to the values.yaml file. allows adding environment variables to the values.yaml file.
Note that the value inside the configmap is {{ "{{ tpl vaname . }}" }}, so Note that the value inside the configmap is {{ "{{ tpl vaname . }}" }}, so
you can set the value to a template that will be rendered with the you can set the value to a template that will be rendered with the
values.yaml file. values.yaml file.
The value can be set with a documentation. This may help to understand The value can be set with a documentation. This may help to understand
the purpose of the variable. the purpose of the variable.
example: |- example: |-
env: env:
@@ -66,7 +66,7 @@
- TO_CONFIGURE - TO_CONFIGURE
# complex values, set as a template in values.yaml with a documentation # complex values, set as a template in values.yaml with a documentation
- A_COMPLEX_VALUE: |- - A_COMPLEX_VALUE: |-
This is the documentation for the variable to This is the documentation for the variable to
configure in values.yaml. configure in values.yaml.
It can be, of course, a multiline text. It can be, of course, a multiline text.
type: "[]string or map[string]string" type: "[]string or map[string]string"
@@ -74,7 +74,7 @@
"secrets": "secrets":
short: "Env vars to be set as secrets." short: "Env vars to be set as secrets."
long: |- long: |-
This label allows setting the environment variables as secrets. The variable This label allows setting the environment variables as secrets. The variable
is removed from the environment and added to a secret object. is removed from the environment and added to a secret object.
The variable can be set to the {{ printf "%s/%s" .KatenaryPrefix "values"}} too, The variable can be set to the {{ printf "%s/%s" .KatenaryPrefix "values"}} too,
@@ -91,7 +91,7 @@
"ports": "ports":
short: "Ports to be added to the service." short: "Ports to be added to the service."
long: |- long: |-
Only useful for services without exposed port. It is mandatory if the Only useful for services without exposed port. It is mandatory if the
service is a dependency of another service. service is a dependency of another service.
example: |- example: |-
labels: labels:
@@ -103,7 +103,7 @@
"ingress": "ingress":
short: "Ingress rules to be added to the service." short: "Ingress rules to be added to the service."
long: |- long: |-
Declare an ingress rule for the service. The port should be exposed or Declare an ingress rule for the service. The port should be exposed or
declared with {{ printf "%s/%s" .KatenaryPrefix "ports" }}. declared with {{ printf "%s/%s" .KatenaryPrefix "ports" }}.
example: |- example: |-
labels: labels:
@@ -116,8 +116,8 @@
short: "Map env vars from the service to the deployment." short: "Map env vars from the service to the deployment."
long: |- long: |-
Because you may need to change the variable for Kubernetes, this label Because you may need to change the variable for Kubernetes, this label
forces the value to another. It is also particullary helpful to use a template forces the value to another. It is also particullary helpful to use a template
value instead. For example, you could bind the value to a service name value instead. For example, you could bind the value to a service name
with Helm attributes: with Helm attributes:
{{ "{{ tpl .Release.Name . }}" }}. {{ "{{ tpl .Release.Name . }}" }}.
@@ -148,10 +148,10 @@
"same-pod": "same-pod":
short: "Move the same-pod deployment to the target deployment." short: "Move the same-pod deployment to the target deployment."
long: |- long: |-
This will make the service to be included in another service pod. Some services This will make the service to be included in another service pod. Some services
must work together in the same pod, like a sidecar or a proxy or nginx + php-fpm. must work together in the same pod, like a sidecar or a proxy or nginx + php-fpm.
Note that volume and VolumeMount are copied from the source to the target Note that volume and VolumeMount are copied from the source to the target
deployment. deployment.
example: |- example: |-
web: web:
@@ -166,7 +166,7 @@
"description": "description":
short: "Description of the service" short: "Description of the service"
long: |- long: |-
This replaces the default comment in values.yaml file to the given description. This replaces the default comment in values.yaml file to the given description.
It is useful to document the service and configuration. It is useful to document the service and configuration.
The value can be set with a documentation in multiline format. The value can be set with a documentation in multiline format.
@@ -186,8 +186,8 @@
"dependencies": "dependencies":
short: "Add Helm dependencies to the service." short: "Add Helm dependencies to the service."
long: |- long: |-
Set the service to be, actually, a Helm dependency. This means that the Set the service to be, actually, a Helm dependency. This means that the
service will not be exported as template. The dependencies are added to service will not be exported as template. The dependencies are added to
the Chart.yaml file and the values are added to the values.yaml file. the Chart.yaml file and the values are added to the values.yaml file.
It's a list of objects with the following attributes: It's a list of objects with the following attributes:
@@ -199,12 +199,12 @@
!!! Info !!! Info
Katenary doesn't update the helm depenedencies by default. Katenary doesn't update the helm depenedencies by default.
Use `--helm-update` (or `-u`) flag to update the dependencies. Use `--helm-update` (or `-u`) flag to update the dependencies.
example: <code>katenary convert -u</code> example: <code>katenary convert -u</code>
By setting an alias, it is possible to change the name of the dependency By setting an alias, it is possible to change the name of the dependency
in values.yaml. in values.yaml.
example: |- example: |-
labels: labels:
@@ -226,17 +226,17 @@
"configmap-files": "configmap-files":
short: "Inject files as Configmap." short: "Inject files as Configmap."
long: |- long: |-
It makes a file or directory to be converted to one or more ConfigMaps It makes a file or directory to be converted to one or more ConfigMaps
and mounted in the pod. The file or directory is relative to the and mounted in the pod. The file or directory is relative to the
service directory. service directory.
If it is a directory, all files inside it are added to the ConfigMap. If it is a directory, all files inside it are added to the ConfigMap.
If the directory as subdirectories, so one configmap per subpath are created. If the directory as subdirectories, so one ConfigMap per sub-path are created.
!!! Warning !!! Warning
It is not intended to be used to store an entire project in configmaps. It is not intended to be used to store an entire project in ConfigMaps.
It is intended to be used to store configuration files that are not managed It is intended to be used to store configuration files that are not managed
by the application, like nginx configuration files. Keep in mind that your by the application, like nginx configuration files. Keep in mind that your
project sources should be stored in an application image or in a storage. project sources should be stored in an application image or in a storage.
example: |- example: |-
@@ -253,16 +253,17 @@
This adds a cronjob to the chart. This adds a cronjob to the chart.
The label value is a YAML object with the following attributes: The label value is a YAML object with the following attributes:
- command: the command to be executed
- schedule: the cron schedule (cron format or @every where "every" is a - command: the command to be executed
- schedule: the cron schedule (cron format or @every where "every" is a
duration like 1h30m, daily, hourly...) duration like 1h30m, daily, hourly...)
- rbac: false (optionnal), if true, it will create a role, a rolebinding and - rbac: false (optionnal), if true, it will create a role, a rolebinding and
a serviceaccount to make your cronjob able to connect the Kubernetes API a serviceaccount to make your cronjob able to connect the Kubernetes API
example: |- example: |-
labels: labels:
{{ .KatenaryPrefix }}/cronjob: |- {{ .KatenaryPrefix }}/cronjob: |-
command: echo "hello world" command: echo "hello world"
schedule: "* */1 * * *" # or @hourly for example schedule: "* */1 * * *" # or @hourly for example
type: "object" type: "object"
"env-from": "env-from":
@@ -274,21 +275,21 @@
service1: service1:
image: nginx:1.19 image: nginx:1.19
environment: environment:
FOO: bar FOO: bar
service2: service2:
image: php:7.4-fpm image: php:7.4-fpm
labels: labels:
# get the congigMap from service1 where FOO is # get the congigMap from service1 where FOO is
# defined inside this service too # defined inside this service too
{{ .KatenaryPrefix }}/env-from: |- {{ .KatenaryPrefix }}/env-from: |-
- myservice1 - myservice1
"exchange-volumes": "exchange-volumes":
short: Add exchange volumes (empty directory on the node) to share data short: Add exchange volumes (empty directory on the node) to share data
type: "[]object" type: "[]object"
long: |- long: |-
This label allows sharing data between containres. The volume is created in This label allows sharing data between containres. The volume is created in
the node and mounted in the pod. It is useful to share data between containers the node and mounted in the pod. It is useful to share data between containers
in a "same pod" logic. For example to let PHP-FPM and Nginx share the same direcotory. in a "same pod" logic. For example to let PHP-FPM and Nginx share the same direcotory.
@@ -299,6 +300,7 @@
- a `initContainer` for each definition - a `initContainer` for each definition
Fields: Fields:
- name: the name of the volume (manadatory) - name: the name of the volume (manadatory)
- mountPath: the path where the volume is mounted in the pod (optional, default is `/opt`) - mountPath: the path where the volume is mounted in the pod (optional, default is `/opt`)
- init: a command to run to initialize the volume with data (optional) - init: a command to run to initialize the volume with data (optional)

View File

@@ -29,13 +29,22 @@ func teardown(tmpDir string) {
} }
} }
// internalCompileTestForce is like internalCompileTest but with the force option enabled to rewrite the chart.
func internalCompileTestForce(t *testing.T, options ...string) string {
return compileTest(t, true, options...)
}
// internalCompileTest is like compileTest but without the force option enabled to rewrite the chart.
func internalCompileTest(t *testing.T, options ...string) string { func internalCompileTest(t *testing.T, options ...string) string {
return compileTest(t, false, options...)
}
func compileTest(t *testing.T, force bool, options ...string) string {
_, err := parser.Parse(nil, nil, "compose.yml") _, err := parser.Parse(nil, nil, "compose.yml")
if err != nil { if err != nil {
t.Fatalf("Failed to parse the project: %s", err) t.Fatalf("Failed to parse the project: %s", err)
} }
force := false
outputDir := "./chart" outputDir := "./chart"
profiles := make([]string, 0) profiles := make([]string, 0)
helmdepUpdate := true helmdepUpdate := true

View File

@@ -5,7 +5,6 @@ import (
"image" "image"
"image/color" "image/color"
"image/png" "image/png"
"log"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@@ -173,7 +172,6 @@ services:
` `
composeFile = fmt.Sprintf(composeFile, labels.KatenaryLabelPrefix) composeFile = fmt.Sprintf(composeFile, labels.KatenaryLabelPrefix)
tmpDir := setup(composeFile) tmpDir := setup(composeFile)
log.Println(tmpDir)
defer teardown(tmpDir) defer teardown(tmpDir)
os.Mkdir(filepath.Join(tmpDir, "images"), utils.DirectoryPermission) os.Mkdir(filepath.Join(tmpDir, "images"), utils.DirectoryPermission)
@@ -243,7 +241,6 @@ services:
` `
composeFile = fmt.Sprintf(composeFile, labels.KatenaryLabelPrefix) composeFile = fmt.Sprintf(composeFile, labels.KatenaryLabelPrefix)
tmpDir := setup(composeFile) tmpDir := setup(composeFile)
log.Println(tmpDir)
defer teardown(tmpDir) defer teardown(tmpDir)
os.Mkdir(filepath.Join(tmpDir, "images"), utils.DirectoryPermission) os.Mkdir(filepath.Join(tmpDir, "images"), utils.DirectoryPermission)

51
internal/logger/logger.go Normal file
View File

@@ -0,0 +1,51 @@
// Package logger provides simple logging functions with icons and colors.
package logger
// Icon is a unicode icon
type Icon string
// Icons used in katenary.
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 = "🔗"
)
const reset = "\033[0m"
// Info prints an informational message.
func Info(msg ...any) {
message("", IconInfo, msg...)
}
// Warn prints a warning message.
func Warn(msg ...any) {
orange := "\033[38;5;214m"
message(orange, IconWarning, msg...)
}
// Success prints a success message.
func Success(msg ...any) {
green := "\033[38;5;34m"
message(green, IconSuccess, msg...)
}
// Failure prints a failure message.
func Failure(msg ...any) {
red := "\033[38;5;196m"
message(red, IconFailure, msg...)
}
// Log prints a message with a custom icon.
func Log(icon Icon, msg ...any) {
message("", icon, msg...)
}

View File

@@ -0,0 +1,12 @@
//go:build !ci
// +build !ci
package logger
import "fmt"
func message(color string, icon Icon, msg ...any) {
fmt.Print(icon, " ", color)
fmt.Print(msg...)
fmt.Println(reset)
}

View File

@@ -0,0 +1,9 @@
//go:build ci
// +build ci
package logger
// CI should be no-op
func message(color string, icon Icon, msg ...any) {
// no-op
}

View File

@@ -1,31 +0,0 @@
package utils
import "fmt"
// Icon is a unicode icon
type Icon string
// Icons used in katenary.
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 = "🔗"
)
// Warn prints a warning message
func Warn(msg ...any) {
orange := "\033[38;5;214m"
reset := "\033[0m"
fmt.Print(IconWarning, orange, " ")
fmt.Print(msg...)
fmt.Println(reset)
}

View File

@@ -12,6 +12,7 @@ import (
"github.com/thediveo/netdb" "github.com/thediveo/netdb"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"katenary.io/internal/logger"
) )
// DirectoryPermission is the default values for permissions apply to created directories. // DirectoryPermission is the default values for permissions apply to created directories.
@@ -64,7 +65,7 @@ func GetKind(path string) (kind string) {
} else { } else {
kind = strings.Split(path, ".")[1] kind = strings.Split(path, ".")[1]
} }
return return kind
} }
// Wrap wraps a string with a string above and below. It will respect the indentation of the src string. // Wrap wraps a string with a string above and below. It will respect the indentation of the src string.
@@ -135,16 +136,17 @@ func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[str
log.Printf("Error parsing label %s: %s", v, err) log.Printf("Error parsing label %s: %s", v, err)
log.Fatal(err) log.Fatal(err)
} }
for _, value := range labelContent { for _, value := range labelContent {
switch val := value.(type) { switch value := value.(type) {
case string: case string:
descriptions[val] = nil descriptions[value] = nil
case map[string]any: case map[string]any:
for k, v := range value.(map[string]any) { for k, v := range value {
descriptions[k] = &EnvConfig{Service: service, Description: v.(string)} descriptions[k] = &EnvConfig{Service: service, Description: v.(string)}
} }
case map[any]any: case map[any]any:
for k, v := range value.(map[any]any) { for k, v := range value {
descriptions[k.(string)] = &EnvConfig{Service: service, Description: v.(string)} descriptions[k.(string)] = &EnvConfig{Service: service, Description: v.(string)}
} }
default: default:
@@ -161,7 +163,7 @@ func WordWrap(text string, lineWidth int) string {
} }
// Confirm asks a question and returns true if the answer is y. // Confirm asks a question and returns true if the answer is y.
func Confirm(question string, icon ...Icon) bool { func Confirm(question string, icon ...logger.Icon) bool {
if len(icon) > 0 { if len(icon) > 0 {
fmt.Printf("%s %s [y/N] ", icon[0], question) fmt.Printf("%s %s [y/N] ", icon[0], question)
} else { } else {