stefanprodan / timoni

Timoni is a package manager for Kubernetes, powered by CUE and inspired by Helm.
https://timoni.sh
Apache License 2.0
1.51k stars 67 forks source link

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

Open b4nst opened 8 months ago

b4nst commented 8 months ago

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 commented 8 months ago

We do look for the force annotation and we repot the dry run action as created https://github.com/stefanprodan/timoni/blob/f44c6a8f11d915998616ae0394e73b760bd70439/cmd/timoni/dyff.go#L106-L112

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

b4nst commented 8 months ago

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