Skip to content

Commit 30543df

Browse files
committed
WIP
1 parent 840ffa9 commit 30543df

File tree

264 files changed

+201000
-94
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

264 files changed

+201000
-94
lines changed

go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ require (
66
cloud.google.com/go/compute v1.23.3
77
github.com/awslabs/operatorpkg v0.0.0-20241205163410-0fff9f28d115
88
github.com/mitchellh/hashstructure/v2 v2.0.2
9+
github.com/onsi/ginkgo/v2 v2.22.2
10+
github.com/onsi/gomega v1.36.2
911
github.com/patrickmn/go-cache v2.1.0+incompatible
1012
github.com/samber/lo v1.49.1
1113
go.uber.org/multierr v1.11.0
@@ -31,13 +33,15 @@ require (
3133
github.com/go-openapi/jsonpointer v0.21.0 // indirect
3234
github.com/go-openapi/jsonreference v0.20.2 // indirect
3335
github.com/go-openapi/swag v0.23.0 // indirect
36+
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
3437
github.com/gogo/protobuf v1.3.2 // indirect
3538
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3639
github.com/golang/protobuf v1.5.4 // indirect
3740
github.com/google/btree v1.1.3 // indirect
3841
github.com/google/gnostic-models v0.6.8 // indirect
3942
github.com/google/go-cmp v0.6.0 // indirect
4043
github.com/google/gofuzz v1.2.0 // indirect
44+
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
4145
github.com/google/s2a-go v0.1.7 // indirect
4246
github.com/google/uuid v1.6.0 // indirect
4347
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
@@ -70,6 +74,7 @@ require (
7074
golang.org/x/term v0.27.0 // indirect
7175
golang.org/x/text v0.21.0 // indirect
7276
golang.org/x/time v0.9.0 // indirect
77+
golang.org/x/tools v0.28.0 // indirect
7378
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
7479
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
7580
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect

go.sum

+2-53
Large diffs are not rendered by default.

pkg/providers/instancetype/instancetype.go

+8-41
Original file line numberDiff line numberDiff line change
@@ -150,52 +150,19 @@ func (p *DefaultProvider) getInstanceTypes(ctx context.Context) ([]*computepb.Ma
150150
it := p.machineTypesClient.AggregatedList(ctx, req)
151151

152152
var vmTypes []*computepb.MachineType
153-
iterationCount := 0
154-
lastTypeCount := 0
153+
for {
154+
resp, err := it.Next()
155+
if errors.Is(err, iterator.Done) {
156+
break
157+
}
155158

156-
// Process the first page
157-
resp, err := it.Next()
158-
if err != nil && !errors.Is(err, iterator.Done) {
159-
return nil, err
160-
}
159+
if err != nil {
160+
return nil, err
161+
}
161162

162-
// If we got a response, process it
163-
if !errors.Is(err, iterator.Done) && resp.Value != nil && resp.Value.MachineTypes != nil {
164163
vmTypes = append(vmTypes, resp.Value.MachineTypes...)
165-
lastTypeCount = len(vmTypes)
166-
}
167-
168-
// Process remaining pages
169-
for {
170-
select {
171-
case <-ctx.Done():
172-
return nil, ctx.Err()
173-
default:
174-
iterationCount++
175-
resp, err := it.Next()
176-
if errors.Is(err, iterator.Done) {
177-
goto done
178-
}
179-
180-
if err != nil {
181-
return nil, err
182-
}
183-
184-
if resp.Value == nil || resp.Value.MachineTypes == nil {
185-
continue
186-
}
187-
188-
vmTypes = append(vmTypes, resp.Value.MachineTypes...)
189-
if len(vmTypes) > lastTypeCount {
190-
lastTypeCount = len(vmTypes)
191-
} else {
192-
// If we're not getting new types, we might be in a loop
193-
goto done
194-
}
195-
}
196164
}
197165

198-
done:
199166
p.cache.SetDefault(InstanceTypesCacheKey, vmTypes)
200167
return vmTypes, nil
201168
}

0 commit comments

Comments
 (0)