73 Commits

Author SHA1 Message Date
327e0aa799 Merge pull request #142 from Katenary/develop
chore(make): manpage requirements are now in requirements
2025-07-15 13:58:48 +02:00
b7e948954b chore(make): manpage requirements are now in requirements 2025-07-15 13:57:35 +02:00
93c0658c19 Merge pull request #141 from Katenary/develop
Develop
2025-07-15 13:53:20 +02:00
bdf74f2deb chore(cleanup): removed unecessary file 2025-07-15 13:51:21 +02:00
2435bb9f8a chore(doc): Rebuild label list and description 2025-07-15 13:50:07 +02:00
5ee38dcf7f Merge pull request #140 from Katenary/develop
Develop
2025-07-15 13:45:38 +02:00
a754dc9275 fix(make): no need to auto retrieve key now 2025-07-15 13:44:25 +02:00
732e080da3 Merge branch 'master' into develop 2025-07-15 13:42:15 +02:00
22e1ebdce1 chore(make): huge refactor, add more tests
- more test on gpg signature
- change build target in the help message
- refactor upx compression
-
2025-07-15 13:41:49 +02:00
e4280f2c4e chore(build): Fixes cache, add better cleanup, add PHONY 2025-07-15 10:27:24 +02:00
a99609d21d Merge pull request #139 from Katenary/develop
fix(doc): Fix documentation linkg
2025-07-13 15:41:01 +02:00
e55658d382 fix(doc): Fix documentation linkg
No translation, so remove "en" from the url.
2025-07-13 15:40:30 +02:00
9dbe9e1114 Merge pull request #138 from Katenary/develop
Develop
2025-07-13 15:37:31 +02:00
eea198786a fix(doc): Readthedocs needs manpage plugin
A pitty, I wanted to leave it separated
2025-07-13 15:29:16 +02:00
da9c0a7b58 chore(doc): regenerate and fixes a typo 2025-07-13 15:16:39 +02:00
d582b884bf chore(rules): Avoid mardownlint to complain 2025-07-13 15:16:20 +02:00
aa3e4c64ee chore(ignore): ignoring binary in the current directory 2025-07-13 15:08:32 +02:00
ce479629f6 fix(service): Fixes naming service ports
- ports should be named "port-XXX" with XXX to be the port number if the
port name cannot be discovered
- it follows what we do in Deployment objects
- this should fix #132
2025-07-13 15:02:26 +02:00
89fd516b20 Merge pull request #137 from Katenary/develop
Develop
2025-07-13 00:53:45 +02:00
8bbb991afb chore(doc): Move to new repository 2025-07-13 00:43:21 +02:00
4c5c9ba553 chore(doc): Move to new repository 2025-07-13 00:39:25 +02:00
ef1511d4f7 Merge pull request #134 from Katenary/develop
Develop
2025-07-13 00:21:15 +02:00
a290219c81 chore(licence): I prefer to mention the project 2025-07-13 00:19:02 +02:00
c4e406f855 chore(moving): Moved repository to organization 2025-07-13 00:17:48 +02:00
2beac5f4dd Merge pull request #135 from Katenary/issue-133
fix(deployment): Missed the command from compose file
2025-07-13 00:10:22 +02:00
5f5cd0268a fix(deployment): Missed the command from compose file
Fixes #133
2025-07-13 00:07:07 +02:00
796cbb6d30 chore(package): Rewrite package targets
- rewrite to make packages building more consistent
- add rpm signature with GPG
- auto test packages in several distributions to ensure the packages are
OK

Even if loops to build stuffs are sometimes easier to automate, it's
simpler to fixup if some rules (targets) are explicitly defined.
2025-07-12 09:12:12 +02:00
39ebf7eb78 chore(package): change description, add a final dot 2025-07-12 09:08:41 +02:00
a1c5161ff7 chore(package): Be able to sign RPM 2025-07-12 09:08:28 +02:00
2307ad667e chore(dev): changed how to test version
- force release version check to use "v" (or not) as first character
- one line condtion
2025-07-11 09:17:33 +02:00
a26e832fed fix(doc): recompiled documentation 2025-07-11 09:16:43 +02:00
8582010d90 fix(versionning): Fix version
Version should be x.y.z for releases. It makes things homogenous for
debian version (that needs a number as first char) and it is
semantically better.

At this time, the Makefile is OK. Maybe we don't need `PKG_VERSION`
later.
2025-07-10 15:15:25 +02:00
b7186eb8b4 chore(makefile): Refacto
Refactor the makefile:

- use the "package" container image to build windows installer
- cleanup and reorder targets
- enhance the way we named packages (add version and architecture to the
name)
2025-07-10 08:13:49 +02:00
0f3528818f chore(package): Add NSIS to the package image
This container image can make Windows installer too.
2025-07-10 08:11:39 +02:00
9fadc77979 chore(package): Add application in registry
Allow the application to appear in "Install/Uninstall" Windows
parameters.
2025-07-10 08:10:11 +02:00
13d231a62c feat(package): Add RPM, deb, pacman and tar packages and manpage
Build package using fpm. As I don't want ruby/gem in my computer, the
build system creates an OCI image with Podman (at this time), and
generate dist pacakges.

To enhance the packages, a manpage is now generated from the
documentation.
2025-07-09 14:11:46 +02:00
6cbaa06bec chore(license): Change date and copyright
I keep MIT license, just changed date and pseudo
2025-07-07 23:50:03 +02:00
1552e9c877 Merge pull request #131 from metal3d/develop
Develop
2025-07-07 23:02:13 +02:00
3b2cd37ea4 chore(test): add tests 2025-07-07 22:48:13 +02:00
4c566cbc1a fix(doc): Fix function doc 2025-07-07 22:47:59 +02:00
69c528e5e0 chore(doc): Enhance documentation, fix typo 2025-07-07 22:10:27 +02:00
42bf35593f chore(makefile): rewrite correctly some rules
- cleanup
- sign and check gpg signature
- fixup NSIS installer method
- also sign windows installer
2025-07-07 21:58:15 +02:00
4e739c5f08 fix(doc): Fixing duplicated package 2025-07-07 21:57:14 +02:00
f75623b4ff chore(nsis): sort language
Sort all languages, excepting the first one wich is the default language
2025-07-07 21:31:58 +02:00
d82b5e4a98 feat(nsis): Add more languages, files and license page
- Include maximum of language for the Windows installer
- Add licence page to inform the user that Katenary is free (as freedom)
2025-07-07 18:18:20 +02:00
42c738211c fix(build): Fixing build, do not use alpine
Alpine image seems to break the Windows binary (striped by error) and
makes katenary unusable.
2025-07-07 17:59:16 +02:00
c54bc35c9f feat(nsis): Create installer for Windows
Use nsis to create an installer for Windows user. It installs the binary
for the user (for now) and set the Path to access katenary binary from
cmd or Powershell.
2025-07-07 17:58:21 +02:00
1f406dc558 Merge pull request #130 from metal3d/develop
fix(build): Windows is a shame
2025-07-07 13:50:31 +02:00
0c0b50b0df fix(build): Windows is a shame
- Windows defender says that UPX compressed files are virus
(https://github.com/upx/upx/issues/437) so I stop using this for
Windows. Sorry, you will download a huge binary
- Windows, one more time, stop making the binary working when it's
stripped. Then, one more time, I cannot reduce the binary size

I'm thinking very seriously about no longer offering support for Windows
and letting people compile Katenary on their own.
2025-07-07 13:47:27 +02:00
6efee2fbae Merge pull request #129 from metal3d/develop
Many fixes on code quality and CI
2025-07-06 15:37:08 +02:00
47e149e20b chore(doc): Regenerated doc 2025-07-06 15:36:43 +02:00
d163700147 feat(tests): Add tests for label structures 2025-07-06 15:31:21 +02:00
fa3befaa88 fix(tests): Fixing unbound error 2025-07-06 15:31:05 +02:00
e5b7c0d550 fix(doc): Respect Go recommandation in docstring 2025-07-06 15:30:31 +02:00
9e4663cc6e chore(convention): Respect Go convention, package name should be lowercase 2025-07-06 14:34:16 +02:00
1a5c95d240 fix(ci): typo in permission block 2025-07-06 14:26:20 +02:00
21845c5de1 fix(ci): typo in permission block 2025-07-06 14:24:12 +02:00
4a91d458fd fix(ci): try to add permission block 2025-07-06 14:21:56 +02:00
a52b20efab Merge pull request #128 from metal3d/feat-change-actions
Feat change actions
2025-07-06 14:16:38 +02:00
02c4c5168b feat(ci): Changes CI
- use SonarQube action
- remove the helm installation as it is already present
- changes types and branches activation
2025-07-06 14:13:23 +02:00
7b875454cb feat(chore): use range over int
More readable range
2025-07-06 11:53:56 +02:00
2da5d9df08 feat(chore): modernize code 2025-07-06 11:53:24 +02:00
a0eb3c0bb6 fix(doc): Fix doc string 2025-07-06 11:52:48 +02:00
7e76543c48 fix(doc): Fix the docstring following Go recommandation 2025-07-06 11:41:19 +02:00
09c2c86d59 fix(permission): globalize and fixes
Permission alert frop OpenGrep is wrong, as the directory must use 0755.
To make things working and to ease futur changes, I set the default
permission in a constant.
2025-07-06 11:39:19 +02:00
e58948bb44 feat(code): use better check on empty string 2025-07-06 10:53:18 +02:00
a00b03b2aa feat(chore): Add SAST with opengrep 2025-07-06 10:52:56 +02:00
b47b956798 fix(install): Enhance checks and code
- Opengrep complains about non quoted strings
- Bad indentation fixed
2025-07-06 10:52:35 +02:00
a409a1347e feat(chore): rename variable 2025-07-06 10:51:25 +02:00
8999aabc21 fix(security): Change access rights on generated directories
Ppengrep complains, it is right.
2025-07-06 10:51:09 +02:00
14e8907437 feat(doc): Add package doc for labels 2025-07-06 10:49:54 +02:00
740c400b9a Merge pull request #127 from metal3d/develop
feat(doc): regenerate the package docs
2025-07-04 15:05:34 +02:00
7cd38bbd23 feat(doc): regenerate the package docs 2025-07-04 14:59:49 +02:00
73 changed files with 1648 additions and 612 deletions

View File

@@ -2,12 +2,15 @@ name: Go-Tests
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- develop
push:
branches:
- master
- main
- develop
- 'releases/**'
jobs:
tests:
runs-on: ubuntu-latest
@@ -16,12 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23
- name: Install Helm
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
go-version: 1.24
- name: Launch Test
run: |
go mod tidy
@@ -33,15 +31,18 @@ jobs:
coverprofile.out
gotest.json
sonar:
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: tests-results
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: tests-results
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v5.2.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}

12
.gitignore vendored
View File

@@ -18,3 +18,15 @@ cover*
# will be treated later
/examples/*
# nsis
nsis/*.dll
nsis/*.exe
doc/share
__pycache__
.rpmmacros
*.gpg
katenary

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2022-2024 Patrice Ferlet
Copyright (c) 2022-2025 The Katenary authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

481
Makefile
View File

@@ -1,45 +1,91 @@
CUR_SHA=$(shell git log -n1 --pretty='%h')
CUR_BRANCH=$(shell git branch --show-current)
VERSION=$(shell git describe --exact-match --tags $(CUR_SHA) 2>/dev/null || echo $(CUR_BRANCH)-$(CUR_SHA))
CTN:=$(shell which podman 2>&1 1>/dev/null && echo "podman" || echo "docker")
PREFIX=~/.local
GOVERSION=1.24
GO=container
OUT=katenary
RELEASE=""
BLD_CMD=go build -ldflags="-X 'katenary/generator.Version=$(RELEASE)$(VERSION)'" -o $(OUT) ./cmd/katenary
GOOS=linux
GOARCH=amd64
SIGNER=metal3d@gmail.com
UPX_OPTS =
UPX ?= upx $(UPX_OPTS)
BUILD_IMAGE=docker.io/golang:$(GOVERSION)-alpine
# SHELL=/bin/bash
# List of source files
SOURCES=$(wildcard ./*.go ./*/*.go ./*/*/*.go)
# List of binaries to build and sign
BINARIES=dist/katenary-linux-amd64 dist/katenary-linux-arm64 dist/katenary.exe dist/katenary-darwin-amd64 dist/katenary-freebsd-amd64 dist/katenary-freebsd-arm64
# List of signatures to build
ASC_BINARIES=$(patsubst %,%.asc,$(BINARIES))
# defaults
BROWSER=$(shell command -v epiphany || echo xdg-open)
# Strict mode
SHELL := bash
# strict mode
.SHELLFLAGS := -eu -o pipefail -c
# One session per target
.ONESHELL:
.DELETE_ON_ERROR:
.PHONY: all binaries build check-dist-all check-dist-archlinux check-dist-debian check-dist-fedora check-dist-rocky check-dist-ubuntu check-sign clean-all clean-dist clean-go-cache clean-package-signer cover deb dist dist-full doc freebsd gpg-sign help install install-gomarkdoc katenary manpage packager-oci-image packages pacman prepare pull rpm rpm-sign sast serve-doc show-cover tar test uninstall upx warn-docker
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
.PHONY: help clean build install tests test doc
# Get a version string from git
CUR_SHA=$(shell git log -n1 --pretty='%h')
CUR_BRANCH=$(shell git branch --show-current)
VERSION=$(shell git describe --exact-match --tags $(CUR_SHA) 2>/dev/null || echo $(CUR_BRANCH)-$(CUR_SHA))# use by golang flags
# Go build command and environment variables for target OS and architecture
GOVERSION=1.24
GO=container# container, local
OUTPUT=katenary
GOOS=linux
GOARCH=amd64
CGO_ENABLED=0
PREFIX=~/.local
warn-docker:
@echo -e "\033[1;31mWarning: Docker is not recommended, use Podman instead.\033[0m"
sleep 5
# Get the container (Podman is preferred, but docker can be used too. It may failed with Docker.)
# TODO: propose nerdctl
CTN:=$(shell which podman 2>&1 1>/dev/null && echo "podman" || echo "docker")
ifeq ($(CTN),podman)
CTN_USERMAP=--userns=keep-id
else
$(MAKE) warn-docker
CTN_USERMAP=--user=$(shell id -u):$(shell id -g) -e HOME=/tmp
endif
# Packaging OCI image, to build rpm, deb, pacman, tar packages
# We changes the keep-id uid/gid for Podman, so that the user inside the container is the same as the user outside.
# For Docker, as it doesn't support userns, we use common options, but it may fail...
PKG_OCI_IMAGE=packaging:fedora
ifeq ($(CTN),podman)
# podman
PKG_OCI_OPTS:=--rm -it \
-v ./:/opt/katenary:z \
--userns keep-id:uid=1001,gid=1001 \
$(PKG_OCI_IMAGE)
else
# docker
PKG_OCI_OPTS:=--rm -it \
-v ./:/opt/katenary:z \
-e HOME=/tmp \
$(CTN_USERMAP) \
$(PKG_OCI_IMAGE)
endif
GO_BUILD=go build -ldflags="-X 'katenary/generator.Version=$(VERSION)'" -o $(OUTPUT) ./cmd/katenary
# UPX compression
UPX_OPTS =
UPX ?= upx $(UPX_OPTS)
BUILD_IMAGE=docker.io/golang:$(GOVERSION)
# List of source files
SOURCES=$(shell find -name "*.go" -or -name "*.tpl" -type f | grep -v -P "^./example|^./vendor")
# List of binaries to build and sign
BINARIES=\
dist/katenary-linux-amd64\
dist/katenary-linux-arm64\
dist/katenary-darwin-amd64\
dist/katenary-freebsd-amd64\
dist/katenary-freebsd-arm64\
dist/katenary.exe\
dist/katenary-windows-setup.exe
## GPG
# List of signatures to build
ASC_BINARIES=$(patsubst %,%.asc,$(BINARIES))
# GPG signer
SIGNER=metal3d@gmail.com
# Browser command to see coverage report after tests
BROWSER=$(shell command -v epiphany || echo xdg-open)
all: build
help:
@cat <<EOF | fold -s -w 80
=== HELP ===
@@ -73,11 +119,13 @@ help:
This will build the binary for darwin amd64.
Or you can build all versions:
$$ make build-all
$$ make binaries
EOF
## Standard build
## BUILD
# Simply build the binary for the current OS and architecture
build: pull katenary
pull:
@@ -86,75 +134,263 @@ ifneq ($(GO),local)
@$(CTN) pull $(BUILD_IMAGE)
endif
katenary: $(SOURCES) Makefile go.mod go.sum
katenary: $(SOURCES) go.mod go.sum
ifeq ($(GO),local)
@echo "=> Build on host using go"
$(GO_BUILD)
else
@echo "=> Build in container using" $(CTN)
@$(CTN) run \
-e CGO_ENABLED=$(CGO_ENABLED) \
-e GOOS=$(GOOS) \
-e GOARCH=$(GOARCH) \
--rm -v $(PWD):/go/src/katenary:z \
-w /go/src/katenary \
-v go-cache:/go/pkg/mod:z \
$(CTN_USERMAP) \
$(BUILD_IMAGE) $(GO_BUILD)
endif
echo $(BLD_CMD)
ifeq ($(GO),local)
$(BLD_CMD)
else ifeq ($(CTN),podman)
@podman run -e CGO_ENABLED=0 -e GOOS=$(GOOS) -e GOARCH=$(GOARCH) \
--rm -v $(PWD):/go/src/katenary:z -w /go/src/katenary --userns keep-id $(BUILD_IMAGE) $(BLD_CMD)
else
@docker run -e CGO_ENABLED=0 -e GOOS=$(GOOS) -e GOARCH=$(GOARCH) \
--rm -v $(PWD):/go/src/katenary:z -w /go/src/katenary --user $(shell id -u):$(shell id -g) -e HOME=/tmp $(BUILD_IMAGE) $(BLD_CMD)
endif
echo "=> Stripping if possible"
strip $(OUT) 2>/dev/null || echo "=> No strip available"
## Release build
dist: prepare $(BINARIES) upx $(ASC_BINARIES)
# Make dist, build executables for all platforms, sign them, and compress them with upx if possible.
# Also generate the windows installer.
binaries: prepare $(BINARIES)
dist: binaries upx packages
dist-full: clean-dist dist gpg-sign check-sign rpm-sign check-dist-all
prepare: pull
prepare: pull packager-oci-image
mkdir -p dist
dist/katenary-linux-amd64:
dist/katenary-linux-amd64: $(SOURCES) go.mod go.sum
@echo
@echo -e "\033[1;32mBuilding katenary $(VERSION) for linux-amd64...\033[0m"
$(MAKE) katenary GOOS=linux GOARCH=amd64 OUT=$@
$(MAKE) katenary GOOS=linux GOARCH=amd64 OUTPUT=$@
strip $@
dist/katenary-linux-arm64:
dist/katenary-linux-arm64: $(SOURCES) go.mod go.sum
@echo
@echo -e "\033[1;32mBuilding katenary $(VERSION) for linux-arm...\033[0m"
$(MAKE) katenary GOOS=linux GOARCH=arm64 OUT=$@
$(MAKE) katenary GOOS=linux GOARCH=arm64 OUTPUT=$@
dist/katenary.exe:
dist/katenary.exe: $(SOURCES) go.mod go.sum
@echo
@echo -e "\033[1;32mBuilding katenary $(VERSION) for windows...\033[0m"
$(MAKE) katenary GOOS=windows GOARCH=amd64 OUT=$@
$(MAKE) katenary GOOS=windows GOARCH=amd64 OUTPUT=$@
dist/katenary-darwin-amd64:
dist/katenary-darwin-amd64: $(SOURCES) go.mod go.sum
@echo
@echo -e "\033[1;32mBuilding katenary $(VERSION) for darwin...\033[0m"
$(MAKE) katenary GOOS=darwin GOARCH=amd64 OUT=$@
$(MAKE) katenary GOOS=darwin GOARCH=amd64 OUTPUT=$@
dist/katenary-freebsd-amd64:
dist/katenary-freebsd-amd64: $(SOURCES) go.mod go.sum
@echo
@echo -e "\033[1;32mBuilding katenary $(VERSION) for freebsd...\033[0m"
$(MAKE) katenary GOOS=freebsd GOARCH=amd64 OUT=$@
$(MAKE) katenary GOOS=freebsd GOARCH=amd64 OUTPUT=$@
strip $@
dist/katenary-freebsd-arm64:
dist/katenary-freebsd-arm64: $(SOURCES) go.mod go.sum
@echo
@echo -e "\033[1;32mBuilding katenary $(VERSION) for freebsd-arm64...\033[0m"
$(MAKE) katenary GOOS=freebsd GOARCH=arm64 OUT=$@
$(MAKE) katenary GOOS=freebsd GOARCH=arm64 OUTPUT=$@
dist/katenary-windows-setup.exe: nsis/EnVar.dll dist/katenary.exe
@$(CTN) run -w /opt/katenary $(PKG_OCI_OPTS) \
makensis -DAPP_VERSION=$(VERSION) nsis/katenary.nsi
mv nsis/katenary-windows-setup.exe dist/katenary-windows-setup.exe
# Download the EnVar plugin for NSIS, put it in the nsis directory, and clean up
nsis/EnVar.dll:
curl https://nsis.sourceforge.io/mediawiki/images/7/7f/EnVar_plugin.zip -o nsis/EnVar_plugin.zip
cd nsis
unzip -o EnVar_plugin.zip Plugins/x86-unicode/EnVar.dll
mv Plugins/x86-unicode/EnVar.dll EnVar.dll
rm -rf EnVar_plugin.zip Plugins
# UPX compression
upx: upx-linux upx-darwin
upx-linux: dist/katenary-linux-amd64 dist/katenary-linux-arm64
$(UPX) $^
upx-darwin: dist/katenary-darwin-amd64
$(UPX) --force-macos $^
## Linux / FreeBSD packages with fpm
DESCRIPTION := $(shell cat packaging/description | sed ':a;N;$$!ba;s/\n/\\n/g')
FPM_OPTS=--name katenary \
--url https://katenary.org \
--vendor "Katenary Project" \
--maintainer "Patrice Ferlet <metal3d@gmail.com>" \
--license "MIT" \
--description="$$(printf "$(DESCRIPTION)" | fold -s)"
# base files (doc...)
FPM_BASES=../LICENSE=/usr/local/share/doc/katenary/LICENSE \
../README.md=/usr/local/share/doc/katenary/README.md
FPM_COMMON_FILES=$(FPM_BASES) ../doc/share/man/man1/katenary.1=/usr/local/share/man/man1/katenary.1
# ArchLinux has got inconsistent /usr/local/man directory
FPM_COMMON_FILES_ARCHLINUX=$(FPM_BASES) ../doc/share/man/man1/katenary.1=/usr/local/man/man1/katenary.1 \
# Pacman refuses dashes in version, and should start with a number
PACMAN_VERSION=$(shell echo $(VERSION) | sed 's/-/./g; s/^v//')
define RPM_MACROS
%_signature gpg
%_gpg_path /home/builder/.gnupg
%_gpg_name $(SIGNER)
%_gpgbin /usr/bin/gpg2
%__gpg_sign_cmd %{__gpg} gpg --force-v3-sigs --batch --verbose --no-armor --no-secmem-warning -u "%{_gpg_name}" -sbo %{__signature_filename} --digest-algo sha256 %{__plaintext_filename}'
endef
rpm: dist/katenary-linux-$(GOARCH)
@echo "==> Building RPM packages for $(GOARCH)..."
$(CTN) run -w /opt/katenary/dist $(PKG_OCI_OPTS) \
fpm -s dir -t rpm -a $(GOARCH) -f $(FPM_OPTS) --version=$(VERSION) \
$(FPM_COMMON_FILES) \
./katenary-linux-$(GOARCH)=/usr/local/bin/katenary
rpm-sign:
[ -f .rpmmacros ] || echo "$(RPM_MACROS)" > .rpmmacros
[ -f .secret.gpg ] || gpg --export-secret-keys -a $(SIGNER) > .secret.gpg
$(CTN) run -w /opt/katenary/dist \
-v ./.secret.gpg:/home/builder/signer.gpg \
-v packager-gpg:/home/builder/.gnupg \
$(PKG_OCI_OPTS) \
gpg --import /home/builder/signer.gpg
$(CTN) run -w /opt/katenary/dist \
-v .rpmmacros:/home/builder/.rpmmacros:z \
-v packager-gpg:/home/builder/.gnupg \
$(PKG_OCI_OPTS) \
bash -c 'for rpm in $$(find . -iname "*.rpm"); do echo signing: $$rpm; rpm --addsign $$rpm; done'
deb:
@echo "==> Building DEB packages for $(GOARCH)..."
$(CTN) run -w /opt/katenary/dist $(PKG_OCI_OPTS) \
fpm -s dir -t deb -a $(GOARCH) -f $(FPM_OPTS) --version=$(VERSION) \
$(FPM_COMMON_FILES) \
./katenary-linux-$(GOARCH)=/usr/local/bin/katenary
pacman:
@echo "==> Building Pacman packages for $(GOARCH)..."
$(CTN) run -w /opt/katenary/dist $(PKG_OCI_OPTS) \
fpm -s dir -t pacman -a $(GOARCH) -f $(FPM_OPTS) --version=$(PACMAN_VERSION) \
$(FPM_COMMON_FILES_ARCHLINUX) \
./katenary-linux-$(GOARCH)=/usr/local/bin/katenary
freebsd:
@echo "==> Building FreeBSD packages for $(GOARCH)..."
$(CTN) run -w /opt/katenary/dist $(PKG_OCI_OPTS) \
fpm -s dir -t freebsd -a $(GOARCH) -f $(FPM_OPTS) --version=$(VERSION)\
$(FPM_COMMON_FILES) \
./katenary-freebsd-$(GOARCH)=/usr/local/bin/katenary
mv dist/katenary-$(VERSION).txz dist/katenary-freebsd-$(VERSION).$(GOARCH).txz
tar:
@echo "==> Building TAR packages for $(GOOS) $(GOARCH)..."
$(CTN) run -w /opt/katenary/dist $(PKG_OCI_OPTS) \
fpm -s dir -t tar -a $(GOARCH) -f $(FPM_OPTS) \
$(FPM_COMMON_FILES) \
./katenary-$(GOOS)-$(GOARCH)=/usr/local/bin/katenary
mv dist/katenary.tar dist/katenary-$(GOOS)-$(VERSION).$(GOARCH).tar
packages: manpage packager-oci-image
for arch in amd64 arm64; do \
$(MAKE) rpm GOARCH=$$arch; \
$(MAKE) deb GOARCH=$$arch; \
$(MAKE) pacman GOARCH=$$arch; \
$(MAKE) freebsd GOARCH=$$arch; \
$(MAKE) tar GOARCH=$$arch GOOS=linux; \
$(MAKE) tar GOARCH=$$arch GOOS=freebsd; \
done
packager-oci-image:
@$(CTN) build -t packaging:fedora ./packaging/oci 1>/dev/null
## GPG signing
gpg-sign:
rm -f dist/*.asc
$(MAKE) $(ASC_BINARIES)
check-sign:
@echo "=> Checking signatures..."
@for f in $(ASC_BINARIES); do \
if gpg --verify $$f &>/dev/null; then \
echo "Signature for $$f is valid"; \
else \
echo "Signature for $$f is invalid"; \
exit 1; \
fi; \
done
@echo "=> checking in blank environment..."
keyid=$(shell gpg -k --with-colons $(SIGNER)| grep '^pub' | cut -d: -f5);
$(CTN) run --rm -it -e GPGKEY=$${keyid} -v ./dist:/opt/dist:z \
packaging:fedora \
bash -c '
gpg --recv-key $$GPGKEY || exit 1;
echo "Trusting $(SIGNER) key...";
echo "trusted-key 483493B2DD0845DA8F21A26DF3702E3FAD8F76DC" >> ~/.gnupg/gpg.conf;
gpg --update-trustdb;
rm -f ~/.gnupg/gpg.conf;
for f in /opt/dist/*.asc; do echo "==> $${f}"; gpg --verify $${f}; done;
echo "=> Listing imported keys...";
gpg -k
'
dist/%.asc: dist/%
gpg --armor --detach-sign --default-key $(SIGNER) $< &>/dev/null || exit 1
upx:
$(UPX) dist/katenary-linux-amd64
$(UPX) dist/katenary-linux-arm64
$(UPX) dist/katenary.exe
$(UPX) dist/katenary-darwin-amd64 --force-macos
check-dist-rocky:
@echo "=> Checking Rocky Linux package..."
p=$(wildcard dist/*x86_64.rpm);
$(CTN) run --rm -it -v ./dist:/opt:z quay.io/rockylinux/rockylinux:latest bash -c "
rpm -ivh /opt/$$(basename $$p);
katenary version;
"
check-dist-fedora:
@echo "=> Checking Fedora package..."
p=$(wildcard dist/*x86_64.rpm);
$(CTN) run --rm -it -v ./dist:/opt:z quay.io/fedora/fedora:latest bash -c "
rpm -ivh /opt/$$(basename $$p);
katenary version;
"
check-dist-archlinux:
echo "=> Checking ArchLinux package..."
p=$(wildcard dist/*x86_64.pkg.tar.zst);
$(CTN) run --rm -it -v ./dist:/opt:z quay.io/archlinux/archlinux bash -c "
pacman -U /opt/$$(basename $$p) --noconfirm;
katenary version;
"
check-dist-debian:
@echo "=> Checking Debian package..."
p=$(wildcard dist/*amd64.deb);
$(CTN) run --rm -it -v ./dist:/opt:z debian:latest bash -c "
dpkg -i /opt/$$(basename $$p);
katenary version;
"
check-dist-ubuntu:
@echo "=> Checking Ubuntu package..."
p=$(wildcard dist/*amd64.deb);
$(CTN) run --rm -it -v ./dist:/opt:z ubuntu:latest bash -c "
dpkg -i /opt/$$(basename $$p);
katenary version;
"
check-dist-all:
$(MAKE) check-dist-fedora
$(MAKE) check-dist-rocky
$(MAKE) check-dist-debian
$(MAKE) check-dist-ubuntu
$(MAKE) check-dist-archlinux
## installation and uninstallation
install: build
install -Dm755 katenary $(PREFIX)/bin/katenary
@@ -162,11 +398,7 @@ install: build
uninstall:
rm -f $(PREFIX)/bin/katenary
clean:
rm -rf katenary dist/* release.id
serve-doc: __label_doc
serve-doc: doc
@cd doc && \
[ -d venv ] || python -m venv venv; \
source venv/bin/activate && \
@@ -175,52 +407,31 @@ serve-doc: __label_doc
echo "==> Serving doc with mkdocs..." && \
mkdocs serve
tests: test
test:
@echo -e "\033[1;33mTesting katenary $(VERSION)...\033[0m"
go test -coverprofile=cover.out ./...
$(MAKE) cover
cover:
go tool cover -func=cover.out | grep "total:"
go tool cover -html=cover.out -o cover.html
if [ "$(BROWSER)" = "xdg-open" ]; then
xdg-open cover.html
else
$(BROWSER) -i --new-window cover.html
fi
push-release: build-all
@rm -f release.id
# read personal access token from .git-credentials
TOKEN=$(shell cat .credentials)
# create a new release based on current tag and get the release id
@curl -sSL -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $$TOKEN" \
-d "{\"tag_name\": \"$(VERSION)\", \"target_commitish\": \"\", \"name\": \"$(VERSION)\", \"draft\": true, \"prerelease\": true}" \
https://api.github.com/repos/metal3d/katenary/releases | jq -r '.id' > release.id
@echo "Release id: $$(cat release.id) created"
@echo "Uploading assets..."
# push all dist binary as assets to the release
@for i in $$(find dist -type f -name "katenary*"); do
curl -sSL -H "Authorization: token $$TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/octet-stream" \
--data-binary @$$i \
https://uploads.github.com/repos/metal3d/katenary/releases/$$(cat release.id)/assets?name=$$(basename $$i)
done
@rm -f release.id
## Documentation generation
doc:
@echo "=> Generating documentation..."
# generate the labels doc and code doc
$(MAKE) __label_doc
manpage:
@echo "=> Generating manpage from documentation"
@cd doc && \
[ -d venv ] || python -m venv venv; \
source venv/bin/activate && \
echo "==> Installing requirements in the virtual env..." && \
pip install -qq -r requirements.txt && \
echo "==> Generating manpage..." && \
MANPAGE=true mkdocs build && \
rm -rf site &&
echo "==> Manpage generated in doc/share/man/man1/katenary.1"
install-gomarkdoc:
go install github.com/princjef/gomarkdoc/cmd/gomarkdoc@latest
__label_doc:
@command -v gomarkdoc || (echo "==> We need to install gomarkdoc..." && \
go install github.com/princjef/gomarkdoc/cmd/gomarkdoc@latest)
$(MAKE) install-gomarkdoc)
@echo "=> Generating labels doc..."
# short label doc
go run ./cmd/katenary help-labels -m | \
@@ -242,3 +453,49 @@ __label_doc:
gomarkdoc --repository.default-branch $(shell git branch --show-current) -o doc/docs/packages/$$pack.md $$pack
sed -i '/^## Index/,/^##/ { /## Index/d; /^##/! d }' doc/docs/packages/$$pack.md
done
## TESTS, security analysis, and code quality
# Scan the source code.
# - we don't need detection of text/template as it's not a web application, and
# - we don't need sha1 detection as it is not used for cryptographic purposes.
# Note: metrics are actually not sent to anyone - it's a thing that is removed from the code in the future.
sast:
opengrep \
--config auto \
--exclude-rule go.lang.security.audit.xss.import-text-template.import-text-template \
--exclude-rule go.lang.security.audit.crypto.use_of_weak_crypto.use-of-sha1 \
--metrics=on \
.
test:
@echo -e "\033[1;33mTesting katenary $(VERSION)...\033[0m"
go test -coverprofile=cover.out ./...
$(MAKE) cover
cover:
@go tool cover -func=cover.out | grep "total:"
go tool cover -html=cover.out -o cover.html
show-cover:
@[ -f cover.html ] || (echo "cover.html is not present, run make test before"; exit 1)
if [ "$(BROWSER)" = "xdg-open" ]; then
xdg-open cover.html
else
$(BROWSER) -i --new-window cover.html
fi
## Miscellaneous
clean-all: clean-dist clean-package-signer clean-go-cache
clean-dist:
rm -rf dist
rm -f katenary
clean-package-signer:
rm -f .secret.gpg .rpmmacros
clean-go-cache:
$(CTN) volume rm -f go-cache

183
README.md
View File

@@ -4,9 +4,9 @@
<div style="text-align:center; margin: auto 0 4em 0" align="center">
[![Documentation Status](https://readthedocs.org/projects/katenary/badge/?version=latest)](https://katenary.readthedocs.io/en/latest/?badge=latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/metal3d/katenary)](https://goreportcard.com/report/github.com/metal3d/katenary)
[![GitHub release](https://img.shields.io/github/v/release/metal3d/katenary)](https://github.com/metal3d/katenary/releases)
[![Documentation Status](https://readthedocs.org/projects/katenary/badge/?version=latest)](https://katenary.readthedocs.io/latest/?badge=latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/Katenary/katenary)](https://goreportcard.com/report/github.com/Katenary/katenary)
[![GitHub release](https://img.shields.io/github/v/release/Katenary/katenary)](https://github.com/Katenary/katenary/releases)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=metal3d_katenary&metric=coverage)](https://sonarcloud.io/summary/new_code?id=metal3d_katenary)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=metal3d_katenary&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=metal3d_katenary)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=metal3d_katenary&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=metal3d_katenary)
@@ -41,16 +41,16 @@ The main developer is [Patrice FERLET](https://github.com/metal3d).
## Install
You can download the binaries from the [Release](https://github.com/metal3d/katenary/releases) section. Copy the binary
You can download the binaries from the [Release](https://github.com/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.
You can of course get the binary with `go install -u github.com/metal3d/katenary/cmd/katenary/...` but the `main` branch
You can of course get the binary with `go install -u github.com/Katenary/katenary/cmd/katenary/...` but the `main` branch
is continuously updated. It's preferable to use releases.
You can use this commands on Linux:
```bash
sh <(curl -sSL https://raw.githubusercontent.com/metal3d/katenary/master/install.sh)
sh <(curl -sSL https://raw.githubusercontent.com/Katenary/katenary/master/install.sh)
```
## Or, build yourself
@@ -111,6 +111,7 @@ katenary completion fish | source
## Usage
```text
Katenary is a tool to convert compose files to Helm Charts.
Each [command] and subcommand has got an "help" and "--help" flag to show more information.
@@ -137,69 +138,69 @@ Flags:
Use "katenary [command] --help" for more information about a command.
```
Katenary will try to find a `docker-compose.yaml` or `docker-compose.yml` file inside the current directory. It will
check *the existence of the `chart` directory to create a new Helm Chart inside a named subdirectory. Katenary will ask
you if you want to delete it before recreating.
Katenary will try to find a `docker-compose.yaml` or `docker-compose.yml` file inside the current directory. It will
check \*the existence of the `chart` directory to create a new Helm Chart inside a named subdirectory. Katenary will ask
you if you want to delete it before recreating.
It creates a subdirectory inside `chart` that is named with the `appname` option (default is `MyApp`)
> To respect the ability to install the same application in the same namespace, Katenary will create variable names
> like `{{ .Release.Name }}-servicename`. So, you will need to use some labels inside your docker-compose file to help
> Katenary to build a correct helm chart.
> To respect the ability to install the same application in the same namespace, Katenary will create variable names
> like `{{ .Release.Name }}-servicename`. So, you will need to use some labels inside your docker-compose file to help
> Katenary to build a correct helm chart.
Example of a possible `docker-compose.yaml` file:
Example of a possible `docker-compose.yaml` file:
```yaml
services:
webapp:
image: php:7-apache
environment:
# note that "database" is a "compose" service name
# so we need to adapt it with the map-env label
DB_HOST: database
# a pitty to repeat this values, isn't it?
# so, let's change them with "values-from" label
DB_USER: foo
DB_PASSWORD: bar
expose:
- 80
depends_on:
# this will create a init container waiting for 3306 port
# because it's the "exposed" port
- database
labels:
# expose the port 80 as an ingress
katenary.v3/ingress: |-
hostname: myapp.example.com
port: 80
# make adaptations, DB_HOST environment is actually the service name
katenary.v3/map-env: |-
DB_HOST: '{{ .Release.Name }}-database'
# get the values from the "database" service
# this will use the database secrets and environment,
# see the "database" service to see the values
katenary.v3/values-from: |-
DB_USER: database.MARIADB_USER
DB_PASSWORD: database.MARIADB_PASSWORD
webapp:
image: php:7-apache
environment:
# note that "database" is a "compose" service name
# so we need to adapt it with the map-env label
DB_HOST: database
# a pitty to repeat this values, isn't it?
# so, let's change them with "values-from" label
DB_USER: foo
DB_PASSWORD: bar
expose:
- 80
depends_on:
# this will create a init container waiting for 3306 port
# because it's the "exposed" port
- database
labels:
# expose the port 80 as an ingress
katenary.v3/ingress: |-
hostname: myapp.example.com
port: 80
# make adaptations, DB_HOST environment is actually the service name
katenary.v3/map-env: |-
DB_HOST: '{{ .Release.Name }}-database'
# get the values from the "database" service
# this will use the database secrets and environment,
# see the "database" service to see the values
katenary.v3/values-from: |-
DB_USER: database.MARIADB_USER
DB_PASSWORD: database.MARIADB_PASSWORD
database:
image: mariadb:10
env_file:
# this valuse will be added in a configMap
- my_env.env
environment:
MARIADB_USER: foo
MARIADB_ROOT_PASSWORD: foobar
MARIADB_PASSWORD: bar
labels:
# no need to declare this port in docker-compose
# but katenary will need it
katenary.v3/ports: |-
- 3306
# these variables are secrets
katenary.v3/secrets: |-
- MARIADB_ROOT_PASSWORD
- MARIADB_PASSWORD
database:
image: mariadb:10
env_file:
# this valuse will be added in a configMap
- my_env.env
environment:
MARIADB_USER: foo
MARIADB_ROOT_PASSWORD: foobar
MARIADB_PASSWORD: bar
labels:
# no need to declare this port in docker-compose
# but katenary will need it
katenary.v3/ports: |-
- 3306
# these variables are secrets
katenary.v3/secrets: |-
- MARIADB_ROOT_PASSWORD
- MARIADB_PASSWORD
```
## Labels
@@ -210,22 +211,22 @@ These labels could be found by `katenary help-labels`, and can be placed as labe
To get more information about a label, use `katenary help-label <name_without_prefix>
e.g. katenary help-label dependencies
katenary.v3/configmap-files: list of strings Add files to the configmap.
katenary.v3/cronjob: object Create a cronjob from the service.
katenary.v3/dependencies: list of objects Add Helm dependencies to the service.
katenary.v3/description: string Description of the service
katenary.v3/env-from: list of strings Add environment variables from antoher service.
katenary.v3/exchange-volumes: list of objects Add exchange volumes (empty directory on the node) to share data
katenary.v3/health-check: object Health check to be added to the deployment.
katenary.v3/ignore: bool Ignore the service
katenary.v3/ingress: object Ingress rules to be added to the service.
katenary.v3/main-app: bool Mark the service as the main app.
katenary.v3/map-env: object Map env vars from the service to the deployment.
katenary.v3/ports: list of uint32 Ports to be added to the service.
katenary.v3/same-pod: string Move the same-pod deployment to the target deployment.
katenary.v3/secrets: list of string Env vars to be set as secrets.
katenary.v3/values: list of string or map Environment variables to be added to the values.yaml
katenary.v3/values-from: map[string]string Add values from another service.
katenary.v3/configmap-files: []string Inject files as Configmap.
katenary.v3/cronjob: object Create a cronjob from the service.
katenary.v3/dependencies: []object Add Helm dependencies to the service.
katenary.v3/description: string Description of the service
katenary.v3/env-from: []string Add environment variables from another service.
katenary.v3/exchange-volumes: []object Add exchange volumes (empty directory on the node) to share data
katenary.v3/health-check: object Health check to be added to the deployment.
katenary.v3/ignore: bool Ignore the service
katenary.v3/ingress: object Ingress rules to be added to the service.
katenary.v3/main-app: bool Mark the service as the main app.
katenary.v3/map-env: map[string]string Map env vars from the service to the deployment.
katenary.v3/ports: []uint32 Ports to be added to the service.
katenary.v3/same-pod: string Move the same-pod deployment to the target deployment.
katenary.v3/secrets: []string Env vars to be set as secrets.
katenary.v3/values: []string or map[string]string Environment variables to be added to the values.yaml
katenary.v3/values-from: map[string]string Add values from another service.
```
## Katenary.yaml file and schema validation
@@ -237,25 +238,25 @@ For example, instead of using this:
```yaml
services:
web:
image: nginx:latest
katenary.v3/ingress: |-
hostname: myapp.example.com
port: 80
web:
image: nginx:latest
katenary.v3/ingress: |-
hostname: myapp.example.com
port: 80
```
You can remove the labels, and use a kanetary.yaml file:
You can remove the labels, and use a `katenary.yaml` file:
```yaml
web:
ingress:
hostname: myapp.example.com
port: 80
ingress:
hostname: myapp.example.com
port: 80
```
To validate the `katenary.yaml` file, you can use the JSON schema using the "master" raw content:
`https://raw.githubusercontent.com/metal3d/katenary/refs/heads/master/katenary.json`
`https://raw.githubusercontent.com/Katenary/katenary/refs/heads/master/katenary.json`
It's easy to configure in [LazyVim](https://www.lazyvim.org/), using `nvim-lspconfig`,
create a Lua file in your `plugins` directory, or apply the settings as the example below:
@@ -272,7 +273,7 @@ return {
settings = {
yaml = {
schemas = {
["https://raw.githubusercontent.com/metal3d/katenary/master/katenary.json"] = "katenary.yaml",
["https://raw.githubusercontent.com/Katenary/katenary/master/katenary.json"] = "katenary.yaml",
},
},
},
@@ -287,9 +288,9 @@ Use this address to validate the `katenary.yaml` file in VSCode:
```json
{
"yaml.schemas": {
"https://raw.githubusercontent.com/metal3d/katenary/master/katenary.json": "katenary.yaml"
}
"yaml.schemas": {
"https://raw.githubusercontent.com/Katenary/katenary/master/katenary.json": "katenary.yaml"
}
}
```

View File

@@ -146,7 +146,7 @@ func generateConvertCommand() *cobra.Command {
Use: "convert",
Short: "Converts a docker-compose file to a Helm Chart",
RunE: func(cmd *cobra.Command, args []string) error {
if givenAppVersion != "" {
if len(strings.TrimSpace(givenAppVersion)) > 0 {
appVersion = &givenAppVersion
}
return generator.Convert(generator.ConvertOptions{

View File

@@ -2,4 +2,5 @@ MD012: false
MD013: false
MD022: false
MD033: false
MD041: false
MD046: false

View File

@@ -19,9 +19,10 @@ and flexibility.
Kompose is able to generate Helm charts, but [it could be not the case in future releases](https://github.com/kubernetes/kompose/issues/1716) for several reasons[^2].
[^2]: The author of Kompose explains that they have no bandwidth to maintain the Helm chart generation. It's a complex
task, and we can confirm. Katenary takes a lot of time to be developed and maintained. This issue mentions Katenary as
an alternative to Helm chart generation :smile:
[^2]:
The author of Kompose explains that they have no bandwidth to maintain the Helm chart generation. It's a complex
task, and we can confirm. Katenary takes a lot of time to be developed and maintained. This issue mentions Katenary as
an alternative to Helm chart generation :smile:
The project is focused on Kubernetes manifests and proposes to use "Kustomize" to adapt the manifests. Helm seems to be
not the priority.
@@ -86,9 +87,9 @@ tested some concepts.
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,
if you have some issues, if you have some ideas, please open an issue on the [GitHub repository](https://github.com/metal3d/katenary).
if you have some issues, if you have some ideas, please open an issue on the [GitHub repository](https://github.com/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,
your help is greatly appreciated.
your help is greatly appreciated.
- And then, of course, we need money, or sponsors.
### If you're a company
@@ -105,6 +106,7 @@ All main contributors[^3] will be listed on the website and in the documentation
> If you want to be anonymous, please tell us.
[^3]: Main contributors are the people who have made a significant contribution to the project. It could be code,
documentation, or any other help. There is no defined rules, at this time, to evaluate the contribution.
It's a subjective decision.
[^3]:
Main contributors are the people who have made a significant contribution to the project. It could be code,
documentation, or any other help. There is no defined rules, at this time, to evaluate the contribution.
It's a subjective decision.

View File

@@ -42,13 +42,13 @@ share it with the community.
The main developer is [Patrice FERLET](https://github.com/metal3d).
The project source
code is hosted on the [:fontawesome-brands-github: Katenary GitHub Repository](https://github.com/metal3d/katenary).
code is hosted on the [:fontawesome-brands-github: Katenary GitHub Repository](https://github.com/Katenary/katenary).
## Install Katenary
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 [release
page](https://github.com/metal3d/katenary/releases) of the project in GitHub.
page](https://github.com/Katenary/katenary/releases) of the project in GitHub.
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`.
@@ -57,17 +57,17 @@ If you are a Linux user, you can use the "one line installation command" which w
`$HOME/.local/bin` directory if it exists.
```bash
sh <(curl -sSL https://raw.githubusercontent.com/metal3d/katenary/master/install.sh)
sh <(curl -sSL https://raw.githubusercontent.com/Katenary/katenary/master/install.sh)
```
!!! Info "Upgrading is integrated to the `katenary` command"
Katenary propose a `upgrade` sub-command to update the current binary to the latest stable release.
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:
!!! 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:.
@@ -77,7 +77,7 @@ sh <(curl -sSL https://raw.githubusercontent.com/metal3d/katenary/master/install
To compile it, you can use the following commands:
```bash
git clone https://github.com/metal3d/katenary.git
git clone https://github.com/Katenary/katenary.git
cd katenary
make build
make install
@@ -127,7 +127,7 @@ thing! :heart:
!!! Edit "Special thanks"
**Katenary is built with:** <br />
**Katenary is built with:** <br />
<a href="https://go.dev" target="_blank">:fontawesome-brands-golang:{ .go-logo }</a>

View File

@@ -1,19 +1,28 @@
# Labels documentation
Katenary proposes labels to set in `compose.yaml` files (or override files) to configure the Helm Chart generation. Because it is sometimes needed to have structured values, it is necessary to use the Yaml syntax. While compose labels are string, we can use `|` to use Yaml multilines as value.
Katenary proposes labels to set in `compose.yaml` files (or override files) to configure the Helm Chart generation.
Because it is sometimes needed to have structured values, it is necessary to use the YAML syntax.
While compose labels are string, we can use _here-doc_ syntax using `|` to use YAML multiline as value.
Katenary will try to Unmarshal these labels.
```yaml
label-name: |-
# this is actually a multiline string here
key1: value1
key2: value2
```
Katenary will try to _Unmarshal_ these labels.
## Label list and types
<!-- START_LABEL_DOC : do not remove this tag !-->
| Label name | Description | Type |
| ------------------------------ | ---------------------------------------------------------------- | -------------------------------- |
| `katenary.v3/configmap-files` | Add files to the configmap. | `[]string` |
| `katenary.v3/configmap-files` | Inject files as Configmap. | `[]string` |
| `katenary.v3/cronjob` | Create a cronjob from the service. | `object` |
| `katenary.v3/dependencies` | Add Helm dependencies to the service. | `[]object` |
| `katenary.v3/description` | Description of the service | `string` |
| `katenary.v3/env-from` | Add environment variables from antoher service. | `[]string` |
| `katenary.v3/env-from` | Add environment variables from another service. | `[]string` |
| `katenary.v3/exchange-volumes` | Add exchange volumes (empty directory on the node) to share data | `[]object` |
| `katenary.v3/health-check` | Health check to be added to the deployment. | `object` |
| `katenary.v3/ignore` | Ignore the service | `bool` |
@@ -33,7 +42,7 @@ Katenary will try to Unmarshal these labels.
<!-- START_DETAILED_DOC : do not remove this tag !-->
### katenary.v3/configmap-files
Add files to the configmap.
Inject files as Configmap.
**Type**: `[]string`
@@ -157,7 +166,7 @@ labels:
### katenary.v3/env-from
Add environment variables from antoher service.
Add environment variables from another service.
**Type**: `[]string`

View File

@@ -6,7 +6,7 @@
import "katenary/generator"
```
The generator package generates kubernetes objects from a "compose" file and transforms them into a helm chart.
Package generator generates kubernetes objects from a "compose" file and transforms them into a helm chart.
The generator package is the core of katenary. It is responsible for generating kubernetes objects from a compose file and transforming them into a helm chart. Conversion manipulates Yaml representation of kubernetes object to add conditions, labels, annotations, etc. to the objects. It also create the values to be set to the values.yaml file.
@@ -35,7 +35,7 @@ var Version = "master" // changed at compile time
```
<a name="Convert"></a>
## func [Convert](<https://github.com/metal3d/katenary/blob/develop/generator/converter.go#L99>)
## func [Convert](<https://github.com/katenary/katenary/blob/develop/generator/converter.go#L99>)
```go
func Convert(config ConvertOptions, dockerComposeFile ...string) error
@@ -44,7 +44,7 @@ func Convert(config ConvertOptions, dockerComposeFile ...string) error
Convert a compose \(docker, podman...\) project to a helm chart. It calls Generate\(\) to generate the chart and then write it to the disk.
<a name="GetLabels"></a>
## func [GetLabels](<https://github.com/metal3d/katenary/blob/develop/generator/labels.go#L12>)
## func [GetLabels](<https://github.com/katenary/katenary/blob/develop/generator/labels.go#L12>)
```go
func GetLabels(serviceName, appName string) map[string]string
@@ -53,7 +53,7 @@ func GetLabels(serviceName, appName string) map[string]string
GetLabels returns the labels for a service. It uses the appName to replace the \_\_replace\_\_ in the labels. This is used to generate the labels in the templates.
<a name="GetMatchLabels"></a>
## func [GetMatchLabels](<https://github.com/metal3d/katenary/blob/develop/generator/labels.go#L25>)
## func [GetMatchLabels](<https://github.com/katenary/katenary/blob/develop/generator/labels.go#L25>)
```go
func GetMatchLabels(serviceName, appName string) map[string]string
@@ -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.
<a name="GetVersion"></a>
## func [GetVersion](<https://github.com/metal3d/katenary/blob/develop/generator/version.go#L14>)
## func [GetVersion](<https://github.com/katenary/katenary/blob/develop/generator/version.go#L14>)
```go
func GetVersion() string
@@ -71,7 +71,7 @@ func GetVersion() string
GetVersion return the version of katneary. It's important to understand that the version is set at compile time for the github release. But, it the user get katneary using \`go install\`, the version should be different.
<a name="Helper"></a>
## func [Helper](<https://github.com/metal3d/katenary/blob/develop/generator/helper.go#L15>)
## func [Helper](<https://github.com/katenary/katenary/blob/develop/generator/helper.go#L15>)
```go
func Helper(name string) string
@@ -80,7 +80,7 @@ func Helper(name string) string
Helper returns the \_helpers.tpl file for a chart.
<a name="NewCronJob"></a>
## func [NewCronJob](<https://github.com/metal3d/katenary/blob/develop/generator/cronJob.go#L28>)
## func [NewCronJob](<https://github.com/katenary/katenary/blob/develop/generator/cronJob.go#L28>)
```go
func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (*CronJob, *RBAC)
@@ -89,7 +89,7 @@ func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (
NewCronJob creates a new CronJob from a compose service. The appName is the name of the application taken from the project name.
<a name="ToK8SYaml"></a>
## func [ToK8SYaml](<https://github.com/metal3d/katenary/blob/develop/generator/utils.go#L90>)
## func [ToK8SYaml](<https://github.com/katenary/katenary/blob/develop/generator/utils.go#L90>)
```go
func ToK8SYaml(obj any) ([]byte, error)
@@ -98,7 +98,7 @@ func ToK8SYaml(obj any) ([]byte, error)
<a name="UnWrapTPL"></a>
## func [UnWrapTPL](<https://github.com/metal3d/katenary/blob/develop/generator/utils.go#L86>)
## func [UnWrapTPL](<https://github.com/katenary/katenary/blob/develop/generator/utils.go#L86>)
```go
func UnWrapTPL(in []byte) []byte
@@ -107,7 +107,7 @@ func UnWrapTPL(in []byte) []byte
UnWrapTPL removes the line wrapping from a template.
<a name="ChartTemplate"></a>
## type [ChartTemplate](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L19-L22>)
## type [ChartTemplate](<https://github.com/katenary/katenary/blob/develop/generator/chart.go#L21-L24>)
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>
## type [ConfigMap](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L37-L42>)
## type [ConfigMap](<https://github.com/katenary/katenary/blob/develop/generator/configMap.go#L37-L42>)
ConfigMap is a kubernetes ConfigMap. Implements the DataMap interface.
@@ -131,7 +131,7 @@ type ConfigMap struct {
```
<a name="NewConfigMap"></a>
### func [NewConfigMap](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L46>)
### func [NewConfigMap](<https://github.com/katenary/katenary/blob/develop/generator/configMap.go#L46>)
```go
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".
<a name="NewConfigMapFromDirectory"></a>
### func [NewConfigMapFromDirectory](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L119>)
### func [NewConfigMapFromDirectory](<https://github.com/katenary/katenary/blob/develop/generator/configMap.go#L119>)
```go
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.
<a name="ConfigMap.AddBinaryData"></a>
### func \(\*ConfigMap\) [AddBinaryData](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L157>)
### func \(\*ConfigMap\) [AddBinaryData](<https://github.com/katenary/katenary/blob/develop/generator/configMap.go#L157>)
```go
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.
<a name="ConfigMap.AddData"></a>
### func \(\*ConfigMap\) [AddData](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L152>)
### func \(\*ConfigMap\) [AddData](<https://github.com/katenary/katenary/blob/develop/generator/configMap.go#L152>)
```go
func (c *ConfigMap) AddData(key, value string)
@@ -167,16 +167,16 @@ 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.
<a name="ConfigMap.AppendDir"></a>
### func \(\*ConfigMap\) [AppendDir](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L166>)
### func \(\*ConfigMap\) [AppendDir](<https://github.com/katenary/katenary/blob/develop/generator/configMap.go#L166>)
```go
func (c *ConfigMap) AppendDir(path string) error
```
AddFile adds files from given path to the configmap. It is not recursive, to add all files in a directory, you need to call this function for each subdirectory.
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>
### func \(\*ConfigMap\) [AppendFile](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L213>)
### func \(\*ConfigMap\) [AppendFile](<https://github.com/katenary/katenary/blob/develop/generator/configMap.go#L213>)
```go
func (c *ConfigMap) AppendFile(path string) error
@@ -185,7 +185,7 @@ func (c *ConfigMap) AppendFile(path string) error
<a name="ConfigMap.Filename"></a>
### func \(\*ConfigMap\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L237>)
### func \(\*ConfigMap\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/configMap.go#L237>)
```go
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.
<a name="ConfigMap.SetData"></a>
### func \(\*ConfigMap\) [SetData](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L247>)
### func \(\*ConfigMap\) [SetData](<https://github.com/katenary/katenary/blob/develop/generator/configMap.go#L247>)
```go
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.
<a name="ConfigMap.Yaml"></a>
### func \(\*ConfigMap\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L252>)
### func \(\*ConfigMap\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/configMap.go#L252>)
```go
func (c *ConfigMap) Yaml() ([]byte, error)
@@ -212,7 +212,7 @@ func (c *ConfigMap) Yaml() ([]byte, error)
Yaml returns the yaml representation of the configmap
<a name="ConfigMapMount"></a>
## type [ConfigMapMount](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L28-L31>)
## type [ConfigMapMount](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L28-L31>)
@@ -223,7 +223,7 @@ type ConfigMapMount struct {
```
<a name="ConvertOptions"></a>
## type [ConvertOptions](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L25-L34>)
## type [ConvertOptions](<https://github.com/katenary/katenary/blob/develop/generator/chart.go#L27-L36>)
ConvertOptions are the options to convert a compose project to a helm chart.
@@ -241,7 +241,7 @@ type ConvertOptions struct {
```
<a name="CronJob"></a>
## type [CronJob](<https://github.com/metal3d/katenary/blob/develop/generator/cronJob.go#L22-L25>)
## type [CronJob](<https://github.com/katenary/katenary/blob/develop/generator/cronJob.go#L22-L25>)
CronJob is a kubernetes CronJob.
@@ -253,7 +253,7 @@ type CronJob struct {
```
<a name="CronJob.Filename"></a>
### func \(\*CronJob\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/cronJob.go#L114>)
### func \(\*CronJob\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/cronJob.go#L114>)
```go
func (c *CronJob) Filename() string
@@ -264,7 +264,7 @@ Filename returns the filename of the cronjob.
Implements the Yaml interface.
<a name="CronJob.Yaml"></a>
### func \(\*CronJob\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/cronJob.go#L121>)
### func \(\*CronJob\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/cronJob.go#L121>)
```go
func (c *CronJob) Yaml() ([]byte, error)
@@ -275,7 +275,7 @@ Yaml returns the yaml representation of the cronjob.
Implements the Yaml interface.
<a name="CronJobValue"></a>
## type [CronJobValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L118-L123>)
## type [CronJobValue](<https://github.com/katenary/katenary/blob/develop/generator/values.go#L118-L123>)
CronJobValue is a cronjob configuration that will be saved in values.yaml.
@@ -289,7 +289,7 @@ type CronJobValue struct {
```
<a name="DataMap"></a>
## type [DataMap](<https://github.com/metal3d/katenary/blob/develop/generator/types.go#L4-L7>)
## type [DataMap](<https://github.com/katenary/katenary/blob/develop/generator/types.go#L4-L7>)
DataMap is a kubernetes ConfigMap or Secret. It can be used to add data to the ConfigMap or Secret.
@@ -301,7 +301,7 @@ type DataMap interface {
```
<a name="Deployment"></a>
## type [Deployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L34-L44>)
## type [Deployment](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L34-L44>)
Deployment is a kubernetes Deployment.
@@ -313,7 +313,7 @@ type Deployment struct {
```
<a name="NewDeployment"></a>
### func [NewDeployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L48>)
### func [NewDeployment](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L48>)
```go
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.
<a name="Deployment.AddContainer"></a>
### func \(\*Deployment\) [AddContainer](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L115>)
### func \(\*Deployment\) [AddContainer](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L115>)
```go
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.
<a name="Deployment.AddHealthCheck"></a>
### func \(\*Deployment\) [AddHealthCheck](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L160>)
### func \(\*Deployment\) [AddHealthCheck](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L161>)
```go
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>
### func \(\*Deployment\) [AddIngress](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L189>)
### func \(\*Deployment\) [AddIngress](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L190>)
```go
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.
<a name="Deployment.AddLegacyVolume"></a>
### func \(\*Deployment\) [AddLegacyVolume](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L219>)
### func \(\*Deployment\) [AddLegacyVolume](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L220>)
```go
func (d *Deployment) AddLegacyVolume(name, kind string)
@@ -358,7 +358,7 @@ func (d *Deployment) AddLegacyVolume(name, kind string)
<a name="Deployment.AddVolumes"></a>
### func \(\*Deployment\) [AddVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L195>)
### func \(\*Deployment\) [AddVolumes](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L196>)
```go
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.
<a name="Deployment.BindFrom"></a>
### func \(\*Deployment\) [BindFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L240>)
### func \(\*Deployment\) [BindFrom](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L241>)
```go
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>
### func \(\*Deployment\) [BindMapFilesToContainer](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L374>)
### func \(\*Deployment\) [BindMapFilesToContainer](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L375>)
```go
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>
### func \(\*Deployment\) [DependsOn](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L268>)
### func \(\*Deployment\) [DependsOn](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L269>)
```go
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.
<a name="Deployment.Filename"></a>
### func \(\*Deployment\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L299>)
### func \(\*Deployment\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L300>)
```go
func (d *Deployment) Filename() string
@@ -403,7 +403,7 @@ func (d *Deployment) Filename() string
Filename returns the filename of the deployment.
<a name="Deployment.MountExchangeVolumes"></a>
### func \(\*Deployment\) [MountExchangeVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L425>)
### func \(\*Deployment\) [MountExchangeVolumes](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L426>)
```go
func (d *Deployment) MountExchangeVolumes()
@@ -412,7 +412,7 @@ func (d *Deployment) MountExchangeVolumes()
<a name="Deployment.SetEnvFrom"></a>
### func \(\*Deployment\) [SetEnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L304>)
### func \(\*Deployment\) [SetEnvFrom](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L305>)
```go
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.
<a name="Deployment.Yaml"></a>
### func \(\*Deployment\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L449>)
### func \(\*Deployment\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/deployment.go#L450>)
```go
func (d *Deployment) Yaml() ([]byte, error)
@@ -430,7 +430,7 @@ func (d *Deployment) Yaml() ([]byte, error)
Yaml returns the yaml representation of the deployment.
<a name="FileMapUsage"></a>
## type [FileMapUsage](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L21>)
## type [FileMapUsage](<https://github.com/katenary/katenary/blob/develop/generator/configMap.go#L21>)
FileMapUsage is the usage of the filemap.
@@ -448,7 +448,7 @@ const (
```
<a name="HelmChart"></a>
## type [HelmChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L38-L51>)
## type [HelmChart](<https://github.com/katenary/katenary/blob/develop/generator/chart.go#L40-L53>)
HelmChart is a Helm Chart representation. It contains all the templates, values, versions, helpers...
@@ -460,18 +460,18 @@ type HelmChart struct {
Name string `yaml:"name"`
Icon string `yaml:"icon,omitempty"`
ApiVersion string `yaml:"apiVersion"`
APIVersion string `yaml:"apiVersion"`
Version string `yaml:"version"`
AppVersion string `yaml:"appVersion"`
Description string `yaml:"description"`
Helper string `yaml:"-"`
Dependencies []labelStructs.Dependency `yaml:"dependencies,omitempty"`
Dependencies []labelstructs.Dependency `yaml:"dependencies,omitempty"`
// contains filtered or unexported fields
}
```
<a name="Generate"></a>
### func [Generate](<https://github.com/metal3d/katenary/blob/develop/generator/generator.go#L31>)
### func [Generate](<https://github.com/katenary/katenary/blob/develop/generator/generator.go#L31>)
```go
func Generate(project *types.Project) (*HelmChart, error)
@@ -491,7 +491,7 @@ The Generate function will create the HelmChart object this way:
- Merge the same\-pod services.
<a name="NewChart"></a>
### func [NewChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L54>)
### func [NewChart](<https://github.com/katenary/katenary/blob/develop/generator/chart.go#L56>)
```go
func NewChart(name string) *HelmChart
@@ -500,7 +500,7 @@ func NewChart(name string) *HelmChart
NewChart creates a new empty chart with the given name.
<a name="HelmChart.SaveTemplates"></a>
### func \(\*HelmChart\) [SaveTemplates](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L69>)
### func \(\*HelmChart\) [SaveTemplates](<https://github.com/katenary/katenary/blob/develop/generator/chart.go#L71>)
```go
func (chart *HelmChart) SaveTemplates(templateDir string)
@@ -509,7 +509,7 @@ func (chart *HelmChart) SaveTemplates(templateDir string)
SaveTemplates the templates of the chart to the given directory.
<a name="Ingress"></a>
## type [Ingress](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L17-L21>)
## type [Ingress](<https://github.com/katenary/katenary/blob/develop/generator/ingress.go#L17-L21>)
@@ -521,7 +521,7 @@ type Ingress struct {
```
<a name="NewIngress"></a>
### func [NewIngress](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L24>)
### func [NewIngress](<https://github.com/katenary/katenary/blob/develop/generator/ingress.go#L24>)
```go
func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress
@@ -530,7 +530,7 @@ func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress
NewIngress creates a new Ingress from a compose service.
<a name="Ingress.Filename"></a>
### func \(\*Ingress\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L128>)
### func \(\*Ingress\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/ingress.go#L128>)
```go
func (ingress *Ingress) Filename() string
@@ -539,7 +539,7 @@ func (ingress *Ingress) Filename() string
<a name="Ingress.Yaml"></a>
### func \(\*Ingress\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L132>)
### func \(\*Ingress\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/ingress.go#L132>)
```go
func (ingress *Ingress) Yaml() ([]byte, error)
@@ -548,7 +548,7 @@ func (ingress *Ingress) Yaml() ([]byte, error)
<a name="IngressValue"></a>
## type [IngressValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L29-L36>)
## type [IngressValue](<https://github.com/katenary/katenary/blob/develop/generator/values.go#L29-L36>)
IngressValue is a ingress configuration that will be saved in values.yaml.
@@ -564,7 +564,7 @@ type IngressValue struct {
```
<a name="PersistenceValue"></a>
## type [PersistenceValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L16-L21>)
## type [PersistenceValue](<https://github.com/katenary/katenary/blob/develop/generator/values.go#L16-L21>)
PersistenceValue is a persistence configuration that will be saved in values.yaml.
@@ -578,7 +578,7 @@ type PersistenceValue struct {
```
<a name="RBAC"></a>
## type [RBAC](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L20-L24>)
## type [RBAC](<https://github.com/katenary/katenary/blob/develop/generator/rbac.go#L20-L24>)
RBAC is a kubernetes RBAC containing a role, a rolebinding and an associated serviceaccount.
@@ -591,7 +591,7 @@ type RBAC struct {
```
<a name="NewRBAC"></a>
### func [NewRBAC](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L27>)
### func [NewRBAC](<https://github.com/katenary/katenary/blob/develop/generator/rbac.go#L27>)
```go
func NewRBAC(service types.ServiceConfig, appName string) *RBAC
@@ -600,7 +600,7 @@ func NewRBAC(service types.ServiceConfig, appName string) *RBAC
NewRBAC creates a new RBAC from a compose service. The appName is the name of the application taken from the project name.
<a name="RepositoryValue"></a>
## type [RepositoryValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L10-L13>)
## type [RepositoryValue](<https://github.com/katenary/katenary/blob/develop/generator/values.go#L10-L13>)
RepositoryValue is a docker repository image and tag that will be saved in values.yaml.
@@ -612,7 +612,7 @@ type RepositoryValue struct {
```
<a name="Role"></a>
## type [Role](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L114-L117>)
## type [Role](<https://github.com/katenary/katenary/blob/develop/generator/rbac.go#L114-L117>)
Role is a kubernetes Role.
@@ -624,7 +624,7 @@ type Role struct {
```
<a name="Role.Filename"></a>
### func \(\*Role\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L119>)
### func \(\*Role\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/rbac.go#L119>)
```go
func (r *Role) Filename() string
@@ -633,7 +633,7 @@ func (r *Role) Filename() string
<a name="Role.Yaml"></a>
### func \(\*Role\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L123>)
### func \(\*Role\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/rbac.go#L123>)
```go
func (r *Role) Yaml() ([]byte, error)
@@ -642,7 +642,7 @@ func (r *Role) Yaml() ([]byte, error)
<a name="RoleBinding"></a>
## type [RoleBinding](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L100-L103>)
## type [RoleBinding](<https://github.com/katenary/katenary/blob/develop/generator/rbac.go#L100-L103>)
RoleBinding is a kubernetes RoleBinding.
@@ -654,7 +654,7 @@ type RoleBinding struct {
```
<a name="RoleBinding.Filename"></a>
### func \(\*RoleBinding\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L105>)
### func \(\*RoleBinding\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/rbac.go#L105>)
```go
func (r *RoleBinding) Filename() string
@@ -663,7 +663,7 @@ func (r *RoleBinding) Filename() string
<a name="RoleBinding.Yaml"></a>
### func \(\*RoleBinding\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L109>)
### func \(\*RoleBinding\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/rbac.go#L109>)
```go
func (r *RoleBinding) Yaml() ([]byte, error)
@@ -672,7 +672,7 @@ func (r *RoleBinding) Yaml() ([]byte, error)
<a name="Secret"></a>
## type [Secret](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L22-L25>)
## type [Secret](<https://github.com/katenary/katenary/blob/develop/generator/secret.go#L22-L25>)
Secret is a kubernetes Secret.
@@ -686,7 +686,7 @@ type Secret struct {
```
<a name="NewSecret"></a>
### func [NewSecret](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L28>)
### func [NewSecret](<https://github.com/katenary/katenary/blob/develop/generator/secret.go#L28>)
```go
func NewSecret(service types.ServiceConfig, appName string) *Secret
@@ -695,7 +695,7 @@ func NewSecret(service types.ServiceConfig, appName string) *Secret
NewSecret creates a new Secret from a compose service
<a name="Secret.AddData"></a>
### func \(\*Secret\) [AddData](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L70>)
### func \(\*Secret\) [AddData](<https://github.com/katenary/katenary/blob/develop/generator/secret.go#L70>)
```go
func (s *Secret) AddData(key, value string)
@@ -704,7 +704,7 @@ func (s *Secret) AddData(key, value string)
AddData adds a key value pair to the secret.
<a name="Secret.Filename"></a>
### func \(\*Secret\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L86>)
### func \(\*Secret\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/secret.go#L86>)
```go
func (s *Secret) Filename() string
@@ -713,7 +713,7 @@ func (s *Secret) Filename() string
Filename returns the filename of the secret.
<a name="Secret.SetData"></a>
### func \(\*Secret\) [SetData](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L91>)
### func \(\*Secret\) [SetData](<https://github.com/katenary/katenary/blob/develop/generator/secret.go#L91>)
```go
func (s *Secret) SetData(data map[string]string)
@@ -722,7 +722,7 @@ func (s *Secret) SetData(data map[string]string)
SetData sets the data of the secret.
<a name="Secret.Yaml"></a>
### func \(\*Secret\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L98>)
### func \(\*Secret\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/secret.go#L98>)
```go
func (s *Secret) Yaml() ([]byte, error)
@@ -731,7 +731,7 @@ func (s *Secret) Yaml() ([]byte, error)
Yaml returns the yaml representation of the secret.
<a name="Service"></a>
## type [Service](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L17-L20>)
## type [Service](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L18-L21>)
Service is a kubernetes Service.
@@ -743,7 +743,7 @@ type Service struct {
```
<a name="NewService"></a>
### func [NewService](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L23>)
### func [NewService](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L24>)
```go
func NewService(service types.ServiceConfig, appName string) *Service
@@ -752,7 +752,7 @@ func NewService(service types.ServiceConfig, appName string) *Service
NewService creates a new Service from a compose service.
<a name="Service.AddPort"></a>
### func \(\*Service\) [AddPort](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L52>)
### func \(\*Service\) [AddPort](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L53>)
```go
func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
@@ -761,7 +761,7 @@ func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
AddPort adds a port to the service.
<a name="Service.Filename"></a>
### func \(\*Service\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L76>)
### func \(\*Service\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L78>)
```go
func (s *Service) Filename() string
@@ -770,7 +770,7 @@ func (s *Service) Filename() string
Filename returns the filename of the service.
<a name="Service.Yaml"></a>
### func \(\*Service\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L81>)
### func \(\*Service\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L83>)
```go
func (s *Service) Yaml() ([]byte, error)
@@ -779,7 +779,7 @@ func (s *Service) Yaml() ([]byte, error)
Yaml returns the yaml representation of the service.
<a name="ServiceAccount"></a>
## type [ServiceAccount](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L132-L135>)
## type [ServiceAccount](<https://github.com/katenary/katenary/blob/develop/generator/rbac.go#L132-L135>)
ServiceAccount is a kubernetes ServiceAccount.
@@ -791,7 +791,7 @@ type ServiceAccount struct {
```
<a name="ServiceAccount.Filename"></a>
### func \(\*ServiceAccount\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L137>)
### func \(\*ServiceAccount\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/rbac.go#L137>)
```go
func (r *ServiceAccount) Filename() string
@@ -800,7 +800,7 @@ func (r *ServiceAccount) Filename() string
<a name="ServiceAccount.Yaml"></a>
### func \(\*ServiceAccount\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/rbac.go#L141>)
### func \(\*ServiceAccount\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/rbac.go#L141>)
```go
func (r *ServiceAccount) Yaml() ([]byte, error)
@@ -809,7 +809,7 @@ func (r *ServiceAccount) Yaml() ([]byte, error)
<a name="TLS"></a>
## type [TLS](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L23-L26>)
## type [TLS](<https://github.com/katenary/katenary/blob/develop/generator/values.go#L23-L26>)
@@ -821,7 +821,7 @@ type TLS struct {
```
<a name="Value"></a>
## type [Value](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L39-L50>)
## type [Value](<https://github.com/katenary/katenary/blob/develop/generator/values.go#L39-L50>)
Value will be saved in values.yaml. It contains configuration for all deployment and services.
@@ -841,7 +841,7 @@ type Value struct {
```
<a name="NewValue"></a>
### func [NewValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L57>)
### func [NewValue](<https://github.com/katenary/katenary/blob/develop/generator/values.go#L57>)
```go
func NewValue(service types.ServiceConfig, main ...bool) *Value
@@ -852,7 +852,7 @@ NewValue creates a new Value from a compose service. The value contains the nece
If \`main\` is true, the tag will be empty because it will be set in the helm chart appVersion.
<a name="Value.AddIngress"></a>
### func \(\*Value\) [AddIngress](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L90>)
### func \(\*Value\) [AddIngress](<https://github.com/katenary/katenary/blob/develop/generator/values.go#L90>)
```go
func (v *Value) AddIngress(host, path string)
@@ -861,7 +861,7 @@ func (v *Value) AddIngress(host, path string)
<a name="Value.AddPersistence"></a>
### func \(\*Value\) [AddPersistence](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L104>)
### func \(\*Value\) [AddPersistence](<https://github.com/katenary/katenary/blob/develop/generator/values.go#L104>)
```go
func (v *Value) AddPersistence(volumeName string)
@@ -870,7 +870,7 @@ func (v *Value) AddPersistence(volumeName string)
AddPersistence adds persistence configuration to the Value.
<a name="VolumeClaim"></a>
## type [VolumeClaim](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L18-L23>)
## type [VolumeClaim](<https://github.com/katenary/katenary/blob/develop/generator/volume.go#L18-L23>)
VolumeClaim is a kubernetes VolumeClaim. This is a PersistentVolumeClaim.
@@ -882,7 +882,7 @@ type VolumeClaim struct {
```
<a name="NewVolumeClaim"></a>
### func [NewVolumeClaim](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L26>)
### func [NewVolumeClaim](<https://github.com/katenary/katenary/blob/develop/generator/volume.go#L26>)
```go
func NewVolumeClaim(service types.ServiceConfig, volumeName, appName string) *VolumeClaim
@@ -891,7 +891,7 @@ func NewVolumeClaim(service types.ServiceConfig, volumeName, appName string) *Vo
NewVolumeClaim creates a new VolumeClaim from a compose service.
<a name="VolumeClaim.Filename"></a>
### func \(\*VolumeClaim\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L62>)
### func \(\*VolumeClaim\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/volume.go#L62>)
```go
func (v *VolumeClaim) Filename() string
@@ -900,7 +900,7 @@ func (v *VolumeClaim) Filename() string
Filename returns the suggested filename for a VolumeClaim.
<a name="VolumeClaim.Yaml"></a>
### func \(\*VolumeClaim\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L67>)
### func \(\*VolumeClaim\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/volume.go#L67>)
```go
func (v *VolumeClaim) Yaml() ([]byte, error)
@@ -909,7 +909,7 @@ func (v *VolumeClaim) Yaml() ([]byte, error)
Yaml marshals a VolumeClaim into yaml.
<a name="Yaml"></a>
## type [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/types.go#L10-L13>)
## type [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/types.go#L10-L13>)
Yaml is a kubernetes object that can be converted to yaml.

View File

@@ -6,9 +6,9 @@
import "katenary/generator/extrafiles"
```
extrafiles package provides function to generate the Chart files that are not objects. Like README.md and notes.txt...
Package extrafiles provides function to generate the Chart files that are not objects. Like README.md and notes.txt...
## func [NotesFile](<https://github.com/metal3d/katenary/blob/develop/generator/extrafiles/notes.go#L13>)
## func [NotesFile](<https://github.com/katenary/katenary/blob/develop/generator/extrafiles/notes.go#L13>)
```go
func NotesFile(services []string) string
@@ -17,7 +17,7 @@ func NotesFile(services []string) string
NotesFile returns the content of the note.txt file.
<a name="ReadMeFile"></a>
## func [ReadMeFile](<https://github.com/metal3d/katenary/blob/develop/generator/extrafiles/readme.go#L46>)
## func [ReadMeFile](<https://github.com/katenary/katenary/blob/develop/generator/extrafiles/readme.go#L46>)
```go
func ReadMeFile(charname, description string, values map[string]any) 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.
## func [GenerateSchema](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryfile/main.go#L137>)
## func [GenerateSchema](<https://github.com/katenary/katenary/blob/develop/generator/katenaryfile/main.go#L137>)
```go
func GenerateSchema() string
@@ -21,7 +21,7 @@ func GenerateSchema() string
GenerateSchema generates the schema for the katenary.yaml file.
<a name="OverrideWithConfig"></a>
## func [OverrideWithConfig](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryfile/main.go#L49>)
## func [OverrideWithConfig](<https://github.com/katenary/katenary/blob/develop/generator/katenaryfile/main.go#L49>)
```go
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.
<a name="Service"></a>
## type [Service](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryfile/main.go#L27-L44>)
## type [Service](<https://github.com/katenary/katenary/blob/develop/generator/katenaryfile/main.go#L27-L44>)
Service is a struct that contains the service configuration for katenary
@@ -38,25 +38,25 @@ Service is a struct that contains the service configuration for katenary
type Service struct {
MainApp *bool `json:"main-app,omitempty" jsonschema:"title=Is this service the main application"`
Values []StringOrMap `json:"values,omitempty" jsonschema:"description=Environment variables to be set in values.yaml with or without a description"`
Secrets *labelStructs.Secrets `json:"secrets,omitempty" jsonschema:"title=Secrets,description=Environment variables to be set as secrets"`
Ports *labelStructs.Ports `json:"ports,omitempty" jsonschema:"title=Ports,description=Ports to be exposed in services"`
Ingress *labelStructs.Ingress `json:"ingress,omitempty" jsonschema:"title=Ingress,description=Ingress configuration"`
HealthCheck *labelStructs.HealthCheck `json:"health-check,omitempty" jsonschema:"title=Health Check,description=Health check configuration that respects the kubernetes api"`
Secrets *labelstructs.Secrets `json:"secrets,omitempty" jsonschema:"title=Secrets,description=Environment variables to be set as secrets"`
Ports *labelstructs.Ports `json:"ports,omitempty" jsonschema:"title=Ports,description=Ports to be exposed in services"`
Ingress *labelstructs.Ingress `json:"ingress,omitempty" jsonschema:"title=Ingress,description=Ingress configuration"`
HealthCheck *labelstructs.HealthCheck `json:"health-check,omitempty" jsonschema:"title=Health Check,description=Health check configuration that respects the kubernetes api"`
SamePod *string `json:"same-pod,omitempty" jsonschema:"title=Same Pod,description=Service that should be in the same pod"`
Description *string `json:"description,omitempty" jsonschema:"title=Description,description=Description of the service that will be injected in the values.yaml file"`
Ignore *bool `json:"ignore,omitempty" jsonschema:"title=Ignore,description=Ignore the service in the conversion"`
Dependencies []labelStructs.Dependency `json:"dependencies,omitempty" jsonschema:"title=Dependencies,description=Services that should be injected in the Chart.yaml file"`
ConfigMapFile *labelStructs.ConfigMapFile `json:"configmap-files,omitempty" jsonschema:"title=ConfigMap Files,description=Files that should be injected as ConfigMap"`
MapEnv *labelStructs.MapEnv `json:"map-env,omitempty" jsonschema:"title=Map Env,description=Map environment variables to another value"`
CronJob *labelStructs.CronJob `json:"cron-job,omitempty" jsonschema:"title=Cron Job,description=Cron Job configuration"`
EnvFrom *labelStructs.EnvFrom `json:"env-from,omitempty" jsonschema:"title=Env From,description=Inject environment variables from another service"`
ExchangeVolumes []*labelStructs.ExchangeVolume `json:"exchange-volumes,omitempty" jsonschema:"title=Exchange Volumes,description=Exchange volumes between services"`
ValuesFrom *labelStructs.ValueFrom `json:"values-from,omitempty" jsonschema:"title=Values From,description=Inject values from another service (secret or configmap environment variables)"`
Dependencies []labelstructs.Dependency `json:"dependencies,omitempty" jsonschema:"title=Dependencies,description=Services that should be injected in the Chart.yaml file"`
ConfigMapFile *labelstructs.ConfigMapFile `json:"configmap-files,omitempty" jsonschema:"title=ConfigMap Files,description=Files that should be injected as ConfigMap"`
MapEnv *labelstructs.MapEnv `json:"map-env,omitempty" jsonschema:"title=Map Env,description=Map environment variables to another value"`
CronJob *labelstructs.CronJob `json:"cron-job,omitempty" jsonschema:"title=Cron Job,description=Cron Job configuration"`
EnvFrom *labelstructs.EnvFrom `json:"env-from,omitempty" jsonschema:"title=Env From,description=Inject environment variables from another service"`
ExchangeVolumes []*labelstructs.ExchangeVolume `json:"exchange-volumes,omitempty" jsonschema:"title=Exchange Volumes,description=Exchange volumes between services"`
ValuesFrom *labelstructs.ValueFrom `json:"values-from,omitempty" jsonschema:"title=Values From,description=Inject values from another service (secret or configmap environment variables)"`
}
```
<a name="StringOrMap"></a>
## type [StringOrMap](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryfile/main.go#L24>)
## type [StringOrMap](<https://github.com/katenary/katenary/blob/develop/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

View File

@@ -6,6 +6,8 @@
import "katenary/generator/labels"
```
Package labels provides functionality to parse and manipulate labels.
## Constants
<a name="KatenaryLabelPrefix"></a>
@@ -15,16 +17,16 @@ const KatenaryLabelPrefix = "katenary.v3"
```
<a name="GetLabelHelp"></a>
## func [GetLabelHelp](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L88>)
## func [GetLabelHelp](<https://github.com/katenary/katenary/blob/develop/generator/labels/katenaryLabels.go#L88>)
```go
func GetLabelHelp(asMarkdown bool) string
```
Generate the help for the labels.
GetLabelHelp return the help for the labels.
<a name="GetLabelHelpFor"></a>
## func [GetLabelHelpFor](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L97>)
## func [GetLabelHelpFor](<https://github.com/katenary/katenary/blob/develop/generator/labels/katenaryLabels.go#L97>)
```go
func GetLabelHelpFor(labelname string, asMarkdown bool) string
@@ -33,7 +35,7 @@ func GetLabelHelpFor(labelname string, asMarkdown bool) string
GetLabelHelpFor returns the help for a specific label.
<a name="GetLabelNames"></a>
## func [GetLabelNames](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L72>)
## func [GetLabelNames](<https://github.com/katenary/katenary/blob/develop/generator/labels/katenaryLabels.go#L72>)
```go
func GetLabelNames() []string
@@ -42,7 +44,7 @@ func GetLabelNames() []string
GetLabelNames returns a sorted list of all katenary label names.
<a name="Prefix"></a>
## func [Prefix](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L235>)
## func [Prefix](<https://github.com/katenary/katenary/blob/develop/generator/labels/katenaryLabels.go#L235>)
```go
func Prefix() string
@@ -51,7 +53,7 @@ func Prefix() string
<a name="Help"></a>
## type [Help](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L64-L69>)
## type [Help](<https://github.com/katenary/katenary/blob/develop/generator/labels/katenaryLabels.go#L64-L69>)
Help is the documentation of a label.
@@ -65,7 +67,7 @@ type Help struct {
```
<a name="Label"></a>
## type [Label](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L57>)
## type [Label](<https://github.com/katenary/katenary/blob/develop/generator/labels/katenaryLabels.go#L57>)
Label is a katenary label to find in compose files.
@@ -97,7 +99,7 @@ const (
```
<a name="LabelName"></a>
### func [LabelName](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L59>)
### func [LabelName](<https://github.com/katenary/katenary/blob/develop/generator/labels/katenaryLabels.go#L59>)
```go
func LabelName(name string) Label

View File

@@ -1,14 +1,14 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# labelStructs
# labelstructs
```go
import "katenary/generator/labels/labelStructs"
import "katenary/generator/labels/labelstructs"
```
labelStructs is a package that contains the structs used to represent the labels in the yaml files.
Package labelstructs is a package that contains the structs used to represent the labels in the yaml files.
## type [ConfigMapFile](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/configMap.go#L5>)
## type [ConfigMapFile](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/configMap.go#L5>)
@@ -17,7 +17,7 @@ type ConfigMapFile []string
```
<a name="ConfigMapFileFrom"></a>
### func [ConfigMapFileFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/configMap.go#L7>)
### func [ConfigMapFileFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/configMap.go#L7>)
```go
func ConfigMapFileFrom(data string) (ConfigMapFile, error)
@@ -26,7 +26,7 @@ func ConfigMapFileFrom(data string) (ConfigMapFile, error)
<a name="CronJob"></a>
## type [CronJob](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/cronJob.go#L5-L10>)
## type [CronJob](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/cronJob.go#L5-L10>)
@@ -40,7 +40,7 @@ type CronJob struct {
```
<a name="CronJobFrom"></a>
### func [CronJobFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/cronJob.go#L12>)
### func [CronJobFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/cronJob.go#L12>)
```go
func CronJobFrom(data string) (*CronJob, error)
@@ -49,7 +49,7 @@ func CronJobFrom(data string) (*CronJob, error)
<a name="Dependency"></a>
## type [Dependency](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/dependencies.go#L6-L12>)
## type [Dependency](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/dependencies.go#L6-L12>)
Dependency is a dependency of a chart to other charts.
@@ -64,7 +64,7 @@ type Dependency struct {
```
<a name="DependenciesFrom"></a>
### func [DependenciesFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/dependencies.go#L15>)
### func [DependenciesFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/dependencies.go#L15>)
```go
func DependenciesFrom(data string) ([]Dependency, error)
@@ -73,7 +73,7 @@ func DependenciesFrom(data string) ([]Dependency, error)
DependenciesFrom returns a slice of dependencies from the given string.
<a name="EnvFrom"></a>
## type [EnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/envFrom.go#L5>)
## type [EnvFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/envFrom.go#L5>)
@@ -82,7 +82,7 @@ type EnvFrom []string
```
<a name="EnvFromFrom"></a>
### func [EnvFromFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/envFrom.go#L8>)
### func [EnvFromFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/envFrom.go#L8>)
```go
func EnvFromFrom(data string) (EnvFrom, error)
@@ -91,7 +91,7 @@ func EnvFromFrom(data string) (EnvFrom, error)
EnvFromFrom returns a EnvFrom from the given string.
<a name="ExchangeVolume"></a>
## type [ExchangeVolume](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/exchangeVolume.go#L5-L10>)
## type [ExchangeVolume](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/exchangeVolume.go#L5-L10>)
@@ -105,7 +105,7 @@ type ExchangeVolume struct {
```
<a name="NewExchangeVolumes"></a>
### func [NewExchangeVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/exchangeVolume.go#L12>)
### func [NewExchangeVolumes](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/exchangeVolume.go#L12>)
```go
func NewExchangeVolumes(data string) ([]*ExchangeVolume, error)
@@ -114,7 +114,7 @@ func NewExchangeVolumes(data string) ([]*ExchangeVolume, error)
<a name="HealthCheck"></a>
## type [HealthCheck](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/probes.go#L11-L14>)
## type [HealthCheck](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/probes.go#L11-L14>)
@@ -126,7 +126,7 @@ type HealthCheck struct {
```
<a name="ProbeFrom"></a>
### func [ProbeFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/probes.go#L16>)
### func [ProbeFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/probes.go#L16>)
```go
func ProbeFrom(data string) (*HealthCheck, error)
@@ -135,7 +135,7 @@ func ProbeFrom(data string) (*HealthCheck, error)
<a name="Ingress"></a>
## type [Ingress](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/ingress.go#L14-L22>)
## type [Ingress](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/ingress.go#L14-L22>)
@@ -143,16 +143,16 @@ func ProbeFrom(data string) (*HealthCheck, error)
type Ingress struct {
Port *int32 `yaml:"port,omitempty" json:"port,omitempty"`
Annotations map[string]string `yaml:"annotations,omitempty" jsonschema:"nullable" json:"annotations,omitempty"`
Hostname string `yaml:"hostname" json:"hostname,omitempty"`
Hostname string `yaml:"hostname,omitempty" json:"hostname,omitempty"`
Path *string `yaml:"path,omitempty" json:"path,omitempty"`
Class *string `yaml:"class,omitempty" json:"class,omitempty" jsonschema:"default:-"`
Enabled bool `yaml:"enabled" json:"enabled,omitempty"`
Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
TLS *TLS `yaml:"tls,omitempty" json:"tls,omitempty"`
}
```
<a name="IngressFrom"></a>
### func [IngressFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/ingress.go#L25>)
### func [IngressFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/ingress.go#L25>)
```go
func IngressFrom(data string) (*Ingress, error)
@@ -161,7 +161,7 @@ func IngressFrom(data string) (*Ingress, error)
IngressFrom creates a new Ingress from a compose service.
<a name="MapEnv"></a>
## type [MapEnv](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/mapenv.go#L5>)
## type [MapEnv](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/mapenv.go#L5>)
@@ -170,7 +170,7 @@ type MapEnv map[string]string
```
<a name="MapEnvFrom"></a>
### func [MapEnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/mapenv.go#L8>)
### func [MapEnvFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/mapenv.go#L8>)
```go
func MapEnvFrom(data string) (MapEnv, error)
@@ -179,7 +179,7 @@ func MapEnvFrom(data string) (MapEnv, error)
MapEnvFrom returns a MapEnv from the given string.
<a name="Ports"></a>
## type [Ports](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/ports.go#L5>)
## type [Ports](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/ports.go#L5>)
@@ -188,7 +188,7 @@ type Ports []uint32
```
<a name="PortsFrom"></a>
### func [PortsFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/ports.go#L8>)
### func [PortsFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/ports.go#L8>)
```go
func PortsFrom(data string) (Ports, error)
@@ -197,7 +197,7 @@ func PortsFrom(data string) (Ports, error)
PortsFrom returns a Ports from the given string.
<a name="Secrets"></a>
## type [Secrets](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/secrets.go#L5>)
## type [Secrets](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/secrets.go#L5>)
@@ -206,7 +206,7 @@ type Secrets []string
```
<a name="SecretsFrom"></a>
### func [SecretsFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/secrets.go#L7>)
### func [SecretsFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/secrets.go#L7>)
```go
func SecretsFrom(data string) (Secrets, error)
@@ -215,7 +215,7 @@ func SecretsFrom(data string) (Secrets, error)
<a name="TLS"></a>
## type [TLS](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/ingress.go#L10-L12>)
## type [TLS](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/ingress.go#L10-L12>)
@@ -226,7 +226,7 @@ type TLS struct {
```
<a name="ValueFrom"></a>
## type [ValueFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/valueFrom.go#L5>)
## type [ValueFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/valueFrom.go#L5>)
@@ -235,7 +235,7 @@ type ValueFrom map[string]string
```
<a name="GetValueFrom"></a>
### func [GetValueFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/valueFrom.go#L7>)
### func [GetValueFrom](<https://github.com/katenary/katenary/blob/develop/generator/labels/labelstructs/valueFrom.go#L7>)
```go
func GetValueFrom(data string) (*ValueFrom, error)

View File

@@ -6,9 +6,9 @@
import "katenary/parser"
```
Parser package is a wrapper around compose\-go to parse compose files.
Package parser is a wrapper around compose\-go to parse compose files.
## func [Parse](<https://github.com/metal3d/katenary/blob/develop/parser/main.go#L29>)
## func [Parse](<https://github.com/katenary/katenary/blob/develop/parser/main.go#L29>)
```go
func Parse(profiles []string, envFiles []string, dockerComposeFile ...string) (*types.Project, error)

View File

@@ -6,9 +6,18 @@
import "katenary/utils"
```
Utils package provides some utility functions used in katenary. It defines some constants and functions used in the whole project.
Package utils provides some utility functions used in katenary. It defines some constants and functions used in the whole project.
## func [AsResourceName](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L193>)
## Constants
<a name="DirectoryPermission"></a>DirectoryPermission is the default values for permissions apply to created directories.
```go
const DirectoryPermission = 0o755
```
<a name="AsResourceName"></a>
## func [AsResourceName](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L196>)
```go
func AsResourceName(name string) string
@@ -17,7 +26,7 @@ func AsResourceName(name string) string
AsResourceName returns a resource name with underscores to respect the kubernetes naming convention. It's the opposite of FixedResourceName.
<a name="Confirm"></a>
## func [Confirm](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L161>)
## func [Confirm](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L164>)
```go
func Confirm(question string, icon ...Icon) bool
@@ -26,7 +35,7 @@ func Confirm(question string, icon ...Icon) bool
Confirm asks a question and returns true if the answer is y.
<a name="CountStartingSpaces"></a>
## func [CountStartingSpaces](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L38>)
## func [CountStartingSpaces](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L41>)
```go
func CountStartingSpaces(line string) int
@@ -35,7 +44,7 @@ func CountStartingSpaces(line string) int
CountStartingSpaces counts the number of spaces at the beginning of a string.
<a name="EncodeBasicYaml"></a>
## func [EncodeBasicYaml](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L175>)
## func [EncodeBasicYaml](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L178>)
```go
func EncodeBasicYaml(data any) ([]byte, error)
@@ -44,7 +53,7 @@ func EncodeBasicYaml(data any) ([]byte, error)
EncodeBasicYaml encodes a basic yaml from an interface.
<a name="FixedResourceName"></a>
## func [FixedResourceName](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L187>)
## func [FixedResourceName](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L190>)
```go
func FixedResourceName(name string) string
@@ -53,7 +62,7 @@ func FixedResourceName(name string) string
FixedResourceName returns a resource name without underscores to respect the kubernetes naming convention.
<a name="GetContainerByName"></a>
## func [GetContainerByName](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L84>)
## func [GetContainerByName](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L87>)
```go
func GetContainerByName(name string, containers []corev1.Container) (*corev1.Container, int)
@@ -62,7 +71,7 @@ func GetContainerByName(name string, containers []corev1.Container) (*corev1.Con
GetContainerByName returns a container by name and its index in the array. It returns nil, \-1 if not found.
<a name="GetKind"></a>
## func [GetKind](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L51>)
## func [GetKind](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L54>)
```go
func GetKind(path string) (kind string)
@@ -71,7 +80,7 @@ func GetKind(path string) (kind string)
GetKind returns the kind of the resource from the file path.
<a name="GetServiceNameByPort"></a>
## func [GetServiceNameByPort](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L74>)
## func [GetServiceNameByPort](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L77>)
```go
func GetServiceNameByPort(port int) string
@@ -80,7 +89,7 @@ func GetServiceNameByPort(port int) string
GetServiceNameByPort returns the service name for a port. It the service name is not found, it returns an empty string.
<a name="GetValuesFromLabel"></a>
## func [GetValuesFromLabel](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L126>)
## func [GetValuesFromLabel](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L129>)
```go
func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[string]*EnvConfig
@@ -89,7 +98,7 @@ func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[str
GetValuesFromLabel returns a map of values from a label.
<a name="HashComposefiles"></a>
## func [HashComposefiles](<https://github.com/metal3d/katenary/blob/develop/utils/hash.go#L12>)
## func [HashComposefiles](<https://github.com/katenary/katenary/blob/develop/utils/hash.go#L12>)
```go
func HashComposefiles(files []string) (string, error)
@@ -98,7 +107,7 @@ func HashComposefiles(files []string) (string, error)
HashComposefiles returns a hash of the compose files.
<a name="Int32Ptr"></a>
## func [Int32Ptr](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L32>)
## func [Int32Ptr](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L35>)
```go
func Int32Ptr(i int32) *int32
@@ -107,7 +116,7 @@ func Int32Ptr(i int32) *int32
Int32Ptr returns a pointer to an int32.
<a name="PathToName"></a>
## func [PathToName](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L103>)
## func [PathToName](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L106>)
```go
func PathToName(path string) string
@@ -116,7 +125,7 @@ func PathToName(path string) string
PathToName converts a path to a kubernetes complient name.
<a name="StrPtr"></a>
## func [StrPtr](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L35>)
## func [StrPtr](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L38>)
```go
func StrPtr(s string) *string
@@ -125,7 +134,7 @@ func StrPtr(s string) *string
StrPtr returns a pointer to a string.
<a name="TplName"></a>
## func [TplName](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L19>)
## func [TplName](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L22>)
```go
func TplName(serviceName, appname string, suffix ...string) string
@@ -134,16 +143,16 @@ 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.
<a name="TplValue"></a>
## func [TplValue](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L94>)
## func [TplValue](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L97>)
```go
func TplValue(serviceName, variable string, pipes ...string) string
```
GetContainerByName returns a container by name and its index in the array.
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://github.com/metal3d/katenary/blob/develop/utils/icons.go#L25>)
## func [Warn](<https://github.com/katenary/katenary/blob/develop/utils/icons.go#L25>)
```go
func Warn(msg ...any)
@@ -152,7 +161,7 @@ func Warn(msg ...any)
Warn prints a warning message
<a name="WordWrap"></a>
## func [WordWrap](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L156>)
## func [WordWrap](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L159>)
```go
func WordWrap(text string, lineWidth int) string
@@ -161,7 +170,7 @@ func WordWrap(text string, lineWidth int) string
WordWrap wraps a string to a given line width. Warning: it may break the string. You need to check the result.
<a name="Wrap"></a>
## func [Wrap](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L68>)
## func [Wrap](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L71>)
```go
func Wrap(src, above, below string) string
@@ -170,7 +179,7 @@ func Wrap(src, above, below string) string
Wrap wraps a string with a string above and below. It will respect the indentation of the src string.
<a name="EnvConfig"></a>
## type [EnvConfig](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L120-L123>)
## type [EnvConfig](<https://github.com/katenary/katenary/blob/develop/utils/utils.go#L123-L126>)
EnvConfig is a struct to hold the description of an environment variable.
@@ -182,7 +191,7 @@ type EnvConfig struct {
```
<a name="Icon"></a>
## type [Icon](<https://github.com/metal3d/katenary/blob/develop/utils/icons.go#L6>)
## type [Icon](<https://github.com/katenary/katenary/blob/develop/utils/icons.go#L6>)
Icon is a unicode icon

View File

@@ -13,7 +13,7 @@ katenary convert
This will create a `chart` directory with the helm chart inside.
But, in general, you will need to add a few configuration to help Katenary to transpose the compose file to a working
But, in general, you will need to add a few configurations to help Katenary to transpose the compose file to a working
helm chart.
There are two ways to configure Katenary:
@@ -25,7 +25,7 @@ The Katenary file `katenary.yaml` has benefits over the labels in the compose fi
- you can validate the configuration with a schema, and use completion in your editor
- you separate the configuration and leave the compose file "intact"
- the syntax is a bit simpler, instead of using `katenary.v3/xxx: |-" you can use`xxx: ...`
- the syntax is a bit simpler, instead of using `katenary.v3/xxx: |-` you can use `xxx: ...`
But: **this implies that you have to maintain two files if the compose file changes.**
@@ -34,19 +34,18 @@ For example. With "labels", you should do:
```yaml
# in compose file
services:
webapp:
image: php:7-apache
ports:
- 8080:80
environment:
DB_HOST: database
labels:
katenary.v3/ingress: |-
hostname: myapp.example.com
port: 8080
katenary.v3/map-env: |-
DB_HOST: "{{ .Release.Name }}-database"
webapp:
image: php:7-apache
ports:
- 8080:80
environment:
DB_HOST: database
labels:
katenary.v3/ingress: |-
hostname: myapp.example.com
port: 8080
katenary.v3/map-env: |-
DB_HOST: "{{ .Release.Name }}-database"
```
Using a Katenary file, you can do:
@@ -54,26 +53,26 @@ Using a Katenary file, you can do:
```yaml
# in compose file, no need to add labels
services:
webapp:
image: php:7-apache
ports:
- 8080:80
environment:
DB_HOST: database
webapp:
image: php:7-apache
ports:
- 8080:80
environment:
DB_HOST: database
# in katenary.yaml
webapp:
ingress:
hostname: myapp.example.com
port: 8080
map-env:
DB_HOST: "{{ .Release.Name }}-database"
ingress:
hostname: myapp.example.com
port: 8080
map-env:
DB_HOST: "{{ .Release.Name }}-database"
```
!!! Warning "YAML in multiline label"
Compose only accept text label. So, to put a complete YAML content in the target label,
Compose only accept text label. So, to put a complete YAML content in the target label,
you need to use a pipe char (`|` or `|-`) and to **indent** your content.
For example :
@@ -130,8 +129,8 @@ 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.
!!! 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:
@@ -142,11 +141,11 @@ 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.
!!! 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?
Kubernetes does not provide service or pod starting detection from others pods. But katenary will create init containers
Kubernetes does not provide service or pod starting detection from others pods. But Katenary will create `initContainer`
to make you able to wait for a service to respond. But you'll probably need to adapt a bit the compose file.
See this compose file:
@@ -155,15 +154,15 @@ See this compose file:
version: "3"
services:
webapp:
image: php:8-apache
depends_on:
- database
webapp:
image: php:8-apache
depends_on:
- database
database:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: foobar
database:
image: mariadb
environment:
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
@@ -174,18 +173,18 @@ So, instead of exposing the port in the compose definition, let's declare this t
version: "3"
services:
webapp:
image: php:8-apache
depends_on:
- database
webapp:
image: php:8-apache
depends_on:
- database
database:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: foobar
labels:
katenary.v3/ports: |-
- 3306
database:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: foobar
labels:
katenary.v3/ports: |-
- 3306
```
### Declare ingresses
@@ -197,14 +196,14 @@ Katenary can create this resource for you. You just need to declare the hostname
```yaml
services:
webapp:
image: ...
ports: 8080:5050
labels:
katenary.v3/ingress: |-
# the target port is 5050 wich is the "service" port
port: 5050
hostname: myapp.example.com
webapp:
image: ...
ports: 8080:5050
labels:
katenary.v3/ingress: |-
# the target port is 5050 wich is the "service" port
port: 5050
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
@@ -219,13 +218,13 @@ With a compose file, there is no problem as Docker/Podman allows resolving the n
```yaml
services:
webapp:
image: php:7-apache
environment:
DB_HOST: database
webapp:
image: php:7-apache
environment:
DB_HOST: database
database:
image: mariadb
database:
image: mariadb
```
Katenary prefixes the services with `{{ .Release.Name }}` (to make it possible to install the application several times
@@ -233,16 +232,16 @@ in a namespace), so you need to "remap" the environment variable to the right on
```yaml
services:
webapp:
image: php:7-apache
environment:
DB_HOST: database
labels:
katenary.v3/mapenv: |-
DB_HOST: "{{ .Release.Name }}-database"
webapp:
image: php:7-apache
environment:
DB_HOST: database
labels:
katenary.v3/mapenv: |-
DB_HOST: "{{ .Release.Name }}-database"
database:
image: mariadb
database:
image: mariadb
```
This label can be used to map others environment for any others reason. E.g. to change an informational environment
@@ -250,13 +249,13 @@ variable.
```yaml
services:
webapp:
#...
environment:
RUNNING: docker
labels:
katenary.v3/mapenv: |-
RUNNING: kubernetes
webapp:
#...
environment:
RUNNING: docker
labels:
katenary.v3/mapenv: |-
RUNNING: kubernetes
```
In the above example, `RUNNING` will be set to `kubernetes` when you'll deploy the application with helm, and it's

View File

@@ -1,8 +1,18 @@
site_name: Katenary documentation
docs_dir: ./docs
plugins:
plugins:
- search
- inline-svg
- manpage:
enabled: !ENV [MANPAGE, false]
preprocess: preprocess.py
pages:
- title: Katenary
header: Katenary helm chart generator
output: share/man/man1/katenary.1
inputs:
- usage.md
- labels.md
theme:
name: material
custom_dir: overrides
@@ -42,24 +52,23 @@ extra:
generator: false
social:
- icon: fontawesome/brands/github
link: https://github.com/metal3d/katenary
link: https://github.com/katenary/katenary
nav:
- "Home": index.md
- usage.md
- labels.md
- Behind the scene:
- coding.md
- dependencies.md
- coding.md
- dependencies.md
- FAQ: faq.md
- Go Packages:
- packages/cmd/katenary.md
- packages/parser.md
- packages/utils.md
- Generator:
- Index: packages/generator.md
- ExtraFiles: packages/generator/extrafiles.md
- labels:
- packages/generator/labels.md
- LabelStructs: packages/generator/labels/labelStructs.md
- KatenaryFile: packages/generator/katenaryfile.md
- packages/cmd/katenary.md
- packages/parser.md
- packages/utils.md
- Generator:
- Index: packages/generator.md
- ExtraFiles: packages/generator/extrafiles.md
- labels:
- packages/generator/labels.md
- Labelstructs: packages/generator/labels/labelstructs.md
- KatenaryFile: packages/generator/katenaryfile.md

22
doc/preprocess.py Normal file
View File

@@ -0,0 +1,22 @@
"""Called by mkdocs to preprocess files and build manpages"""
from bs4 import BeautifulSoup, Tag
def to_remove(tag: Tag) -> bool:
"""Removes images, SVGs, links containing images or SVGs, and permalinks from the BeautifulSoup object."""
if tag.name in {"img", "svg"}:
return True
# remove links containing images or SVGs
if tag.name == "a" and tag.img and to_remove(tag.img):
return True
# remove permalinks
if tag.name == "a" and "headerlink" in tag.get("class", ()):
return True
return False
def preprocess(soup: BeautifulSoup, output: str) -> None:
"""Preprocess the BeautifulSoup object to remove unwanted elements."""
for element in soup.find_all(to_remove):
element.decompose()

View File

@@ -5,3 +5,5 @@ pymdown-extensions==10.*
mkdocs-material==9.*
mkdocs-material-extensions==1.*
mkdocs-plugin-inline-svg-mod
beautifulsoup4==4.*
mkdocs-manpage[preprocess]

View File

@@ -3,7 +3,7 @@ package generator
import (
"fmt"
"katenary/generator/labels"
"katenary/generator/labels/labelStructs"
"katenary/generator/labels/labelstructs"
"katenary/utils"
"log"
"maps"
@@ -49,7 +49,7 @@ type HelmChart struct {
AppVersion string `yaml:"appVersion"`
Description string `yaml:"description"`
Helper string `yaml:"-"`
Dependencies []labelStructs.Dependency `yaml:"dependencies,omitempty"`
Dependencies []labelstructs.Dependency `yaml:"dependencies,omitempty"`
}
// NewChart creates a new empty chart with the given name.
@@ -95,7 +95,7 @@ func (chart *HelmChart) SaveTemplates(templateDir string) {
}
servicename := template.Servicename
if err := os.MkdirAll(filepath.Join(templateDir, servicename), 0o755); err != nil {
if err := os.MkdirAll(filepath.Join(templateDir, servicename), utils.DirectoryPermission); err != nil {
fmt.Println(utils.IconFailure, err)
os.Exit(1)
}
@@ -103,7 +103,7 @@ func (chart *HelmChart) SaveTemplates(templateDir string) {
// if the name is a path, create the directory
if strings.Contains(name, string(filepath.Separator)) {
name = filepath.Join(templateDir, name)
err := os.MkdirAll(filepath.Dir(name), 0o755)
err := os.MkdirAll(filepath.Dir(name), utils.DirectoryPermission)
if err != nil {
fmt.Println(utils.IconFailure, err)
os.Exit(1)
@@ -141,7 +141,7 @@ func (chart *HelmChart) generateConfigMapsAndSecrets(project *types.Project) err
maps.Copy(originalEnv, s.Environment)
if v, ok := s.Labels[labels.LabelSecrets]; ok {
list, err := labelStructs.SecretsFrom(v)
list, err := labelstructs.SecretsFrom(v)
if err != nil {
log.Fatal("error unmarshaling secrets label:", err)
}
@@ -214,7 +214,7 @@ func (chart *HelmChart) generateDeployment(service types.ServiceConfig, deployme
if exchange, ok := service.Labels[labels.LabelExchangeVolume]; ok {
// we need to add a volume and a mount point
ex, err := labelStructs.NewExchangeVolumes(exchange)
ex, err := labelstructs.NewExchangeVolumes(exchange)
if err != nil {
return err
}
@@ -298,7 +298,7 @@ func (chart *HelmChart) setCronJob(service types.ServiceConfig, appName string)
func (chart *HelmChart) setDependencies(service types.ServiceConfig) (bool, error) {
// helm dependency
if v, ok := service.Labels[labels.LabelDependencies]; ok {
d, err := labelStructs.DependenciesFrom(v)
d, err := labelstructs.DependenciesFrom(v)
if err != nil {
return false, err
}
@@ -326,7 +326,7 @@ func (chart *HelmChart) setSharedConf(service types.ServiceConfig, deployments m
if _, ok := service.Labels[labels.LabelEnvFrom]; !ok {
return
}
fromservices, err := labelStructs.EnvFromFrom(service.Labels[labels.LabelEnvFrom])
fromservices, err := labelstructs.EnvFromFrom(service.Labels[labels.LabelEnvFrom])
if err != nil {
log.Fatal("error unmarshaling env-from label:", err)
}
@@ -351,7 +351,7 @@ func (chart *HelmChart) setEnvironmentValuesFrom(service types.ServiceConfig, de
if _, ok := service.Labels[labels.LabelValueFrom]; !ok {
return
}
mapping, err := labelStructs.GetValueFrom(service.Labels[labels.LabelValueFrom])
mapping, err := labelstructs.GetValueFrom(service.Labels[labels.LabelValueFrom])
if err != nil {
log.Fatal("error unmarshaling values-from label:", err)
}
@@ -383,7 +383,7 @@ func (chart *HelmChart) setEnvironmentValuesFrom(service types.ServiceConfig, de
// is it a secret?
isSecret := false
secrets, err := labelStructs.SecretsFrom(dep.service.Labels[labels.LabelSecrets])
secrets, err := labelstructs.SecretsFrom(dep.service.Labels[labels.LabelSecrets])
if err == nil {
if slices.Contains(secrets, depName[1]) {
isSecret = true

View File

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

View File

@@ -7,7 +7,7 @@ import (
"katenary/generator/extrafiles"
"katenary/generator/katenaryfile"
"katenary/generator/labels"
"katenary/generator/labels/labelStructs"
"katenary/generator/labels/labelstructs"
"katenary/parser"
"katenary/utils"
"log"
@@ -173,9 +173,8 @@ func Convert(config ConvertOptions, dockerComposeFile ...string) error {
os.RemoveAll(config.OutputDir)
// create the chart directory
if err := os.MkdirAll(templateDir, 0o755); err != nil {
fmt.Println(utils.IconFailure, err)
os.Exit(1)
if err := os.MkdirAll(templateDir, utils.DirectoryPermission); err != nil {
return err
}
// add icon from the command line
@@ -259,7 +258,7 @@ func addCommentsToValues(values []byte) []byte {
return []byte(strings.Join(lines, "\n"))
}
func addDependencyDescription(values []byte, dependencies []labelStructs.Dependency) []byte {
func addDependencyDescription(values []byte, dependencies []labelstructs.Dependency) []byte {
for _, d := range dependencies {
name := d.Name
if d.Alias != "" {
@@ -522,16 +521,16 @@ func buildCharYamlFile(chart *HelmChart, project *types.Project, chartPath strin
os.Exit(1)
}
// concat chart adding a comment with hash of services on top
yamlChart = append([]byte(fmt.Sprintf("# compose hash (sha1): %s\n", *chart.composeHash)), yamlChart...)
yamlChart = append(fmt.Appendf(nil, "# compose hash (sha1): %s\n", *chart.composeHash), yamlChart...)
// add the list of compose files
files := []string{}
for _, file := range project.ComposeFiles {
base := filepath.Base(file)
files = append(files, base)
}
yamlChart = append([]byte(fmt.Sprintf("# compose files: %s\n", strings.Join(files, ", "))), yamlChart...)
yamlChart = append(fmt.Appendf(nil, "# compose files: %s\n", strings.Join(files, ", ")), yamlChart...)
// add generated date
yamlChart = append([]byte(fmt.Sprintf("# generated at: %s\n", time.Now().Format(time.RFC3339))), yamlChart...)
yamlChart = append(fmt.Appendf(nil, "# generated at: %s\n", time.Now().Format(time.RFC3339)), yamlChart...)
// document Chart.yaml file
yamlChart = addChartDoc(yamlChart, project)

View File

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

View File

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

View File

@@ -495,3 +495,39 @@ services:
t.Errorf("Expected valueFrom to be set")
}
}
func TestCheckCommand(t *testing.T) {
composeFile := `
services:
web-app:
image: nginx:1.29
command:
- sh
- -c
- |-
echo "Hello, World!"
echo "Done"
`
// composeFile = fmt.Sprintf(composeFile, labels.Prefix())
tmpDir := setup(composeFile)
defer teardown(tmpDir)
currentDir, _ := os.Getwd()
os.Chdir(tmpDir)
defer os.Chdir(currentDir)
output := internalCompileTest(t, "-s", "templates/web_app/deployment.yaml")
dt := v1.Deployment{}
if err := yaml.Unmarshal([]byte(output), &dt); err != nil {
t.Errorf(unmarshalError, err)
}
// find the command in the container
command := dt.Spec.Template.Spec.Containers[0].Command
if len(command) != 3 {
t.Errorf("Expected command to have 3 elements, got %d", len(command))
}
if command[0] != "sh" || command[1] != "-c" {
t.Errorf("Expected command to be 'sh -c', got %s", strings.Join(command, " "))
}
}

View File

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

View File

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

View File

@@ -5,7 +5,7 @@ import (
"encoding/json"
"fmt"
"katenary/generator/labels"
"katenary/generator/labels/labelStructs"
"katenary/generator/labels/labelstructs"
"katenary/utils"
"log"
"os"
@@ -27,20 +27,20 @@ type StringOrMap any
type Service struct {
MainApp *bool `json:"main-app,omitempty" jsonschema:"title=Is this service the main application"`
Values []StringOrMap `json:"values,omitempty" jsonschema:"description=Environment variables to be set in values.yaml with or without a description"`
Secrets *labelStructs.Secrets `json:"secrets,omitempty" jsonschema:"title=Secrets,description=Environment variables to be set as secrets"`
Ports *labelStructs.Ports `json:"ports,omitempty" jsonschema:"title=Ports,description=Ports to be exposed in services"`
Ingress *labelStructs.Ingress `json:"ingress,omitempty" jsonschema:"title=Ingress,description=Ingress configuration"`
HealthCheck *labelStructs.HealthCheck `json:"health-check,omitempty" jsonschema:"title=Health Check,description=Health check configuration that respects the kubernetes api"`
Secrets *labelstructs.Secrets `json:"secrets,omitempty" jsonschema:"title=Secrets,description=Environment variables to be set as secrets"`
Ports *labelstructs.Ports `json:"ports,omitempty" jsonschema:"title=Ports,description=Ports to be exposed in services"`
Ingress *labelstructs.Ingress `json:"ingress,omitempty" jsonschema:"title=Ingress,description=Ingress configuration"`
HealthCheck *labelstructs.HealthCheck `json:"health-check,omitempty" jsonschema:"title=Health Check,description=Health check configuration that respects the kubernetes api"`
SamePod *string `json:"same-pod,omitempty" jsonschema:"title=Same Pod,description=Service that should be in the same pod"`
Description *string `json:"description,omitempty" jsonschema:"title=Description,description=Description of the service that will be injected in the values.yaml file"`
Ignore *bool `json:"ignore,omitempty" jsonschema:"title=Ignore,description=Ignore the service in the conversion"`
Dependencies []labelStructs.Dependency `json:"dependencies,omitempty" jsonschema:"title=Dependencies,description=Services that should be injected in the Chart.yaml file"`
ConfigMapFile *labelStructs.ConfigMapFile `json:"configmap-files,omitempty" jsonschema:"title=ConfigMap Files,description=Files that should be injected as ConfigMap"`
MapEnv *labelStructs.MapEnv `json:"map-env,omitempty" jsonschema:"title=Map Env,description=Map environment variables to another value"`
CronJob *labelStructs.CronJob `json:"cron-job,omitempty" jsonschema:"title=Cron Job,description=Cron Job configuration"`
EnvFrom *labelStructs.EnvFrom `json:"env-from,omitempty" jsonschema:"title=Env From,description=Inject environment variables from another service"`
ExchangeVolumes []*labelStructs.ExchangeVolume `json:"exchange-volumes,omitempty" jsonschema:"title=Exchange Volumes,description=Exchange volumes between services"`
ValuesFrom *labelStructs.ValueFrom `json:"values-from,omitempty" jsonschema:"title=Values From,description=Inject values from another service (secret or configmap environment variables)"`
Dependencies []labelstructs.Dependency `json:"dependencies,omitempty" jsonschema:"title=Dependencies,description=Services that should be injected in the Chart.yaml file"`
ConfigMapFile *labelstructs.ConfigMapFile `json:"configmap-files,omitempty" jsonschema:"title=ConfigMap Files,description=Files that should be injected as ConfigMap"`
MapEnv *labelstructs.MapEnv `json:"map-env,omitempty" jsonschema:"title=Map Env,description=Map environment variables to another value"`
CronJob *labelstructs.CronJob `json:"cron-job,omitempty" jsonschema:"title=Cron Job,description=Cron Job configuration"`
EnvFrom *labelstructs.EnvFrom `json:"env-from,omitempty" jsonschema:"title=Env From,description=Inject environment variables from another service"`
ExchangeVolumes []*labelstructs.ExchangeVolume `json:"exchange-volumes,omitempty" jsonschema:"title=Exchange Volumes,description=Exchange volumes between services"`
ValuesFrom *labelstructs.ValueFrom `json:"values-from,omitempty" jsonschema:"title=Values From,description=Inject values from another service (secret or configmap environment variables)"`
}
// OverrideWithConfig overrides the project with the katenary.yaml file. It
@@ -117,7 +117,7 @@ func getLabelContent(o any, service *types.ServiceConfig, labelName string) erro
val := strings.TrimSpace(string(c))
if labelName == labels.LabelIngress {
// special case, values must be set from some defaults
ing, err := labelStructs.IngressFrom(val)
ing, err := labelstructs.IngressFrom(val)
if err != nil {
log.Fatal(err)
return err

View File

@@ -57,6 +57,9 @@ webapp:
cli.WithDefaultConfigPath,
)
project, err := cli.ProjectFromOptions(options)
if err != nil {
t.Fatalf("Failed to create project from options: %s", err.Error())
}
OverrideWithConfig(project)
w := project.Services[0].Labels
@@ -107,6 +110,9 @@ webapp:
cli.WithDefaultConfigPath,
)
project, err := cli.ProjectFromOptions(options)
if err != nil {
t.Fatalf("Failed to create project from options: %s", err.Error())
}
OverrideWithConfig(project)
w := project.Services[0].Labels

2
generator/labels/doc.go Normal file
View File

@@ -0,0 +1,2 @@
// Package labels provides functionality to parse and manipulate labels.
package labels

View File

@@ -84,7 +84,7 @@ func init() {
}
}
// Generate the help for the labels.
// GetLabelHelp return the help for the labels.
func GetLabelHelp(asMarkdown bool) string {
names := GetLabelNames() // sorted
if !asMarkdown {

View File

@@ -224,7 +224,7 @@
type: "[]object"
"configmap-files":
short: "Add files to the configmap."
short: "Inject files as Configmap."
long: |-
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
@@ -266,7 +266,7 @@
type: "object"
"env-from":
short: "Add environment variables from antoher service."
short: "Add environment variables from another service."
type: "[]string"
long: |-
It adds environment variables from another service to the current service.

View File

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

View File

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

View File

@@ -0,0 +1,17 @@
package labelstructs_test
import (
"katenary/generator/labels/labelstructs"
"testing"
)
func TestConfigMapFileFrom(t *testing.T) {
ts := "- foo/bar"
tc2, _ := labelstructs.ConfigMapFileFrom(ts)
if len(tc2) != 1 {
t.Errorf("Expected ConfigMapFile to have 1 item, got %d", len(tc2))
}
if tc2[0] != "foo/bar" {
t.Errorf("Expected ConfigMapFile to contain 'foo/bar', got %s", tc2[0])
}
}

View File

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

View File

@@ -0,0 +1,25 @@
package labelstructs
import "testing"
func TestCronJobFrom(t *testing.T) {
ts := `
image: fooimage
command: thecommand
schedule: "0/3 0 * * *"
Rbac: false
`
tc, _ := CronJobFrom(ts)
if tc.Image != "fooimage" {
t.Errorf("Expected CronJob image to be 'fooimage', got %s", tc.Image)
}
if tc.Command != "thecommand" {
t.Errorf("Expected CronJob command to be 'thecommand', got %s", tc.Command)
}
if tc.Schedule != "0/3 0 * * *" {
t.Errorf("Expected CronJob schedule to be '0/3 0 * * *', got %s", tc.Schedule)
}
if tc.Rbac != false {
t.Errorf("Expected CronJob rbac to be false, got %t", tc.Rbac)
}
}

View File

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

View File

@@ -0,0 +1,14 @@
package labelstructs
import "testing"
func TestDependenciesLabel(t *testing.T) {
ts := "- name: mongodb"
tc, _ := DependenciesFrom(ts)
if len(tc) != 1 {
t.Errorf("Expected DependenciesLabel to have 1 item, got %d", len(tc))
}
if tc[0].Name != "mongodb" {
t.Errorf("Expected DependenciesLabel to contain 'mongodb', got %s", tc[0].Name)
}
}

View File

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

View File

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

View File

@@ -0,0 +1,17 @@
package labelstructs
import "testing"
func TestEnvFromLabel(t *testing.T) {
ts := "- foo\n- bar"
tc, _ := EnvFromFrom(ts)
if len(tc) != 2 {
t.Errorf("Expected EnvFrom to have 2 items, got %d", len(tc))
}
if tc[0] != "foo" {
t.Errorf("Expected EnvFrom to contain 'foo', got %s", tc[0])
}
if tc[1] != "bar" {
t.Errorf("Expected EnvFrom to contain 'bar', got %s", tc[1])
}
}

View File

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

View File

@@ -0,0 +1,17 @@
package labelstructs
import "testing"
func TestExchangeVolumeLabel(t *testing.T) {
ts := "- name: exchange-volume\n mountPath: /exchange\n readOnly: true"
tc, _ := NewExchangeVolumes(ts)
if len(tc) != 1 {
t.Errorf("Expected ExchangeVolumeLabel to have 1 item, got %d", len(tc))
}
if tc[0].Name != "exchange-volume" {
t.Errorf("Expected ExchangeVolumeLabel to contain 'exchange-volume', got %s", tc[0].Name)
}
if tc[0].MountPath != "/exchange" {
t.Errorf("Expected MountPath to be '/exchange', got %s", tc[0].MountPath)
}
}

View File

@@ -1,4 +1,4 @@
package labelStructs
package labelstructs
import (
"fmt"
@@ -14,10 +14,10 @@ type TLS struct {
type Ingress struct {
Port *int32 `yaml:"port,omitempty" json:"port,omitempty"`
Annotations map[string]string `yaml:"annotations,omitempty" jsonschema:"nullable" json:"annotations,omitempty"`
Hostname string `yaml:"hostname" json:"hostname,omitempty"`
Hostname string `yaml:"hostname,omitempty" json:"hostname,omitempty"`
Path *string `yaml:"path,omitempty" json:"path,omitempty"`
Class *string `yaml:"class,omitempty" json:"class,omitempty" jsonschema:"default:-"`
Enabled bool `yaml:"enabled" json:"enabled,omitempty"`
Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
TLS *TLS `yaml:"tls,omitempty" json:"tls,omitempty"`
}

View File

@@ -0,0 +1,31 @@
package labelstructs
import "testing"
func TestIngressLabel(t *testing.T) {
ts := "\nhostname: example.com\npath: /\nenabled: true\nport: 8888"
tc, err := IngressFrom(ts)
if err != nil {
t.Errorf("Error parsing IngressLabel: %v", err)
}
if tc.Hostname != "example.com" {
t.Errorf("Expected IngressLabel to contain 'example.com', got %s", tc.Hostname)
}
if tc.Path == nil || *tc.Path != "/" {
t.Errorf("Expected IngressLabel to contain '/', got %v", tc.Path)
}
if tc.Enabled != true {
t.Errorf("Expected IngressLabel to be enabled, got %v", tc.Enabled)
}
if tc.Port == nil || *tc.Port != 8888 {
t.Errorf("Expected IngressLabel to have port 8888, got %d", tc.Port)
}
}
func TestIngressLabelNoPort(t *testing.T) {
ts := "\nhostname: example.com\npath: /\nenabled: true"
_, err := IngressFrom(ts)
if err == nil {
t.Errorf("Expected error when parsing IngressLabel without port, got nil")
}
}

View File

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

View File

@@ -0,0 +1,11 @@
package labelstructs
import "testing"
func TestConfigMapLabel(t *testing.T) {
ts := "foo: bar"
tc, _ := MapEnvFrom(ts)
if len(tc) != 1 {
t.Errorf("Expected ConfigMapFile to have 1 item, got %d", len(tc))
}
}

View File

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

View File

@@ -0,0 +1,23 @@
package labelstructs
import "testing"
func TestPortsFromLabel(t *testing.T) {
data := "- 8080\n- 9090\n"
expected := Ports{8080, 9090}
ports, err := PortsFrom(data)
if err != nil {
t.Fatalf("expected no error, got %v", err)
}
if len(ports) != len(expected) {
t.Fatalf("expected length %d, got %d", len(expected), len(ports))
}
for i, port := range ports {
if port != expected[i] {
t.Errorf("expected port %d at index %d, got %d", expected[i], i, port)
}
}
}

View File

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

View File

@@ -0,0 +1,16 @@
package labelstructs
import "testing"
func TestProbesLabel(t *testing.T) {
readiness := "readinessProbe:\n httpGet:\n path: /healthz\n port: 8080\n initialDelaySeconds: 5\n periodSeconds: 10"
tc, err := ProbeFrom(readiness)
if err != nil {
t.Errorf("Error parsing ProbesLabel: %v %v", err, tc)
}
liveness := "livenessProbe:\n httpGet:\n path: /healthz\n port: 8080\n initialDelaySeconds: 5\n periodSeconds: 10"
tc2, err := ProbeFrom(liveness)
if err != nil {
t.Errorf("Error parsing ProbesLabel: %v %v", err, tc2)
}
}

View File

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

View File

@@ -0,0 +1,17 @@
package labelstructs
import "testing"
func TestSecretLabel(t *testing.T) {
data := "- foo\n- bar"
tc, err := SecretsFrom(data)
if err != nil {
t.Errorf("Error parsing SecretLabel: %v %v", err, tc)
}
items := []string{"foo", "bar"}
for i, item := range tc {
if item != items[i] {
t.Errorf("Expected SecretLabel to contain '%s', got '%s'", items[i], item)
}
}
}

View File

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

View File

@@ -0,0 +1,25 @@
package labelstructs
import (
"testing"
)
func TestValueFromLabel(t *testing.T) {
data := "data: foo\ndata2: bar"
tc, err := GetValueFrom(data)
if err != nil {
t.Fatalf("expected no error, got %v", err)
}
if tc == nil {
t.Fatalf("expected non-nil map, got nil")
}
if len(*tc) != 2 {
t.Errorf("expected 2 items, got %d", len(*tc))
}
if (*tc)["data"] != "foo" {
t.Errorf("expected 'data' to be 'foo', got %s", (*tc)["data"])
}
if (*tc)["data2"] != "bar" {
t.Errorf("expected 'data2' to be 'bar', got %s", (*tc)["data2"])
}
}

View File

@@ -82,7 +82,9 @@ services:
AppVersion: appVersion,
ChartVersion: chartVersion,
}
Convert(convertOptions, "compose.yml")
if err := Convert(convertOptions, "compose.yml"); err != nil {
t.Fatalf("Failed to convert compose file: %s", err)
}
c, err := os.ReadFile("chart/values.yaml")
if err != nil {
t.Fatal(err)

View File

@@ -1,6 +1,7 @@
package generator
import (
"fmt"
"katenary/utils"
"regexp"
"strings"
@@ -59,6 +60,7 @@ func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string) {
if targetPort := utils.GetServiceNameByPort(int(port.Target)); targetPort == "" {
finalport = intstr.FromInt(int(port.Target))
name = fmt.Sprintf("port-%d", port.Target)
} else {
finalport = intstr.FromString(targetPort)
name = targetPort

View File

@@ -47,3 +47,37 @@ services:
t.Errorf("Expected 2 ports, got %d", foundPort)
}
}
func TestWithSeveralUnknownPorts(t *testing.T) {
composeFile := `
services:
multi:
image: nginx
ports:
- 12443
- 12480
labels:
katenary.v3/ingress: |-
port: 12443
`
tmpDir := setup(composeFile)
defer teardown(tmpDir)
currentDir, _ := os.Getwd()
os.Chdir(tmpDir)
defer os.Chdir(currentDir)
output := internalCompileTest(t, "-s", "templates/multi/service.yaml")
service := v1.Service{}
if err := yaml.Unmarshal([]byte(output), &service); err != nil {
t.Errorf(unmarshalError, err)
}
if len(service.Spec.Ports) != 2 {
t.Errorf("Expected 2 ports, got %d", len(service.Spec.Ports))
}
// ensure that both port names are different
if service.Spec.Ports[0].Name == service.Spec.Ports[1].Name {
t.Errorf("Expected different port names, got %s and %s", service.Spec.Ports[0].Name, service.Spec.Ports[1].Name)
}
}

View File

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

View File

@@ -3,6 +3,7 @@ package generator
import (
"fmt"
"katenary/generator/labels"
"katenary/utils"
"os"
"path/filepath"
"testing"
@@ -25,7 +26,7 @@ services:
}
composeFile := filepath.Join(tmpDir, "compose.yaml")
os.MkdirAll(tmpDir, 0755)
os.MkdirAll(tmpDir, utils.DirectoryPermission)
if err := os.WriteFile(composeFile, []byte(composeFileContent), 0644); err != nil {
t.Log(err)
}
@@ -73,7 +74,7 @@ services:
}
composeFile := filepath.Join(tmpDir, "compose.yaml")
os.MkdirAll(tmpDir, 0755)
os.MkdirAll(tmpDir, utils.DirectoryPermission)
if err := os.WriteFile(composeFile, []byte(composeFileContent), 0644); err != nil {
t.Log(err)
}

View File

@@ -1,8 +1,8 @@
package generator
import (
"regexp"
"runtime/debug"
"strings"
)
// Version is the version of katenary. It is set at compile time.
@@ -12,13 +12,17 @@ var Version = "master" // changed at compile time
// the version is set at compile time for the github release. But, it the user get
// katneary using `go install`, the version should be different.
func GetVersion() string {
if strings.HasPrefix(Version, "release-") {
// try to get the semantic version from the Version variable (theorically set at compile time)
if reg := regexp.MustCompile(`^v?\d+.\d+.\d+.*|^release-.*`); reg.MatchString(Version) {
return Version
}
// get the version from the build info
v, ok := debug.ReadBuildInfo()
if ok {
// OK... let's try to get the version from the build info
// get the version from the build info (when installed with go install)
if v, ok := debug.ReadBuildInfo(); ok {
return v.Main.Version + "-" + v.GoVersion
}
// OK... none worked, so we return the default version
return Version
}

View File

@@ -8,11 +8,24 @@ import (
func TestVersion(t *testing.T) {
// we build on "devel" branch
v := GetVersion()
// by default, the version comes from build info and it's a development version
if !strings.Contains(v, "(devel)") {
t.Errorf("Expected version to be set, got %s", v)
}
// now, imagine we are on a release branch
Version = "1.0.0"
v = GetVersion()
if !strings.Contains(v, "1.0.0") {
t.Errorf("Expected version to be set, got %s", v)
}
// now, imagine we are on v1.0.0
Version = "v1.0.0"
v = GetVersion()
if !strings.Contains(v, "v1.0.0") {
t.Errorf("Expected version to be set, got %s", v)
}
// we can also compile a release branch
Version = "release-1.0.0"
v = GetVersion()
if !strings.Contains(v, "release-1.0.0") {

View File

@@ -6,6 +6,7 @@ import (
"image/color"
"image/png"
"katenary/generator/labels"
"katenary/utils"
"log"
"os"
"path/filepath"
@@ -19,7 +20,7 @@ import (
const (
htmlContent = "<html><body><h1>Hello, World!</h1></body></html>"
developementFile = "templates/web/deployment.yaml"
indexHtmlFile = "index.html"
indexHMLFile = "index.html"
)
func TestGenerateWithBoundVolume(t *testing.T) {
@@ -68,7 +69,7 @@ services:
// create a static directory with an index.html file
staticDir := tmpDir + "/static"
os.Mkdir(staticDir, 0o755)
os.Mkdir(staticDir, utils.DirectoryPermission)
indexFile, err := os.Create(staticDir + "/index.html")
if err != nil {
t.Errorf("Failed to create index.html: %s", err)
@@ -106,8 +107,8 @@ services:
if len(data) != 1 {
t.Errorf("Expected 1 data, got %d", len(data))
}
if data[indexHtmlFile] != htmlContent {
t.Errorf("Expected index.html to be "+htmlContent+", got %s", data[indexHtmlFile])
if data[indexHMLFile] != htmlContent {
t.Errorf("Expected index.html to be "+htmlContent+", got %s", data[indexHMLFile])
}
}
@@ -128,7 +129,7 @@ services:
// create a static directory with an index.html file
staticDir := tmpDir + "/static"
os.Mkdir(staticDir, 0o755)
os.Mkdir(staticDir, utils.DirectoryPermission)
indexFile, err := os.Create(staticDir + "/index.html")
if err != nil {
t.Errorf("Failed to create index.html: %s", err)
@@ -153,7 +154,7 @@ services:
}
// but this time, we need a subpath
subPath := dt.Spec.Template.Spec.Containers[0].VolumeMounts[0].SubPath
if subPath != indexHtmlFile {
if subPath != indexHMLFile {
t.Errorf("Expected subpath to be index.html, got %s", subPath)
}
}
@@ -174,15 +175,15 @@ services:
log.Println(tmpDir)
defer teardown(tmpDir)
os.Mkdir(filepath.Join(tmpDir, "images"), 0o755)
os.Mkdir(filepath.Join(tmpDir, "images"), utils.DirectoryPermission)
// create a png image
pngFile := tmpDir + "/images/foo.png"
w, h := 100, 100
img := image.NewRGBA(image.Rect(0, 0, w, h))
red := color.RGBA{255, 0, 0, 255}
for y := 0; y < h; y++ {
for x := 0; x < w; x++ {
for y := range h {
for x := range w {
img.Set(x, y, red)
}
}
@@ -244,15 +245,15 @@ services:
log.Println(tmpDir)
defer teardown(tmpDir)
os.Mkdir(filepath.Join(tmpDir, "images"), 0o755)
os.Mkdir(filepath.Join(tmpDir, "images"), utils.DirectoryPermission)
// create a png image
pngFile := tmpDir + "/images/foo.png"
w, h := 100, 100
img := image.NewRGBA(image.Rect(0, 0, w, h))
red := color.RGBA{255, 0, 0, 255}
for y := 0; y < h; y++ {
for x := 0; x < w; x++ {
for y := range h {
for x := range w {
img.Set(x, y, red)
}
}

2
go.mod
View File

@@ -1,4 +1,4 @@
module katenary // github.com/metal3d/katenary
module katenary // github.com/katenay/katenary
go 1.24.0

View File

@@ -2,7 +2,7 @@
# Install the latest version of the Katenary detecting the right OS and architecture.
# Can be launched with the following command:
# sh <(curl -sSL https://raw.githubusercontent.com/metal3d/katenary/master/install.sh)
# sh <(curl -sSL https://raw.githubusercontent.com/Katenary/katenary/master/install.sh)
set -e
@@ -18,36 +18,36 @@ COMON_INSTALL_PATHS="$HOME/.local/bin $HOME/.bin $HOME/bin"
INSTALL_PATH=""
for p in $COMON_INSTALL_PATHS; do
if [ -d $p ]; then
INSTALL_PATH=$p
break
fi
if [ -d $p ]; then
INSTALL_PATH=$p
break
fi
done
# check if the user has write access to the INSTALL_PATH
if [ -z "$INSTALL_PATH" ]; then
INSTALL_PATH="/usr/local/bin"
if [ ! -w $INSTALL_PATH ]; then
echo "You don't have write access to $INSTALL_PATH"
echo "Please, run with sudo or install locally"
exit 1
fi
INSTALL_PATH="/usr/local/bin"
if [ ! -w $INSTALL_PATH ]; then
echo "You don't have write access to $INSTALL_PATH"
echo "Please, run with sudo or install locally"
exit 1
fi
fi
# ensure that $INSTALL_PATH is in the PATH
if ! echo $PATH | grep -q $INSTALL_PATH; then
echo "Sorry, $INSTALL_PATH is not in the PATH"
echo "Please, add it to your PATH in your shell configuration file"
echo "then restart your shell and run this script again"
exit 1
if ! echo "$PATH" | grep -q "$INSTALL_PATH"; then
echo "Sorry, ${INSTALL_PATH} is not in the PATH"
echo "Please, add it to your PATH in your shell configuration file"
echo "then restart your shell and run this script again"
exit 1
fi
# Where to download the binary
BASE="https://github.com/metal3d/katenary/releases/latest/download/"
BASE="https://github.com/Katenary/katenary/releases/latest/download/"
# for compatibility with older ARM versions
if [ $ARCH = "x86_64" ]; then
ARCH="amd64"
ARCH="amd64"
fi
BIN_URL="$BASE/katenary-$OS-$ARCH"
@@ -58,8 +58,8 @@ echo "Downloading $BIN_URL"
T=$(mktemp -u)
curl -SL -# $BIN_URL -o $T || (echo "Failed to download katenary" && rm -f $T && exit 1)
mv $T $INSTALL_PATH/katenary
chmod +x $INSTALL_PATH/katenary
mv "$T" "${INSTALL_PATH}/katenary"
chmod +x "${INSTALL_PATH}/katenary"
echo
echo "Installed to $INSTALL_PATH/katenary"
echo "Installation complete! Run 'katenary help' to get started."

124
nsis/katenary.nsi Normal file
View File

@@ -0,0 +1,124 @@
!define APP_NAME "Katenary"
!define COMPANY_NAME "Katenary"
OutFile "katenary-windows-setup.exe"
InstallDir "$LOCALAPPDATA\Katenary"
RequestExecutionLevel user
!include "MUI2.nsh"
!addplugindir "."
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English" ; The first language is the default language
!insertmacro MUI_LANGUAGE "Afrikaans"
!insertmacro MUI_LANGUAGE "Albanian"
!insertmacro MUI_LANGUAGE "Arabic"
!insertmacro MUI_LANGUAGE "Armenian"
!insertmacro MUI_LANGUAGE "Asturian"
!insertmacro MUI_LANGUAGE "Basque"
!insertmacro MUI_LANGUAGE "Belarusian"
!insertmacro MUI_LANGUAGE "Bosnian"
!insertmacro MUI_LANGUAGE "Breton"
!insertmacro MUI_LANGUAGE "Bulgarian"
!insertmacro MUI_LANGUAGE "Catalan"
!insertmacro MUI_LANGUAGE "Corsican"
!insertmacro MUI_LANGUAGE "Croatian"
!insertmacro MUI_LANGUAGE "Czech"
!insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "Esperanto"
!insertmacro MUI_LANGUAGE "Estonian"
!insertmacro MUI_LANGUAGE "Farsi"
!insertmacro MUI_LANGUAGE "Finnish"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Galician"
!insertmacro MUI_LANGUAGE "Georgian"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Greek"
!insertmacro MUI_LANGUAGE "Hebrew"
!insertmacro MUI_LANGUAGE "Hindi"
!insertmacro MUI_LANGUAGE "Hungarian"
!insertmacro MUI_LANGUAGE "Icelandic"
!insertmacro MUI_LANGUAGE "Indonesian"
!insertmacro MUI_LANGUAGE "Irish"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Japanese"
!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Kurdish"
!insertmacro MUI_LANGUAGE "Latvian"
!insertmacro MUI_LANGUAGE "Lithuanian"
!insertmacro MUI_LANGUAGE "Luxembourgish"
!insertmacro MUI_LANGUAGE "Macedonian"
!insertmacro MUI_LANGUAGE "Malay"
!insertmacro MUI_LANGUAGE "Mongolian"
!insertmacro MUI_LANGUAGE "Norwegian"
!insertmacro MUI_LANGUAGE "NorwegianNynorsk"
!insertmacro MUI_LANGUAGE "Pashto"
!insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "PortugueseBR"
!insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "ScotsGaelic"
!insertmacro MUI_LANGUAGE "Serbian"
!insertmacro MUI_LANGUAGE "SerbianLatin"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "Slovenian"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "SpanishInternational"
!insertmacro MUI_LANGUAGE "Swedish"
!insertmacro MUI_LANGUAGE "Tatar"
!insertmacro MUI_LANGUAGE "Thai"
!insertmacro MUI_LANGUAGE "TradChinese"
!insertmacro MUI_LANGUAGE "Turkish"
!insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "Uzbek"
!insertmacro MUI_LANGUAGE "Vietnamese"
!insertmacro MUI_LANGUAGE "Welsh"
Name "${APP_NAME} ${APP_VERSION}"
Section "Install"
SetOutPath "$INSTDIR"
File "..\dist\katenary.exe"
File "..\LICENSE"
File "..\README.md"
WriteUninstaller "$INSTDIR\uninstall-katenary.exe"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Katenary" "DisplayName" "Katenary"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Katenary" "UninstallString" "$INSTDIR\uninstall-katenary.exe"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Katenary" "InstallLocation" "$INSTDIR"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Katenary" "DisplayIcon" "$INSTDIR\katenary.exe"
EnVar::SetHKCU
Pop $0
EnVar::AddValue "Path" "$INSTDIR"
Pop $0
SectionEnd
Section "Uninstall"
EnVar::SetHKCU
Pop $0
EnVar::DeleteValue "Path" "$INSTDIR"
Pop $0
Delete "$INSTDIR\katenary.exe"
Delete "$INSTDIR\uninstall-katenary.exe"
Delete "$INSTDIR\LICENSE"
Delete "$INSTDIR\README.md"
RMDir "$INSTDIR"
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Katenary"
SectionEnd

4
packaging/description Normal file
View File

@@ -0,0 +1,4 @@
Katenary transforms docker/podman compose files to Helm Charts.
It harnesses the labels from your "compose" file to craft complete Helm Charts effortlessly, saving you time and energy.
- Simple automated CLI: Katenary handles the grunt work, generating everything needed for seamless service binding and Helm Chart creation.
- Effortless Efficiency: You only need to add labels when it's necessary to precise things. Then call katenary convert and let the magic happen.

View File

@@ -0,0 +1,20 @@
FROM registry.fedoraproject.org/fedora:42
RUN set -eux; \
microdnf -y install \
rubygems rpmbuild rpmsign bsdtar mingw-nsis-base.x86_64 mingw32-nsis.noarch gpg2; \
microdnf clean all;
# create user with 999 UID/GID
RUN set -eux; \
groupadd -g 1001 builder; \
useradd -m -u 1001 -g 1001 -d /home/builder -s /bin/bash builder; \
chown builder:builder /home/builder
USER builder
ENV PATH="/home/builder/bin:${PATH}"
WORKDIR /home/builder
RUN set -eux; \
gem install fpm

View File

@@ -14,6 +14,9 @@ import (
corev1 "k8s.io/api/core/v1"
)
// DirectoryPermission is the default values for permissions apply to created directories.
const DirectoryPermission = 0o755
// TplName returns the name of the kubernetes resource as a template string.
// It is used in the templates and defined in _helper.tpl file.
func TplName(serviceName, appname string, suffix ...string) string {
@@ -90,7 +93,7 @@ func GetContainerByName(name string, containers []corev1.Container) (*corev1.Con
return nil, -1
}
// TplValue returns a container by name and its index in the array.
// TplValue returns a string that can be used in a template to access a value from the values file.
func TplValue(serviceName, variable string, pipes ...string) string {
if len(pipes) == 0 {
return `{{ tpl .Values.` + serviceName + `.` + variable + ` $ }}`

245
utils/utils_test.go Normal file
View File

@@ -0,0 +1,245 @@
package utils
import (
"testing"
corev1 "k8s.io/api/core/v1"
)
func TestTplName(t *testing.T) {
tests := []struct {
name string // description of this test case
// Named input parameters for target function.
serviceName string
appname string
suffix []string
want string
}{
{"simple test without suffix", "foosvc", "myapp", nil, `{{ include "myapp.fullname" . }}-foosvc`},
{"simple test with suffix", "foosvc", "myapp", []string{"bar"}, `{{ include "myapp.fullname" . }}-foosvc-bar`},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := TplName(tt.serviceName, tt.appname, tt.suffix...)
if got != tt.want {
t.Errorf("TplName() = %v, want %v", got, tt.want)
}
})
}
}
func TestCountStartingSpaces(t *testing.T) {
tests := []struct {
name string // description of this test case
// Named input parameters for target function.
line string
want int
}{
{
"test no spaces",
"the line is here",
0,
},
{
"test with 4 spaces",
" line with 4 spaces",
4,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := CountStartingSpaces(tt.line)
if got != tt.want {
t.Errorf("CountStartingSpaces() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetKind(t *testing.T) {
tests := []struct {
name string // description of this test case
// Named input parameters for target function.
path string
want string
}{
{
"test get kind from file path",
"my.deployment.yaml",
"deployment",
},
{
"test with 2 parts",
"service.yaml",
"service",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := GetKind(tt.path)
if got != tt.want {
t.Errorf("GetKind() = %v, want %v", got, tt.want)
}
})
}
}
func TestWrap(t *testing.T) {
tests := []struct {
name string // description of this test case
// Named input parameters for target function.
src string
above string
below string
want string
}{
{
"test a simple wrap",
" - foo: bar",
"line above",
"line below",
" line above\n - foo: bar\n line below",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := Wrap(tt.src, tt.above, tt.below)
if got != tt.want {
t.Errorf("Wrap() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetServiceNameByPort(t *testing.T) {
tests := []struct {
name string // description of this test case
// Named input parameters for target function.
port int
want string
}{
{
"test http port by service number 80",
80,
"http",
},
{
"test with a port that has no service name",
8745,
"",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := GetServiceNameByPort(tt.port)
if got != tt.want {
t.Errorf("GetServiceNameByPort() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetContainerByName(t *testing.T) {
httpContainer := &corev1.Container{
Name: "http",
}
mariadbContainer := &corev1.Container{
Name: "mariadb",
}
tests := []struct {
name string // description of this test case
// Named input parameters for target function.
containerName string
containers []corev1.Container
want *corev1.Container
want2 int
}{
{
"get container from by name",
"http",
[]corev1.Container{
*httpContainer,
*mariadbContainer,
},
httpContainer, 0,
},
{
"get container from by name",
"mariadb",
[]corev1.Container{
*httpContainer,
*mariadbContainer,
},
mariadbContainer, 1,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, got2 := GetContainerByName(tt.containerName, tt.containers)
if got.Name != tt.want.Name {
t.Errorf("GetContainerByName() = %v, want %v", got.Name, tt.want.Name)
}
if got2 != tt.want2 {
t.Errorf("GetContainerByName() = %v, want %v", got2, tt.want2)
}
})
}
}
func TestTplValue(t *testing.T) {
tests := []struct {
name string // description of this test case
// Named input parameters for target function.
serviceName string
variable string
pipes []string
want string
}{
{
"check simple template value",
"foosvc",
"variableFoo",
nil,
"{{ tpl .Values.foosvc.variableFoo $ }}",
},
{
"check with pipes",
"foosvc",
"bar",
[]string{"toYaml", "nindent 2"},
"{{ tpl .Values.foosvc.bar $ | toYaml | nindent 2 }}",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := TplValue(tt.serviceName, tt.variable, tt.pipes...)
if got != tt.want {
t.Errorf("TplValue() = %v, want %v", got, tt.want)
}
})
}
}
func TestPathToName(t *testing.T) {
tests := []struct {
name string // description of this test case
// Named input parameters for target function.
path string
want string
}{
{
"check complete path with various characters",
"./foo/bar.test/and_bad_name",
"foo-bar-test-and-bad-name",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := PathToName(tt.path)
if got != tt.want {
t.Errorf("PathToName() = %v, want %v", got, tt.want)
}
})
}
}