From 9a857ecbadc21e4b67bbaf3ad163ba191e640c82 Mon Sep 17 00:00:00 2001 From: Dmitriy Kalinin Date: Wed, 18 Mar 2020 11:50:16 -0400 Subject: [PATCH] pull out ExitStatus interface --- cmd/kapp/kapp.go | 2 +- pkg/kapp/cmd/app/deploy_diff_exit_status.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/kapp/kapp.go b/cmd/kapp/kapp.go index 0efa4b341..214cbc94a 100644 --- a/cmd/kapp/kapp.go +++ b/cmd/kapp/kapp.go @@ -27,7 +27,7 @@ func main() { err := command.Execute() if err != nil { confUI.ErrorLinef("kapp: Error: %v", err) - if typedErr, ok := err.(cmdapp.DeployDiffExitStatus); ok { + if typedErr, ok := err.(cmdapp.ExitStatus); ok { os.Exit(typedErr.ExitStatus()) } os.Exit(1) diff --git a/pkg/kapp/cmd/app/deploy_diff_exit_status.go b/pkg/kapp/cmd/app/deploy_diff_exit_status.go index fa89c47a6..652471b4a 100644 --- a/pkg/kapp/cmd/app/deploy_diff_exit_status.go +++ b/pkg/kapp/cmd/app/deploy_diff_exit_status.go @@ -4,10 +4,16 @@ import ( "fmt" ) +type ExitStatus interface { + ExitStatus() int +} + type DeployDiffExitStatus struct { hasNoChanges bool } +var _ ExitStatus = DeployDiffExitStatus{} + func (d DeployDiffExitStatus) Error() string { numStr := "pending changes" if d.hasNoChanges {