codilime / floodgate

Floodgate - Pipelines as Code solution for Spinnaker
Apache License 2.0
16 stars 9 forks source link

Floodgate should return with different code when there is error in compare #128

Open boscard opened 4 years ago

boscard commented 4 years ago

https://app.circleci.com/pipelines/github/codilime/floodgate/784/workflows/4f9815e0-20aa-42d8-88fb-425479fbd1dd/jobs/3486

#!/bin/bash -eo pipefail
echo "Print version using version flag"
/floodgate/bin/floodgate --version
echo "Print version using version command"
/floodgate/bin/floodgate version
echo "Comare changes - clean Spinnaker"
/floodgate/bin/floodgate -q --config ~/floodgate.yaml compare && exit 1 || echo "Found changes"
echo "Apply local resources"
/floodgate/bin/floodgate -q --config ~/floodgate.yaml sync
echo "Compare changes - synced resources"
/floodgate/bin/floodgate -q --config ~/floodgate.yaml compare

Print version using version flag
version 0.3.0-pull/126
Print version using version command
Version:        0.3.0-pull/126
Gate API version:   1.21.x
Go version:     1.14.4
Git commit:     9099505e23301e5e55cdf1dfe00f645ea0d0f806
Built:          2020-10-05_20:25:28
Comare changes - clean Spinnaker
FATA[0007] unexpected end of JSON input                 
Found changes
Apply local resources
Compare changes - synced resources

CircleCI received exit code 0

When there is such error Floodgate should exit with different code than 1 because 1 is used when there is difference between local and remote state.

mertsaygi commented 4 years ago

Also both of the JSONs' valid in this case. Local and remote

boscard commented 4 years ago

I think that we can implement something similar to this https://golang.org/pkg/os/#pkg-variables

mertsaygi commented 4 years ago

Could you please check this PR? I tried to find a different solution for this issue:

https://github.com/codilime/floodgate/pull/126