Skip to content

Commit

Permalink
feat: rename vendor-url parameter
Browse files Browse the repository at this point in the history
Vendor was an early term for the project; chinmina-url is somewhat more clear.
  • Loading branch information
jamestelfer committed Dec 1, 2024
1 parent bddc024 commit 2409f2a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ steps:
- command: ls
plugins:
- chinmina/chinmina-git-credentials#v1.1.0:
vendor-url: "https://chinmina-bridge-url"
chinmina-url: "https://chinmina-bridge-url"
audience: "chinmina:your-github-organization"
```
## Configuration
### `vendor-url` (Required, string)
### `chinmina-url` (Required, string)

The URL of the [`chinmina-bridge`][chinmina-bridge] helper agent that vends a
token for a pipeline. This is a separate HTTP service that must accessible to
Expand Down
12 changes: 8 additions & 4 deletions hooks/environment
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ get_parameter() {
echo "${value}"
}

vendor_url="$(get_parameter "VENDOR_URL")"
chinmina_url="$(get_parameter "CHINMINA_URL")"
vendor_url_compat="$(get_parameter "VENDOR_URL")"
audience="$(get_parameter "AUDIENCE")"

if [ -z "$vendor_url" ]; then
echo "~~~ :error: Missing required parameter vendor-url"
# allow the old name of the parameter to be used
chinmina_url="${chinmina_url:-$vendor_url_compat}"

if [ -z "$chinmina_url" ]; then
echo "~~~ :error: Missing required parameter chinmina-url"
exit 1
fi

Expand Down Expand Up @@ -52,4 +56,4 @@ git_config_add() {
}

git_config_add "credential.https://github.com.usehttppath" "true"
git_config_add "credential.https://github.com.helper" "${plugin_root}/credential-helper/buildkite-connector-credential-helper ${vendor_url} ${audience}"
git_config_add "credential.https://github.com.helper" "${plugin_root}/credential-helper/buildkite-connector-credential-helper ${chinmina_url} ${audience}"
4 changes: 2 additions & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ author: https://github.com/chinmina
requirements: []
configuration:
properties:
vendor-url:
chinmina-url:
type: string
description: The URL of the helper agent that vends a token for a pipeline.
description: The URL of the Chinmina Bridge agent that creates a token for a pipeline.
audience:
type: string
description: |
Expand Down
10 changes: 5 additions & 5 deletions tests/environment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ setup() {
}

teardown() {
unset BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_VENDOR_URL
unset BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_CHINMINA_URL
unset BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_AUDIENCE

clear_git_config
Expand All @@ -40,11 +40,11 @@ run_environment() {
run "$PWD/hooks/environment"

assert_failure
assert_line --partial "Missing required parameter vendor-url"
assert_line --partial "Missing required parameter chinmina-url"
}

@test "Adds config for default audience" {
export BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_VENDOR_URL=http://test-location
export BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_CHINMINA_URL=http://test-location

run_environment "${PWD}/hooks/environment"

Expand All @@ -57,7 +57,7 @@ run_environment() {
}

@test "Adds config for non-default audience" {
export BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_VENDOR_URL=http://test-location
export BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_CHINMINA_URL=http://test-location
export BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_AUDIENCE=test-audience

run_environment "${PWD}/hooks/environment"
Expand Down Expand Up @@ -85,7 +85,7 @@ run_environment() {
}

@test "Adds to existing configuration if present" {
export BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_VENDOR_URL=http://test-location
export BUILDKITE_PLUGIN_CHINMINA_GIT_CREDENTIALS_CHINMINA_URL=http://test-location

# Setup existing config items. These must exist or Git will fail.
export GIT_CONFIG_COUNT="3"
Expand Down

0 comments on commit 2409f2a

Please sign in to comment.