From 5d81d19bdab3c18f9dd932fc5c12037d1bc48174 Mon Sep 17 00:00:00 2001 From: bmurray Date: Tue, 16 Apr 2024 15:13:00 -0700 Subject: [PATCH] removing some dead code --- .../compute/instancegroupinstances/client.go | 67 ------------------- 1 file changed, 67 deletions(-) diff --git a/cloud/services/compute/instancegroupinstances/client.go b/cloud/services/compute/instancegroupinstances/client.go index 783c62f56..5dec0d150 100644 --- a/cloud/services/compute/instancegroupinstances/client.go +++ b/cloud/services/compute/instancegroupinstances/client.go @@ -19,8 +19,6 @@ package instancegroupinstances import ( "context" - "fmt" - "time" "google.golang.org/api/compute/v1" "google.golang.org/api/option" @@ -31,14 +29,9 @@ type Client interface { // Instance methods. GetInstance(ctx context.Context, project, zone, name string) (*compute.Instance, error) - DeleteInstance(ctx context.Context, project, zone, name string) (*compute.Operation, error) // InstanceGroupInstances methods. - GetInstanceGroup(ctx context.Context, project, zone, name string) (*compute.InstanceGroupManager, error) ListInstanceGroupInstances(ctx context.Context, project, zone, name string) (*compute.InstanceGroupManagersListManagedInstancesResponse, error) DeleteInstanceGroupInstances(ctx context.Context, project, zone, name string, instances *compute.InstanceGroupManagersDeleteInstancesRequest) (*compute.Operation, error) - WaitUntilOperationCompleted(project, operation string) error - WaitUntilComputeOperationCompleted(project, zone, operation string) error - CheckIfComputeOperationCompleted(ctx context.Context, project, zone, operation string) error // Disk methods. GetDisk(ctx context.Context, project, zone, name string) (*compute.Disk, error) } @@ -66,16 +59,6 @@ func (c *GCPClient) GetInstance(_ context.Context, project, zone, name string) ( return c.service.Instances.Get(project, zone, name).Do() } -// DeleteInstance deletes a specific instance in a project and zone. -func (c *GCPClient) DeleteInstance(_ context.Context, project, zone, name string) (*compute.Operation, error) { - return c.service.Instances.Delete(project, zone, name).Do() -} - -// GetInstanceGroup returns a specific instance group in a project and zone. -func (c *GCPClient) GetInstanceGroup(_ context.Context, project, zone, name string) (*compute.InstanceGroupManager, error) { - return c.service.InstanceGroupManagers.Get(project, zone, name).Do() -} - // GetDisk returns a specific disk in a project and zone. func (c *GCPClient) GetDisk(_ context.Context, project, zone, name string) (*compute.Disk, error) { return c.service.Disks.Get(project, zone, name).Do() @@ -90,53 +73,3 @@ func (c *GCPClient) ListInstanceGroupInstances(_ context.Context, project, zone, func (c *GCPClient) DeleteInstanceGroupInstances(_ context.Context, project, zone, name string, instances *compute.InstanceGroupManagersDeleteInstancesRequest) (*compute.Operation, error) { return c.service.InstanceGroupManagers.DeleteInstances(project, zone, name, instances).Do() } - -// WaitUntilOperationCompleted waits for an operation to complete. -func (c *GCPClient) WaitUntilOperationCompleted(projectID, operationName string) error { - for { - operation, err := c.service.GlobalOperations.Get(projectID, operationName).Do() - if err != nil { - return err - } - if operation.Status == "DONE" { - if operation.Error != nil { - return fmt.Errorf("operation failed: %v", operation.Error.Errors) - } - return nil - } - // Wait 1s before checking again to avoid spamming the API. - time.Sleep(1 * time.Second) - } -} - -// WaitUntilComputeOperationCompleted waits for a compute operation to complete. -func (c *GCPClient) WaitUntilComputeOperationCompleted(project, zone, operationName string) error { - for { - operation, err := c.service.ZoneOperations.Get(project, zone, operationName).Do() - if err != nil { - return err - } - if operation.Status == "DONE" { - if operation.Error != nil { - return fmt.Errorf("operation failed: %v", operation.Error.Errors) - } - return nil - } - // Wait 1s before checking again to avoid spamming the API. - time.Sleep(1 * time.Second) - } -} - -func (c *GCPClient) CheckIfComputeOperationCompleted(ctx context.Context, project, zone, operationName string) error { - operation, err := c.service.ZoneOperations.Get(project, zone, operationName).Do() - if err != nil { - return err - } - if operation.Status == "DONE" { - if operation.Error != nil { - return fmt.Errorf("operation failed: %v", operation.Error.Errors) - } - return nil - } - return nil -}