Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions registry/coder/modules/jfrog-oauth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module "jfrog" {
pypi = ["pypi", "extra-index-pypi"]
docker = ["example-docker-staging.jfrog.io", "example-docker-production.jfrog.io"]
conda = ["conda", "conda-local"]
maven = ["maven", "maven-local"]
}
}
```
Expand Down
8 changes: 8 additions & 0 deletions registry/coder/modules/jfrog-oauth/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ variable "package_managers" {
pypi = optional(list(string), [])
docker = optional(list(string), [])
conda = optional(list(string), [])
maven = optional(list(string), [])
})
description = <<-EOF
A map of package manager names to their respective artifactory repositories. Unused package managers can be omitted.
Expand All @@ -69,6 +70,7 @@ variable "package_managers" {
pypi = ["YOUR_PYPI_REPO_KEY", "ANOTHER_PYPI_REPO_KEY"]
docker = ["YOUR_DOCKER_REPO_KEY", "ANOTHER_DOCKER_REPO_KEY"]
conda = ["YOUR_CONDA_REPO_KEY", "ANOTHER_CONDA_REPO_KEY"]
maven = ["YOUR_MAVEN_REPO_KEY", "ANOTHER_MAVEN_REPO_KEY"]
}
EOF
}
Expand Down Expand Up @@ -103,6 +105,9 @@ locals {
conda_conf = templatefile(
"${path.module}/conda.conf.tftpl", merge(local.common_values, { REPOS = var.package_managers.conda })
)
maven_settings = templatefile(
"${path.module}/settings.xml.tftpl", merge(local.common_values, { REPOS = var.package_managers.maven })
)
}

data "coder_workspace" "me" {}
Expand Down Expand Up @@ -133,6 +138,9 @@ resource "coder_script" "jfrog" {
HAS_CONDA = length(var.package_managers.conda) == 0 ? "" : "YES"
CONDA_CONF = local.conda_conf
REPOSITORY_CONDA = try(element(var.package_managers.conda, 0), "")
HAS_MAVEN = length(var.package_managers.maven) == 0 ? "" : "YES"
MAVEN_SETTINGS = local.maven_settings
REPOSITORY_MAVEN = try(element(var.package_managers.maven, 0), "")
}
))
run_on_start = true
Expand Down
14 changes: 14 additions & 0 deletions registry/coder/modules/jfrog-oauth/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ EOF
config_complete
fi

# Configure Maven to use the Artifactory "maven" repository.
if [ -z "${HAS_MAVEN}" ]; then
not_configured maven
else
echo "☕ Configuring maven..."
jf mvnc --global --repo-resolve "${REPOSITORY_MAVEN}"
# Create Maven config directory if it doesn't exist
mkdir -p ~/.m2
cat << EOF > ~/.m2/settings.xml
${MAVEN_SETTINGS}
EOF
config_complete
fi

# Install the JFrog vscode extension for code-server.
if [ "${CONFIGURE_CODE_SERVER}" == "true" ]; then
while ! [ -x /tmp/code-server/bin/code-server ]; do
Expand Down
55 changes: 55 additions & 0 deletions registry/coder/modules/jfrog-oauth/settings.xml.tftpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<servers>
%{ for REPO in REPOS ~}
<server>
<id>${REPO}</id>
<username>${ARTIFACTORY_USERNAME}</username>
<password>${ARTIFACTORY_ACCESS_TOKEN}</password>
</server>
%{ endfor ~}
</servers>

<profiles>
<profile>
<id>artifactory</id>
<repositories>
%{ for REPO in REPOS ~}
<repository>
<id>${REPO}</id>
<url>${JFROG_URL}/artifactory/${REPO}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
%{ endfor ~}
</repositories>
<pluginRepositories>
%{ for REPO in REPOS ~}
<pluginRepository>
<id>${REPO}</id>
<url>${JFROG_URL}/artifactory/${REPO}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
%{ endfor ~}
</pluginRepositories>
</profile>
</profiles>

<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>

</settings>
6 changes: 5 additions & 1 deletion registry/coder/modules/jfrog-token/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module "jfrog" {
pypi = ["pypi", "extra-index-pypi"]
docker = ["example-docker-staging.jfrog.io", "example-docker-production.jfrog.io"]
conda = ["conda", "conda-local"]
maven = ["maven", "maven-local"]
}
}
```
Expand Down Expand Up @@ -50,24 +51,27 @@ module "jfrog" {
go = ["go-local"]
pypi = ["pypi-local"]
conda = ["conda-local"]
maven = ["maven-local"]
}
}
```

You should now be able to install packages from Artifactory using both the `jf npm`, `jf go`, `jf pip` and `npm`, `go`, `pip`, `conda` commands.
You should now be able to install packages from Artifactory using both the `jf npm`, `jf go`, `jf pip` and `npm`, `go`, `pip`, `conda`, `maven` commands.

```shell
jf npm install prettier
jf go get github.com/golang/example/hello
jf pip install requests
conda install numpy
mvn clean install
```

```shell
npm install prettier
go get github.com/golang/example/hello
pip install requests
conda install numpy
mvn clean install
```

### Configure code-server with JFrog extension
Expand Down
8 changes: 8 additions & 0 deletions registry/coder/modules/jfrog-token/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ variable "package_managers" {
pypi = optional(list(string), [])
docker = optional(list(string), [])
conda = optional(list(string), [])
maven = optional(list(string), [])
})
description = <<-EOF
A map of package manager names to their respective artifactory repositories. Unused package managers can be omitted.
Expand All @@ -102,6 +103,7 @@ variable "package_managers" {
pypi = ["YOUR_PYPI_REPO_KEY", "ANOTHER_PYPI_REPO_KEY"]
docker = ["YOUR_DOCKER_REPO_KEY", "ANOTHER_DOCKER_REPO_KEY"]
conda = ["YOUR_CONDA_REPO_KEY", "ANOTHER_CONDA_REPO_KEY"]
maven = ["YOUR_MAVEN_REPO_KEY", "ANOTHER_MAVEN_REPO_KEY"]
}
EOF
}
Expand Down Expand Up @@ -136,6 +138,9 @@ locals {
conda_conf = templatefile(
"${path.module}/conda.conf.tftpl", merge(local.common_values, { REPOS = var.package_managers.conda })
)
maven_settings = templatefile(
"${path.module}/settings.xml.tftpl", merge(local.common_values, { REPOS = var.package_managers.maven })
)
}

# Configure the Artifactory provider
Expand Down Expand Up @@ -179,6 +184,9 @@ resource "coder_script" "jfrog" {
HAS_CONDA = length(var.package_managers.conda) == 0 ? "" : "YES"
CONDA_CONF = local.conda_conf
REPOSITORY_CONDA = try(element(var.package_managers.conda, 0), "")
HAS_MAVEN = length(var.package_managers.maven) == 0 ? "" : "YES"
MAVEN_SETTINGS = local.maven_settings
REPOSITORY_MAVEN = try(element(var.package_managers.maven, 0), "")
}
))
run_on_start = true
Expand Down
14 changes: 14 additions & 0 deletions registry/coder/modules/jfrog-token/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ EOF
config_complete
fi

# Configure Maven to use the Artifactory "maven" repository.
if [ -z "${HAS_MAVEN}" ]; then
not_configured maven
else
echo "☕ Configuring maven..."
jf mvnc --global --repo-resolve "${REPOSITORY_MAVEN}"
# Create Maven config directory if it doesn't exist
mkdir -p ~/.m2
cat << EOF > ~/.m2/settings.xml
${MAVEN_SETTINGS}
EOF
config_complete
fi

# Install the JFrog vscode extension for code-server.
if [ "${CONFIGURE_CODE_SERVER}" == "true" ]; then
while ! [ -x /tmp/code-server/bin/code-server ]; do
Expand Down
55 changes: 55 additions & 0 deletions registry/coder/modules/jfrog-token/settings.xml.tftpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<servers>
%{ for REPO in REPOS ~}
<server>
<id>${REPO}</id>
<username>${ARTIFACTORY_USERNAME}</username>
<password>${ARTIFACTORY_ACCESS_TOKEN}</password>
</server>
%{ endfor ~}
</servers>

<profiles>
<profile>
<id>artifactory</id>
<repositories>
%{ for REPO in REPOS ~}
<repository>
<id>${REPO}</id>
<url>${JFROG_URL}/artifactory/${REPO}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
%{ endfor ~}
</repositories>
<pluginRepositories>
%{ for REPO in REPOS ~}
<pluginRepository>
<id>${REPO}</id>
<url>${JFROG_URL}/artifactory/${REPO}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
%{ endfor ~}
</pluginRepositories>
</profile>
</profiles>

<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>

</settings>
Loading