Skip to content

Commit 5787a59

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#57566 from bowei/expose-gce
Automatic merge from submit-queue (batch tested with PRs 57566, 57573). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Expose all GCE cloud provider services versions, not just the GA API ```release-note NONE ```
2 parents 475d5c3 + 301488b commit 5787a59

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

pkg/cloudprovider/providers/gce/gce.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,17 @@ func init() {
211211
})
212212
}
213213

214-
// Raw access to the underlying GCE service, probably should only be used for e2e tests
215-
func (g *GCECloud) GetComputeService() *compute.Service {
216-
return g.service
214+
// Services is the set of all versions of the compute service.
215+
type Services struct {
216+
// GA, Alpha, Beta versions of the compute API.
217+
GA *compute.Service
218+
Alpha *computealpha.Service
219+
Beta *computebeta.Service
220+
}
221+
222+
// ComputeServices returns access to the internal compute services.
223+
func (g *GCECloud) ComputeServices() *Services {
224+
return &Services{g.service, g.serviceAlpha, g.serviceBeta}
217225
}
218226

219227
// newGCECloud creates a new instance of GCECloud.

test/e2e/framework/firewall_util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func ConstructHealthCheckFirewallForLBService(clusterID string, svc *v1.Service,
100100
// GetInstanceTags gets tags from GCE instance with given name.
101101
func GetInstanceTags(cloudConfig CloudConfig, instanceName string) *compute.Tags {
102102
gceCloud := cloudConfig.Provider.(*gcecloud.GCECloud)
103-
res, err := gceCloud.GetComputeService().Instances.Get(cloudConfig.ProjectID, cloudConfig.Zone,
103+
res, err := gceCloud.ComputeServices().GA.Instances.Get(cloudConfig.ProjectID, cloudConfig.Zone,
104104
instanceName).Do()
105105
if err != nil {
106106
Failf("Failed to get instance tags for %v: %v", instanceName, err)
@@ -113,7 +113,7 @@ func SetInstanceTags(cloudConfig CloudConfig, instanceName, zone string, tags []
113113
gceCloud := cloudConfig.Provider.(*gcecloud.GCECloud)
114114
// Re-get instance everytime because we need the latest fingerprint for updating metadata
115115
resTags := GetInstanceTags(cloudConfig, instanceName)
116-
_, err := gceCloud.GetComputeService().Instances.SetTags(
116+
_, err := gceCloud.ComputeServices().GA.Instances.SetTags(
117117
cloudConfig.ProjectID, zone, instanceName,
118118
&compute.Tags{Fingerprint: resTags.Fingerprint, Items: tags}).Do()
119119
if err != nil {

test/e2e/framework/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4335,7 +4335,7 @@ func ensureGCELoadBalancerResourcesDeleted(ip, portRange string) error {
43354335
}
43364336

43374337
return wait.Poll(10*time.Second, 5*time.Minute, func() (bool, error) {
4338-
service := gceCloud.GetComputeService()
4338+
service := gceCloud.ComputeServices().GA
43394339
list, err := service.ForwardingRules.List(project, region).Do()
43404340
if err != nil {
43414341
return false, err

test/e2e/storage/volume_provisioning.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
501501
Expect(err).NotTo(HaveOccurred())
502502

503503
// Get a list of all zones in the project
504-
zones, err := gceCloud.GetComputeService().Zones.List(framework.TestContext.CloudConfig.ProjectID).Do()
504+
zones, err := gceCloud.ComputeServices().GA.Zones.List(framework.TestContext.CloudConfig.ProjectID).Do()
505505
Expect(err).NotTo(HaveOccurred())
506506
for _, z := range zones.Items {
507507
allZones.Insert(z.Name)

0 commit comments

Comments
 (0)