mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #103415 from tiloso/staticcheck-kubelet
Fix staticcheck failure in pkg/kubelet/cm/cpuset
This commit is contained in:
commit
3ca3daac76
@ -1,4 +1,3 @@
|
|||||||
pkg/kubelet/cm/cpuset
|
|
||||||
pkg/util/flag
|
pkg/util/flag
|
||||||
test/e2e/apimachinery
|
test/e2e/apimachinery
|
||||||
vendor/k8s.io/apimachinery/pkg/util/json
|
vendor/k8s.io/apimachinery/pkg/util/json
|
||||||
|
@ -36,8 +36,8 @@ type Builder struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewBuilder returns a mutable CPUSet builder.
|
// NewBuilder returns a mutable CPUSet builder.
|
||||||
func NewBuilder() Builder {
|
func NewBuilder() *Builder {
|
||||||
return Builder{
|
return &Builder{
|
||||||
result: CPUSet{
|
result: CPUSet{
|
||||||
elems: map[int]struct{}{},
|
elems: map[int]struct{}{},
|
||||||
},
|
},
|
||||||
@ -46,7 +46,7 @@ func NewBuilder() Builder {
|
|||||||
|
|
||||||
// Add adds the supplied elements to the result. Calling Add after calling
|
// Add adds the supplied elements to the result. Calling Add after calling
|
||||||
// Result has no effect.
|
// Result has no effect.
|
||||||
func (b Builder) Add(elems ...int) {
|
func (b *Builder) Add(elems ...int) {
|
||||||
if b.done {
|
if b.done {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ func (b Builder) Add(elems ...int) {
|
|||||||
|
|
||||||
// Result returns the result CPUSet containing all elements that were
|
// Result returns the result CPUSet containing all elements that were
|
||||||
// previously added to this builder. Subsequent calls to Add have no effect.
|
// previously added to this builder. Subsequent calls to Add have no effect.
|
||||||
func (b Builder) Result() CPUSet {
|
func (b *Builder) Result() CPUSet {
|
||||||
b.done = true
|
b.done = true
|
||||||
return b.result
|
return b.result
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ package cpuset
|
|||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCPUSetBuilder(t *testing.T) {
|
func TestCPUSetBuilder(t *testing.T) {
|
||||||
@ -36,6 +38,9 @@ func TestCPUSetBuilder(t *testing.T) {
|
|||||||
if len(elems) != result.Size() {
|
if len(elems) != result.Size() {
|
||||||
t.Fatalf("expected cpuset %s to have the same size as %v", result, elems)
|
t.Fatalf("expected cpuset %s to have the same size as %v", result, elems)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b.Add(6)
|
||||||
|
require.False(t, result.Contains(6), "expected calls to Add after calling Result() to have no effect")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCPUSetSize(t *testing.T) {
|
func TestCPUSetSize(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user