Files
speedrun/cloud/google.go

30 lines
580 B
Go

package gcp
import (
"context"
"fmt"
"google.golang.org/api/compute/v1"
)
// ComputeClient wraps the original *compute.Service
type ComputeClient struct {
*compute.Service
Project string
}
// NewComputeClient will initialize a GCP compute API client
func NewComputeClient(project string) (*ComputeClient, error) {
var err error
ctx := context.Background()
s, err := compute.NewService(ctx)
if err != nil {
err = fmt.Errorf("couldn't initialize GCP client: %v", err)
return nil, err
}
computeService := &ComputeClient{s, project}
return computeService, nil
}