diff --git a/install_script.sh.template b/install_script.sh.template index 71ca6135..d0447a0f 100644 --- a/install_script.sh.template +++ b/install_script.sh.template @@ -976,6 +976,11 @@ if [ -n "$DD_PRIVATE_ACTION_RUNNER_ACTIONS_ALLOWLIST" ]; then par_actions_allowlist=$DD_PRIVATE_ACTION_RUNNER_ACTIONS_ALLOWLIST fi +par_api_key_only_enrollment= +if [ -n "$DD_PRIVATE_ACTION_RUNNER_API_KEY_ONLY_ENROLLMENT" ]; then + par_api_key_only_enrollment=$DD_PRIVATE_ACTION_RUNNER_API_KEY_ONLY_ENROLLMENT +fi + ## # INSTALL SCRIPT CONFIGURATION OPTIONS # Technical options to test with non-production values for signature keys, packages or reporting telemetry. @@ -2211,6 +2216,7 @@ function update_par(){ local config_file="$2" local par_enabled="$3" local par_actions_allowlist="$4" + local par_api_key_only_enrollment="$5" if [ "$par_enabled" != "true" ]; then return @@ -2241,6 +2247,10 @@ function update_par(){ par_config="${par_config} actions_allowlist:${actions_append}" fi + if [ -n "$par_api_key_only_enrollment" ]; then + par_config="${par_config} + api_key_only_enrollment: ${par_api_key_only_enrollment}" + fi $sudo_cmd sh -c "cat >> '$config_file'" < /dev/null + ensure_config_file_exists "sudo" $config_file "dd-agent" + update_par "sudo" $config_file "true" "" "true" + yamllint -c "$yaml_config" --no-warnings $config_file + assertEquals 0 $? + assertEquals "$(sudo yq eval '.private_action_runner.enabled' $config_file)" "true" + assertEquals "$(sudo yq eval '.private_action_runner.api_key_only_enrollment' $config_file)" "true" +} +testParEnabledWithoutApiKeyOnlyEnrollment() { + sudo rm $config_file 2> /dev/null + ensure_config_file_exists "sudo" $config_file "dd-agent" + update_par "sudo" $config_file "true" "" + # Should not add api_key_only_enrollment when not provided + assertEquals "$(sudo yq eval '.private_action_runner.api_key_only_enrollment' $config_file)" "null" +} # shellcheck source=/dev/null . shunit2