Skip to content

Commit

Permalink
Added the comment for the query parameter and added one more example …
Browse files Browse the repository at this point in the history
…query for getting the public key data.
  • Loading branch information
ParthaI committed May 17, 2023
1 parent 312e459 commit b7e08ac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 14 additions & 1 deletion docs/tables/gcp_service_account_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ where
key_type = 'USER_MANAGED';
```


### Validity time for the service account keys

```sql
Expand All @@ -29,3 +28,17 @@ select
from
gcp_service_account_key;
```

### Get public key data for a service account key

```sql
select
name,
key_type,
key_origin
public_key_data
from
gcp_service_account_key
where
service_account_name = 'deleteme-testing-pubkeydata@parker-aaa.iam.gserviceaccount.com';
```
6 changes: 5 additions & 1 deletion gcp/table_gcp_service_account_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ func getGcpServiceAccountKey(ctx context.Context, d *plugin.QueryData, h *plugin

keyName := "projects/" + project + "/serviceAccounts/" + serviceAccountName + "/keys/" + name

queryParameter := googleapi.QueryParameter("publicKeyType", "TYPE_RAW_PUBLIC_KEY", "TYPE_X509_PEM_FILE")
// We should pass the supported public key output formats as an query parameter to get the public key data for a service account key as mentioned in the doc https://cloud.google.com/iam/docs/reference/rest/v1/projects.serviceAccounts.keys/get#ServiceAccountPublicKeyType,
// we can pass three value for the query parameter publicKeyType that are TYPE_RAW_PUBLIC_KEY or TYPE_X509_PEM_FILE or TYPE_NONE.
// TYPE_NONE has excluded here from the query parameter value because if we pass that then it do not return the public key.
// We are getting the public key data in raw format here.
queryParameter := googleapi.QueryParameter("publicKeyType", "TYPE_RAW_PUBLIC_KEY")

op, err := service.Projects.ServiceAccounts.Keys.Get(keyName).Do(queryParameter)
if err != nil {
Expand Down

0 comments on commit b7e08ac

Please sign in to comment.