Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ebd656

Browse files
authored
refactor: refactor JFrog docs and template (#11336)
1 parent5a558b6 commit0ebd656

File tree

3 files changed

+51
-44
lines changed

3 files changed

+51
-44
lines changed

‎docs/platforms/jfrog.md‎

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,35 @@ terraform {
4141
required_providers {
4242
coder = {
4343
source = "coder/coder"
44-
version = "~> 0.11.1"
4544
}
4645
docker = {
4746
source = "kreuzwerker/docker"
48-
version = "~> 3.0.1"
4947
}
5048
artifactory = {
5149
source = "registry.terraform.io/jfrog/artifactory"
52-
version = "~> 8.4.0"
5350
}
5451
}
5552
}
5653
57-
variable "jfrog_host" {
54+
variable "jfrog_url" {
5855
type = string
59-
description = "JFrog instance hostname. e.g. YYY.jfrog.io"
56+
description = "JFrog instance URL. e.g. https://jfrog.example.com"
57+
# validate the URL to ensure it starts with https:// or http://
58+
validation {
59+
condition = can(regex("^https?://", var.jfrog_url))
60+
error_message = "JFrog URL must start with https:// or http://"
61+
}
6062
}
6163
62-
variable "artifactory_access_token" {
64+
variable "artifactory_admin_access_token" {
6365
type = string
64-
description = "The admin-level access token to use for JFrog."
66+
description = "The admin-level access token to use for JFrog with scope applied-permissions/admin"
6567
}
6668
6769
# Configure the Artifactory provider
6870
provider "artifactory" {
69-
url = "https://${var.jfrog_host}/artifactory"
70-
access_token = "${var.artifactory_access_token}"
71+
url = "${var.jfrog_url}/artifactory"
72+
access_token = "${var.artifactory_admin_access_token}"
7173
}
7274
7375
resource "artifactory_scoped_token" "me" {
@@ -80,7 +82,7 @@ resource "artifactory_scoped_token" "me" {
8082
When pushing the template, you can pass in the variables using the`--var` flag:
8183

8284
```shell
83-
coder templates push --var'jfrog_host=YYY.jfrog.io' --var'artifactory_access_token=XXX'
85+
coder templates push --var'jfrog_url=https://YYY.jfrog.io' --var'artifactory_admin_access_token=XXX'
8486
```
8587

8688
##Installing JFrog CLI
@@ -118,6 +120,10 @@ locals {
118120
python = "pypi"
119121
go = "go"
120122
}
123+
# Make sure to use the same field as the username field in the Artifactory
124+
# It can be either the username or the email address.
125+
artifactory_username = data.coder_workspace.me.owner_email
126+
jfrog_host = replace(var.jfrog_url, "^https://", "")
121127
}
122128
```
123129

@@ -133,7 +139,7 @@ resource "coder_agent" "main" {
133139
set -e
134140
135141
# install and start code-server
136-
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.11.0
142+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
137143
/tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
138144
139145
# The jf CLI checks $CI when determining whether to use interactive
@@ -142,26 +148,26 @@ resource "coder_agent" "main" {
142148
143149
jf c rm 0 || true
144150
echo ${artifactory_scoped_token.me.access_token} | \
145-
jf c add --access-token-stdin --urlhttps://${var.jfrog_host} 0
151+
jf c add --access-token-stdin --url ${var.jfrog_url} 0
146152
147153
# Configure the `npm` CLI to use the Artifactory "npm" repository.
148154
cat << EOF > ~/.npmrc
149155
email = ${data.coder_workspace.me.owner_email}
150-
registry =https://${var.jfrog_host}/artifactory/api/npm/${local.artifactory_repository_keys["npm"]}
156+
registry = ${var.jfrog_url}/artifactory/api/npm/${local.artifactory_repository_keys["npm"]}
151157
EOF
152158
jf rt curl /api/npm/auth >> .npmrc
153159
154160
# Configure the `pip` to use the Artifactory "python" repository.
155161
mkdir -p ~/.pip
156162
cat << EOF > ~/.pip/pip.conf
157163
[global]
158-
index-url = https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/pypi/${local.artifactory_repository_keys["python"]}/simple
164+
index-url = https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${local.jfrog_host}/artifactory/api/pypi/${local.artifactory_repository_keys["python"]}/simple
159165
EOF
160166
161167
EOT
162168
# Set GOPROXY to use the Artifactory "go" repository.
163169
env = {
164-
GOPROXY : "https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/go/${local.artifactory_repository_keys["go"]}"
170+
GOPROXY : "https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${local..jfrog_host}/artifactory/api/go/${local.artifactory_repository_keys["go"]}"
165171
}
166172
}
167173
```
@@ -192,9 +198,7 @@ following lines into your `startup_script`:
192198
# Install the JFrog VS Code extension.
193199
# Find the latest version number at
194200
# https://open-vsx.org/extension/JFrog/jfrog-vscode-extension.
195-
JFROG_EXT_VERSION=2.4.1
196-
curl -o /tmp/jfrog.vsix -L"https://open-vsx.org/api/JFrog/jfrog-vscode-extension/$JFROG_EXT_VERSION/file/JFrog.jfrog-vscode-extension-$JFROG_EXT_VERSION.vsix"
197-
/tmp/code-server/bin/code-server --install-extension /tmp/jfrog.vsix
201+
/tmp/code-server/bin/code-server --install-extension jfrog.jfrog-vscode-extension
198202
```
199203

200204
Note that this method will only work if your developers use code-server.
@@ -208,7 +212,7 @@ Artifactory:
208212
# Configure the `npm` CLI to use the Artifactory "npm" registry.
209213
cat<<EOF > ~/.npmrc
210214
email =${data.coder_workspace.me.owner_email}
211-
registry =https://${var.jfrog_host}/artifactory/api/npm/npm/
215+
registry =${var.jfrog_url}/artifactory/api/npm/npm/
212216
EOF
213217
jf rt curl /api/npm/auth >> .npmrc
214218
```
@@ -227,7 +231,7 @@ Artifactory:
227231
mkdir -p ~/.pip
228232
cat << EOF > ~/.pip/pip.conf
229233
[global]
230-
index-url = https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/pypi/pypi/simple
234+
index-url = https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${local.jfrog_host}/artifactory/api/pypi/pypi/simple
231235
EOF
232236
```
233237
@@ -243,7 +247,7 @@ Add the following environment variable to your `coder_agent` block to configure
243247
244248
```hcl
245249
env = {
246-
GOPROXY : "https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/go/go"
250+
GOPROXY : "https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${local.jfrog_host}/artifactory/api/go/go"
247251
}
248252
```
249253

‎examples/jfrog/docker/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tags: [local, docker, jfrog]
55
icon:/icon/docker.png
66
---
77

8-
#docker
8+
#Docker
99

1010
To get started, run`coder templates init`. When prompted, select this template.
1111
Follow the on-screen instructions to proceed.
@@ -22,5 +22,5 @@ the dashboard UI over `localhost:13337`.
2222

2323
#Next steps
2424

25-
Check out our[Docker](../docker/) template for a more fully featured Docker
25+
Check out our[Docker](../../templates/docker/) template for a more fully featured Docker
2626
example.

‎examples/jfrog/docker/main.tf‎

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,43 @@ terraform {
1313
}
1414

1515
locals {
16-
#take care to useowner_email instead of owner because users can change
17-
#theirusername.
16+
#Make sure to usethe same field as the username field in the Artifactory
17+
#It can be either theusername or the email address.
1818
artifactory_username=data.coder_workspace.me.owner_email
1919
artifactory_repository_keys={
2020
"npm"="npm"
2121
"python"="python"
2222
"go"="go"
2323
}
2424
workspace_user=data.coder_workspace.me.owner
25+
jfrog_host=replace(var.jfrog_url,"^https://","")
2526
}
2627

27-
data"coder_provisioner""me" {
28-
}
28+
data"coder_provisioner""me" {}
2929

30-
provider"docker" {
31-
}
30+
provider"docker" {}
3231

33-
data"coder_workspace""me" {
34-
}
32+
data"coder_workspace""me" {}
3533

36-
variable"jfrog_host" {
34+
variable"jfrog_url" {
3735
type=string
38-
description="JFrog instance hostname. For example, 'YYY.jfrog.io'."
36+
description="JFrog instance URL. For example, https://jfrog.example.com."
37+
# validate the URL to ensure it starts with https:// or http://
38+
validation {
39+
condition=can(regex("^https?://", var.jfrog_url))
40+
error_message="JFrog URL must start with https:// or http://"
41+
}
3942
}
4043

41-
variable"artifactory_access_token" {
44+
variable"artifactory_admin_access_token" {
4245
type=string
43-
description="The admin-level access token to use for JFrog."
46+
description="The admin-level access token to use for JFrog with scope applied-permissions/admin."
4447
}
4548

46-
# Configure the Artifactory provider
49+
# Configure the Artifactory provider with the admin-level access token.
4750
provider"artifactory" {
48-
url="https://${var.jfrog_host}/artifactory"
49-
access_token=var.artifactory_access_token
51+
url="${var.jfrog_url}/artifactory"
52+
access_token=var.artifactory_admin_access_token
5053
}
5154

5255
resource"artifactory_scoped_token""me" {
@@ -63,7 +66,7 @@ resource "coder_agent" "main" {
6366
set -e
6467
6568
# install and start code-server
66-
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.11.0
69+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
6770
/tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
6871
6972
# Install the JFrog VS Code extension.
@@ -77,28 +80,28 @@ resource "coder_agent" "main" {
7780
7881
jf c rm 0 || true
7982
echo${artifactory_scoped_token.me.access_token} | \
80-
jf c add --access-token-stdin --urlhttps://${var.jfrog_host} 0
83+
jf c add --access-token-stdin --url${var.jfrog_url} 0
8184
8285
# Configure the `npm` CLI to use the Artifactory "npm" repository.
8386
cat << EOF > ~/.npmrc
8487
email =${data.coder_workspace.me.owner_email}
85-
registry =https://${var.jfrog_host}/artifactory/api/npm/${local.artifactory_repository_keys["npm"]}
88+
registry =${var.jfrog_url}/artifactory/api/npm/${local.artifactory_repository_keys["npm"]}
8689
EOF
8790
jf rt curl /api/npm/auth >> .npmrc
8891
8992
# Configure the `pip` to use the Artifactory "python" repository.
9093
mkdir -p ~/.pip
9194
cat << EOF > ~/.pip/pip.conf
9295
[global]
93-
index-url = https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/pypi/${local.artifactory_repository_keys["python"]}/simple
96+
index-url = https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${local.jfrog_host}/artifactory/api/pypi/${local.artifactory_repository_keys["python"]}/simple
9497
EOF
9598
9699
EOT
97100
# Set GOPROXY to use the Artifactory "go" repository.
98101
env={
99-
GOPROXY:"https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/go/${local.artifactory_repository_keys["go"]}"
102+
GOPROXY:"https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${local.jfrog_host}/artifactory/api/go/${local.artifactory_repository_keys["go"]}"
100103
# Authenticate with JFrog extension.
101-
JFROG_IDE_URL:"https://${var.jfrog_host}"
104+
JFROG_IDE_URL:"${var.jfrog_url}"
102105
JFROG_IDE_USERNAME:"${local.artifactory_username}"
103106
JFROG_IDE_PASSWORD:"${artifactory_scoped_token.me.access_token}"
104107
JFROG_IDE_ACCESS_TOKEN:"${artifactory_scoped_token.me.access_token}"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp