github.com/openshift/installer@v1.4.17/pkg/infrastructure/gcp/clusterapi/service.go (about) 1 package clusterapi 2 3 import ( 4 "context" 5 "fmt" 6 7 "google.golang.org/api/compute/v1" 8 "google.golang.org/api/option" 9 10 "github.com/openshift/installer/pkg/asset/installconfig/gcp" 11 ) 12 13 // NewComputeService wraps the creation of a gcp compute service creation. 14 func NewComputeService() (*compute.Service, error) { 15 ctx := context.Background() 16 17 ssn, err := gcp.GetSession(ctx) 18 if err != nil { 19 return nil, fmt.Errorf("failed to get session: %w", err) 20 } 21 22 service, err := compute.NewService(ctx, option.WithCredentials(ssn.Credentials)) 23 if err != nil { 24 return nil, fmt.Errorf("failed to create compute service: %w", err) 25 } 26 27 return service, nil 28 }