perfectsense / gyro

Gyro is a command-line tool for creating, updating, and maintaining cloud infrastructure. Gyro makes infrastructure-as-code possible.
https://gyro.dev
Apache License 2.0
134 stars 7 forks source link

Add a flag to gyro diff for a non-zero exit code when a pending diff is detected #410

Open mlivas opened 9 months ago

mlivas commented 9 months ago

When attempting to automate gyro changes without direct human involvement (via a bash script), I could not find a straightforward way to determine if there are currently pending diffs via the gyro diff command.

Adding a flag to the gyro diff command to provide a non-zero exit code when a diff is detected would enable this use-case, while leaving the default behavior as-is. Helm and Helmfile's diff commands offer this functionality via the --detailed-exitcode flag.

I found a workaround via echo n | gyro up, which exits with zero when there is no diff detected, and will both decline to apply any pending diffs and provide a non-zero exit code. This is not ideal as gyro up may present multiple prompts for changes that need to declined.