Initial commit
This commit is contained in:
29
cloud/google.go
Normal file
29
cloud/google.go
Normal file
@@ -0,0 +1,29 @@
|
||||
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 (Compute): %v", err)
|
||||
return nil, err
|
||||
}
|
||||
computeService := &ComputeClient{s, project}
|
||||
|
||||
return computeService, nil
|
||||
}
|
||||
Reference in New Issue
Block a user