File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,22 @@ process_file() {
3232 env_value=" ${! var_name} "
3333
3434 if [[ -n " $env_value " ]]; then
35- line=" ${line// INJECT_ENV.${var_name} / ${env_value} } "
35+ # Special handling for CIS_CREDENTIAL or similar JSON structures
36+ if [[ " $var_name " == " CIS_CREDENTIAL" ]] || [[ " $var_name " == " CIS_CENTRAL_BINDING" ]]; then
37+ # Validate and format CIS credential JSON
38+ if ! echo " $env_value " | jq empty 2> /dev/null; then
39+ echo " Error: $var_name contains invalid JSON"
40+ exit 1
41+ fi
42+
43+ # Clean JSON and properly escape for parsing
44+ # NOTE: Because the certificate contains \n characters, which are escaped by jq, we need to remove \\n manually from the string
45+ clean_value=$( echo " $env_value " | jq . | sed ' s/\\\\n//g' )
46+ line=" ${line// INJECT_ENV.${var_name} / ${clean_value} } "
47+ else
48+ # For non-JSON variables, use direct substitution
49+ line=" ${line// INJECT_ENV.${var_name} / ${env_value} } "
50+ fi
3651 else
3752 echo " Warning: Environment variable $var_name is not set or empty. Leaving placeholder unchanged."
3853 fi
You can’t perform that action at this time.
0 commit comments