Skip to content

Commit f9c3aec

Browse files
committed
Change test mock signatures for new k8s-cloud-provider
- k8s-cloud-provider added "options ...cloud.Option" to every mock hook function signatures. This commit changes our mocks to have the same signature - This commit fixes repo build
1 parent 28d3677 commit f9c3aec

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

providers/gce/gce_instances_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func TestNodeAddresses(t *testing.T) {
137137

138138
mockGCE := gce.c.(*cloud.MockGCE)
139139
mi := mockGCE.Instances().(*cloud.MockInstances)
140-
mi.GetHook = func(ctx context.Context, key *meta.Key, m *cloud.MockInstances) (bool, *ga.Instance, error) {
140+
mi.GetHook = func(ctx context.Context, key *meta.Key, m *cloud.MockInstances, options ...cloud.Option) (bool, *ga.Instance, error) {
141141
ret, ok := instanceMap[key.Name]
142142
if !ok {
143143
return true, nil, fmt.Errorf("instance not found")
@@ -275,7 +275,7 @@ func TestAliasRangesByProviderID(t *testing.T) {
275275

276276
mockGCE := gce.c.(*cloud.MockGCE)
277277
mai := mockGCE.Instances().(*cloud.MockInstances)
278-
mai.GetHook = func(ctx context.Context, key *meta.Key, m *cloud.MockInstances) (bool, *ga.Instance, error) {
278+
mai.GetHook = func(ctx context.Context, key *meta.Key, m *cloud.MockInstances, options ...cloud.Option) (bool, *ga.Instance, error) {
279279
ret, ok := instanceMap[key.Name]
280280
if !ok {
281281
return true, nil, fmt.Errorf("instance not found")
@@ -363,7 +363,7 @@ func TestInstanceByProviderID(t *testing.T) {
363363

364364
mockGCE := gce.c.(*cloud.MockGCE)
365365
mai := mockGCE.Instances().(*cloud.MockInstances)
366-
mai.GetHook = func(ctx context.Context, key *meta.Key, m *cloud.MockInstances) (bool, *ga.Instance, error) {
366+
mai.GetHook = func(ctx context.Context, key *meta.Key, m *cloud.MockInstances, options ...cloud.Option) (bool, *ga.Instance, error) {
367367
ret, ok := instanceMap[key.Name]
368368
if !ok {
369369
return true, nil, fmt.Errorf("instance not found")

providers/gce/gce_loadbalancer_external_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ func TestFirewallNeedsUpdate(t *testing.T) {
966966
ports []v1.ServicePort
967967
ipnet utilnet.IPNetSet
968968
fwIPProtocol string
969-
getHook func(context.Context, *meta.Key, *cloud.MockFirewalls) (bool, *compute.Firewall, error)
969+
getHook func(context.Context, *meta.Key, *cloud.MockFirewalls, ...cloud.Option) (bool, *compute.Firewall, error)
970970
sourceRange string
971971
exists bool
972972
needsUpdate bool
@@ -1074,7 +1074,7 @@ func TestFirewallNeedsUpdate(t *testing.T) {
10741074
ports: svc.Spec.Ports,
10751075
ipnet: ipnet,
10761076
fwIPProtocol: "tcp",
1077-
getHook: func(ctx context.Context, key *meta.Key, m *cloud.MockFirewalls) (bool, *compute.Firewall, error) {
1077+
getHook: func(ctx context.Context, key *meta.Key, m *cloud.MockFirewalls, options ...cloud.Option) (bool, *compute.Firewall, error) {
10781078
obj, ok := m.Objects[*key]
10791079
if !ok {
10801080
return false, nil, nil
@@ -1098,7 +1098,7 @@ func TestFirewallNeedsUpdate(t *testing.T) {
10981098
ports: svc.Spec.Ports,
10991099
ipnet: ipnet,
11001100
fwIPProtocol: "tcp",
1101-
getHook: func(ctx context.Context, key *meta.Key, m *cloud.MockFirewalls) (bool, *compute.Firewall, error) {
1101+
getHook: func(ctx context.Context, key *meta.Key, m *cloud.MockFirewalls, options ...cloud.Option) (bool, *compute.Firewall, error) {
11021102
obj, ok := m.Objects[*key]
11031103
if !ok {
11041104
return false, nil, nil
@@ -1122,7 +1122,7 @@ func TestFirewallNeedsUpdate(t *testing.T) {
11221122
ports: svc.Spec.Ports,
11231123
ipnet: ipnet,
11241124
fwIPProtocol: "tcp",
1125-
getHook: func(ctx context.Context, key *meta.Key, m *cloud.MockFirewalls) (bool, *compute.Firewall, error) {
1125+
getHook: func(ctx context.Context, key *meta.Key, m *cloud.MockFirewalls, options ...cloud.Option) (bool, *compute.Firewall, error) {
11261126
obj, ok := m.Objects[*key]
11271127
if !ok {
11281128
return false, nil, nil
@@ -1496,7 +1496,7 @@ func TestExternalLoadBalancerEnsureHttpHealthCheck(t *testing.T) {
14961496
gce, err := fakeGCECloud(DefaultTestClusterValues())
14971497
require.NoError(t, err)
14981498
c := gce.c.(*cloud.MockGCE)
1499-
c.MockHttpHealthChecks.UpdateHook = func(ctx context.Context, key *meta.Key, obj *compute.HttpHealthCheck, m *cloud.MockHttpHealthChecks) error {
1499+
c.MockHttpHealthChecks.UpdateHook = func(ctx context.Context, key *meta.Key, obj *compute.HttpHealthCheck, m *cloud.MockHttpHealthChecks, options ...cloud.Option) error {
15001500
m.Objects[*key] = &cloud.MockHttpHealthChecksObj{Obj: obj}
15011501
return nil
15021502
}

providers/gce/gce_loadbalancer_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,7 @@ func TestEnsureInternalLoadBalancerModifyProtocol(t *testing.T) {
18811881
gce, err := fakeGCECloud(vals)
18821882
require.NoError(t, err)
18831883
c := gce.c.(*cloud.MockGCE)
1884-
c.MockRegionBackendServices.UpdateHook = func(ctx context.Context, key *meta.Key, be *compute.BackendService, m *cloud.MockRegionBackendServices) error {
1884+
c.MockRegionBackendServices.UpdateHook = func(ctx context.Context, key *meta.Key, be *compute.BackendService, m *cloud.MockRegionBackendServices, options ...cloud.Option) error {
18851885
// Same key can be used since FR will have the same name.
18861886
fr, err := c.MockForwardingRules.Get(ctx, key)
18871887
if err != nil && !isNotFound(err) {

providers/gce/gce_util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func registerTargetPoolAddInstanceHook(gce *Cloud, callback func(*compute.Target
9696
return fmt.Errorf("couldn't cast cloud to mockGCE: %#v", gce)
9797
}
9898
existingHandler := mockGCE.MockTargetPools.AddInstanceHook
99-
hook := func(ctx context.Context, key *meta.Key, req *compute.TargetPoolsAddInstanceRequest, m *cloud.MockTargetPools) error {
99+
hook := func(ctx context.Context, key *meta.Key, req *compute.TargetPoolsAddInstanceRequest, m *cloud.MockTargetPools, options ...cloud.Option) error {
100100
callback(req)
101101
return existingHandler(ctx, key, req, m)
102102
}
@@ -110,7 +110,7 @@ func registerTargetPoolRemoveInstanceHook(gce *Cloud, callback func(*compute.Tar
110110
return fmt.Errorf("couldn't cast cloud to mockGCE: %#v", gce)
111111
}
112112
existingHandler := mockGCE.MockTargetPools.RemoveInstanceHook
113-
hook := func(ctx context.Context, key *meta.Key, req *compute.TargetPoolsRemoveInstanceRequest, m *cloud.MockTargetPools) error {
113+
hook := func(ctx context.Context, key *meta.Key, req *compute.TargetPoolsRemoveInstanceRequest, m *cloud.MockTargetPools, options ...cloud.Option) error {
114114
callback(req)
115115
return existingHandler(ctx, key, req, m)
116116
}

0 commit comments

Comments
 (0)