feat(common): Release common 4.0.0 (#398)

Co-authored-by: lab-assistant[bot] <180935599+lab-assistant[bot]@users.noreply.github.com>
This commit is contained in:
Bernd Schorgers 2025-05-16 08:40:39 +02:00
parent 1e210f43e3
commit a01a89cb13
No known key found for this signature in database
327 changed files with 11181 additions and 7330 deletions

View file

@ -64,6 +64,8 @@ nav:
- index.md - index.md
- Common Library: - Common Library:
- common-library/index.md - common-library/index.md
- Generated Resources:
- common-library/resources/names.md
- Storage: - Storage:
- Permissions: common-library/storage/permissions.md - Permissions: common-library/storage/permissions.md
- Global options: common-library/storage/globalOptions.md - Global options: common-library/storage/globalOptions.md
@ -78,8 +80,10 @@ nav:
- How To...: - How To...:
- common-library/howto/index.md - common-library/howto/index.md
- Default container options: common-library/howto/default-container-options.md - Default container options: common-library/howto/default-container-options.md
- Default Pod options: common-library/howto/default-pod-options.md
- App Template: - App Template:
- app-template/index.md - app-template/index.md
- Upgrade instructions: app-template/upgrade-instructions.md
- How To...: - How To...:
- app-template/howto/index.md - app-template/howto/index.md
- Helm templates: app-template/howto/helm-templates.md - Helm templates: app-template/howto/helm-templates.md

View file

@ -6,7 +6,6 @@
description: "Process common lib json schema references", description: "Process common lib json schema references",
fileMatch: ["\\.json$"], fileMatch: ["\\.json$"],
matchStrings: [ matchStrings: [
// https://raw.githubusercontent.com/bjw-s-labs/helm-charts/common-3.0.3/charts/library/common/values.schema.json
"https:\\/\\/raw.githubusercontent.com\\/bjw-s-labs\\/helm-charts\\/(?<depName>\\S+?)-(?<currentValue>[\\d\\.]+?)\\/\\S+", "https:\\/\\/raw.githubusercontent.com\\/bjw-s-labs\\/helm-charts\\/(?<depName>\\S+?)-(?<currentValue>[\\d\\.]+?)\\/\\S+",
], ],
datasourceTemplate: "helm", datasourceTemplate: "helm",

View file

@ -63,7 +63,6 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with: with:
path: src path: src
persist-credentials: false
- name: Install Helm - name: Install Helm
uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0 uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0
@ -160,7 +159,6 @@ jobs:
with: with:
path: gh-pages path: gh-pages
ref: gh-pages ref: gh-pages
persist-credentials: false
- name: Copy package to gh-pages structure - name: Copy package to gh-pages structure
id: copy-package id: copy-package

View file

@ -53,7 +53,7 @@ jobs:
patterns: | patterns: |
library/** library/**
- name: Get changed library charts - name: Get changed charts
id: changed-charts id: changed-charts
if: ${{ github.event_name != 'workflow_dispatch' }} if: ${{ github.event_name != 'workflow_dispatch' }}
uses: bjw-s-labs/action-changed-files@930cef8463348e168cab7235c47fe95a7a235f65 # v0.3.3 uses: bjw-s-labs/action-changed-files@930cef8463348e168cab7235c47fe95a7a235f65 # v0.3.3

View file

@ -30,10 +30,12 @@ jobs:
chart: ${{ fromJSON(inputs.charts) }} chart: ${{ fromJSON(inputs.charts) }}
k8s_version: k8s_version:
[ [
"v1.28.15",
"v1.29.13", "v1.29.13",
"v1.30.11", "v1.30.11",
"v1.31.7", "v1.31.7",
"v1.32.3", "v1.32.3",
"v1.33.0",
] ]
fail-fast: false fail-fast: false
steps: steps:

View file

@ -1,4 +1,5 @@
--- ---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3" version: "3"
vars: vars:

17
.taskfiles/docs.yaml Normal file
View file

@ -0,0 +1,17 @@
---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3"
tasks:
serve:
desc: Serve documentation locally
deps:
- install_prerequisies
cmds:
- mkdocs serve -c -f .ci/mkdocs/mkdocs.yml
install_prerequisies:
desc: Install prerequisites
internal: true
cmds:
- pip install -r docs/requirements.txt

View file

@ -1,23 +0,0 @@
---
version: "3"
tasks:
init:
desc: Install pre-commit hooks
cmds:
- pre-commit install --install-hooks --config .ci/pre-commit/config.yaml
update:
desc: Update pre-commit hooks
cmds:
- pre-commit autoupdate --config .ci/pre-commit/config.yaml
run:
desc: Run pre-commit
cmds:
- pre-commit run --config .ci/pre-commit/config.yaml
run-all:
desc: Run pre-commit on all files
cmds:
- pre-commit run --all-files --config .ci/pre-commit/config.yaml

View file

@ -7,7 +7,7 @@ vars:
includes: includes:
charts: .taskfiles/charts.yaml charts: .taskfiles/charts.yaml
precommit: .taskfiles/precommit.yaml docs: .taskfiles/docs.yaml
tasks: tasks:
default: default:

View file

@ -3,8 +3,8 @@ apiVersion: v2
name: common name: common
description: Function library for Helm charts description: Function library for Helm charts
type: library type: library
version: 3.7.3 version: 4.0.0
kubeVersion: ">=1.22.0-0" kubeVersion: ">=1.28.0-0"
keywords: keywords:
- common - common
- library - library
@ -16,9 +16,48 @@ sources:
- https://github.com/bjw-s-labs/helm-charts - https://github.com/bjw-s-labs/helm-charts
annotations: annotations:
artifacthub.io/changes: |- artifacthub.io/changes: |-
- kind: removed
description: |-
Individual `valuesToObject` functions have been removed in favor of a centralized `bjw-s.common.lib.valuesToObject` function.
- kind: fixed - kind: fixed
description: |- description: |-
Fixed name suffix for HTTPRoute Fixed empty backendRefs in HTTPRoute leading to invalid spec
- kind: fixed - kind: added
description: |- description: |-
Fixed incorrect default backendRefs values in HTTPRoute Added support for setting `parentRefs[].port` in HTTPRoute
- kind: added
description: |-
Added support for setting `sessionPersistence` in HTTPRoute
- kind: added
description: |-
Added support for setting `resources` on the Pod Level in Kubernetes >= 1.32
- kind: added
description: |-
Added explicit JSON schema for `rbac` root key
- kind: added
description: |-
Allow configuring the merge strategy for `defaultPodOptions`
- kind: added
description: |-
Added support for setting `subPathExpr` on globalMounts and advancedMounts persistence items
- kind: added
description: |-
Added support for automatically determining the target controller for Services if there is only one enabled controller
- kind: added
description: |-
Added support for automatically determining the target service for Ingress paths if there is only one enabled Service
- kind: changed
description: |-
**Breaking**: Standardized resource name logic for all resources. This may cause changes in the generated resource names.
links:
- name: Documentation
url: https://bjw-s-labs.github.io/helm-charts/docs/common-library/resources/names/
- kind: changed
description: |-
**Breaking**: Increased the minimum supported Kubernetes version to 1.28.0
- kind: changed
description: |-
**Breaking**: ServiceAccounts no longer create a static token by default. This is now controlled by the `staticToken` field in the `serviceAccount` object.
- kind: changed
description: |-
**Breaking**: Renamed the hardcoded app.kubernetes.io/component label to app.kubernetes.io/controller

View file

@ -1,12 +1,16 @@
# common # common
![Version: 3.7.3](https://img.shields.io/badge/Version-3.7.3-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![Version: 4.0.0](https://img.shields.io/badge/Version-4.0.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square)
Function library for Helm charts Function library for Helm charts
## Source Code
* <https://github.com/bjw-s-labs/helm-charts>
## Requirements ## Requirements
Kubernetes: `>=1.22.0-0` Kubernetes: `>=1.28.0-0`
## Dependencies ## Dependencies
@ -27,7 +31,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
# Chart.yaml # Chart.yaml
dependencies: dependencies:
- name: common - name: common
version: 3.7.3 version: 4.0.0
repository: https://bjw-s-labs.github.io/helm-charts/ repository: https://bjw-s-labs.github.io/helm-charts/
``` ```

View file

@ -1,41 +1,46 @@
{ {
"instance": { "instance": {
"type": "object", "allOf": [
"additionalProperties": false, { "$ref": "definitions.json#/resourceIdentifier" },
"properties": { {
"enabled": {
"type": "boolean",
"default": true
},
"includeInChecksum": {
"type": "boolean",
"default": true
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"nameOverride": {
"type": "string"
},
"data": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": false,
"type": "string" "properties": {
} "forceRename": {},
}, "prefix": {},
"binaryData": { "suffix": {},
"type": "object", "enabled": {
"additionalProperties": { "type": "boolean",
"type": "string" "default": true
} },
"includeInChecksum": {
"type": "boolean",
"default": true
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"data": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"binaryData": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"oneOf": [
{"required": ["data"]},
{"required": ["binaryData"]}
]
} }
},
"oneOf": [
{"required": ["data"]},
{"required": ["binaryData"]}
] ]
} }
} }

View file

@ -1,206 +1,136 @@
{ {
"instance": { "instance": {
"type": "object", "allOf": [
"additionalProperties": false, { "$ref": "definitions.json#/resourceIdentifier" },
"properties": { {
"enabled": {
"type": "boolean",
"default": true
},
"type": {
"type": "string",
"enum": [
"deployment",
"statefulset",
"daemonset",
"cronjob",
"job"
],
"default": "deployment"
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"nameOverride": {
"type": "string"
},
"pod": {
"$ref": "pod.json#/options"
},
"replicas": {
"type": [
"integer",
"null"
],
"default": 1
},
"revisionHistoryLimit": {
"type": "integer"
},
"rollingUpdate": {
"type": "object"
},
"strategy": {
"type": "string"
},
"cronjob": {
"$ref": "#/cronjob"
},
"job": {
"$ref": "#/job"
},
"statefulset": {
"$ref": "#/statefulset"
},
"applyDefaultContainerOptionsToInitContainers": {
"type": "boolean",
"default": true
},
"defaultContainerOptionsStrategy": {
"type": "string",
"default": "overwrite",
"enum": [
"overwrite",
"merge"
]
},
"defaultContainerOptions": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"args": { "forceRename": {},
"$ref": "containers.json#/args" "prefix": {},
"suffix": {},
"enabled": {
"type": "boolean",
"default": true
}, },
"command": { "type": {
"$ref": "containers.json#/command" "type": "string",
"enum": [
"deployment",
"statefulset",
"daemonset",
"cronjob",
"job"
],
"default": "deployment"
}, },
"env": { "annotations": {
"$ref": "containers.json#/env" "$ref": "definitions.json#/annotations"
}, },
"envFrom": { "labels": {
"$ref": "containers.json#/envFrom" "$ref": "definitions.json#/labels"
}, },
"image": { "pod": {
"$ref": "containers.json#/image" "$ref": "pod.json#/options"
}, },
"resources": { "replicas": {
"$ref": "k8s-api.json#/core.v1.ResourceRequirements" "type": [
"integer",
"null"
],
"default": 1
}, },
"securityContext": { "revisionHistoryLimit": {
"$ref": "k8s-api.json#/core.v1.ContainerSecurityContext" "type": "integer"
} },
} "rollingUpdate": {
}, "type": "object"
"initContainers": { },
"type": "object", "strategy": {
"additionalProperties": {
"$ref": "containers.json#/container"
}
},
"containers": {
"type": "object",
"additionalProperties": {
"$ref": "containers.json#/container"
}
},
"serviceAccount": {
"type": "object",
"properties": {
"name": {
"type": "string" "type": "string"
}, },
"identifier": { "cronjob": {
"type": "string" "$ref": "#/cronjob"
} },
} "job": {
} "$ref": "#/job"
}, },
"allOf": [ "statefulset": {
{ "$ref": "#/statefulset"
"if": { },
"properties": { "applyDefaultContainerOptionsToInitContainers": {
"type": { "type": "boolean",
"const": "deployment" "default": true
} },
} "defaultContainerOptionsStrategy": {
}, "type": "string",
"then": { "default": "overwrite",
"not": { "enum": [
"anyOf": [ "overwrite",
{ "merge"
"required": [
"statefulset"
]
},
{
"required": [
"cronjob"
]
},
{
"required": [
"job"
]
},
{
"required": [
"daemonset"
]
}
] ]
} },
} "defaultContainerOptions": {
}, "type": "object",
{ "additionalProperties": false,
"if": { "properties": {
"properties": { "args": {
"type": { "$ref": "containers.json#/args"
"const": "statefulset" },
"command": {
"$ref": "containers.json#/command"
},
"env": {
"$ref": "containers.json#/env"
},
"envFrom": {
"$ref": "containers.json#/envFrom"
},
"image": {
"$ref": "containers.json#/image"
},
"resources": {
"$ref": "k8s-api.json#/core.v1.ResourceRequirements"
},
"securityContext": {
"$ref": "k8s-api.json#/core.v1.ContainerSecurityContext"
}
} }
}, },
"required": [ "initContainers": {
"type" "type": "object",
] "additionalProperties": {
}, "$ref": "containers.json#/container"
"then": {
"not": {
"anyOf": [
{
"required": [
"cronjob"
]
},
{
"required": [
"job"
]
},
{
"required": [
"daemonset"
]
}
]
}
}
},
{
"if": {
"properties": {
"type": {
"const": "cronjob"
} }
}, },
"required": [ "containers": {
"type" "type": "object",
] "additionalProperties": {
"$ref": "containers.json#/container"
}
},
"serviceAccount": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"identifier": {
"type": "string"
}
}
}
}, },
"then": { "allOf": [
"allOf": [ {
{ "if": {
"properties": {
"type": {
"const": "deployment"
}
}
},
"then": {
"not": { "not": {
"anyOf": [ "anyOf": [
{ {
@ -208,6 +138,11 @@
"statefulset" "statefulset"
] ]
}, },
{
"required": [
"cronjob"
]
},
{ {
"required": [ "required": [
"job" "job"
@ -220,50 +155,121 @@
} }
] ]
} }
},
{
"required": [
"cronjob"
]
}
]
}
},
{
"if": {
"properties": {
"type": {
"const": "job"
} }
}, },
"required": [ {
"type" "if": {
] "properties": {
}, "type": {
"then": { "const": "statefulset"
"not": { }
"anyOf": [
{
"required": [
"statefulset"
]
}, },
{ "required": [
"required": [ "type"
"cronjob" ]
] },
}, "then": {
{ "not": {
"required": [ "anyOf": [
"daemonset" {
"required": [
"cronjob"
]
},
{
"required": [
"job"
]
},
{
"required": [
"daemonset"
]
}
] ]
} }
] }
},
{
"if": {
"properties": {
"type": {
"const": "cronjob"
}
},
"required": [
"type"
]
},
"then": {
"allOf": [
{
"not": {
"anyOf": [
{
"required": [
"statefulset"
]
},
{
"required": [
"job"
]
},
{
"required": [
"daemonset"
]
}
]
}
},
{
"required": [
"cronjob"
]
}
]
}
},
{
"if": {
"properties": {
"type": {
"const": "job"
}
},
"required": [
"type"
]
},
"then": {
"not": {
"anyOf": [
{
"required": [
"statefulset"
]
},
{
"required": [
"cronjob"
]
},
{
"required": [
"daemonset"
]
}
]
}
}
} }
} ]
} }
] ]
}, },
"statefulset": { "statefulset": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
@ -301,6 +307,7 @@
} }
} }
}, },
"statefulset.volumeClaimTemplate": { "statefulset.volumeClaimTemplate": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
@ -348,6 +355,7 @@
"size" "size"
] ]
}, },
"cronjob": { "cronjob": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
@ -396,6 +404,7 @@
"schedule" "schedule"
] ]
}, },
"job": { "job": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,

View file

@ -1,4 +1,29 @@
{ {
"resourceIdentifier": {
"type": "object",
"properties": {
"forceRename": {
"type": "string",
"description": "Override the default resource name. This field is mutually exclusive with the prefix and suffix fields."
},
"prefix": {
"type": "string",
"description": "Prefix to prepend to the resource name. This field is mutually exclusive with the forceRename field.",
"default": ""
},
"suffix": {
"type": "string",
"description": "Suffix to append to the resource name. Defaults to the resource identifier if there are multiple items, otherwise it defaults to empty. This field is mutually exclusive with the forceRename field."
}
},
"not" : {
"anyOf" : [
{"required" : ["forceRename", "suffix"]},
{"required" : ["forceRename", "prefix"]}
]
}
},
"annotations": { "annotations": {
"type": ["object", "null"], "type": ["object", "null"],
"additionalProperties": { "additionalProperties": {

View file

@ -1,48 +1,45 @@
{ {
"instance": { "instance": {
"type": "object", "allOf": [
"additionalProperties": false, { "$ref": "definitions.json#/resourceIdentifier" },
{
"properties": { "type": "object",
"enabled": { "additionalProperties": false,
"type": "boolean", "properties": {
"default": true "forceRename": {},
}, "prefix": {},
"suffix": {},
"annotations": { "enabled": {
"$ref": "definitions.json#/annotations" "type": "boolean",
}, "default": true
},
"className": { "annotations": {
"type": "string" "$ref": "definitions.json#/annotations"
}, },
"className": {
"defaultBackend": { "type": "string"
"$ref": "k8s-api.json#/networking.v1.ingressBackend" },
}, "defaultBackend": {
"$ref": "k8s-api.json#/networking.v1.ingressBackend"
"hosts": { },
"type": "array", "hosts": {
"items": { "type": "array",
"$ref": "#/hostEntry" "items": {
} "$ref": "#/hostEntry"
}, }
},
"labels": { "labels": {
"$ref": "definitions.json#/labels" "$ref": "definitions.json#/labels"
}, },
"tls": {
"nameOverride": { "type": "array",
"type": "string" "items": {
}, "$ref": "#/tlsEntry"
}
"tls": { }
"type": "array",
"items": {
"$ref": "#/tlsEntry"
} }
} }
} ]
}, },
"hostEntry": { "hostEntry": {
@ -70,7 +67,7 @@
] ]
} }
}, },
"required": ["path", "service"] "required": ["path"]
}, },
"title": "paths", "title": "paths",
"type": "array" "type": "array"
@ -119,7 +116,6 @@
"port": { "port": {
"type": ["string", "integer"] "type": ["string", "integer"]
} }
}, }
"required": ["identifier"]
} }
} }

View file

@ -1,52 +1,57 @@
{ {
"instance": { "instance": {
"type": "object", "allOf": [
"additionalProperties": false, { "$ref": "definitions.json#/resourceIdentifier" },
{
"properties": {
"enabled": {
"type": "boolean",
"default": true
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"controller": {
"type": "string"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"nameOverride": {
"type": "string"
},
"podSelector": {},
"policyTypes": {
"type": "array",
"items": {
"type": "string"
}
},
"rules": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"ingress": { "forceRename": {},
"prefix": {},
"suffix": {},
"enabled": {
"type": "boolean",
"default": true
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"controller": {
"type": "string"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"podSelector": {},
"policyTypes": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "k8s-api.json#/networking.v1.NetworkPolicyIngressRule" "type": "string"
} }
}, },
"egress": { "rules": {
"type": "array", "type": "object",
"items": { "additionalProperties": false,
"$ref": "k8s-api.json#/networking.v1.NetworkPolicyEgressRule"
"properties": {
"ingress": {
"type": "array",
"items": {
"$ref": "k8s-api.json#/networking.v1.NetworkPolicyIngressRule"
}
},
"egress": {
"type": "array",
"items": {
"$ref": "k8s-api.json#/networking.v1.NetworkPolicyEgressRule"
}
}
} }
} }
} },
"required": ["rules"]
} }
}, ]
"required": ["rules"]
} }
} }

View file

@ -13,51 +13,56 @@
}, },
"persistentVolumeClaimItem": { "persistentVolumeClaimItem": {
"type": "object", "allOf": [
"additionalProperties": false, { "$ref": "definitions.json#/resourceIdentifier" },
{
"type": "object",
"additionalProperties": false,
"properties": { "properties": {
"type": { "type": {
"const": "persistentVolumeClaim" "const": "persistentVolumeClaim"
}, },
"enabled": { "forceRename": {},
"type": "boolean", "prefix": {},
"default": true "suffix": {},
}, "enabled": {
"accessMode": { "type": "boolean",
"type": "string" "default": true
}, },
"annotations": { "accessMode": {
"$ref": "definitions.json#/annotations" "type": "string"
}, },
"dataSource": { "annotations": {
"$ref": "#/dataSourceReference" "$ref": "definitions.json#/annotations"
}, },
"dataSourceRef": { "dataSource": {
"$ref": "#/dataSourceReference" "$ref": "#/dataSourceReference"
}, },
"labels": { "dataSourceRef": {
"$ref": "definitions.json#/labels" "$ref": "#/dataSourceReference"
}, },
"nameOverride": { "labels": {
"type": "string" "$ref": "definitions.json#/labels"
}, },
"retain": { "retain": {
"type": "boolean" "type": "boolean"
}, },
"size": { "size": {
"type": "string" "type": "string"
}, },
"storageClass": { "storageClass": {
"type": "string" "type": "string"
}, },
"volumeName": { "volumeName": {
"type": "string" "type": "string"
}, },
"advancedMounts": {"$ref": "#/advancedMounts"}, "advancedMounts": {"$ref": "#/advancedMounts"},
"globalMounts": {"$ref": "#/globalMounts"} "globalMounts": {"$ref": "#/globalMounts"}
}, },
"required": ["accessMode", "size"] "required": ["accessMode", "size"]
}
]
}, },
"persistentVolumeClaimWithExistingClaimItem": { "persistentVolumeClaimWithExistingClaimItem": {
@ -330,6 +335,9 @@
"subPath": { "subPath": {
"type": "string" "type": "string"
}, },
"subPathExpr": {
"type": "string"
},
"mountPropagation": { "mountPropagation": {
"type": "string" "type": "string"
} }

View file

@ -67,6 +67,9 @@
"priorityClassName": { "priorityClassName": {
"type": "string" "type": "string"
}, },
"resources": {
"$ref": "k8s-api.json#/core.v1.ResourceRequirements"
},
"restartPolicy": { "restartPolicy": {
"type": "string" "type": "string"
}, },

View file

@ -1,32 +1,34 @@
{ {
"instance": { "instance": {
"type": "object", "allOf": [
"additionalProperties": false, { "$ref": "definitions.json#/resourceIdentifier" },
"properties": { {
"enabled": { "type": "object",
"type": "boolean", "additionalProperties": false,
"default": true "properties": {
}, "forceRename": {},
"apiVersion": { "prefix": {},
"type": "string" "suffix": {},
}, "enabled": {
"kind": { "type": "boolean",
"type": "string" "default": true
}, },
"annotations": { "apiVersion": {
"$ref": "definitions.json#/annotations" "type": "string"
}, },
"labels": { "kind": {
"$ref": "definitions.json#/labels" "type": "string"
}, },
"nameOverride": { "annotations": {
"type": "string" "$ref": "definitions.json#/annotations"
}, },
"forceRename": { "labels": {
"type": "string" "$ref": "definitions.json#/labels"
}, },
"spec": {} "spec": {}
}, },
"required": ["apiVersion", "kind", "spec"] "required": ["apiVersion", "kind", "spec"]
}
]
} }
} }

View file

@ -0,0 +1,118 @@
{
"role": {
"allOf": [
{ "$ref": "definitions.json#/resourceIdentifier" },
{
"type": "object",
"additionalProperties": false,
"properties": {
"forceRename": {},
"prefix": {},
"suffix": {},
"enabled": {
"type": "boolean",
"default": true
},
"type": {
"type": "string",
"enum": [
"Role",
"ClusterRole"
],
"default": "Role"
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"rules": {
"type": "array"
}
},
"required": ["type", "rules"]
}
]
},
"roleBinding": {
"allOf": [
{ "$ref": "definitions.json#/resourceIdentifier" },
{
"type": "object",
"additionalProperties": false,
"properties": {
"forceRename": {},
"prefix": {},
"suffix": {},
"enabled": {
"type": "boolean",
"default": true
},
"type": {
"type": "string",
"enum": [
"RoleBinding",
"ClusterRoleBinding"
],
"default": "RoleBinding"
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"roleRef": {
"type": "object",
"properties": {
"identifier": {
"type": "string"
},
"name": {
"type": "string"
},
"kind": {
"type": "string",
"enum": [
"Role",
"ClusterRole"
]
}
},
"oneOf": [
{"required": ["identifier"]},
{"required": ["name", "kind"]}
]
},
"subjects": {
"type": "array",
"items": {
"type": "object",
"properties": {
"identifier": {
"type": "string"
},
"name": {
"type": "string"
},
"kind": {
"type": "string"
},
"namespace": {
"type": "string"
}
},
"oneOf": [
{"required": ["identifier"]},
{"required": ["name", "kind", "namespace"]}
]
}
}
},
"required": ["type", "roleRef", "subjects"]
}
]
}
}

View file

@ -1,126 +1,140 @@
{ {
"instance": { "instance": {
"type": "object", "allOf": [
"additionalProperties": false, { "$ref": "definitions.json#/resourceIdentifier" },
{
"type": "object",
"additionalProperties": false,
"properties": {
"forceRename": {},
"prefix": {},
"suffix": {},
"enabled": {
"type": "boolean",
"default": true
},
"properties": { "annotations": {
"enabled": { "$ref": "definitions.json#/annotations"
"type": "boolean", },
"default": true "labels": {
}, "$ref": "definitions.json#/labels"
},
"annotations": { "hostnames": {
"$ref": "definitions.json#/annotations" "type": "array",
}, "items": {"type": "string"}
},
"hostnames": { "kind": {
"type": "array", "type": "string",
"items": {"type": "string"} "enum": ["GRPCRoute", "HTTPRoute", "TCPRoute", "TLSRoute", "UDPRoute"]
}, },
"kind": { "parentRefs": {
"type": "string", "type": "array",
"enum": ["GRPCRoute", "HTTPRoute", "TCPRoute", "TLSRoute", "UDPRoute"] "items": {
}, "type": "object",
"additionalProperties": false,
"labels": { "properties": {
"$ref": "definitions.json#/labels" "group": {
}, "type": "string"
},
"nameOverride": { "kind": {
"type": "string" "type": "string"
}, },
"namespace": {
"parentRefs": { "type": "string"
"type": "array", },
"items": { "name": {
"type": "object", "type": "string"
"additionalProperties": false, },
"properties": { "sectionName": {
"group": { "type": "string"
"type": "string" },
}, "port": {
"kind": { "type": "integer"
"type": "string" }
}, },
"namespace": { "required": ["name"]
"type": "string"
},
"name": {
"type": "string"
},
"sectionName": {
"type": "string"
} }
}, },
"required": ["name"]
}
},
"rules": { "rules": {
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"backendRefs": { "backendRefs": {
"type": "array", "type": "array",
"items": { "items": {
"type": "object",
"additionalProperties": false,
"properties": {
"group": {
"type": "string"
},
"kind": {
"type": "string"
},
"namespace": {
"type": "string"
},
"name": {
"type": "string"
},
"port": {
"type": ["string", "integer"]
},
"weight": {
"type": "integer"
}
}
}
},
"matches": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"path": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"type": { "group": {
"type": "string" "type": "string"
}, },
"value": { "kind": {
"type": "string" "type": "string"
},
"namespace": {
"type": "string"
},
"name": {
"type": "string",
"description": "A reference to a backend Service name."
},
"identifier": {
"type": "string",
"description": "A reference to a backend service that is defined within the chart values."
},
"port": {
"type": ["string", "integer"]
},
"weight": {
"type": "integer"
} }
} }
} }
},
"matches": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"path": {
"type": "object",
"additionalProperties": false,
"properties": {
"type": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
}
}
},
"filters": {
"type": "array",
"items": {}
},
"sessionPersistence": {
"description": "SessionPersistence defines the desired state of SessionPersistence",
"type": "object"
},
"timeouts": {
"type": "object"
} }
} }
},
"filters": {
"type": "array",
"items": {}
},
"timeouts": {
"type": "object"
} }
} }
} }
} }
} ]
} }
} }

View file

@ -1,35 +1,40 @@
{ {
"instance": { "instance": {
"type": "object", "allOf": [
"additionalProperties": false, { "$ref": "definitions.json#/resourceIdentifier" },
"properties": { {
"enabled": {
"type": "boolean",
"default": true
},
"includeInChecksum": {
"type": "boolean",
"default": true
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"nameOverride": {
"type": "string"
},
"type": {
"type": "string"
},
"stringData": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": false,
"type": "string" "properties": {
} "forceRename": {},
"prefix": {},
"suffix": {},
"enabled": {
"type": "boolean",
"default": true
},
"includeInChecksum": {
"type": "boolean",
"default": true
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"type": {
"type": "string"
},
"stringData": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"required": ["stringData"]
} }
}, ]
"required": ["stringData"]
} }
} }

View file

@ -1,92 +1,97 @@
{ {
"instance": { "instance": {
"type": "object", "allOf": [
"additionalProperties": false, { "$ref": "definitions.json#/resourceIdentifier" },
"properties": { {
"enabled": {
"type": "boolean",
"default": true
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"nameOverride": {
"type": "string"
},
"type": {
"type": "string"
},
"clusterIP": {
"type": "string"
},
"externalName": {
"type": "string"
},
"loadBalancerIP": {
"type": "string"
},
"loadBalancerSourceRanges": {
"type": "array",
"items": {"type": "string"}
},
"loadBalancerClass": {
"type": "string"
},
"internalTrafficPolicy": {
"type": "string",
"enum": ["Cluster", "Local"]
},
"externalTrafficPolicy": {
"type": "string",
"enum": ["Cluster", "Local"]
},
"allocateLoadBalancerNodePorts": {
"type": "boolean"
},
"sessionAffinity": {
"type": "string",
"enum": ["None", "ClientIP"]
},
"sessionAffinityConfig": {
"type": "object"
},
"externalIPs": {
"type": "array",
"items": {"type": "string"}
},
"publishNotReadyAddresses": {
"type": "boolean"
},
"ipFamilyPolicy": {
"type": "string",
"enum": ["SingleStack", "PreferDualStack", "RequireDualStack"]
},
"ipFamilies": {
"type": "array",
"items": {
"type": "string",
"enum": ["IPv4", "IPv6"]
}
},
"ports": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": false,
"$ref": "#/servicePort" "properties": {
} "forceRename": {},
}, "prefix": {},
"primary": { "suffix": {},
"type": "boolean", "enabled": {
"default": false "type": "boolean",
}, "default": true
"controller": { },
"type": "string" "annotations": {
}, "$ref": "definitions.json#/annotations"
"extraSelectorLabels": {} },
}, "labels": {
"required": ["controller"] "$ref": "definitions.json#/labels"
},
"type": {
"type": "string"
},
"clusterIP": {
"type": "string"
},
"externalName": {
"type": "string"
},
"loadBalancerIP": {
"type": "string"
},
"loadBalancerSourceRanges": {
"type": "array",
"items": {"type": "string"}
},
"loadBalancerClass": {
"type": "string"
},
"internalTrafficPolicy": {
"type": "string",
"enum": ["Cluster", "Local"]
},
"externalTrafficPolicy": {
"type": "string",
"enum": ["Cluster", "Local"]
},
"allocateLoadBalancerNodePorts": {
"type": "boolean"
},
"sessionAffinity": {
"type": "string",
"enum": ["None", "ClientIP"]
},
"sessionAffinityConfig": {
"type": "object"
},
"externalIPs": {
"type": "array",
"items": {"type": "string"}
},
"publishNotReadyAddresses": {
"type": "boolean"
},
"ipFamilyPolicy": {
"type": "string",
"enum": ["SingleStack", "PreferDualStack", "RequireDualStack"]
},
"ipFamilies": {
"type": "array",
"items": {
"type": "string",
"enum": ["IPv4", "IPv6"]
}
},
"ports": {
"type": "object",
"additionalProperties": {
"$ref": "#/servicePort"
}
},
"primary": {
"type": "boolean",
"default": false
},
"controller": {
"type": "string"
},
"extraSelectorLabels": {}
},
"required": []
}
]
}, },
"servicePort": { "servicePort": {

View file

@ -1,43 +1,30 @@
{ {
"settings": { "instance": {
"type": "object", "allOf": [
"additionalProperties": false, { "$ref": "definitions.json#/resourceIdentifier" },
"properties": { {
"create": {
"type": "boolean",
"default": false
},
"name": {
"type": "string"
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"extraServiceAccounts": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": false,
"type": "object", "properties": {
"additionalProperties": false, "forceRename": {},
"properties": { "prefix": {},
"create": { "suffix": {},
"type": "boolean", "enabled": {
"default": false "type": "boolean",
}, "default": true
"name": { },
"type": "string" "annotations": {
}, "$ref": "definitions.json#/annotations"
"annotations": { },
"$ref": "definitions.json#/annotations" "labels": {
}, "$ref": "definitions.json#/labels"
"labels": { },
"$ref": "definitions.json#/labels" "staticToken": {
} "type": "boolean",
"default": false
} }
} }
} }
} ]
} }
} }

View file

@ -1,65 +1,70 @@
{ {
"instance": { "instance": {
"type": "object", "allOf": [
"additionalProperties": false, { "$ref": "definitions.json#/resourceIdentifier" },
"properties": { {
"enabled": {
"type": "boolean",
"default": true
},
"annotations": {
"$ref": "definitions.json#/annotations"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"nameOverride": {
"type": "string"
},
"endpoints": {
"type": "array",
"items": {
"type": "object"
}
},
"selector": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"matchLabels": { "forceRename": {},
"type": "object", "prefix": {},
"additionalProperties": { "suffix": {},
"type": "string" "enabled": {
} "type": "boolean",
"default": true
}, },
"matchExpressions": { "annotations": {
"$ref": "definitions.json#/annotations"
},
"labels": {
"$ref": "definitions.json#/labels"
},
"endpoints": {
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "type": "object"
"additionalProperties": false, }
"properties": { },
"key": {"type": "string"}, "selector": {
"operator": {"type": "string"}, "type": "object",
"values": { "additionalProperties": false,
"type": "array", "properties": {
"items": {"type": "string"} "matchLabels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"matchExpressions": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"key": {"type": "string"},
"operator": {"type": "string"},
"values": {
"type": "array",
"items": {"type": "string"}
}
}
} }
} }
} }
},
"serviceName": {
"type": "string"
},
"targetLabels": {
"type": "array"
} }
},
"oneOf": [{"required": ["serviceName"]}, {"required": ["selector"]}],
"dependencies": {
"selector": {"not": {"required": ["serviceName"]}},
"serviceName": {"not": {"required": ["selector"]}}
} }
},
"serviceName": {
"type": "string"
},
"targetLabels": {
"type": "array"
} }
}, ]
"oneOf": [{"required": ["serviceName"]}, {"required": ["selector"]}],
"dependencies": {
"selector": {"not": {"required": ["serviceName"]}},
"serviceName": {"not": {"required": ["selector"]}}
}
} }
} }

View file

@ -22,13 +22,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}

View file

@ -6,13 +6,10 @@ using the common library.
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $cronjobObject := .object -}} {{- $cronjobObject := .object -}}
{{- $timeZone := "" -}} {{- $timeZone := dig "cronjob" "timeZone" "" $cronjobObject -}}
{{- if ge (int $rootContext.Capabilities.KubeVersion.Minor) 27 }}
{{- $timeZone = dig "cronjob" "timeZone" "" $cronjobObject -}}
{{- end -}}
{{- $labels := merge {{- $labels := merge
(dict "app.kubernetes.io/component" $cronjobObject.identifier) (dict "app.kubernetes.io/controller" $cronjobObject.identifier)
($cronjobObject.labels | default dict) ($cronjobObject.labels | default dict)
(include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml)
-}} -}}
@ -30,13 +27,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}

View file

@ -7,7 +7,7 @@ within the common library.
{{- $daemonsetObject := .object -}} {{- $daemonsetObject := .object -}}
{{- $labels := merge {{- $labels := merge
(dict "app.kubernetes.io/component" $daemonsetObject.identifier) (dict "app.kubernetes.io/controller" $daemonsetObject.identifier)
($daemonsetObject.labels | default dict) ($daemonsetObject.labels | default dict)
(include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml)
-}} -}}
@ -23,13 +23,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}
@ -37,7 +37,7 @@ spec:
revisionHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $daemonsetObject.revisionHistoryLimit "default" 3) }} revisionHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $daemonsetObject.revisionHistoryLimit "default" 3) }}
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/component: {{ $daemonsetObject.identifier }} app.kubernetes.io/controller: {{ $daemonsetObject.identifier }}
{{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }} {{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }}
template: template:
metadata: metadata:

View file

@ -7,7 +7,7 @@ using the common library.
{{- $deploymentObject := .object -}} {{- $deploymentObject := .object -}}
{{- $labels := merge {{- $labels := merge
(dict "app.kubernetes.io/component" $deploymentObject.identifier) (dict "app.kubernetes.io/controller" $deploymentObject.identifier)
($deploymentObject.labels | default dict) ($deploymentObject.labels | default dict)
(include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml)
-}} -}}
@ -23,13 +23,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}
@ -57,7 +57,7 @@ spec:
{{- end }} {{- end }}
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/component: {{ $deploymentObject.identifier }} app.kubernetes.io/controller: {{ $deploymentObject.identifier }}
{{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }} {{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }}
template: template:
metadata: metadata:

View file

@ -23,13 +23,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}
@ -72,7 +72,7 @@ spec:
{{ else if .service.identifier -}} {{ else if .service.identifier -}}
{{ $service = (include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" .service.identifier) | fromYaml ) -}} {{ $service = (include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" .service.identifier) | fromYaml ) -}}
{{ if not $service -}} {{ if not $service -}}
{{fail (printf "No service found with this identifier. (ingress: '%s', path: '%s', identifier: '%s')" $ingressObject.identifier .path .service.identifier)}} {{fail (printf "No enabled Service found with this identifier. (ingress: '%s', path: '%s', identifier: '%s')" $ingressObject.identifier .path .service.identifier)}}
{{ end -}} {{ end -}}
{{ $serviceName = $service.name -}} {{ $serviceName = $service.name -}}
{{ end -}} {{ end -}}

View file

@ -7,7 +7,7 @@ within the common library.
{{- $jobObject := .object -}} {{- $jobObject := .object -}}
{{- $labels := merge {{- $labels := merge
(dict "app.kubernetes.io/component" $jobObject.identifier) (dict "app.kubernetes.io/controller" $jobObject.identifier)
($jobObject.labels | default dict) ($jobObject.labels | default dict)
(include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml)
-}} -}}
@ -25,13 +25,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}

View file

@ -20,7 +20,7 @@ within the common library.
{{- else -}} {{- else -}}
{{- $podSelector = dict "matchLabels" (merge {{- $podSelector = dict "matchLabels" (merge
($networkPolicyObject.extraSelectorLabels | default dict) ($networkPolicyObject.extraSelectorLabels | default dict)
(dict "app.kubernetes.io/component" $networkPolicyObject.controller) (dict "app.kubernetes.io/controller" $networkPolicyObject.controller)
(include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | fromYaml) (include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | fromYaml)
) -}} ) -}}
{{- end -}} {{- end -}}
@ -32,13 +32,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}

View file

@ -20,7 +20,6 @@ within the common library.
$annotations $annotations
-}} -}}
{{- end -}} {{- end -}}
--- ---
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
apiVersion: v1 apiVersion: v1
@ -29,13 +28,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}

View file

@ -22,13 +22,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $resourceObject.spec }} {{- with $resourceObject.spec }}

View file

@ -25,16 +25,21 @@ kind: {{ . }}
metadata: metadata:
name: {{ $roleObject.name }} name: {{ $roleObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }}
{{- end }} {{- end }}
{{ if eq $roleObject.type "Role" -}} {{- if eq $roleObject.type "Role" }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}
{{- end -}} {{- end }}
{{ with $rules }} {{- with $rules }}
rules: {{- tpl . $rootContext | nindent 2 }} rules: {{- tpl . $rootContext | nindent 2 }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}

View file

@ -18,6 +18,9 @@ This template serves as a blueprint for generating RoleBinding objects in Kubern
{{- range $subject := . -}} {{- range $subject := . -}}
{{- if hasKey . "identifier" -}} {{- if hasKey . "identifier" -}}
{{- $subject := include "bjw-s.common.lib.serviceAccount.getByIdentifier" (dict "rootContext" $rootContext "id" .identifier) | fromYaml -}} {{- $subject := include "bjw-s.common.lib.serviceAccount.getByIdentifier" (dict "rootContext" $rootContext "id" .identifier) | fromYaml -}}
{{- if not $subject }}
{{- fail (printf "No enabled ServiceAccount found with this identifier. (rolebinding: '%s', identifier: '%s')" $roleBindingObject.identifier .identifier) -}}
{{- end -}}
{{- $subject = pick $subject "name" -}} {{- $subject = pick $subject "name" -}}
{{- $_ := set $subject "kind" "ServiceAccount" -}} {{- $_ := set $subject "kind" "ServiceAccount" -}}
{{- $_ := set $subject "namespace" $rootContext.Release.Namespace -}} {{- $_ := set $subject "namespace" $rootContext.Release.Namespace -}}
@ -38,7 +41,6 @@ This template serves as a blueprint for generating RoleBinding objects in Kubern
{{- $_ := set $role "name" .name -}} {{- $_ := set $role "name" .name -}}
{{- $_ := set $role "type" .kind -}} {{- $_ := set $role "type" .kind -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
--- ---
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
@ -48,10 +50,16 @@ kind: {{ . }}
metadata: metadata:
name: {{ $roleBindingObject.name }} name: {{ $roleBindingObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }}
{{- end }} {{- end }}
{{ if eq $roleBindingObject.type "RoleBinding" -}} {{ if eq $roleBindingObject.type "RoleBinding" -}}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}

View file

@ -50,6 +50,9 @@ spec:
{{- if .sectionName }} {{- if .sectionName }}
sectionName: {{ .sectionName | quote }} sectionName: {{ .sectionName | quote }}
{{- end }} {{- end }}
{{- if .port }}
port: {{ .port }}
{{- end }}
{{- end }} {{- end }}
{{- if and (ne $routeKind "TCPRoute") (ne $routeKind "UDPRoute") $routeObject.hostnames }} {{- if and (ne $routeKind "TCPRoute") (ne $routeKind "UDPRoute") $routeObject.hostnames }}
hostnames: hostnames:
@ -59,35 +62,47 @@ spec:
{{- end }} {{- end }}
rules: rules:
{{- range $routeObject.rules }} {{- range $routeObject.rules }}
- backendRefs: - backendRefs:
{{- range .backendRefs }} {{- if empty .backendRefs }}
{{ $service := include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" .name) | fromYaml -}} {{- printf " []" }}
{{ $servicePrimaryPort := dict -}} {{- else }}
{{ if $service -}} {{- range .backendRefs }}
{{ $servicePrimaryPort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $service) | fromYaml -}} {{- $service := dict }}
{{- end }} {{- $serviceName := "" }}
- group: {{ .group | default "" | quote}} {{- $defaultServicePort := dict }}
kind: {{ .kind | default "Service" }} {{- if .name }}
name: {{ $service.name | default .name }} {{- $serviceName = tpl .name $rootContext }}
namespace: {{ .namespace | default $rootContext.Release.Namespace }} {{- else if .identifier }}
port: {{ .port | default $servicePrimaryPort.port }} {{- $service = (include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" .identifier) | fromYaml ) }}
weight: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" .weight "default" 1) }} {{- if not $service }}
{{- end }} {{- fail (printf "No enabled Service found with this identifier. (route: '%s', identifier: '%s')" $routeObject.identifier .identifier) }}
{{- if or (eq $routeKind "HTTPRoute") (eq $routeKind "GRPCRoute") }} {{- end }}
{{- with .matches }} {{- $serviceName = $service.name }}
matches: {{- $defaultServicePort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $service) | fromYaml }}
{{- toYaml . | nindent 6 }} {{- end }}
- group: {{ .group | default "" | quote}}
kind: {{ .kind | default "Service" }}
name: {{ $serviceName }}
namespace: {{ .namespace | default $rootContext.Release.Namespace }}
port: {{ .port | default $defaultServicePort.port }}
weight: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" .weight "default" 1) }}
{{- end }}
{{- end }} {{- end }}
{{- if or (eq $routeKind "HTTPRoute") (eq $routeKind "GRPCRoute") }}
{{- with .matches }}
matches: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .filters }} {{- with .filters }}
filters: filters: {{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 6 }} {{- end }}
{{- with .sessionPersistence }}
sessionPersistence: {{- toYaml . | nindent 8 }}
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- if (eq $routeKind "HTTPRoute") }}
{{- if (eq $routeKind "HTTPRoute") }} {{- with .timeouts }}
{{- with .timeouts }} timeouts: {{- toYaml . | nindent 8 }}
timeouts: {{- end }}
{{- toYaml . | nindent 6 }}
{{- end }} {{- end }}
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}

View file

@ -30,13 +30,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}

View file

@ -25,13 +25,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}
@ -114,7 +114,7 @@ spec:
{{- end -}} {{- end -}}
{{- with (merge {{- with (merge
($serviceObject.extraSelectorLabels | default dict) ($serviceObject.extraSelectorLabels | default dict)
(dict "app.kubernetes.io/component" $serviceObject.controller) (dict "app.kubernetes.io/controller" $serviceObject.controller)
(include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | fromYaml) (include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | fromYaml)
) }} ) }}
selector: {{- toYaml . | nindent 4 }} selector: {{- toYaml . | nindent 4 }}

View file

@ -22,16 +22,18 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}
{{- if $serviceAccountObject.staticToken }}
secrets: secrets:
- name: {{ get (include "bjw-s.common.lib.secret.getByIdentifier" (dict "rootContext" $rootContext "id" (printf "%s-sa-token" $serviceAccountObject.identifier) ) | fromYaml) "name"}} - name: {{ get (include "bjw-s.common.lib.secret.getByIdentifier" (dict "rootContext" $rootContext "id" (printf "%s-sa-token" $serviceAccountObject.identifier) ) | fromYaml) "name"}}
{{- end }}
{{- end -}} {{- end -}}

View file

@ -17,13 +17,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}

View file

@ -7,7 +7,7 @@ within the common library.
{{- $statefulsetObject := .object -}} {{- $statefulsetObject := .object -}}
{{- $labels := merge {{- $labels := merge
(dict "app.kubernetes.io/component" $statefulsetObject.identifier) (dict "app.kubernetes.io/controller" $statefulsetObject.identifier)
($statefulsetObject.labels | default dict) ($statefulsetObject.labels | default dict)
(include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml)
-}} -}}
@ -23,13 +23,13 @@ metadata:
{{- with $labels }} {{- with $labels }}
labels: labels:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }} {{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}
namespace: {{ $rootContext.Release.Namespace }} namespace: {{ $rootContext.Release.Namespace }}
@ -45,7 +45,7 @@ spec:
{{- end }} {{- end }}
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/component: {{ $statefulsetObject.identifier }} app.kubernetes.io/controller: {{ $statefulsetObject.identifier }}
{{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }} {{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }}
serviceName: {{ include "bjw-s.common.lib.chart.names.fullname" $rootContext }} serviceName: {{ include "bjw-s.common.lib.chart.names.fullname" $rootContext }}
{{- with (dig "statefulset" "persistentVolumeClaimRetentionPolicy" nil $statefulsetObject) }} {{- with (dig "statefulset" "persistentVolumeClaimRetentionPolicy" nil $statefulsetObject) }}

View file

@ -0,0 +1,38 @@
{{/*
Determine a recourse name based on Helm values
*/}}
{{- define "bjw-s.common.lib.determineResourceNameFromValues" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $objectValues := .values -}}
{{- $itemCount := .itemCount -}}
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.forceRename -}}
{{- $objectName = tpl $objectValues.forceRename $rootContext -}}
{{- else -}}
{{- if not (empty $objectValues.prefix) -}}
{{- $renderedPrefix := (tpl $objectValues.prefix $rootContext) -}}
{{- if not (eq $objectName $renderedPrefix) -}}
{{- $objectName = printf "%s-%s" $renderedPrefix $objectName -}}
{{- end -}}
{{- end -}}
{{- if not (empty $itemCount) -}}
{{- if (gt $itemCount 1) -}}
{{- if not (hasSuffix (printf "-%s" $identifier) $objectName) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if not (empty $objectValues.suffix) -}}
{{- $renderedSuffix := (tpl $objectValues.suffix $rootContext) -}}
{{- if not (hasSuffix (printf "-%s" $renderedSuffix) $objectName) -}}
{{- $objectName = printf "%s-%s" $objectName $renderedSuffix -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $objectName | lower -}}
{{- end -}}

View file

@ -5,25 +5,12 @@ Convert values to an object
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $identifier := .id -}} {{- $identifier := .id -}}
{{- $objectValues := .values -}} {{- $objectValues := .values -}}
{{- $itemCount := .itemCount -}}
{{- /* Determine and inject the name */ -}} {{- $objectName := (include "bjw-s.common.lib.determineResourceNameFromValues" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" $itemCount)) -}}
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.forceRename -}}
{{- $objectName = tpl $objectValues.forceRename $rootContext -}}
{{- else if $objectValues.nameOverride -}}
{{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}}
{{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}}
{{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}} {{- $_ := set $objectValues "identifier" $identifier -}}
{{- /* Return the object */ -}}
{{- $objectValues | toYaml -}} {{- $objectValues | toYaml -}}
{{- end -}} {{- end -}}

View file

@ -0,0 +1,23 @@
{{/*
Return the enabled configMaps.
*/}}
{{- define "bjw-s.common.lib.configMap.enabledConfigmaps" -}}
{{- $rootContext := .rootContext -}}
{{- $enabledSecrets := dict -}}
{{- range $identifier, $secret := $rootContext.Values.configMaps -}}
{{- if kindIs "map" $secret -}}
{{- /* Enable Secret by default, but allow override */ -}}
{{- $secretEnabled := true -}}
{{- if hasKey $secret "enabled" -}}
{{- $secretEnabled = $secret.enabled -}}
{{- end -}}
{{- if $secretEnabled -}}
{{- $_ := set $enabledSecrets $identifier . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $enabledSecrets | toYaml -}}
{{- end -}}

View file

@ -4,9 +4,10 @@ Return a configMap Object by its Identifier.
{{- define "bjw-s.common.lib.configMap.getByIdentifier" -}} {{- define "bjw-s.common.lib.configMap.getByIdentifier" -}}
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $identifier := .id -}} {{- $identifier := .id -}}
{{- $enabledConfigMaps := (include "bjw-s.common.lib.configMap.enabledConfigmaps" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- $configMapValues := dig $identifier nil $rootContext.Values.configMaps -}} {{- if (hasKey $enabledConfigMaps $identifier) -}}
{{- if not (empty $configMapValues) -}} {{- $objectValues := get $enabledConfigMaps $identifier -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $configMapValues) -}} {{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledConfigMaps)) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -6,9 +6,10 @@ Validate configMap values
{{- $configMapValues := .object -}} {{- $configMapValues := .object -}}
{{- $identifier := .id -}} {{- $identifier := .id -}}
{{- if empty $configMapValues -}} {{- if eq (len (without (keys $configMapValues) "name" "identifier")) 0 -}}
{{- fail (printf "There was an error loading ConfigMap: %s. If it was automatically generated from a folder verify that files are properly flagged as `binary` or `escaped`" $identifier) -}} {{- fail (printf "There was an error loading ConfigMap: %s. If it was automatically generated from a folder verify that files are properly flagged as `binary` or `escaped`" $identifier) -}}
{{- end -}} {{- end -}}
{{- if and (empty (get $configMapValues "data")) (empty (get $configMapValues "binaryData")) -}} {{- if and (empty (get $configMapValues "data")) (empty (get $configMapValues "binaryData")) -}}
{{- fail (printf "No data or binaryData specified for configMap. (configMap: %s)" $configMapValues.identifier) }} {{- fail (printf "No data or binaryData specified for configMap. (configMap: %s)" $configMapValues.identifier) }}
{{- end -}} {{- end -}}

View file

@ -81,20 +81,22 @@ volumeMounts used by the container.
{{- /* Use the specified subPath if provided */ -}} {{- /* Use the specified subPath if provided */ -}}
{{- with .subPath -}} {{- with .subPath -}}
{{- $subPath := . -}} {{- $_ := set $volumeMount "subPath" . -}}
{{- $_ := set $volumeMount "subPath" $subPath -}} {{- end -}}
{{- /* Use the specified subPathExpr if provided */ -}}
{{- with .subPathExpr -}}
{{- $_ := set $volumeMount "subPathExpr" . -}}
{{- end -}} {{- end -}}
{{- /* Use the specified readOnly setting if provided */ -}} {{- /* Use the specified readOnly setting if provided */ -}}
{{- with .readOnly -}} {{- with .readOnly -}}
{{- $readOnly := . -}} {{- $_ := set $volumeMount "readOnly" . -}}
{{- $_ := set $volumeMount "readOnly" $readOnly -}}
{{- end -}} {{- end -}}
{{- /* Use the specified mountPropagation setting if provided */ -}} {{- /* Use the specified mountPropagation setting if provided */ -}}
{{- with .mountPropagation -}} {{- with .mountPropagation -}}
{{- $mountPropagation := . -}} {{- $_ := set $volumeMount "mountPropagation" . -}}
{{- $_ := set $volumeMount "mountPropagation" $mountPropagation -}}
{{- end -}} {{- end -}}
{{- $enabledVolumeMounts = append $enabledVolumeMounts $volumeMount -}} {{- $enabledVolumeMounts = append $enabledVolumeMounts $volumeMount -}}

View file

@ -1,14 +1,19 @@
{{/* {{/*
Return a controller by its identifier. Return a controller object by its Identifier.
*/}} */}}
{{- define "bjw-s.common.lib.controller.getByIdentifier" -}} {{- define "bjw-s.common.lib.controller.getByIdentifier" -}}
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $identifier := .id -}} {{- $identifier := .id -}}
{{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- $enabledControllers := include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml -}} {{- if (hasKey $enabledControllers $identifier) -}}
{{- $controllerValues := get $enabledControllers $identifier -}} {{- $objectValues := get $enabledControllers $identifier -}}
{{- if not (empty $controllerValues) -}} {{- /* Default the controller type to Deployment */ -}}
{{- include "bjw-s.common.lib.controller.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $controllerValues) -}} {{- if empty (dig "type" nil $objectValues) -}}
{{- $_ := set $objectValues "type" "deployment" -}}
{{- end -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledControllers)) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -1,35 +0,0 @@
{{/*
Convert controller values to an object
*/}}
{{- define "bjw-s.common.lib.controller.valuesToObject" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $objectValues := .values -}}
{{- /* Default the controller type to Deployment */ -}}
{{- if empty (dig "type" nil $objectValues) -}}
{{- $_ := set $objectValues "type" "deployment" -}}
{{- end -}}
{{- /* Determine and inject the controller name */ -}}
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}}
{{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}}
{{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if gt (len $enabledControllers) 1 -}}
{{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- /* Return the controller object */ -}}
{{- $objectValues | toYaml -}}
{{- end -}}

View file

@ -5,6 +5,12 @@ Convert Cronjob values to an object
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $identifier := .id -}} {{- $identifier := .id -}}
{{- $objectValues := .values -}} {{- $objectValues := .values -}}
{{- $itemCount := .itemCount -}}
{{- $objectName := (include "bjw-s.common.lib.determineResourceNameFromValues" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" $itemCount)) -}}
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- if not (hasKey $objectValues "pod") -}} {{- if not (hasKey $objectValues "pod") -}}
{{- $_ := set $objectValues "pod" dict -}} {{- $_ := set $objectValues "pod" dict -}}
@ -13,6 +19,5 @@ Convert Cronjob values to an object
{{- $restartPolicy := default "Never" $objectValues.pod.restartPolicy -}} {{- $restartPolicy := default "Never" $objectValues.pod.restartPolicy -}}
{{- $_ := set $objectValues.pod "restartPolicy" $restartPolicy -}} {{- $_ := set $objectValues.pod "restartPolicy" $restartPolicy -}}
{{- /* Return the CronJob object */ -}}
{{- $objectValues | toYaml -}} {{- $objectValues | toYaml -}}
{{- end -}} {{- end -}}

View file

@ -0,0 +1,30 @@
{{/*
Return an Ingress Object by its Identifier.
*/}}
{{- define "bjw-s.common.lib.ingress.getByIdentifier" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{- $enabledIngresses := (include "bjw-s.common.lib.ingress.enabledIngresses" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if (hasKey $enabledIngresses $identifier) -}}
{{- $objectValues := get $enabledIngresses $identifier -}}
{{- $object := include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledIngresses)) | fromYaml -}}
{{- /* Try to automatically determine the default Service identifier if needed and possible */ -}}
{{- if eq 1 (len $enabledServices) -}}
{{- range $object.hosts -}}
{{- range .paths -}}
{{- if not (has "service" (keys .)) -}}
{{- $_ := set . "service" (dict "identifier" ($enabledServices | keys | first)) -}}
{{- else if and (not .service.name) (not .service.identifier) -}}
{{- $_ := set .service "identifier" ($enabledServices | keys | first) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $object | toYaml -}}
{{- end -}}
{{- end -}}

View file

@ -3,5 +3,21 @@ Validate Ingress values
*/}} */}}
{{- define "bjw-s.common.lib.ingress.validate" -}} {{- define "bjw-s.common.lib.ingress.validate" -}}
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $ingressValues := .object -}} {{- $ingressObject := .object -}}
{{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{/* Verify automatic service detection */}}
{{- if not (eq 1 (len $enabledServices)) -}}
{{- range $ingressObject.hosts -}}
{{- $host := . -}}
{{- range $host.paths -}}
{{- $path := . -}}
{{- if or (not (has "service" (keys .))) (and (not $path.service.name) (not $path.service.identifier)) -}}
{{- fail (printf "Either service.name or service.identifier is required because automatic Service detection is not possible. (ingress: %s, host: %s, path: %s)" $ingressObject.identifier $host.host $path.path ) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}} {{- end -}}

View file

@ -1,30 +0,0 @@
{{/*
Convert ingress values to an object
*/}}
{{- define "bjw-s.common.lib.ingress.valuesToObject" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $objectValues := .values -}}
{{- /* Determine and inject the ingress name */ -}}
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}}
{{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}}
{{- $enabledIngresses := (include "bjw-s.common.lib.ingress.enabledIngresses" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if gt (len $enabledIngresses) 1 -}}
{{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- /* Return the ingress object */ -}}
{{- $objectValues | toYaml -}}
{{- end -}}

View file

@ -1,7 +1,7 @@
{{/* {{/*
Return the enabled NetworkPolicies. Return the enabled NetworkPolicies.
*/}} */}}
{{- define "bjw-s.common.lib.networkPolicy.enabledNetworkPolicies" -}} {{- define "bjw-s.common.lib.networkpolicy.enabledNetworkPolicies" -}}
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $enabledNetworkPolicies := dict -}} {{- $enabledNetworkPolicies := dict -}}

View file

@ -0,0 +1,13 @@
{{/*
Return a NetworkPolicy object by its Identifier.
*/}}
{{- define "bjw-s.common.lib.networkpolicy.getByIdentifier" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $enabledNetworkPolicies := (include "bjw-s.common.lib.networkpolicy.enabledNetworkPolicies" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if (hasKey $enabledNetworkPolicies $identifier) -}}
{{- $objectValues := get $enabledNetworkPolicies $identifier -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledNetworkPolicies)) -}}
{{- end -}}
{{- end -}}

View file

@ -1,30 +0,0 @@
{{/*
Convert networkPolicy values to an object
*/}}
{{- define "bjw-s.common.lib.networkpolicy.valuesToObject" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $objectValues := .values -}}
{{- /* Determine and inject the networkPolicy name */ -}}
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}}
{{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}}
{{- $enabledNetworkPolicies := (include "bjw-s.common.lib.networkPolicy.enabledNetworkPolicies" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if gt (len $enabledNetworkPolicies) 1 -}}
{{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- /* Return the networkPolicy object */ -}}
{{- $objectValues | toYaml -}}
{{- end -}}

View file

@ -6,9 +6,10 @@ Returns the value for the specified field
{{- $controllerObject := .ctx.controllerObject -}} {{- $controllerObject := .ctx.controllerObject -}}
{{- $option := .option -}} {{- $option := .option -}}
{{- $default := default "" .default -}} {{- $default := default "" .default -}}
{{- $value := $default -}} {{- $value := $default -}}
{{- $defaultPodOptionsStrategy := dig "defaultPodOptionsStrategy" "overwrite" $rootContext.Values -}}
{{- /* Set to the default if it is set */ -}} {{- /* Set to the default if it is set */ -}}
{{- $defaultOption := dig $option nil (default dict $rootContext.Values.defaultPodOptions) -}} {{- $defaultOption := dig $option nil (default dict $rootContext.Values.defaultPodOptions) -}}
{{- if kindIs "bool" $defaultOption -}} {{- if kindIs "bool" $defaultOption -}}
@ -19,8 +20,15 @@ Returns the value for the specified field
{{- /* See if a pod-specific override is needed */ -}} {{- /* See if a pod-specific override is needed */ -}}
{{- $podOption := dig $option nil (default dict $controllerObject.pod) -}} {{- $podOption := dig $option nil (default dict $controllerObject.pod) -}}
{{- if kindIs "bool" $podOption -}} {{- if kindIs "bool" $podOption -}}
{{- $value = $podOption -}} {{- $value = $podOption -}}
{{- else if kindIs "map" $podOption -}}
{{- if eq "merge" $defaultPodOptionsStrategy -}}
{{- $value = merge $podOption $value -}}
{{- else if eq "overwrite" $defaultPodOptionsStrategy -}}
{{- $value = $podOption -}}
{{- end -}}
{{- else if not (empty $podOption) -}} {{- else if not (empty $podOption) -}}
{{- $value = $podOption -}} {{- $value = $podOption -}}
{{- end -}} {{- end -}}

View file

@ -48,6 +48,11 @@ imagePullSecrets: {{ . | nindent 2 }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "terminationGracePeriodSeconds")) }} {{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "terminationGracePeriodSeconds")) }}
terminationGracePeriodSeconds: {{ . | trim }} terminationGracePeriodSeconds: {{ . | trim }}
{{- end -}} {{- end -}}
{{- if ge ($rootContext.Capabilities.KubeVersion.Minor | int) 32 }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "resources")) }}
resources: {{ . | nindent 2 }}
{{- end -}}
{{- end -}}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "restartPolicy")) }} {{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "restartPolicy")) }}
restartPolicy: {{ . | trim }} restartPolicy: {{ . | trim }}
{{- end -}} {{- end -}}

View file

@ -4,24 +4,20 @@ Returns the value for serviceAccountName
{{- define "bjw-s.common.lib.pod.field.serviceAccountName" -}} {{- define "bjw-s.common.lib.pod.field.serviceAccountName" -}}
{{- $rootContext := .ctx.rootContext -}} {{- $rootContext := .ctx.rootContext -}}
{{- $controllerObject := .ctx.controllerObject -}} {{- $controllerObject := .ctx.controllerObject -}}
{{- $serviceAccountName := "default" -}} {{- $serviceAccountName := "default" -}}
{{- if $rootContext.Values.enforceServiceAccountCreation -}}
{{- if (get (include "bjw-s.common.lib.serviceAccount.getByIdentifier" (dict "rootContext" $rootContext "id" "default") | fromYaml) "create") -}}
{{- $serviceAccountName = get (include "bjw-s.common.lib.serviceAccount.getByIdentifier" (dict "rootContext" $rootContext "id" "default") | fromYaml) "name" -}}
{{- end -}}
{{- else -}}
{{- $serviceAccountName = get (include "bjw-s.common.lib.serviceAccount.getByIdentifier" (dict "rootContext" $rootContext "id" "default") | fromYaml) "name" -}}
{{- end -}}
{{- with $controllerObject.serviceAccount -}} {{- with $controllerObject.serviceAccount -}}
{{- if hasKey . "identifier" -}} {{- if hasKey . "identifier" -}}
{{- $serviceAccountName = get (include "bjw-s.common.lib.serviceAccount.getByIdentifier" (dict "rootContext" $rootContext "id" .identifier) | fromYaml) "name" -}} {{- $subject := (include "bjw-s.common.lib.serviceAccount.getByIdentifier" (dict "rootContext" $rootContext "id" .identifier) | fromYaml) -}}
{{- if not $subject }}
{{- fail (printf "No enabled ServiceAccount found with this identifier. (controller: '%s', identifier: '%s')" $controllerObject.identifier .identifier) -}}
{{- end -}}
{{- $serviceAccountName = get $subject "name" -}}
{{- else if hasKey . "name" -}} {{- else if hasKey . "name" -}}
{{- $serviceAccountName = .name -}} {{- $serviceAccountName = .name -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- $serviceAccountName -}} {{- $serviceAccountName -}}
{{- end -}} {{- end -}}

View file

@ -46,15 +46,8 @@ Returns the value for volumes
{{- $pvcName = $persistenceValues.existingClaim -}} {{- $pvcName = $persistenceValues.existingClaim -}}
{{- else -}} {{- else -}}
{{- /* Otherwise refer to the PVC name */ -}} {{- /* Otherwise refer to the PVC name */ -}}
{{- if $persistenceValues.nameOverride -}} {{- $object := (include "bjw-s.common.lib.pvc.getByIdentifier" (dict "rootContext" $rootContext "id" $identifier) | fromYaml) -}}
{{- if not (eq $persistenceValues.nameOverride "-") -}} {{- $pvcName = get $object "name" -}}
{{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $rootContext) $persistenceValues.nameOverride) -}}
{{- end -}}
{{- else -}}
{{- if not (eq $pvcName $identifier) -}}
{{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $rootContext) $identifier) -}}
{{- end -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- $_ := set $volume "persistentVolumeClaim" (dict "claimName" $pvcName) -}} {{- $_ := set $volume "persistentVolumeClaim" (dict "claimName" $pvcName) -}}

View file

@ -7,7 +7,7 @@ Returns the value for labels
{{- /* Default labels */ -}} {{- /* Default labels */ -}}
{{- $labels := merge {{- $labels := merge
(dict "app.kubernetes.io/component" $controllerObject.identifier) (dict "app.kubernetes.io/controller" $controllerObject.identifier)
-}} -}}
{{- /* Include global labels if specified */ -}} {{- /* Include global labels if specified */ -}}

View file

@ -0,0 +1,23 @@
{{/*
Return the enabled PVCs.
*/}}
{{- define "bjw-s.common.lib.pvc.enabledPVCs" -}}
{{- $rootContext := .rootContext -}}
{{- $enabledPVCs := dict -}}
{{- range $identifier, $persistenceItem := $rootContext.Values.persistence -}}
{{- if kindIs "map" $persistenceItem -}}
{{- /* Enable PVC by default, but allow override */ -}}
{{- $pvcEnabled := true -}}
{{- if hasKey $persistenceItem "enabled" -}}
{{- $pvcEnabled = $persistenceItem.enabled -}}
{{- end -}}
{{- if and $pvcEnabled (eq (default "persistentVolumeClaim" $persistenceItem.type) "persistentVolumeClaim") (not $persistenceItem.existingClaim) -}}
{{- $_ := set $enabledPVCs $identifier . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $enabledPVCs | toYaml -}}
{{- end -}}

View file

@ -0,0 +1,23 @@
{{/*
Return the enabled roles.
*/}}
{{- define "bjw-s.common.lib.rbac.role.enabledRoles" -}}
{{- $rootContext := .rootContext -}}
{{- $enabledRoles := dict -}}
{{- range $name, $role := $rootContext.Values.rbac.roles -}}
{{- if kindIs "map" $role -}}
{{- /* Enable Role by default, but allow override */ -}}
{{- $roleEnabled := true -}}
{{- if hasKey $role "enabled" -}}
{{- $roleEnabled = $role.enabled -}}
{{- end -}}
{{- if $roleEnabled -}}
{{- $_ := set $enabledRoles $name . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $enabledRoles | toYaml -}}
{{- end -}}

View file

@ -0,0 +1,13 @@
{{/*
Return a PVC object by its Identifier.
*/}}
{{- define "bjw-s.common.lib.pvc.getByIdentifier" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $enabledPVCs := (include "bjw-s.common.lib.pvc.enabledPVCs" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if (hasKey $enabledPVCs $identifier) -}}
{{- $objectValues := get $enabledPVCs $identifier -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledPVCs)) -}}
{{- end -}}
{{- end -}}

View file

@ -1,7 +0,0 @@
{{/*
Validate PVC values
*/}}
{{- define "bjw-s.common.lib.pvc.validate" -}}
{{- $rootContext := .rootContext -}}
{{- $pvcObject := .object -}}
{{- end -}}

View file

@ -1,26 +0,0 @@
{{/*
Convert PVC values to an object
*/}}
{{- define "bjw-s.common.lib.pvc.valuesToObject" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $objectValues := .values -}}
{{- /* Determine and inject the PVC name */ -}}
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}}
{{- if ne $objectValues.nameOverride "-" -}}
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}}
{{- end -}}
{{- else -}}
{{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}}
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- /* Return the PVC object */ -}}
{{- $objectValues | toYaml -}}
{{- end -}}

View file

@ -0,0 +1,23 @@
{{/*
Return the enabled raw resources.
*/}}
{{- define "bjw-s.common.lib.rawResource.enabledRawResources" -}}
{{- $rootContext := .rootContext -}}
{{- $enabledRawResources := dict -}}
{{- range $name, $resource := $rootContext.Values.rawResources -}}
{{- if kindIs "map" $resource -}}
{{- /* Enable Raw Resource by default, but allow override */ -}}
{{- $resourceEnabled := true -}}
{{- if hasKey $resource "enabled" -}}
{{- $resourceEnabled = $resource.enabled -}}
{{- end -}}
{{- if $resourceEnabled -}}
{{- $_ := set $enabledRawResources $name . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $enabledRawResources | toYaml -}}
{{- end -}}

View file

@ -0,0 +1,13 @@
{{/*
Return a RawResource Object by its Identifier.
*/}}
{{- define "bjw-s.common.lib.rawResource.getByIdentifier" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $enabledRawResources := (include "bjw-s.common.lib.rawResource.enabledRawResources" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if (hasKey $enabledRawResources $identifier) -}}
{{- $objectValues := get $enabledRawResources $identifier -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledRawResources)) -}}
{{- end -}}
{{- end -}}

View file

@ -1,7 +0,0 @@
{{/*
Validate raw resource values
*/}}
{{- define "bjw-s.common.lib.rawResource.validate" -}}
{{- $rootContext := .rootContext -}}
{{- $resourceObject := .object -}}
{{- end -}}

View file

@ -0,0 +1,23 @@
{{/*
Return the enabled roles.
*/}}
{{- define "bjw-s.common.lib.rbac.role.enabledRoles" -}}
{{- $rootContext := .rootContext -}}
{{- $enabledRoles := dict -}}
{{- range $name, $role := $rootContext.Values.rbac.roles -}}
{{- if kindIs "map" $role -}}
{{- /* Enable Role by default, but allow override */ -}}
{{- $roleEnabled := true -}}
{{- if hasKey $role "enabled" -}}
{{- $roleEnabled = $role.enabled -}}
{{- end -}}
{{- if $roleEnabled -}}
{{- $_ := set $enabledRoles $name . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $enabledRoles | toYaml -}}
{{- end -}}

View file

@ -4,9 +4,10 @@ Return a Role Object by its Identifier.
{{- define "bjw-s.common.lib.rbac.role.getByIdentifier" -}} {{- define "bjw-s.common.lib.rbac.role.getByIdentifier" -}}
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $identifier := .id -}} {{- $identifier := .id -}}
{{- $enabledRoles := (include "bjw-s.common.lib.rbac.role.enabledRoles" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- $roleValues := dig $identifier nil $rootContext.Values.rbac.roles -}} {{- if (hasKey $enabledRoles $identifier) -}}
{{- if not (empty $roleValues) -}} {{- $objectValues := get $enabledRoles $identifier -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $roleValues) -}} {{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledRoles)) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -4,15 +4,9 @@ Validate Role values
{{- define "bjw-s.common.lib.rbac.role.validate" -}} {{- define "bjw-s.common.lib.rbac.role.validate" -}}
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $roleValues := .object -}} {{- $roleValues := .object -}}
{{- $type := required "The role needs to have an explicitly declared type" $roleValues.type -}}
{{- $typeList := list "Role" "ClusterRole" -}}
{{- $rules := $roleValues.rules -}} {{- $rules := $roleValues.rules -}}
{{- if not (mustHas $type $typeList) -}}
{{- fail (printf "\nYou selected: `%s`. Type must be one of:\n%s\n" $type ($typeList|toYaml)) -}}
{{- end -}}
{{- if not $rules -}} {{- if not $rules -}}
{{- fail "Rules can't be empty" -}} {{- fail "Rules can't be empty" -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -0,0 +1,23 @@
{{/*
Return the enabled RoleBindings.
*/}}
{{- define "bjw-s.common.lib.rbac.roleBinding.enabledRoleBindings" -}}
{{- $rootContext := .rootContext -}}
{{- $enabledRoleBindings := dict -}}
{{- range $name, $role := $rootContext.Values.rbac.bindings -}}
{{- if kindIs "map" $role -}}
{{- /* Enable Role by default, but allow override */ -}}
{{- $roleEnabled := true -}}
{{- if hasKey $role "enabled" -}}
{{- $roleEnabled = $role.enabled -}}
{{- end -}}
{{- if $roleEnabled -}}
{{- $_ := set $enabledRoleBindings $name . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $enabledRoleBindings | toYaml -}}
{{- end -}}

View file

@ -4,9 +4,10 @@ Return a RoleBinding Object by its Identifier.
{{- define "bjw-s.common.lib.rbac.roleBinding.getByIdentifier" -}} {{- define "bjw-s.common.lib.rbac.roleBinding.getByIdentifier" -}}
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $identifier := .id -}} {{- $identifier := .id -}}
{{- $enabledRoleBindings := (include "bjw-s.common.lib.rbac.roleBinding.enabledRoleBindings" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- $roleBindingValues := dig $identifier nil $rootContext.Values.rbac.bindings -}} {{- if (hasKey $enabledRoleBindings $identifier) -}}
{{- if not (empty $roleBindingValues) -}} {{- $objectValues := get $enabledRoleBindings $identifier -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $roleBindingValues) -}} {{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledRoleBindings)) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -1,32 +0,0 @@
{{/*
Validate RoleBinding values
*/}}
{{- define "bjw-s.common.lib.rbac.roleBinding.validate" -}}
{{- $rootContext := .rootContext -}}
{{- $roleBindingValues := .object -}}
{{- $type := required "The binding needs to have an explicitly declared type" $roleBindingValues.type -}}
{{- $typeList := list "RoleBinding" "ClusterRoleBinding" -}}
{{- $subjects := $roleBindingValues.subjects -}}
{{- $roleRef := required "A roleRef is required" $roleBindingValues.roleRef -}}
{{- if not (mustHas $type $typeList) -}}
{{- fail (printf "\nYou selected: `%s`. Type must be one of:\n%s\n" $type ($typeList|toYaml)) -}}
{{- end -}}
{{- if not (hasKey $roleRef "identifier") -}}
{{- $name := required "If not using identifier roleRef must have a `name` key" $roleRef.name -}}
{{- $name := required "If not using identifier roleRef must have a `kind` key" $roleRef.kind -}}
{{- end -}}
{{- range $subject := $subjects -}}
{{- if not (hasKey . "identifier") -}}
{{- if not (hasKey . "name") -}}
{{- $name := required "If not using identifier a subject must have a `name` key" .name -}}
{{- else if not (hasKey . "namespace") -}}
{{- $namespace := required "If not using identifier a subject must have a `namespace` key" .namespace -}}
{{- else if not (hasKey . "kind") -}}
{{- $kind := required "If not using identifier a subject must have a `kind` key" .kind -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

View file

@ -0,0 +1,13 @@
{{/*
Return a Route object by its Identifier.
*/}}
{{- define "bjw-s.common.lib.route.getByIdentifier" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $enabledRoutes := (include "bjw-s.common.lib.route.enabledRoutes" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if (hasKey $enabledRoutes $identifier) -}}
{{- $objectValues := get $enabledRoutes $identifier -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledRoutes)) -}}
{{- end -}}
{{- end -}}

View file

@ -1,30 +0,0 @@
{{/*
Convert Route values to an object
*/}}
{{- define "bjw-s.common.lib.route.valuesToObject" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $objectValues := .values -}}
{{- /* Determine and inject the Route name */ -}}
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}}
{{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}}
{{- $enabledRoutes := (include "bjw-s.common.lib.route.enabledRoutes" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if and (not $objectValues.primary) (gt (len $enabledRoutes) 1) -}}
{{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- /* Return the Route object */ -}}
{{- $objectValues | toYaml -}}
{{- end -}}

View file

@ -0,0 +1,23 @@
{{/*
Return the enabled secrets.
*/}}
{{- define "bjw-s.common.lib.secret.enabledSecrets" -}}
{{- $rootContext := .rootContext -}}
{{- $enabledSecrets := dict -}}
{{- range $identifier, $secret := $rootContext.Values.secrets -}}
{{- if kindIs "map" $secret -}}
{{- /* Enable Secret by default, but allow override */ -}}
{{- $secretEnabled := true -}}
{{- if hasKey $secret "enabled" -}}
{{- $secretEnabled = $secret.enabled -}}
{{- end -}}
{{- if $secretEnabled -}}
{{- $_ := set $enabledSecrets $identifier . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $enabledSecrets | toYaml -}}
{{- end -}}

View file

@ -4,9 +4,10 @@ Return a secret Object by its Identifier.
{{- define "bjw-s.common.lib.secret.getByIdentifier" -}} {{- define "bjw-s.common.lib.secret.getByIdentifier" -}}
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $identifier := .id -}} {{- $identifier := .id -}}
{{- $enabledSecrets := (include "bjw-s.common.lib.secret.enabledSecrets" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- $secretValues := dig $identifier nil $rootContext.Values.secrets -}} {{- if (hasKey $enabledSecrets $identifier) -}}
{{- if not (empty $secretValues) -}} {{- $objectValues := get $enabledSecrets $identifier -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $secretValues) -}} {{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledSecrets)) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -1,7 +0,0 @@
{{/*
Validate Secret values
*/}}
{{- define "bjw-s.common.lib.secret.validate" -}}
{{- $rootContext := .rootContext -}}
{{- $secretValues := .object -}}
{{- end -}}

View file

@ -14,6 +14,8 @@ Return the enabled services.
{{- end -}} {{- end -}}
{{- if $serviceEnabled -}} {{- if $serviceEnabled -}}
{{- $_ := set $enabledServices $name . -}} {{- $_ := set $enabledServices $name . -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -4,10 +4,19 @@ Return a service Object by its Identifier.
{{- define "bjw-s.common.lib.service.getByIdentifier" -}} {{- define "bjw-s.common.lib.service.getByIdentifier" -}}
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $identifier := .id -}} {{- $identifier := .id -}}
{{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{- range $name, $serviceValues := $rootContext.Values.service -}} {{- if (hasKey $enabledServices $identifier) -}}
{{- if eq $name $identifier -}} {{- $objectValues := get $enabledServices $identifier -}}
{{- include "bjw-s.common.lib.service.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $serviceValues) -}} {{- $object := include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledServices)) | fromYaml -}}
{{- if eq 1 (len $enabledControllers) -}}
{{- if (empty (dig "controller" nil $object)) -}}
{{- $_ := set $object "controller" ($enabledControllers | keys | first) -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- $object | toYaml -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -5,7 +5,7 @@ Return the primary service object for a controller
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $controllerIdentifier := .controllerIdentifier -}} {{- $controllerIdentifier := .controllerIdentifier -}}
{{- $identifier := "" -}} {{- $serviceIdentifier := "" -}}
{{- $result := dict -}} {{- $result := dict -}}
{{- /* Loop over all enabled services */ -}} {{- /* Loop over all enabled services */ -}}
@ -13,27 +13,29 @@ Return the primary service object for a controller
{{- if $enabledServices -}} {{- if $enabledServices -}}
{{- /* We are only interested in services for the specified controller */ -}} {{- /* We are only interested in services for the specified controller */ -}}
{{- $enabledServicesForController := dict -}} {{- $enabledServicesForController := dict -}}
{{- range $name, $service := $enabledServices -}} {{- range $identifier, $serviceObject := $enabledServices -}}
{{- if eq $service.controller $controllerIdentifier -}} {{- if eq $serviceObject.controller $controllerIdentifier -}}
{{- $_ := set $enabledServicesForController $name $service -}} {{- $_ := set $enabledServicesForController $identifier $serviceObject -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- range $name, $service := $enabledServicesForController -}} {{- range $identifier, $serviceObject := $enabledServicesForController -}}
{{- /* Determine the Service that has been marked as primary */ -}} {{- /* Determine the Service that has been marked as primary */ -}}
{{- if $service.primary -}} {{- if $serviceObject.primary -}}
{{- $identifier = $name -}} {{- $serviceIdentifier = $identifier -}}
{{- $result = $service -}} {{- $result = $serviceObject -}}
{{- end -}} {{- end -}}
{{- /* Return the first Service (alphabetically) if none has been explicitly marked as primary */ -}} {{- /* Return the first Service (alphabetically) if none has been explicitly marked as primary */ -}}
{{- if not $result -}} {{- if not $result -}}
{{- $firstServiceKey := keys $enabledServicesForController | sortAlpha | first -}} {{- $firstServiceKey := keys $enabledServicesForController | sortAlpha | first -}}
{{- $result = get $enabledServicesForController $firstServiceKey -}} {{- $result = get $enabledServicesForController $firstServiceKey -}}
{{- $identifier = $result.identifier -}} {{- $serviceIdentifier = $identifier -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- include "bjw-s.common.lib.service.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $result) -}} {{- if not (empty $serviceIdentifier) -}}
{{- include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" $serviceIdentifier) -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -5,6 +5,15 @@ Validate Service values
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $serviceObject := .object -}} {{- $serviceObject := .object -}}
{{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{/* Verify automatic controller detection */}}
{{- if not (eq 1 (len $enabledControllers)) -}}
{{- if or (not (has "controller" (keys $serviceObject))) (empty (get $serviceObject "controller")) -}}
{{- fail (printf "controller field is required because automatic controller detection is not possible. (service: %s)" $serviceObject.identifier ) -}}
{{- end -}}
{{- end -}}
{{- if empty (get $serviceObject "controller") -}} {{- if empty (get $serviceObject "controller") -}}
{{- fail (printf "controller field is required for Service. (service: %s)" $serviceObject.identifier) -}} {{- fail (printf "controller field is required for Service. (service: %s)" $serviceObject.identifier) -}}
{{- end -}} {{- end -}}
@ -29,13 +38,13 @@ Validate Service values
{{- $enabledPorts := include "bjw-s.common.lib.service.enabledPorts" (dict "rootContext" $rootContext "serviceObject" $serviceObject) | fromYaml }} {{- $enabledPorts := include "bjw-s.common.lib.service.enabledPorts" (dict "rootContext" $rootContext "serviceObject" $serviceObject) | fromYaml }}
{{- /* Validate at least one port is enabled */ -}} {{- /* Validate at least one port is enabled */ -}}
{{- if not $enabledPorts -}} {{- if not $enabledPorts -}}
{{- fail (printf "no ports are enabled for Service with key \"%s\"" $serviceObject.identifier) -}} {{- fail (printf "No ports are enabled for Service with this identifier. (service: '%s')" $serviceObject.identifier) -}}
{{- end -}} {{- end -}}
{{- range $name, $port := $enabledPorts -}} {{- range $name, $port := $enabledPorts -}}
{{- /* Validate a port number is configured */ -}} {{- /* Validate a port number is configured */ -}}
{{- if not $port.port -}} {{- if not $port.port -}}
{{- fail (printf "no port number is configured for port \"%s\" under Service with key \"%s\"" $name $serviceObject.identifier) -}} {{- fail (printf "No port number is configured for this port. (port: '%s', service: '%s')" $name $serviceObject.identifier) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -1,30 +0,0 @@
{{/*
Convert Service values to an object
*/}}
{{- define "bjw-s.common.lib.service.valuesToObject" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $objectValues := .values -}}
{{- /* Determine and inject the Service name */ -}}
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}}
{{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}}
{{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if and (not $objectValues.primary) (gt (len $enabledServices) 1) -}}
{{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- /* Return the Service object */ -}}
{{- $objectValues | toYaml -}}
{{- end -}}

View file

@ -0,0 +1,23 @@
{{/*
Return the enabled serviceAccounts.
*/}}
{{- define "bjw-s.common.lib.serviceAccount.enabledServiceAccounts" -}}
{{- $rootContext := .rootContext -}}
{{- $enabledServiceAccounts := dict -}}
{{- range $identifier, $serviceAccount := $rootContext.Values.serviceAccount -}}
{{- if kindIs "map" $serviceAccount -}}
{{- /* Enable Service by default, but allow override */ -}}
{{- $serviceAccountEnabled := true -}}
{{- if hasKey $serviceAccount "enabled" -}}
{{- $serviceAccountEnabled = $serviceAccount.enabled -}}
{{- end -}}
{{- if $serviceAccountEnabled -}}
{{- $_ := set $enabledServiceAccounts $identifier . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $enabledServiceAccounts | toYaml -}}
{{- end -}}

View file

@ -4,18 +4,10 @@ Return a ServiceAccount Object by its Identifier.
{{- define "bjw-s.common.lib.serviceAccount.getByIdentifier" -}} {{- define "bjw-s.common.lib.serviceAccount.getByIdentifier" -}}
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $identifier := .id -}} {{- $identifier := .id -}}
{{- if eq $identifier "default" -}} {{- $enabledServiceAccounts := (include "bjw-s.common.lib.serviceAccount.enabledServiceAccounts" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- $serviceAccount := deepCopy $rootContext.Values.serviceAccount -}}
{{- if and (eq ($serviceAccount.name) "") (not $serviceAccount.create ) -}} {{- if (hasKey $enabledServiceAccounts $identifier) -}}
{{- $_ := set $serviceAccount "name" "default" -}} {{- $objectValues := get $enabledServiceAccounts $identifier -}}
{{- end -}} {{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledServiceAccounts)) -}}
{{- include "bjw-s.common.lib.serviceAccount.valuesToObject" (dict "rootContext" $rootContext "id" "default" "values" $serviceAccount) -}}
{{- else -}}
{{- $serviceAccountValues := dig "extraServiceAccounts" $identifier nil $rootContext.Values.serviceAccount -}}
{{- if not (empty $serviceAccountValues) -}}
{{- include "bjw-s.common.lib.serviceAccount.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $serviceAccountValues) -}}
{{- else -}}
{{- fail (printf "No ServiceAccount configured with identifier: %s" $identifier) -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -1,25 +0,0 @@
{{/*
Convert ServiceAccount values to an object
*/}}
{{- define "bjw-s.common.lib.serviceAccount.valuesToObject" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $objectValues := .values -}}
{{- /* Determine and inject the serviceAccount name */ -}}
{{- $defaultServiceAccountName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- $objectName := $defaultServiceAccountName -}}
{{- with $objectValues.name -}}
{{- $objectName = . -}}
{{- end -}}
{{- if and (ne $identifier "default") (not $objectValues.name) -}}
{{- $objectName = printf "%s-%s" $defaultServiceAccountName $identifier -}}
{{- end -}}
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- /* Return the serviceAccount object */ -}}
{{- $objectValues | toYaml -}}
{{- end -}}

View file

@ -1,20 +1,20 @@
{{/* {{/*
Return the enabled ServiceMonitors. Return the enabled serviceMonitors.
*/}} */}}
{{- define "bjw-s.common.lib.serviceMonitor.enabledServiceMonitors" -}} {{- define "bjw-s.common.lib.serviceMonitor.enabledServiceMonitors" -}}
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $enabledServiceMonitors := dict -}} {{- $enabledServiceMonitors := dict -}}
{{- range $name, $serviceMonitor := $rootContext.Values.serviceMonitor -}} {{- range $identifier, $serviceMonitor := $rootContext.Values.serviceMonitor -}}
{{- if kindIs "map" $serviceMonitor -}} {{- if kindIs "map" $serviceMonitor -}}
{{- /* Enable by default, but allow override */ -}} {{- /* Enable Service by default, but allow override */ -}}
{{- $serviceMonitorEnabled := true -}} {{- $serviceMonitorEnabled := true -}}
{{- if hasKey $serviceMonitor "enabled" -}} {{- if hasKey $serviceMonitor "enabled" -}}
{{- $serviceMonitorEnabled = $serviceMonitor.enabled -}} {{- $serviceMonitorEnabled = $serviceMonitor.enabled -}}
{{- end -}} {{- end -}}
{{- if $serviceMonitorEnabled -}} {{- if $serviceMonitorEnabled -}}
{{- $_ := set $enabledServiceMonitors $name . -}} {{- $_ := set $enabledServiceMonitors $identifier . -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -0,0 +1,13 @@
{{/*
Return a ServiceMonitor Object by its Identifier.
*/}}
{{- define "bjw-s.common.lib.serviceMonitor.getByIdentifier" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $enabledServiceMonitors := (include "bjw-s.common.lib.serviceMonitor.enabledServiceMonitors" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if (hasKey $enabledServiceMonitors $identifier) -}}
{{- $objectValues := get $enabledServiceMonitors $identifier -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledServiceMonitors)) -}}
{{- end -}}
{{- end -}}

View file

@ -1,30 +0,0 @@
{{/*
Convert ServiceMonitor values to an object
*/}}
{{- define "bjw-s.common.lib.serviceMonitor.valuesToObject" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $objectValues := .values -}}
{{- /* Determine and inject the ServiceMonitor name */ -}}
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}}
{{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}}
{{- $enabledServiceMonitors := (include "bjw-s.common.lib.serviceMonitor.enabledServiceMonitors" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if gt (len $enabledServiceMonitors) 1 -}}
{{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- /* Return the ServiceMonitor object */ -}}
{{- $objectValues | toYaml -}}
{{- end -}}

View file

@ -5,10 +5,15 @@ Convert StatefulSet values to an object
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $identifier := .id -}} {{- $identifier := .id -}}
{{- $objectValues := .values -}} {{- $objectValues := .values -}}
{{- $itemCount := .itemCount -}}
{{- $objectName := (include "bjw-s.common.lib.determineResourceNameFromValues" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" $itemCount)) -}}
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- $strategy := default "RollingUpdate" $objectValues.strategy -}} {{- $strategy := default "RollingUpdate" $objectValues.strategy -}}
{{- $_ := set $objectValues "strategy" $strategy -}} {{- $_ := set $objectValues "strategy" $strategy -}}
{{- /* Return the StatefulSet object */ -}}
{{- $objectValues | toYaml -}} {{- $objectValues | toYaml -}}
{{- end -}} {{- end -}}

View file

@ -2,21 +2,23 @@
Secondary entrypoint and primary loader for the common chart Secondary entrypoint and primary loader for the common chart
*/}} */}}
{{- define "bjw-s.common.loader.generate" -}} {{- define "bjw-s.common.loader.generate" -}}
{{- $rootContext := $ -}}
{{- /* Run global chart validations */ -}} {{- /* Run global chart validations */ -}}
{{- include "bjw-s.common.lib.chart.validate" . -}} {{- include "bjw-s.common.lib.chart.validate" $rootContext -}}
{{- /* Build the templates */ -}} {{- /* Build the templates */ -}}
{{- include "bjw-s.common.render.pvcs" . | nindent 0 -}} {{- include "bjw-s.common.render.pvcs" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.serviceAccount" . | nindent 0 -}} {{- include "bjw-s.common.render.serviceAccount" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.configMaps.fromFolder" . | nindent 0 -}} {{- include "bjw-s.common.render.configMaps.fromFolder" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.configMaps" . | nindent 0 -}} {{- include "bjw-s.common.render.configMaps" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.controllers" . | nindent 0 -}} {{- include "bjw-s.common.render.controllers" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.services" . | nindent 0 -}} {{- include "bjw-s.common.render.services" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.ingresses" . | nindent 0 -}} {{- include "bjw-s.common.render.ingresses" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.serviceMonitors" . | nindent 0 -}} {{- include "bjw-s.common.render.serviceMonitors" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.routes" . | nindent 0 -}} {{- include "bjw-s.common.render.routes" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.secrets" . | nindent 0 -}} {{- include "bjw-s.common.render.secrets" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.networkpolicies" . | nindent 0 -}} {{- include "bjw-s.common.render.networkpolicies" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.rawResources" . | nindent 0 -}} {{- include "bjw-s.common.render.rawResources" $rootContext | nindent 0 -}}
{{- include "bjw-s.common.render.rbac" . | nindent 0 -}} {{- include "bjw-s.common.render.rbac" $rootContext | nindent 0 -}}
{{- end -}} {{- end -}}

View file

@ -4,25 +4,18 @@ Renders the configMap objects required by the chart.
{{- define "bjw-s.common.render.configMaps" -}} {{- define "bjw-s.common.render.configMaps" -}}
{{- $rootContext := $ -}} {{- $rootContext := $ -}}
{{- /* Generate named configMaps as required */ -}} {{- /* Generate configMaps as required */ -}}
{{- range $key, $configMap := .Values.configMaps }} {{- $enabledConfigMaps := (include "bjw-s.common.lib.configMap.enabledConfigmaps" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{- /* Enable configMap by default, but allow override */ -}}
{{- $configMapEnabled := true -}}
{{- if hasKey $configMap "enabled" -}}
{{- $configMapEnabled = $configMap.enabled -}}
{{- end -}}
{{- if $configMapEnabled -}} {{- range $identifier := keys $enabledConfigMaps -}}
{{- $configMapValues := (mustDeepCopy $configMap) -}} {{- /* Generate object from the raw configMap values */ -}}
{{- $configMapObject := (include "bjw-s.common.lib.configMap.getByIdentifier" (dict "rootContext" $rootContext "id" $identifier) | fromYaml) -}}
{{- /* Create object from the raw configMap values */ -}} {{- /* Perform validations on the configMap before rendering */ -}}
{{- $configMapObject := (include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $configMapValues)) | fromYaml -}} {{- include "bjw-s.common.lib.configMap.validate" (dict "rootContext" $rootContext "object" $configMapObject "id" $identifier) -}}
{{- /* Perform validations on the configMap before rendering */ -}}
{{- include "bjw-s.common.lib.configMap.validate" (dict "rootContext" $ "object" $configMapObject "id" $key) -}}
{{/* Include the configMap class */}} {{/* Include the configMap class */}}
{{- include "bjw-s.common.class.configMap" (dict "rootContext" $ "object" $configMapObject) | nindent 0 -}} {{- include "bjw-s.common.class.configMap" (dict "rootContext" $rootContext "object" $configMapObject) | nindent 0 -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
@ -30,23 +23,26 @@ Renders the configMap objects required by the chart.
Renders configMap objects required by the chart from a folder in the repo's path. Renders configMap objects required by the chart from a folder in the repo's path.
*/}} */}}
{{- define "bjw-s.common.render.configMaps.fromFolder" -}} {{- define "bjw-s.common.render.configMaps.fromFolder" -}}
{{- $rootContext := $ -}}
{{- $valuesCopy := .Values -}} {{- $valuesCopy := $rootContext.Values -}}
{{- $configMapsFromFolder := .Values.configMapsFromFolder | default dict -}} {{- $configMapsFromFolder := $rootContext.Values.configMapsFromFolder | default dict -}}
{{- $configMapsFromFolderEnabled := dig "enabled" false $configMapsFromFolder -}} {{- $configMapsFromFolderEnabled := dig "enabled" false $configMapsFromFolder -}}
{{- if $configMapsFromFolderEnabled -}} {{- if $configMapsFromFolderEnabled -}}
{{- /* Perform validations before rendering */ -}} {{- /* Perform validations before rendering */ -}}
{{- include "bjw-s.common.lib.configMap.fromFolder.validate" (dict "rootContext" $ "basePath" $configMapsFromFolder.basePath) -}} {{- include "bjw-s.common.lib.configMap.fromFolder.validate" (dict "rootContext" $ "basePath" $configMapsFromFolder.basePath) -}}
{{- $basePath := $configMapsFromFolder.basePath -}}
{{/* Generate a list of unique top level folders */}} {{/* Generate a list of unique top level folders */}}
{{ $topLevelFolders := dict}} {{- $basePath := $configMapsFromFolder.basePath -}}
{{- $topLevelFolders := dict -}}
{{- range $path, $_ := .Files.Glob (printf "%s/*/*" $basePath) -}} {{- range $path, $_ := .Files.Glob (printf "%s/*/*" $basePath) -}}
{{- $_ := set $topLevelFolders (dir $path) "" -}} {{- $_ := set $topLevelFolders (dir $path) "" -}}
{{- end -}} {{- end -}}
{{- $top_level_folder_list := keys $topLevelFolders | sortAlpha -}} {{- $top_level_folder_list := keys $topLevelFolders | sortAlpha -}}
{{/* Iterate over the top level folders */}}
{{ range $path := $top_level_folder_list }} {{- /* Iterate over the top level folders */ -}}
{{- range $path := $top_level_folder_list -}}
{{- $folder := base $path -}} {{- $folder := base $path -}}
{{- $configMapData := dict -}} {{- $configMapData := dict -}}
{{- $configMapBinaryData := dict -}} {{- $configMapBinaryData := dict -}}
@ -70,16 +66,16 @@ Renders configMap objects required by the chart from a folder in the repo's path
{{- $configMapData = merge $configMapData (dict $file $fileContent) -}} {{- $configMapData = merge $configMapData (dict $file $fileContent) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end -}}
{{ end }}
{{- $configMapValues := dict "enabled" true "forceRename" $configMapForceRename "labels" $configMapLabels "annotations" $configMapAnnotations "data" $configMapData "binaryData" $configMapBinaryData -}} {{- $configMapValues := dict "enabled" true "forceRename" $configMapForceRename "labels" $configMapLabels "annotations" $configMapAnnotations "data" $configMapData "binaryData" $configMapBinaryData -}}
{{- $configMapObject := (include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $ "id" $folder "values" $configMapValues)) | fromYaml -}} {{- $configMapObject := (include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $folder "values" $configMapValues) | fromYaml) -}}
{{/* Append it to .Values.configMaps so it can be created by "bjw-s.common.render.configMaps" and fetched by identifier */}}
{{- $existingConfigMaps := (get $valuesCopy "configMaps"| default dict) -}}
{{- $mergedConfigMaps := deepCopy $existingConfigMaps | merge (dict (base $path) $configMapValues) -}}
{{- $valuesCopy := merge $valuesCopy (dict "configMaps" $mergedConfigMaps) -}}
{{ end }}
{{ end }}
{{ end }} {{- /* Append it to .Values.configMaps so it can be created by "bjw-s.common.render.configMaps" and fetched by identifier */ -}}
{{- $existingConfigMaps := (get $valuesCopy "configMaps" | default dict) -}}
{{- $mergedConfigMaps := deepCopy $existingConfigMaps | merge (dict $folder $configMapObject) -}}
{{- $valuesCopy := merge $valuesCopy (dict "configMaps" $mergedConfigMaps) -}}
{{- end -}}
{{- end -}}
{{- end -}}

View file

@ -5,43 +5,38 @@ Renders the controller objects required by the chart.
{{- $rootContext := $ -}} {{- $rootContext := $ -}}
{{- /* Generate named controller objects as required */ -}} {{- /* Generate named controller objects as required */ -}}
{{- range $key, $controller := .Values.controllers -}} {{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{- /* Enable controller by default, but allow override */ -}} {{- range $identifier := keys $enabledControllers -}}
{{- $controllerEnabled := true -}} {{- /* Create object from the raw controller values */ -}}
{{- if hasKey $controller "enabled" -}} {{- $controllerObject := (include "bjw-s.common.lib.controller.getByIdentifier" (dict "rootContext" $rootContext "id" $identifier) | fromYaml) -}}
{{- $controllerEnabled = $controller.enabled -}}
{{- end -}}
{{- if $controllerEnabled -}} {{- /* Perform validations on the controller before rendering */ -}}
{{- $controllerValues := $controller -}} {{- include "bjw-s.common.lib.controller.validate" (dict "rootContext" $rootContext "object" $controllerObject) -}}
{{- /* Create object from the raw controller values */ -}} {{- if eq $controllerObject.type "deployment" -}}
{{- $controllerObject := (include "bjw-s.common.lib.controller.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $controllerValues)) | fromYaml -}} {{- $deploymentObject := (include "bjw-s.common.lib.deployment.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $controllerObject "itemCount" (len $enabledControllers))) | fromYaml -}}
{{- include "bjw-s.common.lib.deployment.validate" (dict "rootContext" $rootContext "object" $deploymentObject) -}}
{{- include "bjw-s.common.class.deployment" (dict "rootContext" $rootContext "object" $deploymentObject) | nindent 0 -}}
{{- /* Perform validations on the controller before rendering */ -}} {{- else if eq $controllerObject.type "cronjob" -}}
{{- include "bjw-s.common.lib.controller.validate" (dict "rootContext" $rootContext "object" $controllerObject) -}} {{- $cronjobObject := (include "bjw-s.common.lib.cronjob.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $controllerObject "itemCount" (len $enabledControllers))) | fromYaml -}}
{{- include "bjw-s.common.lib.cronjob.validate" (dict "rootContext" $rootContext "object" $cronjobObject) -}}
{{- include "bjw-s.common.class.cronjob" (dict "rootContext" $rootContext "object" $cronjobObject) | nindent 0 -}}
{{- if eq $controllerObject.type "deployment" -}} {{- else if eq $controllerObject.type "daemonset" -}}
{{- $deploymentObject := (include "bjw-s.common.lib.deployment.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $controllerObject)) | fromYaml -}} {{- $daemonsetObject := (include "bjw-s.common.lib.daemonset.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $controllerObject "itemCount" (len $enabledControllers))) | fromYaml -}}
{{- include "bjw-s.common.lib.deployment.validate" (dict "rootContext" $rootContext "object" $deploymentObject) -}} {{- include "bjw-s.common.lib.daemonset.validate" (dict "rootContext" $rootContext "object" $daemonsetObject) -}}
{{- include "bjw-s.common.class.deployment" (dict "rootContext" $rootContext "object" $deploymentObject) | nindent 0 -}} {{- include "bjw-s.common.class.daemonset" (dict "rootContext" $rootContext "object" $daemonsetObject) | nindent 0 -}}
{{- else if eq $controllerObject.type "cronjob" -}}
{{- $cronjobObject := (include "bjw-s.common.lib.cronjob.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $controllerObject)) | fromYaml -}} {{- else if eq $controllerObject.type "statefulset" -}}
{{- include "bjw-s.common.lib.cronjob.validate" (dict "rootContext" $rootContext "object" $cronjobObject) -}} {{- $statefulsetObject := (include "bjw-s.common.lib.statefulset.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $controllerObject "itemCount" (len $enabledControllers))) | fromYaml -}}
{{- include "bjw-s.common.class.cronjob" (dict "rootContext" $rootContext "object" $cronjobObject) | nindent 0 -}} {{- include "bjw-s.common.lib.statefulset.validate" (dict "rootContext" $rootContext "object" $statefulsetObject) -}}
{{- else if eq $controllerObject.type "daemonset" -}} {{- include "bjw-s.common.class.statefulset" (dict "rootContext" $rootContext "object" $statefulsetObject) | nindent 0 -}}
{{- $daemonsetObject := (include "bjw-s.common.lib.daemonset.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $controllerObject)) | fromYaml -}}
{{- include "bjw-s.common.lib.daemonset.validate" (dict "rootContext" $rootContext "object" $daemonsetObject) -}} {{- else if eq $controllerObject.type "job" -}}
{{- include "bjw-s.common.class.daemonset" (dict "rootContext" $rootContext "object" $daemonsetObject) | nindent 0 -}} {{- $jobObject := (include "bjw-s.common.lib.job.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $controllerObject "itemCount" (len $enabledControllers))) | fromYaml -}}
{{- else if eq $controllerObject.type "statefulset" -}} {{- include "bjw-s.common.lib.job.validate" (dict "rootContext" $rootContext "object" $jobObject) -}}
{{- $statefulsetObject := (include "bjw-s.common.lib.statefulset.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $controllerObject)) | fromYaml -}} {{- include "bjw-s.common.class.job" (dict "rootContext" $rootContext "object" $jobObject) | nindent 0 -}}
{{- include "bjw-s.common.lib.statefulset.validate" (dict "rootContext" $rootContext "object" $statefulsetObject) -}}
{{- include "bjw-s.common.class.statefulset" (dict "rootContext" $rootContext "object" $statefulsetObject) | nindent 0 -}}
{{- else if eq $controllerObject.type "job" -}}
{{- $jobObject := (include "bjw-s.common.lib.job.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $controllerObject)) | fromYaml -}}
{{- include "bjw-s.common.lib.job.validate" (dict "rootContext" $rootContext "object" $jobObject) -}}
{{- include "bjw-s.common.class.job" (dict "rootContext" $rootContext "object" $jobObject) | nindent 0 -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -2,25 +2,18 @@
Renders the Ingress objects required by the chart. Renders the Ingress objects required by the chart.
*/}} */}}
{{- define "bjw-s.common.render.ingresses" -}} {{- define "bjw-s.common.render.ingresses" -}}
{{- /* Generate named Ingresses as required */ -}} {{- $rootContext := $ -}}
{{- range $key, $ingress := .Values.ingress }}
{{- /* Enable Ingress by default, but allow override */ -}}
{{- $ingressEnabled := true -}}
{{- if hasKey $ingress "enabled" -}}
{{- $ingressEnabled = $ingress.enabled -}}
{{- end -}}
{{- if $ingressEnabled -}} {{- /* Generate Ingresses as required */ -}}
{{- $ingressValues := (mustDeepCopy $ingress) -}} {{- $enabledIngresses := (include "bjw-s.common.lib.ingress.enabledIngresses" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{- range $identifier := keys $enabledIngresses -}}
{{- /* Generate object from the raw persistence values */ -}}
{{- $ingressObject := (include "bjw-s.common.lib.ingress.getByIdentifier" (dict "rootContext" $rootContext "id" $identifier) | fromYaml) -}}
{{- /* Create object from the raw ingress values */ -}} {{- /* Perform validations on the Ingress before rendering */ -}}
{{- $ingressObject := (include "bjw-s.common.lib.ingress.valuesToObject" (dict "rootContext" $ "id" $key "values" $ingressValues)) | fromYaml -}} {{- include "bjw-s.common.lib.ingress.validate" (dict "rootContext" $rootContext "object" $ingressObject) -}}
{{- /* Perform validations on the ingress before rendering */ -}} {{- /* Include the ingress class */ -}}
{{- include "bjw-s.common.lib.ingress.validate" (dict "rootContext" $ "object" $ingressObject) -}} {{- include "bjw-s.common.class.ingress" (dict "rootContext" $ "object" $ingressObject) | nindent 0 -}}
{{/* Include the ingress class */}}
{{- include "bjw-s.common.class.ingress" (dict "rootContext" $ "object" $ingressObject) | nindent 0 -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -2,25 +2,18 @@
Renders the networkPolicy objects required by the chart. Renders the networkPolicy objects required by the chart.
*/}} */}}
{{- define "bjw-s.common.render.networkpolicies" -}} {{- define "bjw-s.common.render.networkpolicies" -}}
{{- /* Generate named networkPolicy as required */ -}} {{- $rootContext := $ -}}
{{- range $key, $networkPolicy := .Values.networkpolicies }}
{{- /* Enable networkPolicy by default, but allow override */ -}}
{{- $networkPolicyEnabled := true -}}
{{- if hasKey $networkPolicy "enabled" -}}
{{- $networkPolicyEnabled = $networkPolicy.enabled -}}
{{- end -}}
{{- if $networkPolicyEnabled -}} {{- /* Generate networkPolicy as required */ -}}
{{- $networkPolicyValues := (mustDeepCopy $networkPolicy) -}} {{- $enabledNetworkPolicies := (include "bjw-s.common.lib.networkpolicy.enabledNetworkPolicies" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{- range $identifier := keys $enabledNetworkPolicies -}}
{{- /* Generate object from the raw persistence values */ -}}
{{- $networkPolicyObject := (include "bjw-s.common.lib.networkpolicy.getByIdentifier" (dict "rootContext" $rootContext "id" $identifier) | fromYaml) -}}
{{- /* Create object from the raw networkPolicy values */ -}} {{- /* Perform validations on the networkPolicy before rendering */ -}}
{{- $networkPolicyObject := (include "bjw-s.common.lib.networkpolicy.valuesToObject" (dict "rootContext" $ "id" $key "values" $networkPolicyValues)) | fromYaml -}} {{- include "bjw-s.common.lib.networkpolicy.validate" (dict "rootContext" $ "object" $networkPolicyObject) -}}
{{- /* Perform validations on the networkPolicy before rendering */ -}} {{- /* Include the networkPolicy class */ -}}
{{- include "bjw-s.common.lib.networkpolicy.validate" (dict "rootContext" $ "object" $networkPolicyObject) -}} {{- include "bjw-s.common.class.networkpolicy" (dict "rootContext" $ "object" $networkPolicyObject) | nindent 0 -}}
{{/* Include the networkPolicy class */}}
{{- include "bjw-s.common.class.networkpolicy" (dict "rootContext" $ "object" $networkPolicyObject) | nindent 0 -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -1,26 +1,16 @@
{{/* {{/*
Renders the Persistent Volume Claim objects required by the chart. Renders the Persistent Volume Claim objects required by the chart
*/}} */}}
{{- define "bjw-s.common.render.pvcs" -}} {{- define "bjw-s.common.render.pvcs" -}}
{{- $rootContext := $ -}}
{{- /* Generate pvc as required */ -}} {{- /* Generate pvc as required */ -}}
{{- range $key, $pvc := .Values.persistence -}} {{- $enabledPVCs := (include "bjw-s.common.lib.pvc.enabledPVCs" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{- /* Enable PVC by default, but allow override */ -}} {{- range $identifier := keys $enabledPVCs -}}
{{- $pvcEnabled := true -}} {{- /* Generate object from the raw persistence values */ -}}
{{- if hasKey $pvc "enabled" -}} {{- $pvcObject := (include "bjw-s.common.lib.pvc.getByIdentifier" (dict "rootContext" $rootContext "id" $identifier) | fromYaml) -}}
{{- $pvcEnabled = $pvc.enabled -}}
{{- end -}}
{{- if and $pvcEnabled (eq (default "persistentVolumeClaim" $pvc.type) "persistentVolumeClaim") (not $pvc.existingClaim) -}} {{- /* Include the PVC class */ -}}
{{- $pvcValues := (mustDeepCopy $pvc) -}} {{- include "bjw-s.common.class.pvc" (dict "rootContext" $rootContext "object" $pvcObject) | nindent 0 -}}
{{- /* Create object from the raw PVC values */ -}}
{{- $pvcObject := (include "bjw-s.common.lib.pvc.valuesToObject" (dict "rootContext" $ "id" $key "values" $pvcValues)) | fromYaml -}}
{{- /* Perform validations on the PVC before rendering */ -}}
{{- include "bjw-s.common.lib.pvc.validate" (dict "rootContext" $ "object" $pvcValues) -}}
{{- /* Include the PVC class */ -}}
{{- include "bjw-s.common.class.pvc" (dict "rootContext" $ "object" $pvcValues) | nindent 0 -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -5,24 +5,12 @@ Renders other arbirtrary objects required by the chart.
{{- $rootContext := $ -}} {{- $rootContext := $ -}}
{{- /* Generate raw resources as required */ -}} {{- /* Generate raw resources as required */ -}}
{{- range $key, $resource := .Values.rawResources -}} {{- $enabledRawResources := (include "bjw-s.common.lib.rawResource.enabledRawResources" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{- /* Enable by default, but allow override */ -}} {{- range $identifier := keys $enabledRawResources -}}
{{- $resourceEnabled := true -}} {{- /* Generate object from the raw resource values */ -}}
{{- if hasKey $resource "enabled" -}} {{- $rawResourceObject := (include "bjw-s.common.lib.rawResource.getByIdentifier" (dict "rootContext" $rootContext "id" $identifier) | fromYaml) -}}
{{- $resourceEnabled = $resource.enabled -}}
{{- end -}}
{{- if $resourceEnabled -}} {{- /* Include the raw resource class */ -}}
{{- $resourceValues := (mustDeepCopy $resource) -}} {{- include "bjw-s.common.class.rawResource" (dict "rootContext" $rootContext "object" $rawResourceObject) | nindent 0 -}}
{{- /* Create object from the raw resource values */ -}}
{{- $resourceObject := (include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $resourceValues)) | fromYaml -}}
{{- /* Perform validations on the resource before rendering */ -}}
{{- include "bjw-s.common.lib.rawResource.validate" (dict "rootContext" $ "object" $resourceValues) -}}
{{- /* Include the raw resource class */ -}}
{{- include "bjw-s.common.class.rawResource" (dict "rootContext" $ "object" $resourceValues) | nindent 0 -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

Some files were not shown because too many files have changed in this diff Show more