Skip to content

Commit 825388d

Browse files
authored
chore: work without gcp creds (#1397)
1 parent ac4df94 commit 825388d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pkg/kcp/provider/gcp/client/gcpClients.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ type VpcPeeringClients struct {
3737
}
3838

3939
func NewGcpClients(ctx context.Context, saJsonKeyPath string, vpcPeeringSaJsonKeyPath string, logger logr.Logger) (*GcpClients, error) {
40+
if saJsonKeyPath == "" || saJsonKeyPath == "none" || vpcPeeringSaJsonKeyPath == "" || vpcPeeringSaJsonKeyPath == "none" {
41+
logger.Info("Creating GCP clients stub since no GCP credentials provided")
42+
return &GcpClients{}, nil
43+
}
44+
4045
logger.
4146
WithValues("saJsonKeyPath", saJsonKeyPath).
4247
WithValues("vpcPeeringSaJsonKeyPath", vpcPeeringSaJsonKeyPath).
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package client
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func Test_GcpClientsCanCloseOnNilClients(t *testing.T) {
10+
gcpClients := &GcpClients{}
11+
err := gcpClients.Close()
12+
assert.NoError(t, err)
13+
}

0 commit comments

Comments
 (0)