Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

feat(jfrog-token): update module to accept username #408

Merged
merged 3 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions jfrog-token/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Install the JF CLI and authenticate package managers with Artifactory using Arti
```tf
module "jfrog" {
source = "registry.coder.com/modules/jfrog-token/coder"
version = "1.0.19"
version = "1.0.30"
agent_id = coder_agent.example.id
jfrog_url = "https://XXXX.jfrog.io"
artifactory_access_token = var.artifactory_access_token
Expand All @@ -42,7 +42,7 @@ For detailed instructions, please see this [guide](https://coder.com/docs/v2/lat
```tf
module "jfrog" {
source = "registry.coder.com/modules/jfrog-token/coder"
version = "1.0.19"
version = "1.0.30"
agent_id = coder_agent.example.id
jfrog_url = "https://YYYY.jfrog.io"
artifactory_access_token = var.artifactory_access_token # An admin access token
Expand Down Expand Up @@ -75,7 +75,7 @@ The [JFrog extension](https://open-vsx.org/extension/JFrog/jfrog-vscode-extensio
```tf
module "jfrog" {
source = "registry.coder.com/modules/jfrog-token/coder"
version = "1.0.19"
version = "1.0.30"
agent_id = coder_agent.example.id
jfrog_url = "https://XXXX.jfrog.io"
artifactory_access_token = var.artifactory_access_token
Expand All @@ -95,7 +95,7 @@ data "coder_workspace" "me" {}

module "jfrog" {
source = "registry.coder.com/modules/jfrog-token/coder"
version = "1.0.19"
version = "1.0.30"
agent_id = coder_agent.example.id
jfrog_url = "https://XXXX.jfrog.io"
artifactory_access_token = var.artifactory_access_token
Expand Down
1 change: 1 addition & 0 deletions jfrog-token/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe("jfrog-token", async () => {
refreshable?: boolean;
expires_in?: number;
username_field?: string;
username?: string;
jfrog_server_id?: string;
configure_code_server?: boolean;
};
Expand Down
10 changes: 8 additions & 2 deletions jfrog-token/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ variable "username_field" {
}
}

variable "username" {
type = string
description = "Username to use for Artifactory. Overrides the field specified in `username_field`"
default = null
}

variable "agent_id" {
type = string
description = "The ID of a Coder agent."
Expand Down Expand Up @@ -99,8 +105,8 @@ variable "package_managers" {
}

locals {
# The username field to use for artifactory
username = var.username_field == "email" ? data.coder_workspace_owner.me.email : data.coder_workspace_owner.me.name
# The username to use for artifactory
username = coalesce(var.username, var.username_field == "email" ? data.coder_workspace_owner.me.email : data.coder_workspace_owner.me.name)
jfrog_host = split("://", var.jfrog_url)[1]
common_values = {
JFROG_URL = var.jfrog_url
Expand Down