Skip to content

Commit

Permalink
update request options for nodegroup (#66)
Browse files Browse the repository at this point in the history
* update request options for nodegroup

* added new test cases, fixed failed tests

* move duplicated variables to constants, fixed linter issues

* revert .golangci.yml changes

* fix golangci

* updated .golangci.yml; bumped golangci to version 1.44.0

* fixed NodegroupUpdateOpts fields declaration

* slight changes for docstrings

* removed unnecessary field from update requests

* fixed failed tests

* remove redundant nolint directives; turn off goerr113 and tagliatelle linters

* convert tabs to spaces in raw request body

* added taints update example to docs

* fixes for failed tests

* remove unused linters from config

Co-authored-by: Kulakov Ilya <[email protected]>
  • Loading branch information
TawR1024 and Kulakov Ilya authored Apr 7, 2022
1 parent 54a9160 commit d3f4fa0
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 70 deletions.
48 changes: 30 additions & 18 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
run:
timeout: 5m
skip-files:
- "fixtures.go"

linters-settings:
nlreturn:
block-size: 3
funlen:
statements: 65

cyclop:
# the maximal code complexity to report, 8 by default
max-complexity: 9

godot:
scope: declarations

gci:
# put imports beginning with prefix after 3rd-party packages;
# only support one prefix
# if not set, use goimports.local-prefixes
local-prefixes: github.com/selectel

nestif:
# minimal complexity of if statements to report, 5 by default
min-complexity: 5

linters:
fast: false
disable-all: true
Expand All @@ -15,13 +43,10 @@ linters:
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gci
- goconst
- gochecknoglobals
- gocritic
- godot
# - goerr113
- gofmt
- gofumpt
- goheader
Expand All @@ -46,10 +71,11 @@ linters:
- predeclared
- promlinter
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
# - tagliatelle
- tparallel
- typecheck
- unconvert
Expand All @@ -58,17 +84,3 @@ linters:
- varcheck
- wastedassign
- whitespace

linters-settings:
funlen:
statements: 65

tagliatelle:
case:
use-field-name: false
rules:
json: snake

run:
skip-files:
- "fixtures.go"
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: go
install:
- go get github.com/mattn/goveralls
- go get github.com/wadey/gocovmerge
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.44.0
go:
- "1.16"
- "1.17"
Expand Down
16 changes: 16 additions & 0 deletions pkg/v1/nodegroup/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,21 @@ Example of updating nodegroup labels
if err != nil {
log.Fatal(err)
}
Example of updating nodegroup taints
updateOpts := &nodegroup.UpdateOpts{
Taints: []nodegroup.Taint{
{
Key: "new-key-0",
Value: "new-value-0",
Effect: nodegroup.NoScheduleEffect,
},
},
}
_, err := nodegroup.Update(ctx, mksClient, clusterID, nodegroupID, updateOpts)
if err != nil {
log.Fatal(err)
}
*/
package nodegroup
4 changes: 4 additions & 0 deletions pkg/v1/nodegroup/requests_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ type UpdateOpts struct {
// for each node in the group. The keys must be user-defined.
Labels map[string]string `json:"labels"`

// Taints represents a list of nodegroup taints which will be applied
// for each node in the group.
Taints []Taint `json:"taints"`

// EnableAutoscale reflects if the nodegroup is allowed to be scaled automatically.
EnableAutoscale *bool `json:"enable_autoscale,omitempty"`

Expand Down
35 changes: 31 additions & 4 deletions pkg/v1/nodegroup/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,48 @@ const testUpdateNodegroupOptsRaw = `
{
"nodegroup": {
"labels": {
"test-label-key": "test-label-value"
"test-label-key": "test-label-value"
},
"enable_autoscale": false
"enable_autoscale": false,
"taints": null
}
}
`
}`

// testCreateNodegroupOpts represents options for the Update request.
var testUpdateNodegroupOpts = &nodegroup.UpdateOpts{
Labels: map[string]string{
"test-label-key": "test-label-value",
},
EnableAutoscale: testutils.BoolToPtr(false),
Taints: nil,
}

// testUpdateNodegroupTaints represents options for the nodegroup taints update request.
var testUpdateNodegroupTaints = &nodegroup.UpdateOpts{
Taints: []nodegroup.Taint{
{
Key: "TestKey",
Value: "TestValue",
Effect: "NoSchedule",
},
},
Labels: nil,
}

// testUpdateNodegroupTaintsRaw represents marshalled options for the nodegroup taints update request.
const testUpdateNodegroupTaintsRaw = `
{
"nodegroup": {
"labels": null,
"taints": [{
"key": "TestKey",
"value": "TestValue",
"effect": "NoSchedule"
}]
}
}
`

// testResizeNodegroupOptsRaw represents marshalled options for the Resize request.
const testResizeNodegroupOptsRaw = `
{
Expand Down
Loading

0 comments on commit d3f4fa0

Please sign in to comment.