Fail early if chart or release is missing
This commit is contained in:
parent
e4fa70239e
commit
1560c05100
|
@ -8,7 +8,7 @@ TODO:
|
||||||
* [x] Make `golint` part of the build process (and make it pass)
|
* [x] Make `golint` part of the build process (and make it pass)
|
||||||
* [x] Implement debug output
|
* [x] Implement debug output
|
||||||
* [x] Flesh out `helm upgrade` until it's capable of working
|
* [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 lint`
|
||||||
* [ ] Implement `helm delete`
|
* [ ] Implement `helm delete`
|
||||||
* [ ] EKS support
|
* [ ] EKS support
|
||||||
|
|
|
@ -26,6 +26,13 @@ func (u *Upgrade) Execute(_ Config) error {
|
||||||
|
|
||||||
// Prepare gets the Upgrade ready to execute.
|
// Prepare gets the Upgrade ready to execute.
|
||||||
func (u *Upgrade) Prepare(cfg Config) error {
|
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}
|
args := []string{"--kubeconfig", cfg.KubeConfig}
|
||||||
|
|
||||||
if cfg.Namespace != "" {
|
if cfg.Namespace != "" {
|
||||||
|
|
|
@ -136,6 +136,26 @@ func (suite *UpgradeTestSuite) TestPrepareWithUpgradeFlags() {
|
||||||
suite.Require().Nil(err)
|
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() {
|
func (suite *UpgradeTestSuite) TestPrepareDebugFlag() {
|
||||||
u := Upgrade{
|
u := Upgrade{
|
||||||
Chart: "at40",
|
Chart: "at40",
|
||||||
|
|
Loading…
Reference in a new issue