Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d31865c94 | ||
|
|
d3fc2d2212 |
@@ -9,7 +9,7 @@ tags: [git, helper]
|
|||||||
|
|
||||||
# Git Clone
|
# Git Clone
|
||||||
|
|
||||||
This module allows you to automatically clone a repository by URL and skip if it exists in the path provided.
|
This module allows you to automatically clone a repository by URL and skip if it exists in the base directory provided.
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
module "git-clone" {
|
module "git-clone" {
|
||||||
@@ -38,6 +38,6 @@ module "git-clone" {
|
|||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
url = "https://github.com/coder/coder"
|
url = "https://github.com/coder/coder"
|
||||||
path = "~/projects/coder/coder"
|
base_dir = "~/projects/coder"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ variable "url" {
|
|||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "path" {
|
variable "base_dir" {
|
||||||
default = ""
|
default = ""
|
||||||
description = "The path to clone the repository. Defaults to \"$HOME/<basename of url>\"."
|
description = "The base directory to clone the repository. Defaults to \"$HOME\"."
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,10 +25,19 @@ variable "agent_id" {
|
|||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
clone_path = var.base_dir != "" ? join("/", [var.base_dir, replace(basename(var.url), ".git", "")]) : join("/", ["~", replace(basename(var.url), ".git", "")])
|
||||||
|
}
|
||||||
|
|
||||||
|
output "repo_dir" {
|
||||||
|
value = local.clone_path
|
||||||
|
description = "Full path of cloned repo directory"
|
||||||
|
}
|
||||||
|
|
||||||
resource "coder_script" "git_clone" {
|
resource "coder_script" "git_clone" {
|
||||||
agent_id = var.agent_id
|
agent_id = var.agent_id
|
||||||
script = templatefile("${path.module}/run.sh", {
|
script = templatefile("${path.module}/run.sh", {
|
||||||
CLONE_PATH = var.path != "" ? join("/", [var.path, replace(basename(var.url), ".git", "")]) : join("/", ["~", replace(basename(var.url), ".git", "")])
|
CLONE_PATH = local.clone_path
|
||||||
REPO_URL : var.url,
|
REPO_URL : var.url,
|
||||||
})
|
})
|
||||||
display_name = "Git Clone"
|
display_name = "Git Clone"
|
||||||
|
|||||||
@@ -10,18 +10,16 @@ tags: [integration, jfrog]
|
|||||||
|
|
||||||
# JFrog
|
# JFrog
|
||||||
|
|
||||||
Install the JF CLI and authenticate package managers with Artifactory using OAuth configured via the Coder `external-auth` feature.
|
Install the JF CLI and authenticate package managers with Artifactory using OAuth configured via the Coder [`external-auth`](https://coder.com/docs/v2/latest/admin/external-auth) feature.
|
||||||
|
|
||||||
<p align="center">
|

|
||||||
<img src='../.images/jfrog-oauth.png' alt="JFrog OAuth" width='600'>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
module "jfrog" {
|
module "jfrog" {
|
||||||
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
jfrog_url = "https://jfrog.example.com"
|
jfrog_url = "https://example.jfrog.io"
|
||||||
username_field = "username" # If you are using GitHub to login to both Coder and Artifactory, use username_field = "username"
|
username_field = "username" # If you are using GitHub to login to both Coder and Artifactory, use username_field = "username"
|
||||||
package_managers = {
|
package_managers = {
|
||||||
"npm": "npm",
|
"npm": "npm",
|
||||||
@@ -36,49 +34,7 @@ module "jfrog" {
|
|||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
Coder [`external-auth`](https://coder.com/docs/v2/latest/admin/external-auth) configured with Artifactory. This requires a [custom integration](https://jfrog.com/help/r/jfrog-installation-setup-documentation/enable-new-integrations) in Artifactory with **Callback URL** set to `https://<your-coder-url>/external-auth/jfrog/callback`.
|
This module is usable by JFrog self-hosted (on-premises) Artifactory as it requires configuring a custom integration. This integration benefits from Coder's [external-auth](https://coder.com/docs/v2/latest/admin/external-auth) feature and allows each user to authenticate with Artifactory using an OAuth flow and issues user-scoped tokens to each user. For configuration instructions, see this [guide](coder.com/docs/v2/latest/guides/artifactory-integration#jfrog-oauth) on the Coder documentation.
|
||||||
|
|
||||||
To set this up,
|
|
||||||
|
|
||||||
1. Modify your `values.yaml` for JFrog Artifactory to add,
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
artifactory:
|
|
||||||
enabled: true
|
|
||||||
frontend:
|
|
||||||
extraEnvironmentVariables:
|
|
||||||
- name: JF_FRONTEND_FEATURETOGGLER_ACCESSINTEGRATION
|
|
||||||
value: "true"
|
|
||||||
access:
|
|
||||||
accessConfig:
|
|
||||||
integrations-enabled: true
|
|
||||||
integration-templates:
|
|
||||||
- id: "1"
|
|
||||||
name: "CODER"
|
|
||||||
redirect-uri: "https://CODER_URL/external-auth/jfrog/callback"
|
|
||||||
scope: "applied-permissions/user"
|
|
||||||
```
|
|
||||||
|
|
||||||
> Note
|
|
||||||
> Replace `CODER_URL` with your Coder deployment URL, e.g., <coder.example.com>
|
|
||||||
|
|
||||||
2. Add a new [external authetication](https://coder.com/docs/v2/latest/admin/external-auth) to Coder by setting these env variables,
|
|
||||||
|
|
||||||
```env
|
|
||||||
# JFrog Artifactory External Auth
|
|
||||||
CODER_EXTERNAL_AUTH_1_ID="jfrog"
|
|
||||||
CODER_EXTERNAL_AUTH_1_TYPE="jfrog"
|
|
||||||
CODER_EXTERNAL_AUTH_1_CLIENT_ID="YYYYYYYYYYYYYYY"
|
|
||||||
CODER_EXTERNAL_AUTH_1_CLIENT_SECRET="XXXXXXXXXXXXXXXXXXX"
|
|
||||||
CODER_EXTERNAL_AUTH_1_DISPLAY_NAME="JFrog Artifactory"
|
|
||||||
CODER_EXTERNAL_AUTH_1_DISPLAY_ICON="/icon/jfrog.svg"
|
|
||||||
CODER_EXTERNAL_AUTH_1_AUTH_URL="https://JFROG_URL/ui/authorization"
|
|
||||||
CODER_EXTERNAL_AUTH_1_TOKEN_URL="https://JFROG_URL/access/api/v1/integrations/YYYYYYYYYYYYYYY/token"
|
|
||||||
CODER_EXTERNAL_AUTH_1_SCOPES="applied-permissions/user"
|
|
||||||
```
|
|
||||||
|
|
||||||
> Note
|
|
||||||
> Replace `JFROG_URL` with your JFrog Artifactory base URL, e.g., <artifactory.example.com>
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
@@ -89,8 +45,7 @@ module "jfrog" {
|
|||||||
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
jfrog_url = "https://jfrog.example.com"
|
jfrog_url = "https://example.jfrog.io"
|
||||||
auth_method = "oauth"
|
|
||||||
username_field = "email"
|
username_field = "email"
|
||||||
package_managers = {
|
package_managers = {
|
||||||
"pypi": "pypi"
|
"pypi": "pypi"
|
||||||
@@ -117,7 +72,7 @@ module "jfrog" {
|
|||||||
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
jfrog_url = "https://jfrog.example.com"
|
jfrog_url = "https://example.jfrog.io"
|
||||||
username_field = "username" # If you are using GitHub to login to both Coder and Artifactory, use username_field = "username"
|
username_field = "username" # If you are using GitHub to login to both Coder and Artifactory, use username_field = "username"
|
||||||
configure_code_server = true # Add JFrog extension configuration for code-server
|
configure_code_server = true # Add JFrog extension configuration for code-server
|
||||||
package_managers = {
|
package_managers = {
|
||||||
@@ -133,13 +88,14 @@ module "jfrog" {
|
|||||||
JFrog Access token is also available as a terraform output. You can use it in other terraform resources. For example, you can use it to configure an [Artifactory docker registry](https://jfrog.com/help/r/jfrog-artifactory-documentation/docker-registry) with the [docker terraform provider](https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs).
|
JFrog Access token is also available as a terraform output. You can use it in other terraform resources. For example, you can use it to configure an [Artifactory docker registry](https://jfrog.com/help/r/jfrog-artifactory-documentation/docker-registry) with the [docker terraform provider](https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs).
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
|
|
||||||
provider "docker" {
|
provider "docker" {
|
||||||
...
|
...
|
||||||
registry_auth {
|
registry_auth {
|
||||||
address = "https://YYYY.jfrog.io/artifactory/api/docker/REPO-KEY"
|
address = "https://example.jfrog.io/artifactory/api/docker/REPO-KEY"
|
||||||
username = module.jfrog.username
|
username = module.jfrog.username
|
||||||
password = module.jfrog.access_token
|
password = module.jfrog.access_token
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> Here `REPO_KEY` is the name of docker repository in Artifactory.
|
||||||
|
|||||||
@@ -27,14 +27,7 @@ module "jfrog" {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
For detailed instructions, please see this [guide](https://coder.com/docs/v2/latest/guides/artifactory-integration#jfrog-token) on the Coder documentation.
|
||||||
|
|
||||||
```hcl
|
|
||||||
variable "artifactory_access_token" {
|
|
||||||
type = string
|
|
||||||
sensitive = true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
> Note
|
> Note
|
||||||
> This module does not install `npm`, `go`, `pip`, etc but only configure them. You need to handle the installation of these tools yourself.
|
> This module does not install `npm`, `go`, `pip`, etc but only configure them. You need to handle the installation of these tools yourself.
|
||||||
|
|||||||
Reference in New Issue
Block a user