Skip to content

Commit 004b809

Browse files
committed
feat: normalise paths in generates config files
1 parent d845a5f commit 004b809

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

scripts/config-diff.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,23 @@ function main {
241241
clean_copy "$KAYOBE_CONFIG_SOURCE_PATH" "$source_kayobe_config_dir"
242242
clean_copy "$KAYOBE_CONFIG_SOURCE_PATH" "$target_kayobe_config_dir"
243243

244+
function normalize_file_text() {
245+
local file="$1"
246+
local text="$2"
247+
248+
sed -i "s#/tmp/$text/\(.*\)#/tmp/\1#g" "$file"
249+
}
250+
251+
function normalize_files_in_folder() {
252+
local folder="$1"
253+
local text="$2"
254+
255+
# Find all files in the folder and its subfolders and loop through them
256+
find "$folder" -type f -print0 | while IFS= read -r -d '' file; do
257+
normalize_file_text "$file" "$text"
258+
done
259+
}
260+
244261
function generate_target_config {
245262
target_environment_path=/tmp/target-kayobe-env
246263
export ANSIBLE_LOG_PATH=/tmp/target-kayobe.log
@@ -251,6 +268,7 @@ function main {
251268
redact_config_dir "$target_environment_path"
252269
encrypt_config_dir "$target_environment_path"
253270
generate_config "$target_environment_path" "$target_dir"
271+
normalize_files_in_folder "$target_environment_path" "target-kayobe-env"
254272
}
255273

256274
function generate_source_config {
@@ -265,6 +283,7 @@ function main {
265283
redact_config_dir "$source_environment_path" "$target_kayobe_config_dir"
266284
encrypt_config_dir "$source_environment_path"
267285
generate_config "$source_environment_path" "$source_dir"
286+
normalize_files_in_folder "$source_environment_path" "source-kayobe-env"
268287
}
269288

270289
generate_target_config $1 >/dev/null 2>&1 &

0 commit comments

Comments
 (0)