Skip to content

Commit

Permalink
Merge pull request #33 from foomo/squadron-vars
Browse files Browse the repository at this point in the history
feat: use globals
  • Loading branch information
franklinkim authored Oct 27, 2024
2 parents 3daad4f + 6f2fc4f commit 383d13d
Show file tree
Hide file tree
Showing 27 changed files with 370 additions and 208 deletions.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@

.PHONY: check
## Lint, Schema & docs
check: lint schema docs
@echo "✓ lint"
@echo "✓ schema"
@echo "✓ docs"
check: lint docs

.PHONY: lint
## Lint Helm charts
## https://github.com/helm/chart-testing
lint: schema
@for dir in ./charts/* ; do \
helm lint $${dir} --strict ;\
@echo "--- lint ------------------------------------------"
@set -e; for dir in ./charts/* ; do \
helm lint $${dir} ;\
done

.PHONY: docs
## Generate README
## https://github.com/norwoodj/helm-docs
docs:
@for dir in ./charts/* ; do \
@echo "--- docs ------------------------------------------"
@set -e; for dir in ./charts/* ; do \
docker run --rm --volume "$$(pwd)/$${dir}:/helm-docs/$${dir}" jnorwood/helm-docs:v1.14.2 --template-files "$${dir}/README.md.gotmpl" ;\
done

Expand All @@ -33,6 +32,7 @@ docs:
## https://github.com/knechtionscoding/helm-schema-gen
schema: PWD=$(pwd)
schema:
@echo "--- schema ---------------------------------------"
helm-schema -n -c charts/namespace
helm-schema -n -c charts/squadron-keel-server
helm-schema -n -c charts/squadron-keel-cronjob
Expand All @@ -43,7 +43,7 @@ schema:
helm schema-gen charts/gateway-crds/values.yaml > charts/gateway-crds/values.schema.json
helm schema-gen charts/sesamy-gtm/values.yaml > charts/sesamy-gtm/values.schema.json
helm schema-gen charts/sesamy-umami/values.yaml > charts/sesamy-umami/values.schema.json
#@for dir in ./charts/* ; do \
#@set -e; for dir in ./charts/* ; do \
# helm-schema -n -c $${dir} ;\
#done

Expand Down
4 changes: 2 additions & 2 deletions charts/namespace/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ annotations:
- name: Chart Source
url: https://github.com/foomo/helm-charts
version: 0.2.1
appVersion: 0.2.1
version: 0.2.2
appVersion: 0.2.2
4 changes: 2 additions & 2 deletions charts/namespace/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# namespace

![Version: 0.2.1](https://img.shields.io/badge/Version-0.2.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.1](https://img.shields.io/badge/AppVersion-0.2.1-informational?style=flat-square)
![Version: 0.2.2](https://img.shields.io/badge/Version-0.2.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.2](https://img.shields.io/badge/AppVersion-0.2.2-informational?style=flat-square)

Common Namespace Resource Chart

Expand All @@ -20,7 +20,7 @@ Common Namespace Resource Chart
| secrets | object | `{}` | Opaque secrets |
| serviceAccounts | object | `{}` | Service accounts settings |
| tlsSecrets | object | `{}` | TLS secrets |
| volumes | object | `{}` | Service accounts settings |
| volumeClaims | object | `{}` | Service accounts settings |

### Overrides

Expand Down
2 changes: 1 addition & 1 deletion charts/namespace/templates/persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- range $key, $value := .Values.volumes }}
{{- range $key, $value := .Values.volumeClaims }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
Expand Down
2 changes: 1 addition & 1 deletion charts/namespace/templates/secret-docker.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- range $key, $value := .Values.secrets.dockerConfigs }}
{{- range $key, $value := .Values.dockerSecrets }}
apiVersion: v1
kind: Secret
type: "kubernetes.io/dockerconfigjson"
Expand Down
2 changes: 1 addition & 1 deletion charts/namespace/templates/secret-tls.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- range $key, $value := .Values.secrets.tls }}
{{- range $key, $value := .Values.tlsSecrets }}
apiVersion: v1
kind: Secret
type: kubernetes.io/tls
Expand Down
2 changes: 1 addition & 1 deletion charts/namespace/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- range $key, $value := .Values.secrets.opaque }}
{{- range $key, $value := .Values.secrets }}
apiVersion: v1
kind: Secret
type: Opaque
Expand Down
4 changes: 2 additions & 2 deletions charts/namespace/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"title": "tlsSecrets",
"type": "object"
},
"volumes": {
"volumeClaims": {
"additionalProperties": {
"additionalProperties": true,
"properties": {
Expand All @@ -118,7 +118,7 @@
},
"description": "Service accounts settings",
"required": [],
"title": "volumes",
"title": "volumeClaims",
"type": "object"
}
},
Expand Down
13 changes: 7 additions & 6 deletions charts/namespace/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ serviceAccounts: {}
# @schema
# -- Service accounts settings
# @section -- General
volumes: {}
# my-volume:
# name: my-existing-volume
# annotations: {}
# storageClass: local-path
# size: 1Gi
volumeClaims: {}
# volumeClaims:
# my-volume:
# name: my-existing-volume
# annotations: {}
# storageClass: local-path
# size: 1Gi


4 changes: 2 additions & 2 deletions charts/squadron-keel-cronjob/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ annotations:
- name: Chart Source
url: https://github.com/foomo/helm-charts
version: 0.1.3
appVersion: 0.1.3
version: 0.1.4
appVersion: 0.1.4
24 changes: 15 additions & 9 deletions charts/squadron-keel-cronjob/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# squadron-keel-cronjob

![Version: 0.1.3](https://img.shields.io/badge/Version-0.1.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.3](https://img.shields.io/badge/AppVersion-0.1.3-informational?style=flat-square)
![Version: 0.1.4](https://img.shields.io/badge/Version-0.1.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.4](https://img.shields.io/badge/AppVersion-0.1.4-informational?style=flat-square)

Squadron Keel CronJob Chart

Expand Down Expand Up @@ -47,14 +47,6 @@ Squadron Keel CronJob Chart
| secrets | object | `{}` | Map of secrets to be mounted |
| timeZone | string | `"Europe/Berlin"` | Cron job time zone |

### Squadron settings

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| fleet | string | `""` | Squadron fleet name |
| squadron | string | `""` | Squadron name |
| unit | string | `""` | Squadron unit name |

### Overrides

| Key | Type | Default | Description |
Expand All @@ -63,6 +55,14 @@ Squadron Keel CronJob Chart
| nameOverride | string | `""` | Overrides the chart's name |
| namespaceOverride | string | `""` | The name of the Namespace to deploy |

### Global

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| global.foomo.squadron.fleet | string | `""` | Will be automatically injected (optional) |
| global.foomo.squadron.name | string | `""` | Will be automatically injected |
| global.foomo.squadron.unit | string | `""` | Will be automatically injected |

### Graceful settings

| Key | Type | Default | Description |
Expand Down Expand Up @@ -159,3 +159,9 @@ Squadron Keel CronJob Chart
| serviceAccount.automount | bool | `true` | Automatically mount a ServiceAccount's API credentials? |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
| serviceAccount.name | string | `""` | The name of the service account to use. |

### Other Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| global.foomo.withDeprecatedSelectorLabels | bool | `false` | |
16 changes: 8 additions & 8 deletions charts/squadron-keel-cronjob/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ If release name contains chart name it will be used as a full name.
{{- define "keel.cronjob.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- tpl .Values.fullnameOverride . | trunc 63 | trimSuffix "-" -}}
{{- else if and .Values.squadron .Values.unit -}}
{{- printf "%s-%s" .Values.squadron .Values.unit | trunc 63 | trimSuffix "-" -}}
{{- else if and .Values.global.foomo.squadron.name .Values.global.foomo.squadron.unit -}}
{{- printf "%s-%s" .Values.global.foomo.squadron.name .Values.global.foomo.squadron.unit | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
Expand Down Expand Up @@ -115,17 +115,17 @@ Squadron standard envs
{{- include "keel.cronjob.env.squadron" . | nindent 12 }}
*/}}
{{- define "keel.cronjob.env.squadron" -}}
{{- if .Values.fleet }}
{{- if .Values.global.foomo.squadron.fleet }}
- name: FLEET
value: {{ .Values.fleet | quote }}
value: {{ .Values.global.foomo.squadron.fleet | quote }}
{{- end }}
{{- if .Values.squadron }}
{{- if .Values.global.foomo.squadron.name }}
- name: SQUADRON
value: {{ .Values.squadron | quote }}
value: {{ .Values.global.foomo.squadron.name | quote }}
{{- end }}
{{- if .Values.unit }}
{{- if .Values.global.foomo.squadron.unit }}
- name: UNIT
value: {{ .Values.unit | quote }}
value: {{ .Values.global.foomo.squadron.unit | quote }}
{{- end }}
{{- end -}}

Expand Down
69 changes: 47 additions & 22 deletions charts/squadron-keel-cronjob/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,6 @@
"title": "env",
"type": "object"
},
"fleet": {
"default": "",
"description": "Squadron fleet name",
"required": [],
"title": "fleet",
"type": "string"
},
"fullnameOverride": {
"default": "",
"description": "Overrides the chart's computed fullname",
Expand All @@ -298,7 +291,53 @@
"type": "string"
},
"global": {
"description": "Global values are values that can be accessed from any chart or subchart by exactly the same name.",
"additionalProperties": true,
"properties": {
"foomo": {
"additionalProperties": true,
"properties": {
"squadron": {
"additionalProperties": false,
"properties": {
"fleet": {
"default": "",
"description": "Squadron fleet name\nWill be automatically injected (optional)",
"required": [],
"title": "fleet",
"type": "string"
},
"name": {
"default": "",
"description": "Squadron name\nWill be automatically injected",
"required": [],
"title": "name",
"type": "string"
},
"unit": {
"default": "",
"description": "Squadron unit name\nWill be automatically injected",
"required": [],
"title": "unit",
"type": "string"
}
},
"required": [],
"title": "squadron",
"type": "object"
},
"withDeprecatedSelectorLabels": {
"default": false,
"description": "Enable for backward compatibility",
"required": [],
"title": "withDeprecatedSelectorLabels",
"type": "boolean"
}
},
"required": [],
"title": "foomo",
"type": "object"
}
},
"required": [],
"title": "global",
"type": "object"
Expand Down Expand Up @@ -872,26 +911,12 @@
"title": "serviceAccount",
"type": "object"
},
"squadron": {
"default": "",
"description": "Squadron name",
"required": [],
"title": "squadron",
"type": "string"
},
"timeZone": {
"default": "Europe/Berlin",
"description": "Cron job time zone",
"required": [],
"title": "timeZone",
"type": "string"
},
"unit": {
"default": "",
"description": "Squadron unit name",
"required": [],
"title": "unit",
"type": "string"
}
},
"required": [],
Expand Down
60 changes: 41 additions & 19 deletions charts/squadron-keel-cronjob/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
# yaml-language-server: $schema=values.schema.json

# @schema
# type: object
# additionalProperties: true
# @schema
global:
# @schema
# type: object
# additionalProperties: true
# @schema
foomo:
# @schema
# type: boolean
# @schema
# Enable for backward compatibility
# @section -- Global
withDeprecatedSelectorLabels: false
# @schema
# type: object
# @schema
squadron:
# @schema
# type: string
# @schema
# -- Squadron name
# -- Will be automatically injected
# @section -- Global
name: ''
# @schema
# type: string
# @schema
# -- Squadron unit name
# -- Will be automatically injected
# @section -- Global
unit: ''
# @schema
# type: string
# @schema
# -- Squadron fleet name
# -- Will be automatically injected (optional)
# @section -- Global
fleet: ''
# @schema
# type: string
# @schema
Expand Down Expand Up @@ -38,25 +79,6 @@ schedule: ''
# @section -- General
timeZone: 'Europe/Berlin'

# @schema
# type: string
# @schema
# -- Squadron fleet name
# @section -- Squadron settings
fleet: ''
# @schema
# type: string
# @schema
# -- Squadron name
# @section -- Squadron settings
squadron: ''
# @schema
# type: string
# @schema
# -- Squadron unit name
# @section -- Squadron settings
unit: ''

# @schema
# type: object
# @schema
Expand Down
Loading

0 comments on commit 383d13d

Please sign in to comment.