Skip to content

Commit

Permalink
removing some dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennenMM7 committed Apr 16, 2024
1 parent 500db6c commit 5d81d19
Showing 1 changed file with 0 additions and 67 deletions.
67 changes: 0 additions & 67 deletions cloud/services/compute/instancegroupinstances/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package instancegroupinstances

import (
"context"
"fmt"
"time"

"google.golang.org/api/compute/v1"
"google.golang.org/api/option"
Expand All @@ -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)
}
Expand Down Expand Up @@ -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()
Expand All @@ -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
}

0 comments on commit 5d81d19

Please sign in to comment.