mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Merge pull request #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 ```
This commit is contained in:
commit
5787a59ced
@ -211,9 +211,17 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Raw access to the underlying GCE service, probably should only be used for e2e tests
|
// Services is the set of all versions of the compute service.
|
||||||
func (g *GCECloud) GetComputeService() *compute.Service {
|
type Services struct {
|
||||||
return g.service
|
// GA, Alpha, Beta versions of the compute API.
|
||||||
|
GA *compute.Service
|
||||||
|
Alpha *computealpha.Service
|
||||||
|
Beta *computebeta.Service
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputeServices returns access to the internal compute services.
|
||||||
|
func (g *GCECloud) ComputeServices() *Services {
|
||||||
|
return &Services{g.service, g.serviceAlpha, g.serviceBeta}
|
||||||
}
|
}
|
||||||
|
|
||||||
// newGCECloud creates a new instance of GCECloud.
|
// newGCECloud creates a new instance of GCECloud.
|
||||||
|
@ -100,7 +100,7 @@ func ConstructHealthCheckFirewallForLBService(clusterID string, svc *v1.Service,
|
|||||||
// GetInstanceTags gets tags from GCE instance with given name.
|
// GetInstanceTags gets tags from GCE instance with given name.
|
||||||
func GetInstanceTags(cloudConfig CloudConfig, instanceName string) *compute.Tags {
|
func GetInstanceTags(cloudConfig CloudConfig, instanceName string) *compute.Tags {
|
||||||
gceCloud := cloudConfig.Provider.(*gcecloud.GCECloud)
|
gceCloud := cloudConfig.Provider.(*gcecloud.GCECloud)
|
||||||
res, err := gceCloud.GetComputeService().Instances.Get(cloudConfig.ProjectID, cloudConfig.Zone,
|
res, err := gceCloud.ComputeServices().GA.Instances.Get(cloudConfig.ProjectID, cloudConfig.Zone,
|
||||||
instanceName).Do()
|
instanceName).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Failf("Failed to get instance tags for %v: %v", instanceName, err)
|
Failf("Failed to get instance tags for %v: %v", instanceName, err)
|
||||||
@ -113,7 +113,7 @@ func SetInstanceTags(cloudConfig CloudConfig, instanceName, zone string, tags []
|
|||||||
gceCloud := cloudConfig.Provider.(*gcecloud.GCECloud)
|
gceCloud := cloudConfig.Provider.(*gcecloud.GCECloud)
|
||||||
// Re-get instance everytime because we need the latest fingerprint for updating metadata
|
// Re-get instance everytime because we need the latest fingerprint for updating metadata
|
||||||
resTags := GetInstanceTags(cloudConfig, instanceName)
|
resTags := GetInstanceTags(cloudConfig, instanceName)
|
||||||
_, err := gceCloud.GetComputeService().Instances.SetTags(
|
_, err := gceCloud.ComputeServices().GA.Instances.SetTags(
|
||||||
cloudConfig.ProjectID, zone, instanceName,
|
cloudConfig.ProjectID, zone, instanceName,
|
||||||
&compute.Tags{Fingerprint: resTags.Fingerprint, Items: tags}).Do()
|
&compute.Tags{Fingerprint: resTags.Fingerprint, Items: tags}).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -4335,7 +4335,7 @@ func ensureGCELoadBalancerResourcesDeleted(ip, portRange string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return wait.Poll(10*time.Second, 5*time.Minute, func() (bool, error) {
|
return wait.Poll(10*time.Second, 5*time.Minute, func() (bool, error) {
|
||||||
service := gceCloud.GetComputeService()
|
service := gceCloud.ComputeServices().GA
|
||||||
list, err := service.ForwardingRules.List(project, region).Do()
|
list, err := service.ForwardingRules.List(project, region).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@ -501,7 +501,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
// Get a list of all zones in the project
|
// Get a list of all zones in the project
|
||||||
zones, err := gceCloud.GetComputeService().Zones.List(framework.TestContext.CloudConfig.ProjectID).Do()
|
zones, err := gceCloud.ComputeServices().GA.Zones.List(framework.TestContext.CloudConfig.ProjectID).Do()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
for _, z := range zones.Items {
|
for _, z := range zones.Items {
|
||||||
allZones.Insert(z.Name)
|
allZones.Insert(z.Name)
|
||||||
|
Loading…
Reference in New Issue
Block a user