cpuset: Delete 'builder' methods

All usage of builder pattern is convertible to cpuset.New()
with the same or fewer lines of code.

Migrate Builder.Add to a private method of CPUSet, with a comment
that it is only intended for internal use to preserve immutable
propoerty of the exported interface.

This also removes 'require' library dependency, which avoids
non-standard library usage.
This commit is contained in:
Ian K. Coolidge
2022-11-08 14:57:03 +00:00
parent f3829c4be3
commit cbb985a310
6 changed files with 77 additions and 124 deletions

View File

@@ -522,11 +522,11 @@ func podresourcesGetAllocatableResourcesTests(ctx context.Context, cli kubeletpo
resp, err := cli.GetAllocatableResources(ctx, &kubeletpodresourcesv1.AllocatableResourcesRequest{})
framework.ExpectNoErrorWithOffset(1, err)
devs := resp.GetDevices()
b := cpuset.NewBuilder()
var cpus []int
for _, cpuid := range resp.GetCpuIds() {
b.Add(int(cpuid))
cpus = append(cpus, int(cpuid))
}
allocatableCPUs := b.Result()
allocatableCPUs := cpuset.New(cpus...)
if onlineCPUs.Size() == 0 {
ginkgo.By("expecting no CPUs reported")