Skip to content

Commit

Permalink
remove nonmandatory projectId
Browse files Browse the repository at this point in the history
  • Loading branch information
veceraj committed Feb 26, 2025
1 parent 8c78ebb commit de96fb5
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pbm/storage/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ type Config struct {
}

type Credentials struct {
ProjectID string `bson:"projectId" json:"projectId,omitempty" yaml:"projectId,omitempty"`
PrivateKey string `bson:"privateKey" json:"privateKey,omitempty" yaml:"privateKey,omitempty"`
ClientEmail string `bson:"clientEmail" json:"clientEmail,omitempty" yaml:"clientEmail,omitempty"`
PrivateKey string `bson:"privateKey" json:"privateKey,omitempty" yaml:"privateKey,omitempty"`
}

type Retryer struct {
Expand All @@ -54,7 +53,6 @@ type Retryer struct {

type ServiceAccountCredentials struct {
Type string `json:"type"`
ProjectID string `json:"project_id"`
PrivateKey string `json:"private_key"`
ClientEmail string `json:"client_email"`
AuthURI string `json:"auth_uri"`
Expand Down Expand Up @@ -265,15 +263,12 @@ func (g *GCS) Copy(src, dst string) error {
func (g *GCS) gcsClient() (*gcs.Client, error) {
ctx := context.Background()

if g.opts.Credentials.ProjectID == "" ||
g.opts.Credentials.PrivateKey == "" ||
g.opts.Credentials.ClientEmail == "" {
return nil, errors.New("projectID, privateKey and clientEmail are required for GCS credentials")
if g.opts.Credentials.PrivateKey == "" || g.opts.Credentials.ClientEmail == "" {
return nil, errors.New("clientEmail and privateKey are required for GCS credentials")
}

creds, err := json.Marshal(ServiceAccountCredentials{
Type: "service_account",
ProjectID: g.opts.Credentials.ProjectID,
PrivateKey: g.opts.Credentials.PrivateKey,
ClientEmail: g.opts.Credentials.ClientEmail,
AuthURI: "https://accounts.google.com/o/oauth2/auth",
Expand Down

0 comments on commit de96fb5

Please sign in to comment.