|
| 1 | +# Usage: |
| 2 | +# |
| 3 | +# Feed arguments into ocm CLI like this: |
| 4 | +# ocm add componentversions ... -- CHART_REGISTRY=... IMG_REGISTRY=... |
| 5 | +# |
| 6 | +# Required values: |
| 7 | +# - VERSION (set via the ocm CLI's --version flag) |
| 8 | +# - Used as version for the source element pointing to this repo. |
| 9 | +# - Used as referenced GitHub release, if it does not contain a '-dev'. |
| 10 | +# - Used as fallback value for other versions. |
| 11 | +# - COMMIT |
| 12 | +# - Commit hash of the git commit used to generate this component descriptor. |
| 13 | +# - Used for the source element pointing to this repo. |
| 14 | +# - CHART_REGISTRY |
| 15 | +# - URL of the OCI registry used for the helm charts |
| 16 | +# - IMG_REGISTRY |
| 17 | +# - URL of the OCI registry used for the container images |
| 18 | +# - COMPONENTS |
| 19 | +# - Comma-separated list of components for which resources should be added to the component descriptor, e.g. "apiserver-controller,managedcontrolplane-controller,landscaper-connector". |
| 20 | +# - Not required if all of BP_COMPONENTS, CHART_COMPONENTS, and IMG_COMPONENTS are specified instead. |
| 21 | +# - MODULE_NAME |
| 22 | +# - Name of the Go module. |
| 23 | +# - REPO_URL |
| 24 | +# - URL of the git repository. |
| 25 | +# |
| 26 | +# Optional values: |
| 27 | +# - CD_VERSION |
| 28 | +# - Version used for the component descriptor. |
| 29 | +# - Defaults to VERSION if not specified. |
| 30 | +# - CHART_VERSION |
| 31 | +# - Default version for referenced helm charts. |
| 32 | +# - Defaults to VERSION if not specified. |
| 33 | +# - IMG_VERSION |
| 34 | +# - Default version for referenced container images. |
| 35 | +# - Defaults to VERSION if not specified. |
| 36 | +# - BP_PATH |
| 37 | +# - Path to the blueprint directory. Must be specified if BP_COMPONENTS is set. |
| 38 | +# - BP_COMPONENTS |
| 39 | +# - Comma-separated list of components for which the blueprint should be added to the component descriptor, e.g. "apiserver-controller,managedcontrolplane-controller,landscaper-connector" |
| 40 | +# - Each element will result in a resource entry of type 'landscaper.gardener.cloud/blueprint' named '<component>-blueprint'. The corresponding blueprint is expected at 'BP_PATH/<component>' (relative to this file). |
| 41 | +# - Defaults to COMPONENTS if BP_PATH is set and is empty otherwise. |
| 42 | +# - CHART_COMPONENTS |
| 43 | +# - Comma-separated list of components for which helm charts should be referenced in the component descriptor, optionally with version (separated by ":"). |
| 44 | +# - Example: "apiserver-controller:v0.1.0,managedcontrolplane-controller:v0.2.0,landscaper-connector" |
| 45 | +# - Each element will result in a resource entry of type 'helmChart' named '<component>-chart'. The chart is expected in the OCI registry at '<CHART_REGISTRY>/<component>:<version>'. |
| 46 | +# - Defaults to COMPONENTS if not specified. |
| 47 | +# - Each chart's version defaults to CHART_VERSION if not specified. |
| 48 | +# - IMG_COMPONENTS |
| 49 | +# - Comma-separated list of components for which container images should be referenced in the component descriptor, optionally with version (separated by ":"). |
| 50 | +# - Example: "apiserver-controller:v0.1.0,managedcontrolplane-controller:v0.2.0,landscaper-connector" |
| 51 | +# - Each element will result in a resource entry of type 'ociImage' named '<component>-image'. The image is expected in the OCI registry at '<IMG_REGISTRY>/<component>:<version>'. |
| 52 | +# - Defaults to COMPONENTS if not specified. |
| 53 | +# - Each image's version defaults to IMG_VERSION if not specified. |
| 54 | + |
| 55 | + |
| 56 | +name: (( lower(values.MODULE_NAME) )) |
| 57 | +version: (( defaults.CD_VERSION )) |
| 58 | +provider: |
| 59 | + name: sap.com |
| 60 | + |
| 61 | +sources: |
| 62 | +- name: (( ( "tmp" = split("/", values.REPO_URL) ) element(tmp, length(tmp) - 1) )) |
| 63 | + type: blob |
| 64 | + version: (( values.VERSION )) |
| 65 | + access: |
| 66 | + type: gitHub |
| 67 | + repoUrl: (( values.REPO_URL )) |
| 68 | + commit: (( values.COMMIT )) |
| 69 | + ref: (( contains(values.VERSION, "-dev") ? ~~ :"refs/tags/" values.VERSION )) |
| 70 | +resources: |
| 71 | +- <<<: (( sum[funcs.splitIgnoreEmpty(",", defaults.BP_COMPONENTS)|[]|s,comp|-> s *templates.blueprint] )) |
| 72 | +- <<<: (( sum[funcs.splitIgnoreEmpty(",", defaults.CHART_COMPONENTS)|[]|s,cv|-> ("cvs" = split(":", cv)) ("comp" = cvs[0], "chart_version" = (cvs[1] || defaults.CHART_VERSION)) s *templates.chart] )) |
| 73 | +- <<<: (( sum[funcs.splitIgnoreEmpty(",", defaults.IMG_COMPONENTS)|[]|s,cv|-> ("cvs" = split(":", cv)) ("comp" = cvs[0], "img_version" = (cvs[1] || defaults.IMG_VERSION)) s *templates.image] )) |
| 74 | + |
| 75 | + |
| 76 | +# ########################################################################## |
| 77 | +# # Everything below this is temporary stuff only required during rendering and will not be part of the generated component descriptor. |
| 78 | + |
| 79 | +defaults: |
| 80 | + <<<: (( &temporary )) |
| 81 | + CD_VERSION: (( funcs.notEmpty(values.CD_VERSION || "") ? values.CD_VERSION :values.VERSION )) |
| 82 | + CHART_VERSION: (( funcs.notEmpty(values.CHART_VERSION || "") ? values.CHART_VERSION :values.VERSION )) |
| 83 | + IMG_VERSION: (( funcs.notEmpty(values.IMG_VERSION || "") ? values.IMG_VERSION :values.VERSION )) |
| 84 | + BP_COMPONENTS: (( funcs.notEmpty(values.BP_PATH || "") ? ( funcs.notEmpty(values.BP_COMPONENTS || "") ? values.BP_COMPONENTS :values.COMPONENTS ) :"" )) |
| 85 | + CHART_COMPONENTS: (( funcs.notEmpty(values.CHART_COMPONENTS || "") ? values.CHART_COMPONENTS :values.COMPONENTS )) |
| 86 | + IMG_COMPONENTS: (( funcs.notEmpty(values.IMG_COMPONENTS || "") ? values.IMG_COMPONENTS :values.COMPONENTS )) |
| 87 | + |
| 88 | +funcs: |
| 89 | + <<<: (( &temporary )) |
| 90 | + notEmpty: (( |x|-> x != "" )) # returns true if the input is not an empty string |
| 91 | + splitIgnoreEmpty: (( |d,s|-> select[split(d, s)|x|-> x != ""] )) # splits a string by a delimiter and removes empty elements |
| 92 | + |
| 93 | +templates: |
| 94 | + <<<: (( &temporary )) |
| 95 | + blueprint: |
| 96 | + <<<: (( &template )) |
| 97 | + name: (( comp "-blueprint" )) |
| 98 | + type: landscaper.gardener.cloud/blueprint |
| 99 | + input: |
| 100 | + path: (( "../blueprints/" comp )) |
| 101 | + type: dir |
| 102 | + chart: |
| 103 | + <<<: (( &template )) |
| 104 | + name: (( comp "-chart" )) |
| 105 | + type: helmChart |
| 106 | + version: (( chart_version )) |
| 107 | + access: |
| 108 | + type: ociArtifact |
| 109 | + imageReference: (( values.CHART_REGISTRY "/" comp ":" chart_version )) |
| 110 | + image: |
| 111 | + <<<: (( &template )) |
| 112 | + name: (( comp "-image" )) |
| 113 | + type: ociImage |
| 114 | + version: (( img_version )) |
| 115 | + access: |
| 116 | + imageReference: (( values.IMG_REGISTRY "/" comp ":" img_version )) |
| 117 | + type: ociArtifact |
| 118 | + |
| 119 | + |
| 120 | + |
0 commit comments