Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
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 @@ -26,6 +26,7 @@ module "jfrog" {
go = ["go", "another-go-repo"]
pypi = ["pypi", "extra-index-pypi"]
docker = ["example-docker-staging.jfrog.io", "example-docker-production.jfrog.io"]
conda = ["conda", "conda-local"]
}
}
```
Expand Down
6 changes: 6 additions & 0 deletions registry/coder/modules/jfrog-oauth/conda.conf.tftpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
channels:
%{ for REPO in REPOS ~}
- https://${ARTIFACTORY_USERNAME}:${ARTIFACTORY_ACCESS_TOKEN}@${JFROG_HOST}/artifactory/api/conda/${REPO}
%{ endfor ~}
- defaults
ssl_verify: true
24 changes: 24 additions & 0 deletions registry/coder/modules/jfrog-oauth/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,28 @@ EOF`;
'if [ -z "YES" ]; then\n not_configured go',
);
});

it("generates a conda config with multiple repos", async () => {
const state = await runTerraformApply<TestVariables>(import.meta.dir, {
agent_id: "some-agent-id",
jfrog_url: fakeFrogUrl,
package_managers: JSON.stringify({
conda: ["conda-main", "conda-secondary", "conda-local"],
}),
});
const coderScript = findResourceInstance(state, "coder_script");
const condaStanza = `cat << EOF > ~/.condarc
channels:
- https://${user}:@${fakeFrogApi}/conda/conda-main
- https://${user}:@${fakeFrogApi}/conda/conda-secondary
- https://${user}:@${fakeFrogApi}/conda/conda-local
- defaults
ssl_verify: true

EOF`;
expect(coderScript.script).toContain(condaStanza);
expect(coderScript.script).toContain(
'if [ -z "YES" ]; then\n not_configured conda',
);
});
});
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 @@ -58,6 +58,7 @@ variable "package_managers" {
go = optional(list(string), [])
pypi = optional(list(string), [])
docker = optional(list(string), [])
conda = optional(list(string), [])
})
description = <<-EOF
A map of package manager names to their respective artifactory repositories. Unused package managers can be omitted.
Expand All @@ -67,6 +68,7 @@ variable "package_managers" {
go = ["YOUR_GO_REPO_KEY", "ANOTHER_GO_REPO_KEY"]
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"]
}
EOF
}
Expand Down Expand Up @@ -98,6 +100,9 @@ locals {
pip_conf = templatefile(
"${path.module}/pip.conf.tftpl", merge(local.common_values, { REPOS = var.package_managers.pypi })
)
conda_conf = templatefile(
"${path.module}/conda.conf.tftpl", merge(local.common_values, { REPOS = var.package_managers.conda })
)
}

data "coder_workspace" "me" {}
Expand Down Expand Up @@ -125,6 +130,9 @@ resource "coder_script" "jfrog" {
REPOSITORY_PYPI = try(element(var.package_managers.pypi, 0), "")
HAS_DOCKER = length(var.package_managers.docker) == 0 ? "" : "YES"
REGISTER_DOCKER = join("\n", formatlist("register_docker \"%s\"", var.package_managers.docker))
HAS_CONDA = length(var.package_managers.conda) == 0 ? "" : "YES"
CONDA_CONF = local.conda_conf
REPOSITORY_CONDA = try(element(var.package_managers.conda, 0), "")
}
))
run_on_start = true
Expand Down
13 changes: 13 additions & 0 deletions registry/coder/modules/jfrog-oauth/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ else
fi
fi

# Configure conda to use the Artifactory "conda" repository.
if [ -z "${HAS_CONDA}" ]; then
not_configured conda
else
echo "🐍 Configuring conda..."
# Create conda config directory if it doesn't exist
mkdir -p ~/.conda
cat << EOF > ~/.condarc
${CONDA_CONF}
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
12 changes: 8 additions & 4 deletions registry/coder/modules/jfrog-token/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module "jfrog" {
go = ["go", "another-go-repo"]
pypi = ["pypi", "extra-index-pypi"]
docker = ["example-docker-staging.jfrog.io", "example-docker-production.jfrog.io"]
conda = ["conda", "conda-local"]
}
}
```
Expand All @@ -45,25 +46,28 @@ module "jfrog" {
jfrog_url = "https://YYYY.jfrog.io"
artifactory_access_token = var.artifactory_access_token # An admin access token
package_managers = {
npm = ["npm-local"]
go = ["go-local"]
pypi = ["pypi-local"]
npm = ["npm-local"]
go = ["go-local"]
pypi = ["pypi-local"]
conda = ["conda-local"]
}
}
```

You should now be able to install packages from Artifactory using both the `jf npm`, `jf go`, `jf pip` and `npm`, `go`, `pip` 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` commands.

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

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

### Configure code-server with JFrog extension
Expand Down
6 changes: 6 additions & 0 deletions registry/coder/modules/jfrog-token/conda.conf.tftpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
channels:
%{ for REPO in REPOS ~}
- https://${ARTIFACTORY_USERNAME}:${ARTIFACTORY_ACCESS_TOKEN}@${JFROG_HOST}/artifactory/api/conda/${REPO}
%{ endfor ~}
- defaults
ssl_verify: true
25 changes: 25 additions & 0 deletions registry/coder/modules/jfrog-token/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,29 @@ EOF`;
'if [ -z "YES" ]; then\n not_configured go',
);
});

it("generates a conda config with multiple repos", async () => {
const state = await runTerraformApply<TestVariables>(import.meta.dir, {
agent_id: "some-agent-id",
jfrog_url: fakeFrogUrl,
artifactory_access_token: "XXXX",
package_managers: JSON.stringify({
conda: ["conda-main", "conda-secondary", "conda-local"],
}),
});
const coderScript = findResourceInstance(state, "coder_script");
const condaStanza = `cat << EOF > ~/.condarc
channels:
- https://${user}:${token}@${fakeFrogApi}/conda/conda-main
- https://${user}:${token}@${fakeFrogApi}/conda/conda-secondary
- https://${user}:${token}@${fakeFrogApi}/conda/conda-local
- defaults
ssl_verify: true

EOF`;
expect(coderScript.script).toContain(condaStanza);
expect(coderScript.script).toContain(
'if [ -z "YES" ]; then\n not_configured conda',
);
});
});
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 @@ -91,6 +91,7 @@ variable "package_managers" {
go = optional(list(string), [])
pypi = optional(list(string), [])
docker = optional(list(string), [])
conda = optional(list(string), [])
})
description = <<-EOF
A map of package manager names to their respective artifactory repositories. Unused package managers can be omitted.
Expand All @@ -100,6 +101,7 @@ variable "package_managers" {
go = ["YOUR_GO_REPO_KEY", "ANOTHER_GO_REPO_KEY"]
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"]
}
EOF
}
Expand Down Expand Up @@ -131,6 +133,9 @@ locals {
pip_conf = templatefile(
"${path.module}/pip.conf.tftpl", merge(local.common_values, { REPOS = var.package_managers.pypi })
)
conda_conf = templatefile(
"${path.module}/conda.conf.tftpl", merge(local.common_values, { REPOS = var.package_managers.conda })
)
}

# Configure the Artifactory provider
Expand Down Expand Up @@ -171,6 +176,9 @@ resource "coder_script" "jfrog" {
REPOSITORY_PYPI = try(element(var.package_managers.pypi, 0), "")
HAS_DOCKER = length(var.package_managers.docker) == 0 ? "" : "YES"
REGISTER_DOCKER = join("\n", formatlist("register_docker \"%s\"", var.package_managers.docker))
HAS_CONDA = length(var.package_managers.conda) == 0 ? "" : "YES"
CONDA_CONF = local.conda_conf
REPOSITORY_CONDA = try(element(var.package_managers.conda, 0), "")
}
))
run_on_start = true
Expand Down
13 changes: 13 additions & 0 deletions registry/coder/modules/jfrog-token/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ else
fi
fi

# Configure conda to use the Artifactory "conda" repository.
if [ -z "${HAS_CONDA}" ]; then
not_configured conda
else
echo "🐍 Configuring conda..."
# Create conda config directory if it doesn't exist
mkdir -p ~/.conda
cat << EOF > ~/.condarc
${CONDA_CONF}
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
Loading