Fail early if chart or release is missing

This commit is contained in:
Erin Call 2019-12-16 16:55:54 -08:00
parent e4fa70239e
commit 1560c05100
No known key found for this signature in database
GPG key ID: 4071FF6C15B8DAD1
3 changed files with 28 additions and 1 deletions

View file

@ -8,7 +8,7 @@ TODO:
* [x] Make `golint` part of the build process (and make it pass)
* [x] Implement debug output
* [x] Flesh out `helm upgrade` until it's capable of working
* [ ] Implement config settings for `upgrade`
* [x] Implement config settings for `upgrade`
* [ ] Implement `helm lint`
* [ ] Implement `helm delete`
* [ ] EKS support

View file

@ -26,6 +26,13 @@ func (u *Upgrade) Execute(_ Config) error {
// Prepare gets the Upgrade ready to execute.
func (u *Upgrade) Prepare(cfg Config) error {
if u.Chart == "" {
return fmt.Errorf("chart is required")
}
if u.Release == "" {
return fmt.Errorf("release is required")
}
args := []string{"--kubeconfig", cfg.KubeConfig}
if cfg.Namespace != "" {

View file

@ -136,6 +136,26 @@ func (suite *UpgradeTestSuite) TestPrepareWithUpgradeFlags() {
suite.Require().Nil(err)
}
func (suite *UpgradeTestSuite) TestRequiresChartAndRelease() {
// These aren't really expected, but allowing them gives clearer test-failure messages
suite.mockCmd.EXPECT().Stdout(gomock.Any()).AnyTimes()
suite.mockCmd.EXPECT().Stderr(gomock.Any()).AnyTimes()
u := Upgrade{
Release: "seth_everman_unskippable_cutscene",
}
err := u.Prepare(Config{})
suite.EqualError(err, "chart is required", "Chart should be mandatory")
u = Upgrade{
Chart: "billboard_top_zero",
}
err = u.Prepare(Config{})
suite.EqualError(err, "release is required", "Release should be mandatory")
}
func (suite *UpgradeTestSuite) TestPrepareDebugFlag() {
u := Upgrade{
Chart: "at40",