From a89b5ceccf8dd33e089dfb2d0b0ee7f29b781d2e Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Nov 2023 10:03:07 +0300 Subject: [PATCH 1/7] fix(jfrog-token): add `check_license` attribute to skip pre-flight license check --- jfrog-token/main.tf | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jfrog-token/main.tf b/jfrog-token/main.tf index a5861480..e07d05cc 100644 --- a/jfrog-token/main.tf +++ b/jfrog-token/main.tf @@ -23,6 +23,12 @@ variable "artifactory_access_token" { description = "The admin-level access token to use for JFrog." } +variable "check_license" { + type = bool + description = "If your usage doesn't require a license, you can set `check_license` attribute to `false` to skip this check." + deafult = false +} + variable "username_field" { type = string description = "The field to use for the artifactory username. i.e. Coder username or email." @@ -58,8 +64,9 @@ locals { # Configure the Artifactory provider provider "artifactory" { - url = join("/", [var.jfrog_url, "artifactory"]) - access_token = var.artifactory_access_token + url = join("/", [var.jfrog_url, "artifactory"]) + access_token = var.artifactory_access_token + check_license = var.check_license } resource "artifactory_scoped_token" "me" { From a96fe3fd5b99ef9b1e9733827059a33dbc41dfcb Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Nov 2023 10:08:44 +0300 Subject: [PATCH 2/7] use `checj_license = true` by default --- jfrog-token/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jfrog-token/main.tf b/jfrog-token/main.tf index e07d05cc..9a001d65 100644 --- a/jfrog-token/main.tf +++ b/jfrog-token/main.tf @@ -26,7 +26,7 @@ variable "artifactory_access_token" { variable "check_license" { type = bool description = "If your usage doesn't require a license, you can set `check_license` attribute to `false` to skip this check." - deafult = false + deafult = true } variable "username_field" { From 6005ec1bd683ebf79ca3183a6e60464801fe8aaf Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Nov 2023 10:10:10 +0300 Subject: [PATCH 3/7] update description --- jfrog-token/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jfrog-token/main.tf b/jfrog-token/main.tf index 9a001d65..78c08248 100644 --- a/jfrog-token/main.tf +++ b/jfrog-token/main.tf @@ -25,8 +25,8 @@ variable "artifactory_access_token" { variable "check_license" { type = bool - description = "If your usage doesn't require a license, you can set `check_license` attribute to `false` to skip this check." - deafult = true + description = "Toggle for pre-flight checking of Artifactory license. Default to `true`." + default = true } variable "username_field" { From 33cbee952184f75f4c7fce53e5cc7d46e239987c Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Nov 2023 10:38:00 +0300 Subject: [PATCH 4/7] add `refreshable` and `expires_in` attributess --- jfrog-token/main.tf | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/jfrog-token/main.tf b/jfrog-token/main.tf index 78c08248..2def46ce 100644 --- a/jfrog-token/main.tf +++ b/jfrog-token/main.tf @@ -29,6 +29,18 @@ variable "check_license" { default = true } +variable "refreshable" { + type = bool + description = "Is this token refreshable? Default is `false`." + default = false +} + +variable "expires_in" { + type = bool + description = "The amount of time, in seconds, it would take for the token to expire." + default = null +} + variable "username_field" { type = string description = "The field to use for the artifactory username. i.e. Coder username or email." @@ -74,7 +86,8 @@ resource "artifactory_scoped_token" "me" { # which fails validation. username = length(local.username) > 0 ? local.username : "dummy" scopes = ["applied-permissions/user"] - refreshable = true + refreshable = var.refreshable + expires_in = var.expires_in } data "coder_workspace" "me" {} From baf1936b5663db67c81cc02e1f06ac4dd454b906 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Nov 2023 10:39:15 +0300 Subject: [PATCH 5/7] fix: make `expires_in` type number --- jfrog-token/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jfrog-token/main.tf b/jfrog-token/main.tf index 2def46ce..fd7b0428 100644 --- a/jfrog-token/main.tf +++ b/jfrog-token/main.tf @@ -36,7 +36,7 @@ variable "refreshable" { } variable "expires_in" { - type = bool + type = number description = "The amount of time, in seconds, it would take for the token to expire." default = null } From 534ab32d5bac6b7e55e3b9d4f26a7e071eedf199 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Nov 2023 11:06:04 +0300 Subject: [PATCH 6/7] update `username_field` default to `username` --- jfrog-token/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jfrog-token/main.tf b/jfrog-token/main.tf index fd7b0428..efee07fe 100644 --- a/jfrog-token/main.tf +++ b/jfrog-token/main.tf @@ -43,8 +43,8 @@ variable "expires_in" { variable "username_field" { type = string - description = "The field to use for the artifactory username. i.e. Coder username or email." - default = "email" + description = "The field to use for the artifactory username. Default `username`." + default = "username" validation { condition = can(regex("^(email|username)$", var.username_field)) error_message = "username_field must be either 'email' or 'username'" From 308249871da08339efec4ab58700b90def8b0918 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Nov 2023 11:09:24 +0300 Subject: [PATCH 7/7] Update README.md --- jfrog-token/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jfrog-token/README.md b/jfrog-token/README.md index 291111f0..42525fc2 100644 --- a/jfrog-token/README.md +++ b/jfrog-token/README.md @@ -16,8 +16,8 @@ Install the JF CLI and authenticate package managers with Artifactory using Arti module "jfrog" { source = "https://registry.coder.com/modules/jfrog-token" agent_id = coder_agent.example.id - jfrog_url = "https://YYYY.jfrog.io" - artifactory_access_token = var.artifactory_access_token # An admin access token + jfrog_url = "https://XXXX.jfrog.io" + artifactory_access_token = var.artifactory_access_token package_managers = { "npm": "npm", "go": "go", @@ -26,7 +26,7 @@ module "jfrog" { } ``` -Get a JFrog access token from your Artifactory instance. The token must have admin permissions. It is recommended to store the token in a secret terraform variable. +Get a JFrog access token from your Artifactory instance. The token must be an [admin token](https://registry.terraform.io/providers/jfrog/artifactory/latest/docs#access-token). It is recommended to store the token in a secret terraform variable. ```hcl variable "artifactory_access_token" {