Merge pull request #86713 from liggitt/fix-gce-unit-test

Fix unit test to run in non-gce environments
This commit is contained in:
Kubernetes Prow Robot 2019-12-30 05:13:40 -08:00 committed by GitHub
commit f7e9a7c194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,7 @@ import (
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud"
compute "google.golang.org/api/compute/v1"
option "google.golang.org/api/option"
"k8s.io/client-go/tools/cache"
)
@ -62,7 +63,10 @@ func fakeClusterID(clusterID string) ClusterID {
// NewFakeGCECloud constructs a fake GCE Cloud from the cluster values.
func NewFakeGCECloud(vals TestClusterValues) *Cloud {
service, _ := compute.NewService(context.Background())
service, err := compute.NewService(context.Background(), option.WithoutAuthentication())
if err != nil {
panic(err)
}
gce := &Cloud{
region: vals.Region,
service: service,