Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nil pointer dereference in scale command #2416

Merged
merged 3 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/ctl/cmdutils/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func NewScaleNodeGroupLoader(cmd *Cmd, ng *api.NodeGroup) ClusterConfigLoader {
if err := validateNumberOfNodes(loadedNG); err != nil {
return err
}
*ng = *loadedNG
l.Plan = false
return nil
}
Expand Down
12 changes: 9 additions & 3 deletions pkg/ctl/cmdutils/scale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (
)

type scaleNodeGroupCase struct {
name string
error error
name string
error error
minSize *int
}

var _ = Describe("scale node group config file loader", func() {
Expand All @@ -22,6 +23,7 @@ var _ = Describe("scale node group config file loader", func() {
Run: func(_ *cobra.Command, _ []string) {},
}
}
minSizeOne := 1

DescribeTable("create nodegroup successfully",
func(params scaleNodeGroupCase) {
Expand All @@ -39,6 +41,9 @@ var _ = Describe("scale node group config file loader", func() {
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring(params.error.Error()))
} else {
if params.minSize != nil {
Expect(ng.MinSize).To(Equal(params.minSize))
}
Expect(err).ToNot(HaveOccurred())
}
},
Expand All @@ -57,7 +62,8 @@ var _ = Describe("scale node group config file loader", func() {
name: "ng-no-min-max",
}),
Entry("ng with minSize", scaleNodeGroupCase{
name: "ng-with-min",
name: "ng-with-min",
minSize: &minSizeOne,
}),
Entry("ng with wrong value for minSize", scaleNodeGroupCase{
name: "ng-with-wrong-min",
Expand Down