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

refactor: refactor JFrog docs and template#11336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
matifali merged 5 commits intomainfromjfrog-example
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes fromall 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
46 changes: 25 additions & 21 deletionsdocs/platforms/jfrog.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,33 +41,35 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "~> 0.11.1"
}
docker = {
source = "kreuzwerker/docker"
version = "~> 3.0.1"
}
artifactory = {
source = "registry.terraform.io/jfrog/artifactory"
version = "~> 8.4.0"
}
}
}

variable "jfrog_host" {
variable "jfrog_url" {
type = string
description = "JFrog instance hostname. e.g. YYY.jfrog.io"
description = "JFrog instance URL. e.g. https://jfrog.example.com"
# validate the URL to ensure it starts with https:// or http://
validation {
condition = can(regex("^https?://", var.jfrog_url))
error_message = "JFrog URL must start with https:// or http://"
}
}

variable "artifactory_access_token" {
variable "artifactory_admin_access_token" {
type = string
description = "The admin-level access token to use for JFrog."
description = "The admin-level access token to use for JFrog with scope applied-permissions/admin"
}

# Configure the Artifactory provider
provider "artifactory" {
url = "https://${var.jfrog_host}/artifactory"
access_token = "${var.artifactory_access_token}"
url = "${var.jfrog_url}/artifactory"
access_token = "${var.artifactory_admin_access_token}"
}

resource "artifactory_scoped_token" "me" {
Expand All@@ -80,7 +82,7 @@ resource "artifactory_scoped_token" "me" {
When pushing the template, you can pass in the variables using the `--var` flag:

```shell
coder templates push --var 'jfrog_host=YYY.jfrog.io' --var 'artifactory_access_token=XXX'
coder templates push --var 'jfrog_url=https://YYY.jfrog.io' --var 'artifactory_admin_access_token=XXX'
```

## Installing JFrog CLI
Expand DownExpand Up@@ -118,6 +120,10 @@ locals {
python = "pypi"
go = "go"
}
# Make sure to use the same field as the username field in the Artifactory
# It can be either the username or the email address.
artifactory_username = data.coder_workspace.me.owner_email
jfrog_host = replace(var.jfrog_url, "^https://", "")
}
```

Expand All@@ -133,7 +139,7 @@ resource "coder_agent" "main" {
set -e

# install and start code-server
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.11.0
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
/tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &

# The jf CLI checks $CI when determining whether to use interactive
Expand All@@ -142,26 +148,26 @@ resource "coder_agent" "main" {

jf c rm 0 || true
echo ${artifactory_scoped_token.me.access_token} | \
jf c add --access-token-stdin --urlhttps://${var.jfrog_host} 0
jf c add --access-token-stdin --url ${var.jfrog_url} 0

# Configure the `npm` CLI to use the Artifactory "npm" repository.
cat << EOF > ~/.npmrc
email = ${data.coder_workspace.me.owner_email}
registry =https://${var.jfrog_host}/artifactory/api/npm/${local.artifactory_repository_keys["npm"]}
registry = ${var.jfrog_url}/artifactory/api/npm/${local.artifactory_repository_keys["npm"]}
EOF
jf rt curl /api/npm/auth >> .npmrc

# Configure the `pip` to use the Artifactory "python" repository.
mkdir -p ~/.pip
cat << EOF > ~/.pip/pip.conf
[global]
index-url = https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/pypi/${local.artifactory_repository_keys["python"]}/simple
index-url = https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${local.jfrog_host}/artifactory/api/pypi/${local.artifactory_repository_keys["python"]}/simple
EOF

EOT
# Set GOPROXY to use the Artifactory "go" repository.
env = {
GOPROXY : "https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/go/${local.artifactory_repository_keys["go"]}"
GOPROXY : "https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${local..jfrog_host}/artifactory/api/go/${local.artifactory_repository_keys["go"]}"
}
}
```
Expand DownExpand Up@@ -192,9 +198,7 @@ following lines into your `startup_script`:
# Install the JFrog VS Code extension.
# Find the latest version number at
# https://open-vsx.org/extension/JFrog/jfrog-vscode-extension.
JFROG_EXT_VERSION=2.4.1
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"
/tmp/code-server/bin/code-server --install-extension /tmp/jfrog.vsix
/tmp/code-server/bin/code-server --install-extension jfrog.jfrog-vscode-extension
```

Note that this method will only work if your developers use code-server.
Expand All@@ -208,7 +212,7 @@ Artifactory:
# Configure the `npm` CLI to use the Artifactory "npm" registry.
cat << EOF > ~/.npmrc
email = ${data.coder_workspace.me.owner_email}
registry =https://${var.jfrog_host}/artifactory/api/npm/npm/
registry = ${var.jfrog_url}/artifactory/api/npm/npm/
EOF
jf rt curl /api/npm/auth >> .npmrc
```
Expand All@@ -227,7 +231,7 @@ Artifactory:
mkdir -p ~/.pip
cat << EOF > ~/.pip/pip.conf
[global]
index-url = https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/pypi/pypi/simple
index-url = https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${local.jfrog_host}/artifactory/api/pypi/pypi/simple
EOF
```

Expand All@@ -243,7 +247,7 @@ Add the following environment variable to your `coder_agent` block to configure

```hcl
env = {
GOPROXY : "https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/go/go"
GOPROXY : "https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${local.jfrog_host}/artifactory/api/go/go"
}
```

Expand Down
4 changes: 2 additions & 2 deletionsexamples/jfrog/docker/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@ tags: [local, docker, jfrog]
icon: /icon/docker.png
---

#docker
#Docker

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

# Next steps

Check out our [Docker](../docker/) template for a more fully featured Docker
Check out our [Docker](../../templates/docker/) template for a more fully featured Docker
example.
45 changes: 24 additions & 21 deletionsexamples/jfrog/docker/main.tf
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,40 +13,43 @@ terraform {
}

locals {
#take care to useowner_email instead of owner because users can change
#theirusername.
#Make sure to usethe same field as the username field in the Artifactory
#It can be either theusername or the email address.
artifactory_username = data.coder_workspace.me.owner_email
artifactory_repository_keys = {
"npm" = "npm"
"python" = "python"
"go" = "go"
}
workspace_user = data.coder_workspace.me.owner
jfrog_host = replace(var.jfrog_url, "^https://", "")
}

data "coder_provisioner" "me" {
}
data "coder_provisioner" "me" {}

provider "docker" {
}
provider "docker" {}

data "coder_workspace" "me" {
}
data "coder_workspace" "me" {}

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

variable "artifactory_access_token" {
variable "artifactory_admin_access_token" {
type = string
description = "The admin-level access token to use for JFrog."
description = "The admin-level access token to use for JFrog with scope applied-permissions/admin."
}

# Configure the Artifactory provider
# Configure the Artifactory provider with the admin-level access token.
provider "artifactory" {
url = "https://${var.jfrog_host}/artifactory"
access_token = var.artifactory_access_token
url = "${var.jfrog_url}/artifactory"
access_token = var.artifactory_admin_access_token
}

resource "artifactory_scoped_token" "me" {
Expand All@@ -63,7 +66,7 @@ resource "coder_agent" "main" {
set -e

# install and start code-server
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.11.0
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
/tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &

# Install the JFrog VS Code extension.
Expand All@@ -77,28 +80,28 @@ resource "coder_agent" "main" {

jf c rm 0 || true
echo ${artifactory_scoped_token.me.access_token} | \
jf c add --access-token-stdin --urlhttps://${var.jfrog_host} 0
jf c add --access-token-stdin --url ${var.jfrog_url} 0

# Configure the `npm` CLI to use the Artifactory "npm" repository.
cat << EOF > ~/.npmrc
email = ${data.coder_workspace.me.owner_email}
registry =https://${var.jfrog_host}/artifactory/api/npm/${local.artifactory_repository_keys["npm"]}
registry = ${var.jfrog_url}/artifactory/api/npm/${local.artifactory_repository_keys["npm"]}
EOF
jf rt curl /api/npm/auth >> .npmrc

# Configure the `pip` to use the Artifactory "python" repository.
mkdir -p ~/.pip
cat << EOF > ~/.pip/pip.conf
[global]
index-url = https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/pypi/${local.artifactory_repository_keys["python"]}/simple
index-url = https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${local.jfrog_host}/artifactory/api/pypi/${local.artifactory_repository_keys["python"]}/simple
EOF

EOT
# Set GOPROXY to use the Artifactory "go" repository.
env = {
GOPROXY : "https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/go/${local.artifactory_repository_keys["go"]}"
GOPROXY : "https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${local.jfrog_host}/artifactory/api/go/${local.artifactory_repository_keys["go"]}"
# Authenticate with JFrog extension.
JFROG_IDE_URL : "https://${var.jfrog_host}"
JFROG_IDE_URL : "${var.jfrog_url}"
JFROG_IDE_USERNAME : "${local.artifactory_username}"
JFROG_IDE_PASSWORD : "${artifactory_scoped_token.me.access_token}"
JFROG_IDE_ACCESS_TOKEN : "${artifactory_scoped_token.me.access_token}"
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp