This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid printing deprecation notices on KVM (#615)
* Add utility function to format deprecation notice * Only display deprecation notices for non-kvm installations * Move provider checking logic to 'GetDeprecatedNotice' utility function and add tests * Print deprecated notice * Highlight command literals with yellow and remove double quotes * Also remove quotes from test output
- Loading branch information
Showing
9 changed files
with
91 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package util | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/fatih/color" | ||
p "github.com/giantswarm/gsctl/pkg/provider" | ||
) | ||
|
||
func GetDeprecatedNotice(provider, gsctlCmd, kubectlgsCmd, docsURL string) string { | ||
if provider == p.KVM { | ||
return "" | ||
} | ||
|
||
return fmt.Sprintf(`Command %s is deprecated, gsctl is being phased out in favor of our kubectl-gs plugin. | ||
We recommend you familiarize yourself with the %s command as a replacement for this. | ||
For more details see: %s | ||
`, color.YellowString(gsctlCmd), color.YellowString("kubectl gs "+kubectlgsCmd), docsURL) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package util | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/giantswarm/gsctl/pkg/provider" | ||
) | ||
|
||
func TestGetDeprecatedNotice(t *testing.T) { | ||
var testCases = []struct { | ||
provider string | ||
gsctlCmd string | ||
kubectlgsCmd string | ||
docsURL string | ||
output string | ||
}{ | ||
{ | ||
provider: provider.AWS, | ||
gsctlCmd: "list something", | ||
kubectlgsCmd: "get something", | ||
docsURL: "https://docs.giantswarm.io/ui-api/kubectl-gs/get-something/", | ||
output: `Command list something is deprecated, gsctl is being phased out in favor of our kubectl-gs plugin. | ||
We recommend you familiarize yourself with the kubectl gs get something command as a replacement for this. | ||
For more details see: https://docs.giantswarm.io/ui-api/kubectl-gs/get-something/ | ||
`, | ||
}, | ||
{ | ||
provider: provider.Azure, | ||
gsctlCmd: "list something", | ||
kubectlgsCmd: "get something", | ||
docsURL: "https://docs.giantswarm.io/ui-api/kubectl-gs/get-something/", | ||
output: `Command list something is deprecated, gsctl is being phased out in favor of our kubectl-gs plugin. | ||
We recommend you familiarize yourself with the kubectl gs get something command as a replacement for this. | ||
For more details see: https://docs.giantswarm.io/ui-api/kubectl-gs/get-something/ | ||
`, | ||
}, | ||
{ | ||
provider: provider.KVM, | ||
gsctlCmd: "list anotherthing", | ||
kubectlgsCmd: "get anotherthing", | ||
docsURL: "https://docs.giantswarm.io/ui-api/kubectl-gs/get-anotherthing/", | ||
output: "", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
notice := GetDeprecatedNotice(tc.provider, tc.gsctlCmd, tc.kubectlgsCmd, tc.docsURL) | ||
if notice != tc.output { | ||
t.Errorf("Got '%s', wanted '%s'", notice, tc.output) | ||
} | ||
} | ||
} |