Skip to content

Commit

Permalink
🐛 fix fetching of service accounts on gke cluster nodepool config
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeffrey committed Jan 31, 2025
1 parent a52394f commit ff4e2e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion providers/gcp/resources/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ func (g *mqlGcpProjectGkeServiceClusterNodepoolConfig) serviceAccount() (*mqlGcp
}
email := g.ServiceAccountEmail.Data

res, err := CreateResource(g.MqlRuntime, "gcp.project.iamService.serviceAccount", map[string]*llx.RawData{
res, err := NewResource(g.MqlRuntime, "gcp.project.iamService.serviceAccount", map[string]*llx.RawData{
"projectId": llx.StringData(projectId),
"email": llx.StringData(email),
})
Expand Down
18 changes: 16 additions & 2 deletions providers/gcp/resources/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package resources

import (
"context"
"errors"
"fmt"

"go.mondoo.com/cnquery/v11/llx"
Expand Down Expand Up @@ -74,7 +73,15 @@ func initGcpProjectIamServiceServiceAccount(runtime *plugin.Runtime, args map[st
return args, sa, nil
}
}
return nil, nil, errors.New("service account not found")

args["name"] = llx.NilData
args["uniqueId"] = llx.NilData
args["displayName"] = llx.NilData
args["description"] = llx.NilData
args["oauth2ClientId"] = llx.NilData
args["disabled"] = llx.NilData

return args, nil, nil
}

func (g *mqlGcpProjectIamService) serviceAccounts() ([]interface{}, error) {
Expand Down Expand Up @@ -137,6 +144,13 @@ func (g *mqlGcpProjectIamServiceServiceAccount) keys() ([]interface{}, error) {
}
email := g.Email.Data

// if the unique id is null, we were not able to find a record of this service account
// so skip the keys discovery
if g.UniqueId.IsNull() {
g.Keys.State = plugin.StateIsNull | plugin.StateIsSet
return nil, nil
}

conn := g.MqlRuntime.Connection.(*connection.GcpConnection)

creds, err := conn.Credentials(admin.DefaultAuthScopes()...)
Expand Down

0 comments on commit ff4e2e6

Please sign in to comment.