6
6
# -o pipefail: Exit if any command in a pipeline fails.
7
7
set -exuo pipefail
8
8
9
- FLEET_GITOPS_DIR=" ${FLEET_GITOPS_DIR:- ./ } "
9
+ FLEET_GITOPS_DIR=" ${FLEET_GITOPS_DIR:- .} "
10
10
FLEET_GLOBAL_FILE=" ${FLEET_GLOBAL_FILE:- $FLEET_GITOPS_DIR / default.yml} "
11
11
FLEETCTL=" ${FLEETCTL:- fleetctl} "
12
12
FLEET_DRY_RUN_ONLY=" ${FLEET_DRY_RUN_ONLY:- false} "
13
+ FLEET_DELETE_OTHER_TEAMS=" ${FLEET_DELETE_OTHER_TEAMS:- true} "
13
14
14
15
# Validate that global file contains org_settings
15
16
grep -Exq " ^org_settings:.*" " $FLEET_GLOBAL_FILE "
@@ -20,21 +21,19 @@ if compgen -G "$FLEET_GITOPS_DIR"/teams/*.yml > /dev/null; then
20
21
! perl -nle ' print $1 if /^name:\s*(.+)$/' " $FLEET_GITOPS_DIR " /teams/* .yml | sort | uniq -d | grep . -cq
21
22
fi
22
23
23
- # Dry run
24
- $FLEETCTL gitops -f " $FLEET_GLOBAL_FILE " --dry-run
24
+ args=(-f " $FLEET_GLOBAL_FILE " )
25
25
for team_file in " $FLEET_GITOPS_DIR " /teams/* .yml; do
26
- if [ -f " $team_file " ]; then
27
- $FLEETCTL gitops -f " $team_file " --dry-run
28
- fi
26
+ args+=(-f " $team_file " )
29
27
done
28
+ if [ " $FLEET_DELETE_OTHER_TEAMS " = true ]; then
29
+ args+=(--delete-other-teams)
30
+ fi
31
+
32
+ # Dry run
33
+ $FLEETCTL gitops " ${args[@]} " --dry-run
30
34
if [ " $FLEET_DRY_RUN_ONLY " = true ]; then
31
35
exit 0
32
36
fi
33
37
34
38
# Real run
35
- $FLEETCTL gitops -f " $FLEET_GLOBAL_FILE "
36
- for team_file in " $FLEET_GITOPS_DIR " /teams/* .yml; do
37
- if [ -f " $team_file " ]; then
38
- $FLEETCTL gitops -f " $team_file "
39
- fi
40
- done
39
+ $FLEETCTL gitops " ${args[@]} "
0 commit comments