From a3d44cc66949a6e56b066e1db6d6a806b340a713 Mon Sep 17 00:00:00 2001 From: Victor Urvantsev Date: Wed, 14 Feb 2024 15:15:30 +0200 Subject: [PATCH 1/2] feat(jfrog): add option to customize server id for JFrog CLI --- jfrog-oauth/main.tf | 7 +++++++ jfrog-oauth/run.sh | 4 ++-- jfrog-token/main.tf | 7 +++++++ jfrog-token/run.sh | 4 ++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/jfrog-oauth/main.tf b/jfrog-oauth/main.tf index 9f05e56a..7d090d83 100644 --- a/jfrog-oauth/main.tf +++ b/jfrog-oauth/main.tf @@ -19,6 +19,12 @@ variable "jfrog_url" { } } +variable "jfrog_server_id" { + type = string + description = "The server ID of the JFrog instance for JFrog CLI confuguration" + default = "0" +} + variable "username_field" { type = string description = "The field to use for the artifactory username. i.e. Coder username or email." @@ -79,6 +85,7 @@ resource "coder_script" "jfrog" { script = templatefile("${path.module}/run.sh", { JFROG_URL : var.jfrog_url, JFROG_HOST : local.jfrog_host, + JFROG_SERVER_ID : var.jfrog_server_id, ARTIFACTORY_USERNAME : local.username, ARTIFACTORY_EMAIL : data.coder_workspace.me.owner_email, ARTIFACTORY_ACCESS_TOKEN : data.coder_external_auth.jfrog.access_token, diff --git a/jfrog-oauth/run.sh b/jfrog-oauth/run.sh index c0fa5890..2a7b0d12 100644 --- a/jfrog-oauth/run.sh +++ b/jfrog-oauth/run.sh @@ -15,9 +15,9 @@ fi # flows. export CI=true # Authenticate JFrog CLI with Artifactory. -echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite 0 +echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite "${JFROG_SERVER_ID}" # Set the configured server as the default. -jf c use 0 +jf c use "${JFROG_SERVER_ID}" # Configure npm to use the Artifactory "npm" repository. if [ -z "${REPOSITORY_NPM}" ]; then diff --git a/jfrog-token/main.tf b/jfrog-token/main.tf index 7e63649d..e13e64cb 100644 --- a/jfrog-token/main.tf +++ b/jfrog-token/main.tf @@ -23,6 +23,12 @@ variable "jfrog_url" { } } +variable "jfrog_server_id" { + type = string + description = "The server ID of the JFrog instance for JFrog CLI confuguration" + default = "0" +} + variable "artifactory_access_token" { type = string description = "The admin-level access token to use for JFrog." @@ -112,6 +118,7 @@ resource "coder_script" "jfrog" { script = templatefile("${path.module}/run.sh", { JFROG_URL : var.jfrog_url, JFROG_HOST : local.jfrog_host, + JFROG_SERVER_ID : var.jfrog_server_id, ARTIFACTORY_USERNAME : local.username, ARTIFACTORY_EMAIL : data.coder_workspace.me.owner_email, ARTIFACTORY_ACCESS_TOKEN : artifactory_scoped_token.me.access_token, diff --git a/jfrog-token/run.sh b/jfrog-token/run.sh index 629a65db..52b35139 100644 --- a/jfrog-token/run.sh +++ b/jfrog-token/run.sh @@ -15,9 +15,9 @@ fi # flows. export CI=true # Authenticate JFrog CLI with Artifactory. -echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite 0 +echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite "${JFROG_SERVER_ID}" # Set the configured server as the default. -jf c use 0 +jf c use "${JFROG_SERVER_ID}" # Configure npm to use the Artifactory "npm" repository. if [ -z "${REPOSITORY_NPM}" ]; then From 90c04369db9b31346d94f52047eea7f06e2cbb1e Mon Sep 17 00:00:00 2001 From: Victor Urvantsev Date: Fri, 16 Feb 2024 12:04:25 +0200 Subject: [PATCH 2/2] typo --- jfrog-oauth/main.tf | 2 +- jfrog-token/main.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jfrog-oauth/main.tf b/jfrog-oauth/main.tf index 7d090d83..70fd0e84 100644 --- a/jfrog-oauth/main.tf +++ b/jfrog-oauth/main.tf @@ -21,7 +21,7 @@ variable "jfrog_url" { variable "jfrog_server_id" { type = string - description = "The server ID of the JFrog instance for JFrog CLI confuguration" + description = "The server ID of the JFrog instance for JFrog CLI configuration" default = "0" } diff --git a/jfrog-token/main.tf b/jfrog-token/main.tf index e13e64cb..1caca4db 100644 --- a/jfrog-token/main.tf +++ b/jfrog-token/main.tf @@ -25,7 +25,7 @@ variable "jfrog_url" { variable "jfrog_server_id" { type = string - description = "The server ID of the JFrog instance for JFrog CLI confuguration" + description = "The server ID of the JFrog instance for JFrog CLI configuration" default = "0" }