From a936334ad79a87e942ea3b1e622ad2bce097e6b7 Mon Sep 17 00:00:00 2001 From: Chris Durham <47731853+chrsdrhm@users.noreply.github.com> Date: Sun, 11 Oct 2026 17:38:06 -0500 Subject: [PATCH] Fix the duplicate fleet name check in the fleetctl new GitOps template The template's gitops.sh used `! perl ... | grep . -cq`, which never stops the script: set -e ignores a command that starts with `!`. This applies the same fix #53469 made to .github/actions/gitops/gitops.sh. Co-Authored-By: Claude Opus 5.5 --- changes/53726-gitops-template-duplicate-fleet-check | 1 + .../fleetctl/templates/new/.github/fleet-gitops/gitops.sh | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changes/53726-gitops-template-duplicate-fleet-check diff --git a/changes/53726-gitops-template-duplicate-fleet-check b/changes/53726-gitops-template-duplicate-fleet-check new file mode 100644 index 00000000000..c9953cef372 --- /dev/null +++ b/changes/53726-gitops-template-duplicate-fleet-check @@ -0,0 +1 @@ +- Fixed the duplicate fleet name check in the GitOps `gitops.sh` that `fleetctl new` generates: it never stopped the run, because `set -e` ignores a command starting with `!`. This applies the same fix #53469 made to Fleet's own GitOps action. diff --git a/cmd/fleetctl/fleetctl/templates/new/.github/fleet-gitops/gitops.sh b/cmd/fleetctl/fleetctl/templates/new/.github/fleet-gitops/gitops.sh index 45caa6c81c1..23f469bc1b5 100755 --- a/cmd/fleetctl/fleetctl/templates/new/.github/fleet-gitops/gitops.sh +++ b/cmd/fleetctl/fleetctl/templates/new/.github/fleet-gitops/gitops.sh @@ -32,7 +32,10 @@ fi if compgen -G "$FLEET_GITOPS_DIR"/fleets/*.yml > /dev/null; then # Validate that every fleet has a unique name. # This is a limited check that assumes all per-fleet .yml files contain the phrase: `name: ` - ! perl -nle 'print $1 if /^name:\s*(.+)$/' "$FLEET_GITOPS_DIR"/fleets/*.yml | sort | uniq -d | grep . -cq + if [ -n "$(perl -nle 'print $1 if /^name:\s*(.+)$/' "$FLEET_GITOPS_DIR"/fleets/*.yml | sort | uniq -d)" ]; then + echo "Error: duplicate fleet names found" >&2 + exit 1 + fi fi args=()