Skip to content

Commit

Permalink
Merge pull request #4 from CaioIcy/main
Browse files Browse the repository at this point in the history
add lifetime property support
  • Loading branch information
HugeIRL committed Aug 3, 2023
2 parents 2a94346 + 3cd1a4d commit 98f6b69
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -68,6 +68,10 @@ steps:

- The service account for which you want to acquire an access token.

### `lifetime` (number)

- The time (in seconds) the OIDC token will be valid for before expiry. Must be a non-negative integer. If the flag is omitted or set to 0, the API will choose a default finite lifetime. (default: 0)

## Developing

To run testing, shellchecks and plugin linting use use `bk run` with the [Buildkite CLI](https://github.com/buildkite/cli).
Expand Down
2 changes: 1 addition & 1 deletion hooks/pre-command
Expand Up @@ -17,7 +17,7 @@ TMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'buildkiteXXXX')

echo "~~~ :buildkite: Requesting OIDC token from Buildkite"

buildkite-agent oidc request-token --audience "$BUILDKITE_PLUGIN_GCP_WORKLOAD_IDENTITY_FEDERATION_AUDIENCE" > "$TMPDIR"/token.json
buildkite-agent oidc request-token --audience "$BUILDKITE_PLUGIN_GCP_WORKLOAD_IDENTITY_FEDERATION_AUDIENCE" --lifetime "${BUILDKITE_PLUGIN_GCP_WORKLOAD_IDENTITY_FEDERATION_LIFETIME:-0}" > "$TMPDIR"/token.json

echo "~~~ :gcloud: Configuring Google Cloud credentials"

Expand Down
2 changes: 2 additions & 0 deletions plugin.yml
Expand Up @@ -11,6 +11,8 @@ configuration:
type: string
service-account:
type: string
lifetime:
type: number
required:
- audience
- service-account
Expand Down
2 changes: 1 addition & 1 deletion tests/pre-command.bats
Expand Up @@ -57,7 +57,7 @@ setup() {
export BUILDKITE_PLUGIN_GCP_WORKLOAD_IDENTITY_FEDERATION_SERVICE_ACCOUNT="buildkite-example-pipeline@oidc-project.iam.gserviceaccount.com"

stub mktemp "-d : echo $BATS_TEST_TMPDIR"
stub buildkite-agent "oidc request-token --audience //iam.googleapis.com/projects/123456789/locations/global/workloadIdentityPools/buildkite-example-pipeline/providers/buildkite : echo dummy-jwt"
stub buildkite-agent "oidc request-token --audience //iam.googleapis.com/projects/123456789/locations/global/workloadIdentityPools/buildkite-example-pipeline/providers/buildkite --lifetime 0 : echo dummy-jwt"

run "$PWD/hooks/pre-command"

Expand Down

0 comments on commit 98f6b69

Please sign in to comment.