apiVersion: batch/v1 kind: CronJob metadata: name: configuration-overwriter spec: schedule: "10 12 * * *" jobTemplate: spec: template: spec: restartPolicy: Never volumes: - name: sitedefault configMap: name: sitedefault containers: - name: configuration-overwriter image: a_acr_name.azurecr.io/viya-4-x64_oci_linux_2-docker/sas-viya-cli: command: ["/bin/bash","-c"] args: - | # Log into the CLI export OAUTH_TOKEN=$(curl -k -X POST 'https://a_fqdn/SASLogon/oauth/token' -H 'Content-Type: application/x-www-form-urlencoded' -d 'grant_type=client_credentials' -u $client_id:$client_secret | jq .access_token --raw-output) # Loop through all services for service in $(cat /sitedefault/sitedefault.json | jq -r '.config | keys[]'); do # Loop through all definitions for that service for definition in $(cat /sitedefault/sitedefault.json | jq --arg service "$service" -r '.config[$service] | keys[]'); do # Loop through all settings for that definition for setting in $(cat /sitedefault/sitedefault.json | jq --arg service "$service" --arg definition "$definition" -r '.config[$service][$definition] | keys[]'); do if [ "$service" == "application" ]; then applied_service="GLOBAL"; else applied_service="$service"; fi # Retrieve the value to set update_value=$(cat /sitedefault/sitedefault.json | jq --arg service "$service" --arg definition "$definition" --arg setting "$setting" '.config[$service][$definition][$setting]'); # Download the current configuration for the specified service and definition ./sas-viya --quiet configuration configurations download --definition-name $definition --service $applied_service --target ${definition}_${applied_service}.json # Determine the current value of the setting current_value=$(jq --arg setting "$setting" '(.items[0][$setting])' ${definition}_${applied_service}.json) if [ "$update_value" == "$current_value" ]; then echo "Not updating $applied_service definition $definition. Setting $setting is already configured as $update_value" else echo "Updating $applied_service definition $definition. Changing setting $setting from $current_value to $update_value" jq --arg setting "$setting" --argjson update_value "$update_value" '(.items[0][$setting]) = $update_value' ${definition}_$applied_service.json > ${definition}_${applied_service}_update.json ./sas-viya configuration configurations update --file ${definition}_${applied_service}_update.json fi done done done env: - name: SAS_SERVICES_ENDPOINT value: "https://a_fqdn" - name: SAS_SKIP_OAUTH_EXPIRY_CHECK value: "true" envFrom: - secretRef: name: configuration-overwriter-secret volumeMounts: - name: sitedefault mountPath: /sitedefault