add auth id var
This commit is contained in:
@@ -14,10 +14,15 @@ Templates that utilize Github External Auth can automatically ensure that the Co
|
||||
# Example
|
||||
|
||||
```tf
|
||||
data "coder_external_auth" "github" {
|
||||
id = "myauthid"
|
||||
}
|
||||
|
||||
module "github-upload-public-key" {
|
||||
source = "registry.coder.com/modules/github-upload-public-key/coder"
|
||||
version = "1.0.13"
|
||||
agent_id = coder_agent.example.id
|
||||
external_auth_id = data.coder_external_auth.github.id
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -14,11 +14,18 @@ variable "agent_id" {
|
||||
description = "The ID of a Coder agent."
|
||||
}
|
||||
|
||||
variable "external_auth_id" {
|
||||
type = string
|
||||
description = "The ID of the GitHub external auth."
|
||||
default = "github"
|
||||
}
|
||||
|
||||
resource "coder_script" "github_upload_public_key" {
|
||||
agent_id = var.agent_id
|
||||
script = templatefile("${path.module}/run.sh", {
|
||||
CODER_OWNER_SESSION_TOKEN : data.coder_workspace.me.owner_session_token,
|
||||
CODER_ACCESS_URL : data.coder_workspace.me.access_url,
|
||||
GITHUB_EXTERNAL_AUTH_ID : var.external_auth_id,
|
||||
})
|
||||
display_name = "Github Upload Public Key"
|
||||
icon = "/icon/github.svg"
|
||||
|
||||
@@ -4,6 +4,7 @@ set -e
|
||||
|
||||
CODER_ACCESS_URL="${CODER_ACCESS_URL}"
|
||||
CODER_OWNER_SESSION_TOKEN="${CODER_OWNER_SESSION_TOKEN}"
|
||||
GITHUB_EXTERNAL_AUTH_ID="${GITHUB_EXTERNAL_AUTH_ID}"
|
||||
|
||||
if [ -z "$CODER_ACCESS_URL" ]; then
|
||||
echo "No coder access url specified!"
|
||||
@@ -15,8 +16,13 @@ if [ -z "$CODER_OWNER_SESSION_TOKEN" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$GITHUB_EXTERNAL_AUTH_ID" ]; then
|
||||
echo "No GitHub external auth id specified!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Fetching GitHub token..."
|
||||
GITHUB_TOKEN=$(coder external-auth access-token github)
|
||||
GITHUB_TOKEN=$(coder external-auth access-token $GITHUB_EXTERNAL_AUTH_ID)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to fetch GitHub token!"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user