diff --git a/.gitignore b/.gitignore deleted file mode 100644 index ba077a4..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/.woodpecker/helm.yaml b/.woodpecker/helm.yaml index 7fcca44..bc48073 100644 --- a/.woodpecker/helm.yaml +++ b/.woodpecker/helm.yaml @@ -37,22 +37,21 @@ steps: when: - branch: main secrets: - - registry_password + - gitea_token environment: - DISABLE_FORCE_OVERWRITE='true' - ALLOW_OVERWRITE='false' - - REGISTRY_URL=registry.badhouseplants.net - - REGISTRY_USERNAME=woody commands: - | - helm registry login $REGISTRY_URL \ - --username $REGISTRY_USERNAME \ - --password $REGISTRY_PASSWORD + helm registry login git.badhouseplants.net \ + --username allanger \ + --password $GITEA_TOKEN - | for chart in $(find charts -maxdepth 1 -mindepth 1 -type d); do helm package $chart -d chart-packages; done - | for chart in $(find chart-packages -maxdepth 1 -mindepth 1 -type f); do - helm push $chart oci://$REGISTRY_URL/softplayer/helm + helm push $chart oci://git.badhouseplants.net/softplayer done + diff --git a/Makefile b/Makefile deleted file mode 100644 index 267da52..0000000 --- a/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -LOCALBIN ?= $(shell pwd)/bin -$(LOCALBIN): - mkdir -p $(LOCALBIN) - -.PHONY: gen_docs -gen_docs: ## Generate helm documentation - test -s $(LOCALBIN)/helm-docs || GOBIN=$(LOCALBIN) go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest - ./bin/helm-docs --template-files=./README.md.gotmpl --template-files=./docs --sort-values-order file - -.PHONY: gen_schema -gen_schema: ## Generate helm schema - test -s $(LOCALBIN)/helm-schema || GOBIN=$(LOCALBIN) go install github.com/dadav/helm-schema/cmd/helm-schema@latest - ./bin/helm-schema --chart-search-root charts diff --git a/charts/crds/Chart.yaml b/charts/crds/Chart.yaml index 224a6ed..4d50e48 100644 --- a/charts/crds/Chart.yaml +++ b/charts/crds/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: softplayer-lib-crd description: A library to be reused accross softplayer charts type: library -version: 0.1.1 +version: 0.1.0 maintainers: - name: allanger email: allanger@badhouseplants.net diff --git a/charts/crds/templates/metadata/_base.tpl b/charts/crds/templates/metadata/_base.tpl index c734658..769852c 100644 --- a/charts/crds/templates/metadata/_base.tpl +++ b/charts/crds/templates/metadata/_base.tpl @@ -10,4 +10,4 @@ metadata: {{- end }} {{- define "metadata.customName" -}} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/charts/crds/values.schema.json b/charts/crds/values.schema.json deleted file mode 100644 index 3e67707..0000000 --- a/charts/crds/values.schema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "additionalProperties": false, - "properties": { - "global": { - "description": "Global values are values that can be accessed from any chart or subchart by exactly the same name.", - "title": "global", - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object" -} \ No newline at end of file diff --git a/charts/workload/Chart.yaml b/charts/workload/Chart.yaml index d6b3bb9..1e01e39 100644 --- a/charts/workload/Chart.yaml +++ b/charts/workload/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: softplayer-lib-workload description: A library to be reused accross softplayer charts type: library -version: 0.2.1 +version: 0.1.0 maintainers: - name: allanger email: allanger@badhouseplants.net diff --git a/charts/workload/templates/addons/traefik/_ingress_route_tcp.tpl b/charts/workload/templates/addons/traefik/_ingress_route_tcp.tpl index f477fea..8761e18 100644 --- a/charts/workload/templates/addons/traefik/_ingress_route_tcp.tpl +++ b/charts/workload/templates/addons/traefik/_ingress_route_tcp.tpl @@ -2,7 +2,7 @@ {{- range $k, $v := .Values.traefik.tcpRoutes }} {{- $customName := printf "%s-%s" (include "chart.fullname" $) $k }} --- -{{- if $.Capabilities.APIVersions.Has "traefik.io/v1alpha1/IngressRouteTCP" }} +{{- if .Capabilities.APIVersions.Has "traefik.io/v1alpha1/IngressRouteTCP" }} apiVersion: traefik.io/v1alpha1 kind: IngressRouteTCP {{- include "lib.metadata" (dict "Context" $ "customName" $customName)}} diff --git a/charts/workload/templates/addons/traefik/_ingress_route_udp.tpl b/charts/workload/templates/addons/traefik/_ingress_route_udp.tpl index c98dd66..823930b 100644 --- a/charts/workload/templates/addons/traefik/_ingress_route_udp.tpl +++ b/charts/workload/templates/addons/traefik/_ingress_route_udp.tpl @@ -2,7 +2,7 @@ {{- range $k, $v := .Values.traefik.udpRoutes }} {{- $customName := printf "%s-%s" (include "chart.fullname" $) $k }} --- -{{- if $.Capabilities.APIVersions.Has "traefik.io/v1alpha1/IngressRouteUDP" }} +{{- if .Capabilities.APIVersions.Has "traefik.io/v1alpha1/IngressRouteUDP" }} apiVersion: traefik.io/v1alpha1 kind: IngressRouteUDP {{- include "lib.metadata" (dict "Context" $ "customName" $customName)}} diff --git a/charts/workload/templates/configs/_env.tpl b/charts/workload/templates/configs/_env.tpl index 806b318..6137725 100644 --- a/charts/workload/templates/configs/_env.tpl +++ b/charts/workload/templates/configs/_env.tpl @@ -1,7 +1,6 @@ {{- define "lib.config.env" -}} {{- range $k, $v := .Values.env }} {{- $customName := printf "%s-%s" (include "chart.fullname" $) $k }} -{{- if $v.enabled }} --- apiVersion: v1 {{- if not $v.sensitive }} @@ -13,11 +12,9 @@ kind: Secret {{- include "lib.metadata" (dict "Context" $ "customName" $customName)}} stringData: {{- end }} -{{- range $key, $value := $v.data }} - {{- if $value }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{- with $v.data }} +{{ toYaml . | indent 2}} {{- end }} {{- end }} -{{- end }} -{{- end -}} \ No newline at end of file +{{- end -}} + diff --git a/charts/workload/templates/deployment/_containers.tpl b/charts/workload/templates/deployment/_containers.tpl index b3ed8db..2cd02af 100644 --- a/charts/workload/templates/deployment/_containers.tpl +++ b/charts/workload/templates/deployment/_containers.tpl @@ -3,8 +3,15 @@ {{ fail ".Values.workload.containers can not be empty (heler.deployment.containers)" }} {{- end -}} {{- /* /(1) */ -}} containers: -{{- range $k, $v := .Values.workload.containers }} {{- /* (1) */}} -{{ include "helper.deployment.container" (dict "Context" $ "ContainerName" $k "ContainerData" $v) | indent 2}} +{{- range $k,$v := .Values.workload.containers }} {{- /* (1) */}} + - name: {{ $k }} + {{- include "helper.workload.containerSecurityContext" . | nindent 4 -}} + {{- include "helper.workload.image" (dict "Chart" $.Chart "Image" .image) | indent 4 -}} + {{- include "helper.container.command" $v | nindent 4 -}} + {{- include "helper.container.args" $v | nindent 4 -}} + {{- include "helper.container.ports" (dict "Context" $ "Container" $v) | nindent 4 -}} + {{- include "helper.container.volumeMounts" $v | nindent 4 -}} + {{- include "helper.container.envFrom" (dict "Context" $ "Container" $v) | nindent 4 -}} {{- end }} {{- /* /(1) */}} {{- end -}} {{- /* /(define) */ -}} @@ -12,24 +19,20 @@ containers: {{- if .Values.workload.initContainers -}} {{- /* (1) */ -}} initContainers: {{- range $k,$v := .Values.workload.initContainers }} {{- /* (2) */}} -{{ include "helper.deployment.container" (dict "Context" $ "ContainerName" $k "ContainerData" $v) | indent 2}} + - name: {{ $k }} + {{- include "helper.workload.containerSecurityContext" . | nindent 4 -}} + {{- include "helper.workload.image" (dict "Chart" $.Chart "Image" .image) | indent 4 -}} + {{- include "helper.container.command" $v | nindent 4 -}} + {{- include "helper.container.args" $v | nindent 4 -}} + {{- include "helper.container.ports" (dict "Context" $ "Container" $v) | nindent 4 -}} + {{- include "helper.container.volumeMounts" $v | nindent 4 -}} + {{- include "helper.container.envFrom" (dict "Context" $ "Container" $v) | nindent 4 -}} {{- end }} {{- /* /(1) */}} {{- end -}} {{- /* /(2) */ -}} {{- end -}} {{- /* /(define) */ -}} {{- define "helper.deployment.container" -}} {{- /* (define) */ -}} -- name: {{ .ContainerName }} - {{- include "helper.workload.containerSecurityContext" .ContainerData | nindent 2 -}} - {{- include "helper.workload.image" (dict "Chart" .Context.Chart "Image" .ContainerData.image) | indent 2 -}} - {{- include "helper.container.command" .ContainerData | nindent 2 -}} - {{- include "helper.container.args" .ContainerData | nindent 2 -}} - {{- include "helper.container.ports" (dict "Context" .Context "Container" .ContainerData) | nindent 2 -}} - {{- include "helper.container.volumeMounts" .ContainerData | nindent 2 -}} - {{- include "helper.container.envFrom" (dict "Context" .Context "Container" .ContainerData) | nindent 2 -}} - {{- include "helper.container.livenessProbe" .ContainerData | nindent 2 -}} - {{- include "helper.container.readinessProbe" .ContainerData | nindent 2 -}} - {{- include "helper.container.startupProbe" .ContainerData | nindent 2 -}} {{- end -}} {{- /* /(define) */ -}} {{- define "helper.container.command" -}} {{- /* (define) */ -}} @@ -75,9 +78,6 @@ volumeMounts: {{- range $mountName, $mountEntry := $mountData }} {{- /* (4) */}} - name: {{ printf "%s-file" $mountName }} mountPath: {{ $mountEntry.path }} -{{- if $mountEntry.subPath }} {{- /* (5) */}} - subPath: {{ $mountEntry.subPath }} -{{- end }} {{- /* /(5) */}} {{- end }} {{- /* /(4) */}} {{- end }} {{- /* /(3) */}} {{- if eq $mountKind "extraVolumes" }} {{- /* (3) */}} @@ -103,7 +103,7 @@ envFrom: {{- else }} - configMapRef: {{- end }} {{- /* /(5) */}} - name: {{- printf " %s-%s" (include "chart.fullname" $.Context) $k -}} + name: {{- printf " %s-%s" (include "chart.fullname" $.Context) $k -}} {{- end -}} {{- /* /(4) */}} {{- /* Otherwise try to add references directly (if Secrets/ConfigMaps are not managed by the chart) */ -}} {{- else -}} @@ -115,25 +115,3 @@ envFrom: {{- end -}} {{- /* /(2) */ -}} {{- end -}} {{- /* /(1) */ -}} {{- end -}} {{- /* /(define) */ -}} - -{{- /* Probes */ -}} -{{- define "helper.container.readinessProbe" -}} {{- /* (define) */ -}} -{{- if .readinessProbe }} {{- /* (1) */}} -readinessProbe: -{{ .readinessProbe | toYaml | indent 2 }} -{{- end }} {{- /* /(0) */}} -{{- end -}} {{- /* /(define) */ -}} - -{{- define "helper.container.livenessProbe" -}} {{- /* (define) */ -}} -{{- if .livenessProbe }} {{- /* (1) */}} -livenessProbe: -{{ .livenessProbe | toYaml | indent 2 }} -{{- end }} {{- /* /(0) */}} -{{- end -}} {{- /* /(define) */ -}} - -{{- define "helper.container.startupProbe" -}} {{- /* (define) */ -}} -{{- if .startupProbe }} {{- /* (1) */}} -startupProbe: -{{ .startupProbe | toYaml | indent 2 }} -{{- end }} {{- /* /(0) */}} -{{- end -}} {{- /* /(define) */ -}} diff --git a/charts/workload/templates/deployment/_spec.tpl b/charts/workload/templates/deployment/_spec.tpl index bb5e199..82f9074 100644 --- a/charts/workload/templates/deployment/_spec.tpl +++ b/charts/workload/templates/deployment/_spec.tpl @@ -2,15 +2,6 @@ This is a builder for deployments */}} -{{- define "lib.metadata.hash" -}} {{- /* (define) */ -}} -{{- range $k, $v := .Env -}} {{- /* (1) */ -}} -{{ printf "softplayer.net/env-%s" $k }}: {{ $v.data | toString | sha256sum }} -{{ end -}} {{/* /(1) */}} -{{- range $k, $v := .Files -}} {{- /* (1) */ -}} -{{ printf "softplayer.net/files-%s" $k }}: {{ $v.data | toString | sha256sum }} -{{ end }} {{/* /(1) */}} -{{- end -}} {{- /* /(define) */ -}} - {{- define "deployment.spec" }} {{- /* (define) */}} # --------------------------------------------------------------------- # The spec is build within the helm library @@ -30,8 +21,6 @@ template: metadata: labels: {{- include "metadata.labels" . | nindent 6 }} - annotations: - {{- include "lib.metadata.hash" (dict "Env" $.Values.env "Files" $.Values.files) | nindent 6 }} spec: {{- include "helper.workload.securityContext" . | nindent 4 -}} {{- include "helper.deployment.volumes" . | nindent 4 }} diff --git a/charts/workload/templates/ingress/_ingresses.tpl b/charts/workload/templates/ingress/_ingresses.tpl deleted file mode 100644 index aec6056..0000000 --- a/charts/workload/templates/ingress/_ingresses.tpl +++ /dev/null @@ -1,29 +0,0 @@ -{{- define "lib.ingress" }} -{{- range $k, $v := .Values.ingress }} -{{- $customName := printf "%s-%s" (include "chart.fullname" $) $k }} -{{- if $v.annotations -}} -{{- $annotations := $v.annotations }} -{{- else }} -{{- $annotations := "" }} -{{- end }} ---- -# --------------------------------------------------------------------- -# This ingress is created as a part of softplayer helm library -# please see /lib/tempaltes/ingress/_ingress.tpl -# --------------------------------------------------------------------- -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: -{{- include "lib.metadata" (dict "Context" $ "customName" $customName "annotations" $v.annotations)}} -spec: - ingressClassName: {{ $v.class }} - {{- with $v.rules }} - rules: - {{- tpl ( . | toYaml | nindent 4 | toString) $ }} - {{- end }} - {{- with $v.tls }} - tls: - {{- tpl ( . | toYaml | nindent 4 | toString) $ }} - {{- end }} -{{- end }} -{{- end }} diff --git a/charts/workload/templates/metadata/_base.tpl b/charts/workload/templates/metadata/_base.tpl index 35e7de2..f42efdb 100644 --- a/charts/workload/templates/metadata/_base.tpl +++ b/charts/workload/templates/metadata/_base.tpl @@ -7,10 +7,6 @@ metadata: {{- end }} labels: {{ include "metadata.labels" .Context | indent 4 }} - {{- if .annotations }} - annotations: -{{ .annotations | toYaml | indent 4 }} - {{- end }} {{- end }} {{- define "metadata.customName" -}} diff --git a/charts/workload/templates/raw/_raw.tpl b/charts/workload/templates/raw/_raw.tpl deleted file mode 100644 index 02cd46b..0000000 --- a/charts/workload/templates/raw/_raw.tpl +++ /dev/null @@ -1,8 +0,0 @@ -{{- define "lib.raw" -}} -{{- if $.Values.raw -}} - {{- range $.Values.raw }} ----{{- (tpl . $) | nindent 0 }} - {{- end }} -{{- end -}} -{{- end -}} - diff --git a/charts/workload/values.schema.json b/charts/workload/values.schema.json deleted file mode 100644 index b523728..0000000 --- a/charts/workload/values.schema.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "additionalProperties": false, - "properties": { - "global": { - "additionalProperties": false, - "title": "global", - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": [ - "global" - ] -} diff --git a/charts/workload/values.yaml b/charts/workload/values.yaml index 490a0b7..54bcf30 100644 --- a/charts/workload/values.yaml +++ b/charts/workload/values.yaml @@ -1 +1 @@ -global: {} +~