Skip to content

Commit

Permalink
Add support for regional non-autopilot clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphasite committed Jun 7, 2023
1 parent d537522 commit 77a9df3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions gcp/container/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func (c client) ListClusters() (*gcpcontainer.ListClustersResponse, error) {
return c.containers.List(parent).Do()
}

func (c client) DeleteCluster(zone string, cluster string) error {
name := fmt.Sprintf("projects/%v/locations/%v/clusters/%v", c.project, zone, cluster)
func (c client) DeleteCluster(location string, cluster string) error {
name := fmt.Sprintf("projects/%v/locations/%v/clusters/%v", c.project, location, cluster)
return c.wait(c.containers.Delete(name))
}

Expand Down
16 changes: 8 additions & 8 deletions gcp/container/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ package container
import "fmt"

type Cluster struct {
name string
zone string
client clustersClient
name string
location string
client clustersClient
}

func NewCluster(client clustersClient, zone string, name string) Cluster {
func NewCluster(client clustersClient, location string, name string) Cluster {
return Cluster{
name: name,
zone: zone,
client: client,
name: name,
location: location,
client: client,
}
}

func (c Cluster) Delete() error {
err := c.client.DeleteCluster(c.zone, c.name)
err := c.client.DeleteCluster(c.location, c.name)
if err != nil {
return fmt.Errorf("Delete: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions gcp/container/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Clusters struct {
//go:generate faux --interface clustersClient --output fakes/clusters_client.go
type clustersClient interface {
ListClusters() (*gcpcontainer.ListClustersResponse, error)
DeleteCluster(zone, cluster string) error
DeleteCluster(location, cluster string) error
}

func NewClusters(client clustersClient, zones map[string]string, logger logger) Clusters {
Expand All @@ -38,7 +38,7 @@ func (c Clusters) List(filter string) ([]common.Deletable, error) {

deletables := []common.Deletable{}
for _, cluster := range clusters {
resource := NewCluster(c.client, cluster.Zone, cluster.Name)
resource := NewCluster(c.client, cluster.Location, cluster.Name)

if !strings.Contains(resource.Name(), filter) {
continue
Expand Down
6 changes: 3 additions & 3 deletions gcp/container/operation_waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (

type operationWaiter struct {
op *gcpcontainer.Operation
service *gcpcontainer.ProjectsZonesService
service *gcpcontainer.ProjectsLocationsService
project string
logger logger
}

func NewOperationWaiter(op *gcpcontainer.Operation, service *gcpcontainer.Service, project string, logger logger) operationWaiter {
return operationWaiter{
op: op,
service: service.Projects.Zones,
service: service.Projects.Locations,
project: project,
logger: logger,
}
Expand All @@ -42,7 +42,7 @@ func (w *operationWaiter) Wait() error {

func (c *operationWaiter) refreshFunc() common.StateRefreshFunc {
return func() (interface{}, string, error) {
op, err := c.service.Operations.Get(c.project, c.op.Zone, c.op.Name).Do()
op, err := c.service.Operations.Get(c.op.Name).Do()

if err != nil {
return nil, "", fmt.Errorf("Refreshing operation request: %s", err)
Expand Down

0 comments on commit 77a9df3

Please sign in to comment.