From f933a3ae4992e8ec59f7a0f0518e6d164a70c0c3 Mon Sep 17 00:00:00 2001 From: ashutosh16 <11219262+ashutosh16@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:50:07 -0700 Subject: [PATCH] chore: disabled health alert for test-dev Signed-off-by: ashutosh16 <11219262+ashutosh16@users.noreply.github.com> --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++------------- install.sh | 18 ++++++++++++--- 2 files changed, 66 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index a20e336..cf3dcf5 100644 --- a/README.md +++ b/README.md @@ -11,31 +11,41 @@ and install the configured UI extension. All configuration is provided as environment variables as part of the init container. Find below the list of all environment variables that can be configured: -| Env Var | Required? | Default | Description | -|------------------------|-------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| EXTENSION_ENABLED | No | true | If set to false will skip the installation. Noop | -| EXTENSION_URL | Yes | "" | Must be set to a valid URL where the UI extension can be downloaded from.
Argo CD API server needs to have network access to this URL. | -| EXTENSION_CHECKSUM_URL | No | "" | Can be set to the file containing the checksum to validate the downloaded
extension. Will skip the checksum validation if not provided.
Argo CD API server needs to have network access to this URL. | -| MAX_DOWNLOAD_SEC | No | 30 | Total time in seconds allowed to download the extension. | -| EXTENSION_VARS | No | "" | Define variables to be exported in `vars.json` within the extension folder. These variables serve as external configurations for the extension.
The format should be `{key1=value1, key2=value2}`. | +| Env Var | Required? | Default | Description | +|--------------------------|-----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| EXTENSION_NAME | Yes | "" | Extension Name | +| EXTENSION_ENABLED | No | true | If set to false will skip the installation. Noop | +| EXTENSION_URL | Yes | "" | Must be set to a valid URL where the UI extension can be downloaded from.
Argo CD API server needs to have network access to this URL. | +| EXTENSION_VERSION | Yes | "" | The version of the extension to be installed. | +| EXTENSION_CHECKSUM_URL | No | "" | Can be set to the file containing the checksum to validate the downloaded
extension. Will skip the checksum validation if not provided.
Argo CD API server needs to have network access to this URL. | +| MAX_DOWNLOAD_SEC | No | 30 | Total time in seconds allowed to download the extension. | +| EXTENSION_VARS | No | "" | Specifies the variables to be exported in $EXTENSION_VARS_FILE_NAME in json format within the extension folder. These variables serve as external configurations for the extension.
The format should be `{key1=value1, key2=value2}`. | +| EXTENSION_VARS_FILE_NAME | No | 'vars' | Specifies the file name where the variables will be exported. The default is 'vars', but you can provide your own file name, e.g., 'Metrics'. | +| EXTENSION_VARS_FILE_PATH | No | "" | Specifies the path where the variables will be exported. For example, you can use a path like '/tmp/extensions/resources/extension-{EXTENSION_VARS_FILE_NAME}.js'. | + ```yaml apiVersion: v1 kind: ConfigMap metadata: - name: argocd-ephemeral-access-global-vars-cm + name: argocd-extension-cm data: extension.url: 'http://example.com/extension.tar.gz' + extension.version: 'v0.3.1' extension.enabled: 'true' extension.checksum_url: 'http://example.com/extension_checksums.txt' extension.max_download_sec: '30' extension.vars: | - { - "key1": "value1", - "key2": "value2" - } + { + "key1": "value1", + "key2": "value2" + } + extension.vars_file_name: 'vars' + extension.vars_file_path: '/tmp/extensions/resources/extension-.js' + + ``` ```yaml @@ -54,11 +64,37 @@ spec: # https://quay.io/repository/argoprojlabs/argocd-extension-installer?tab=tags image: docker.intuit.com/quay-rmt/argoprojlabs/argocd-extension-installer:v0.0.1@sha256:f50fa11a4592f3fcdd5a137dab8ed32067bb779a77a393f179e8a5d96abe1a80 env: - - name: EXTENSION_URL + - name: EXTENSION_NAME valueFrom: configMapKeyRef: - key: extension.url - name: argocd-extension-cm + key: extension.name + name: argocd-extension-cm + - name: EXTENSION_URL + valueFrom: + configMapKeyRef: + key: extension.url + name: argocd-extension-cm + - name: EXTENSION_VERSION + valueFrom: + configMapKeyRef: + key: extension.version + name: argocd-extension-cm + ## Optional fields + - name: EXTENSION_VARS + valueFrom: + configMapKeyRef: + key: extension.vars + name: argocd-extension-cm + - name: EXTENSION_VARS_FILE_NAME + valueFrom: + configMapKeyRef: + key: extension.vars_file_name + name: argocd-extension-cm + - name: EXTENSION_VARS_FILE_PATH + valueFrom: + configMapKeyRef: + key: extension.vars_file_path + name: argocd-extension-cm volumeMounts: - name: extensions mountPath: /tmp/extensions/ diff --git a/install.sh b/install.sh index 66e2b97..1e4d1c9 100755 --- a/install.sh +++ b/install.sh @@ -28,6 +28,7 @@ finalizer() { } trap finalizer EXIT + # will download the extension respecting the max download # duration setting download_extension() { @@ -63,7 +64,15 @@ install_extension() { mkdir -p /tmp/extensions/resources fi cp -Rf resources/* /tmp/extensions/resources/ + + if [ -n "$vars" ] && [ "$vars" != "null" ]; then + echo "Installing extension vars" + json_vars=$(printf '%s\n' "$vars" | jq -R . | jq -s .) + echo "Exporting extension vars to path $ext_vars_file_path/$ext_vars_file_name.json" + echo "$json_vars" > "$ext_vars_file_path/$ext_vars_file_name.json" + fi echo "UI extension installed successfully" + } @@ -85,14 +94,17 @@ fi checksum_url="${EXTENSION_CHECKSUM_URL:-}" download_max_sec="${MAX_DOWNLOAD_SEC:-30}" -vars="${VARS:-}" -echo "$vars" | jq '.' > /tmp/extensions/resources/$ext_filename/vars.json - ext_filename=$(basename -- "$ext_url") download_dir=`mktemp -d -t extension-XXXXXX` ext_file="$download_dir/$ext_filename" if [ -f $ext_file ]; then rm $ext_file fi + +vars=$(echo "$EXTENSION_VARS" | jq -c '.') +ext_vars_file_name="${EXTENSION_VARS_FILE_NAME:-}" +ext_vars_file_path="${EXTENSION_VARS_FILE_PATH:-}" + + download_extension install_extension