Skip to content

Commit bb35b95

Browse files
authored
Support team only GitOps repository (#89)
1 parent a85a814 commit bb35b95

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

gitops.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ FLEETCTL="${FLEETCTL:-fleetctl}"
1212
FLEET_DRY_RUN_ONLY="${FLEET_DRY_RUN_ONLY:-false}"
1313
FLEET_DELETE_OTHER_TEAMS="${FLEET_DELETE_OTHER_TEAMS:-true}"
1414

15-
# Validate that global file contains org_settings
16-
grep -Exq "^org_settings:.*" "$FLEET_GLOBAL_FILE"
15+
# Check for existence of the global file in case the script is used
16+
# on repositories with team only yamls.
17+
if [ -f "$FLEET_GLOBAL_FILE" ]; then
18+
# Validate that global file contains org_settings
19+
grep -Exq "^org_settings:.*" "$FLEET_GLOBAL_FILE"
20+
else
21+
FLEET_DELETE_OTHER_TEAMS=false
22+
fi
1723

1824
# Copy/pasting raw SSO metadata into GitHub secrets will result in malformed yaml.
1925
# Adds spaces to all but the first line of metadata keeps the multiline string in bounds.
@@ -28,7 +34,11 @@ if compgen -G "$FLEET_GITOPS_DIR"/teams/*.yml > /dev/null; then
2834
! perl -nle 'print $1 if /^name:\s*(.+)$/' "$FLEET_GITOPS_DIR"/teams/*.yml | sort | uniq -d | grep . -cq
2935
fi
3036

31-
args=(-f "$FLEET_GLOBAL_FILE")
37+
args=()
38+
if [ -f "$FLEET_GLOBAL_FILE" ]; then
39+
args=(-f "$FLEET_GLOBAL_FILE")
40+
fi
41+
3242
for team_file in "$FLEET_GITOPS_DIR"/teams/*.yml; do
3343
if [ -f "$team_file" ]; then
3444
args+=(-f "$team_file")

0 commit comments

Comments
 (0)