Skip to content

Commit 228d671

Browse files
authored
remove not needed global (#18)
* remove not needed global * fix test * remove not needed version from docker compose * improve tests * improve tests * improve tests * add todos
1 parent 1e1c76a commit 228d671

File tree

7 files changed

+28
-35
lines changed

7 files changed

+28
-35
lines changed

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.8'
2-
31
services:
42
env-loader:
53
build:

parse-config.sh

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,38 @@ load_dir() {
2929

3030
# $3, is the numbers of characters to strip in front of the key
3131
KEY="${KEY:$3}"
32+
33+
# Removes the application.$application_name prefix if it exists
34+
if [[ "$KEY" == "application.$APPLICATION_NAME."* ]]; then
35+
KEY=${KEY#"application.$APPLICATION_NAME."}
36+
fi
37+
38+
# TODO: remove when not needed - we use tag source instead
39+
# Removes the .terraform suffix if it exists
40+
if [[ "$KEY" == *".terraform" ]]; then
41+
KEY=${KEY%".terraform"}
42+
fi
3243

33-
# Removes the infrastructure.global prefix if it exists
44+
# TODO: remove when not needed - we use tag visibility instead
45+
# Removes the infrastructure.global. prefix if it exists
3446
if [[ "$KEY" == "infrastructure.global."* ]]; then
3547
KEY=${KEY#"infrastructure.global."}
3648
fi
3749

38-
if [[ "$KEY" =~ infrastructure\.[^.]+\.global\..+ ]]; then
39-
# Remove 'infrastructure.' prefix
40-
TEMP=${KEY#infrastructure.}
41-
42-
# Split off the part after 'global.'
43-
PART_BEFORE_GLOBAL=${TEMP%%.global.*}
44-
PART_AFTER_GLOBAL=${TEMP#*.global.}
45-
46-
# Combine the parts
47-
KEY="${PART_BEFORE_GLOBAL}.${PART_AFTER_GLOBAL}"
50+
# Removes the infrastructure. prefix if it exists
51+
if [[ "$KEY" == "infrastructure."* ]]; then
52+
KEY=${KEY#"infrastructure."}
4853
fi
4954

50-
# Removes the application.global prefix if it exists
55+
# TODO: remove when not needed - we use tag visibility instead
56+
# Removes the application.global. prefix if it exists
5157
if [[ "$KEY" == "application.global."* ]]; then
5258
KEY=${KEY#"application.global."}
5359
fi
5460

55-
if [[ "$KEY" =~ application\.[^.]+\.global\..+ ]]; then
56-
# Remove 'application.' prefix
57-
TEMP=${KEY#application.}
58-
59-
# Split off the part after 'global.'
60-
PART_BEFORE_GLOBAL=${TEMP%%.global.*}
61-
PART_AFTER_GLOBAL=${TEMP#*.global.}
62-
63-
# Combine the parts
64-
KEY="${PART_BEFORE_GLOBAL}.${PART_AFTER_GLOBAL}"
65-
fi
66-
67-
# Removes the application.$application_name prefix if it exists
68-
if [[ "$KEY" == "application.$APPLICATION_NAME."* ]]; then
69-
KEY=${KEY#"application.$APPLICATION_NAME."}
70-
fi
71-
72-
# Removes the .terraform suffix if it exists
73-
if [[ "$KEY" == *".terraform" ]]; then
74-
KEY=${KEY%".terraform"}
61+
# Removes the application. prefix if it exists
62+
if [[ "$KEY" == "application."* ]]; then
63+
KEY=${KEY#"application."}
7564
fi
7665

7766
log "source=$FILENAME destination=$KEY"

test/validate.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ else
99
printf 'The file "%s" is different from "%s"\n' "$result" "$expected"
1010
printf '\n'
1111
echo $(diff $result $expected)
12-
12+
printf '\n\n'
13+
printf 'Expected:\n'
14+
cat "$expected"
15+
printf '\n\n'
16+
printf 'Result:\n'
17+
cat "$result"
18+
1319
exit 1
1420
fi

0 commit comments

Comments
 (0)