Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dry-run status code when --force flag is not present #298

Open
b4nst opened this issue Dec 27, 2023 · 2 comments
Open

Dry-run status code when --force flag is not present #298

b4nst opened this issue Dec 27, 2023 · 2 comments

Comments

@b4nst
Copy link
Contributor

b4nst commented Dec 27, 2023

Currently a dry-run without a force will display something like that for immutable resources

2:20PM ERR i:object-name> Deployment/namesapce/my-app immutable (server dry run)

However it will exit with status 0. Imo this is wrong because if we remove the --dry-run and the object doesn't have the action.timoni.sh/force annotation, the apply will fail.

I propose we show an ERR and exit with an error status (maybe 2 to identify immutable error versus runtime error) if force arg is not used and action.timoni.sh/force is not set on that resource.
If force or action.timoni.sh/force is present, then we can set a WARN or something like this and exit 0.

@stefanprodan
Copy link
Owner

stefanprodan commented Dec 27, 2023

We do look for the force annotation and we repot the dry run action as created

timoni/cmd/timoni/dyff.go

Lines 106 to 112 in f44c6a8

if ssa.AnyInMetadata(r, map[string]string{
apiv1.ForceAction: apiv1.EnabledValue,
}) {
log.Info(colorizeJoin(r, ssa.CreatedAction, dryRunServer))
} else {
log.Error(nil, colorizeJoin(r, "immutable", dryRunServer))
}

I agree that we should return a non zero exit code for immutable and without --force.

@b4nst
Copy link
Contributor Author

b4nst commented Dec 27, 2023

I'll give it a try this week if I find some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants