Add contextual error code for flux diff kustomization
If implemented, calling the diff command on kustomization will return 0, 1(if changes are identified), >1 for errors. Signed-off-by: Soule BA <soule@weave.works>
This commit is contained in:
@@ -325,6 +325,12 @@ type cmdTestCase struct {
|
||||
|
||||
func (cmd *cmdTestCase) runTestCmd(t *testing.T) {
|
||||
actual, testErr := executeCommand(cmd.args)
|
||||
|
||||
// If the cmd error is a change, discard it
|
||||
if isChangeError(testErr) {
|
||||
testErr = nil
|
||||
}
|
||||
|
||||
if assertErr := cmd.assert(actual, testErr); assertErr != nil {
|
||||
t.Error(assertErr)
|
||||
}
|
||||
@@ -366,3 +372,12 @@ func resetCmdArgs() {
|
||||
getArgs = GetFlags{}
|
||||
secretGitArgs = NewSecretGitFlags()
|
||||
}
|
||||
|
||||
func isChangeError(err error) bool {
|
||||
if reqErr, ok := err.(*RequestError); ok {
|
||||
if strings.Contains(err.Error(), "identified at least one change, exiting with non-zero exit code") && reqErr.StatusCode == 1 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user