diff --git a/scripts/generate_config.sh b/scripts/generate_config.sh index aceef0a..b81aa14 100644 --- a/scripts/generate_config.sh +++ b/scripts/generate_config.sh @@ -104,20 +104,23 @@ apply_secret_to_config() { apply_controller_to_config() { local file="$1" + local ui_dir="$RUNTIME_DIR/ui" if [ "$EXTERNAL_CONTROLLER_ENABLED" = "true" ]; then upsert_yaml_kv_local "$file" "external-controller" "$EXTERNAL_CONTROLLER" - local ui_dir - ui_dir="$RUNTIME_DIR/ui" - rm -rf "$ui_dir" mkdir -p "$ui_dir" if [ -d "$PROJECT_DIR/dashboard/public" ]; then cp -a "$PROJECT_DIR/dashboard/public/." "$ui_dir/" upsert_yaml_kv_local "$file" "external-ui" "$ui_dir" + else + remove_yaml_key_local "$file" "external-ui" fi + else + remove_yaml_key_local "$file" "external-controller" + remove_yaml_key_local "$file" "external-ui" fi } @@ -161,6 +164,14 @@ finalize_config() { mv -f "$file" "$RUNTIME_CONFIG" } +remove_yaml_key_local() { + local file="$1" + local key="$2" + + [ -f "$file" ] || return 0 + sed -i -E "/^[[:space:]]*${key}:/d" "$file" +} + main() { local template_file="$CONFIG_DIR/template.yaml"