Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b90f6f9de8 | ||
|
|
948280600a | ||
|
|
407738b2be | ||
|
|
08adb4a839 | ||
|
|
313ec59d46 | ||
|
|
4b04d18f39 | ||
|
|
ee53ca0281 | ||
|
|
8e254a3bb9 | ||
|
|
1ab53139b3 | ||
|
|
147bea9782 | ||
|
|
8d8910c52a | ||
|
|
c00b7536cb | ||
|
|
d66d7e994e | ||
|
|
d10ce91a64 | ||
|
|
534491613f |
3
.github/workflows/update-readme.yaml
vendored
3
.github/workflows/update-readme.yaml
vendored
@@ -9,7 +9,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
update-readme:
|
update-readme:
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -33,6 +33,7 @@ jobs:
|
|||||||
title: 'chore: bump version to ${{ env.TAG }} in README.md files'
|
title: 'chore: bump version to ${{ env.TAG }} in README.md files'
|
||||||
body: 'This is an auto-generated PR to update README.md files of all modules with the new tag ${{ env.TAG }}'
|
body: 'This is an auto-generated PR to update README.md files of all modules with the new tag ${{ env.TAG }}'
|
||||||
branch: 'update-readme-branch'
|
branch: 'update-readme-branch'
|
||||||
|
base: 'main'
|
||||||
env:
|
env:
|
||||||
TAG: ${{ steps.get-latest-tag.outputs.TAG }}
|
TAG: ${{ steps.get-latest-tag.outputs.TAG }}
|
||||||
|
|
||||||
|
|||||||
BIN
.images/hcp-vault-secrets-credentials.png
Normal file
BIN
.images/hcp-vault-secrets-credentials.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 174 KiB |
@@ -69,7 +69,7 @@ resource "coder_app" "MODULE_NAME" {
|
|||||||
slug = "MODULE_NAME"
|
slug = "MODULE_NAME"
|
||||||
display_name = "MODULE_NAME"
|
display_name = "MODULE_NAME"
|
||||||
url = "http://localhost:${var.port}"
|
url = "http://localhost:${var.port}"
|
||||||
icon = loocal.icon_url
|
icon = local.icon_url
|
||||||
subdomain = false
|
subdomain = false
|
||||||
share = "owner"
|
share = "owner"
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Automatically install [code-server](https://github.com/coder/code-server) in a w
|
|||||||
```tf
|
```tf
|
||||||
module "code-server" {
|
module "code-server" {
|
||||||
source = "registry.coder.com/modules/code-server/coder"
|
source = "registry.coder.com/modules/code-server/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -28,7 +28,7 @@ module "code-server" {
|
|||||||
```tf
|
```tf
|
||||||
module "code-server" {
|
module "code-server" {
|
||||||
source = "registry.coder.com/modules/code-server/coder"
|
source = "registry.coder.com/modules/code-server/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
install_version = "4.8.3"
|
install_version = "4.8.3"
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ Install the Dracula theme from [OpenVSX](https://open-vsx.org/):
|
|||||||
```tf
|
```tf
|
||||||
module "code-server" {
|
module "code-server" {
|
||||||
source = "registry.coder.com/modules/code-server/coder"
|
source = "registry.coder.com/modules/code-server/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
extensions = [
|
extensions = [
|
||||||
"dracula-theme.theme-dracula"
|
"dracula-theme.theme-dracula"
|
||||||
@@ -58,7 +58,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte
|
|||||||
```tf
|
```tf
|
||||||
module "code-server" {
|
module "code-server" {
|
||||||
source = "registry.coder.com/modules/code-server/coder"
|
source = "registry.coder.com/modules/code-server/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
extensions = ["dracula-theme.theme-dracula"]
|
extensions = ["dracula-theme.theme-dracula"]
|
||||||
settings = {
|
settings = {
|
||||||
@@ -74,7 +74,7 @@ Just run code-server in the background, don't fetch it from GitHub:
|
|||||||
```tf
|
```tf
|
||||||
module "code-server" {
|
module "code-server" {
|
||||||
source = "registry.coder.com/modules/code-server/coder"
|
source = "registry.coder.com/modules/code-server/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
extensions = ["dracula-theme.theme-dracula", "ms-azuretools.vscode-docker"]
|
extensions = ["dracula-theme.theme-dracula", "ms-azuretools.vscode-docker"]
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ Just run code-server in the background, don't fetch it from GitHub:
|
|||||||
```tf
|
```tf
|
||||||
module "code-server" {
|
module "code-server" {
|
||||||
source = "registry.coder.com/modules/code-server/coder"
|
source = "registry.coder.com/modules/code-server/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
offline = true
|
offline = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ variable "display_name" {
|
|||||||
default = "code-server"
|
default = "code-server"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "slug" {
|
||||||
|
type = string
|
||||||
|
description = "The slug for the code-server application."
|
||||||
|
default = "code-server"
|
||||||
|
}
|
||||||
|
|
||||||
variable "settings" {
|
variable "settings" {
|
||||||
type = map(string)
|
type = map(string)
|
||||||
description = "A map of settings to apply to code-server."
|
description = "A map of settings to apply to code-server."
|
||||||
@@ -89,7 +95,7 @@ resource "coder_script" "code-server" {
|
|||||||
|
|
||||||
resource "coder_app" "code-server" {
|
resource "coder_app" "code-server" {
|
||||||
agent_id = var.agent_id
|
agent_id = var.agent_id
|
||||||
slug = "code-server"
|
slug = var.slug
|
||||||
display_name = var.display_name
|
display_name = var.display_name
|
||||||
url = "http://localhost:${var.port}/${var.folder != "" ? "?folder=${urlencode(var.folder)}" : ""}"
|
url = "http://localhost:${var.port}/${var.folder != "" ? "?folder=${urlencode(var.folder)}" : ""}"
|
||||||
icon = "/icon/code.svg"
|
icon = "/icon/code.svg"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ A file browser for your workspace.
|
|||||||
```tf
|
```tf
|
||||||
module "filebrowser" {
|
module "filebrowser" {
|
||||||
source = "registry.coder.com/modules/filebrowser/coder"
|
source = "registry.coder.com/modules/filebrowser/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -28,7 +28,7 @@ module "filebrowser" {
|
|||||||
```tf
|
```tf
|
||||||
module "filebrowser" {
|
module "filebrowser" {
|
||||||
source = "registry.coder.com/modules/filebrowser/coder"
|
source = "registry.coder.com/modules/filebrowser/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
folder = "/home/coder/project"
|
folder = "/home/coder/project"
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ module "filebrowser" {
|
|||||||
```tf
|
```tf
|
||||||
module "filebrowser" {
|
module "filebrowser" {
|
||||||
source = "registry.coder.com/modules/filebrowser/coder"
|
source = "registry.coder.com/modules/filebrowser/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
database_path = ".config/filebrowser.db"
|
database_path = ".config/filebrowser.db"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ This module has a chance of conflicting with the user's dotfiles / the personali
|
|||||||
```tf
|
```tf
|
||||||
module "git-commit-signing" {
|
module "git-commit-signing" {
|
||||||
source = "registry.coder.com/modules/git-commit-signing/coder"
|
source = "registry.coder.com/modules/git-commit-signing/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -14,16 +14,25 @@ This module lets you fetch all or selective secrets from a [HCP Vault Secrets](h
|
|||||||
|
|
||||||
```tf
|
```tf
|
||||||
module "vault" {
|
module "vault" {
|
||||||
source = "registry.coder.com/modules/hcp-vault-secrets/coder"
|
source = "registry.coder.com/modules/hcp-vault-secrets/coder"
|
||||||
version = "1.0.3"
|
version = "1.0.7"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
app_name = "demo-app"
|
app_name = "demo-app"
|
||||||
|
project_id = "aaa-bbb-ccc"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
To configure the HCP Vault Secrets module, you must create an HCP Service Principal from the HCP Vault Secrets app in the HCP console. This will give you the `HCP_CLIENT_ID` and `HCP_CLIENT_SECRET` that you need to authenticate with HCP Vault Secrets. See the [HCP Vault Secrets documentation](https://developer.hashicorp.com/hcp/docs/vault-secrets) for more information.
|
To configure the HCP Vault Secrets module, follow these steps,
|
||||||
|
|
||||||
|
1. [Create secrets in HCP Vault Secrets](https://developer.hashicorp.com/vault/tutorials/hcp-vault-secrets-get-started/hcp-vault-secrets-create-secret)
|
||||||
|
2. Create an HCP Service Principal from the HCP Vault Secrets app in the HCP console. This will give you the `HCP_CLIENT_ID` and `HCP_CLIENT_SECRET` that you need to authenticate with HCP Vault Secrets.
|
||||||
|

|
||||||
|
3. Set `HCP_CLIENT_ID` and `HCP_CLIENT_SECRET` variables on the coder provisioner (recommended) or supply them as input to the module.
|
||||||
|
4. Set the `project_id`. This is the ID of the project where the HCP Vault Secrets app is running.
|
||||||
|
|
||||||
|
> See the [HCP Vault Secrets documentation](https://developer.hashicorp.com/hcp/docs/vault-secrets) for more information.
|
||||||
|
|
||||||
## Fetch All Secrets
|
## Fetch All Secrets
|
||||||
|
|
||||||
@@ -31,10 +40,11 @@ To fetch all secrets from the HCP Vault Secrets app, skip the `secrets` input.
|
|||||||
|
|
||||||
```tf
|
```tf
|
||||||
module "vault" {
|
module "vault" {
|
||||||
source = "registry.coder.com/modules/hcp-vault-secrets/coder"
|
source = "registry.coder.com/modules/hcp-vault-secrets/coder"
|
||||||
version = "1.0.3"
|
version = "1.0.7"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
app_name = "demo-app"
|
app_name = "demo-app"
|
||||||
|
project_id = "aaa-bbb-ccc"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -44,11 +54,12 @@ To fetch selective secrets from the HCP Vault Secrets app, set the `secrets` inp
|
|||||||
|
|
||||||
```tf
|
```tf
|
||||||
module "vault" {
|
module "vault" {
|
||||||
source = "registry.coder.com/modules/hcp-vault-secrets/coder"
|
source = "registry.coder.com/modules/hcp-vault-secrets/coder"
|
||||||
version = "1.0.3"
|
version = "1.0.7"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
app_name = "demo-app"
|
app_name = "demo-app"
|
||||||
secrets = ["MY_SECRET_1", "MY_SECRET_2"]
|
project_id = "aaa-bbb-ccc"
|
||||||
|
secrets = ["MY_SECRET_1", "MY_SECRET_2"]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -59,9 +70,10 @@ Set `client_id` and `client_secret` as module inputs.
|
|||||||
```tf
|
```tf
|
||||||
module "vault" {
|
module "vault" {
|
||||||
source = "registry.coder.com/modules/hcp-vault-secrets/coder"
|
source = "registry.coder.com/modules/hcp-vault-secrets/coder"
|
||||||
version = "1.0.3"
|
version = "1.0.7"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
app_name = "demo-app"
|
app_name = "demo-app"
|
||||||
|
project_id = "aaa-bbb-ccc"
|
||||||
client_id = "HCP_CLIENT_ID"
|
client_id = "HCP_CLIENT_ID"
|
||||||
client_secret = "HCP_CLIENT_SECRET"
|
client_secret = "HCP_CLIENT_SECRET"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ terraform {
|
|||||||
provider "hcp" {
|
provider "hcp" {
|
||||||
client_id = var.client_id
|
client_id = var.client_id
|
||||||
client_secret = var.client_secret
|
client_secret = var.client_secret
|
||||||
|
project_id = var.project_id
|
||||||
}
|
}
|
||||||
|
|
||||||
provider "coder" {}
|
provider "coder" {}
|
||||||
@@ -25,6 +26,11 @@ variable "agent_id" {
|
|||||||
description = "The ID of a Coder agent."
|
description = "The ID of a Coder agent."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "project_id" {
|
||||||
|
type = string
|
||||||
|
description = "The ID of the HCP project."
|
||||||
|
}
|
||||||
|
|
||||||
variable "client_id" {
|
variable "client_id" {
|
||||||
type = string
|
type = string
|
||||||
description = <<-EOF
|
description = <<-EOF
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ This module adds a JetBrains Gateway Button to open any workspace with a single
|
|||||||
```tf
|
```tf
|
||||||
module "jetbrains_gateway" {
|
module "jetbrains_gateway" {
|
||||||
source = "registry.coder.com/modules/jetbrains-gateway/coder"
|
source = "registry.coder.com/modules/jetbrains-gateway/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.6"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
agent_name = "example"
|
agent_name = "example"
|
||||||
folder = "/home/coder/example"
|
folder = "/home/coder/example"
|
||||||
@@ -32,7 +32,7 @@ module "jetbrains_gateway" {
|
|||||||
```tf
|
```tf
|
||||||
module "jetbrains_gateway" {
|
module "jetbrains_gateway" {
|
||||||
source = "registry.coder.com/modules/jetbrains-gateway/coder"
|
source = "registry.coder.com/modules/jetbrains-gateway/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.6"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
agent_name = "example"
|
agent_name = "example"
|
||||||
folder = "/home/coder/example"
|
folder = "/home/coder/example"
|
||||||
|
|||||||
@@ -11,18 +11,16 @@ describe("jetbrains-gateway", async () => {
|
|||||||
await testRequiredVariables(import.meta.dir, {
|
await testRequiredVariables(import.meta.dir, {
|
||||||
agent_id: "foo",
|
agent_id: "foo",
|
||||||
agent_name: "foo",
|
agent_name: "foo",
|
||||||
folder: "/baz/",
|
folder: "/home/foo",
|
||||||
});
|
});
|
||||||
|
|
||||||
it("default to first ide", async () => {
|
it("default to first ide", async () => {
|
||||||
const state = await runTerraformApply(import.meta.dir, {
|
const state = await runTerraformApply(import.meta.dir, {
|
||||||
agent_id: "foo",
|
agent_id: "foo",
|
||||||
agent_name: "foo",
|
agent_name: "foo",
|
||||||
folder: "/baz/",
|
folder: "/home/foo",
|
||||||
jetbrains_ides: '["IU", "GO", "PY"]',
|
jetbrains_ides: '["IU", "GO", "PY"]',
|
||||||
});
|
});
|
||||||
expect(state.outputs.jetbrains_ides.value).toBe(
|
expect(state.outputs.identifier.value).toBe("IU");
|
||||||
'["IU","232.10203.10","https://download.jetbrains.com/idea/ideaIU-2023.2.4.tar.gz"]',
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ variable "agent_name" {
|
|||||||
variable "folder" {
|
variable "folder" {
|
||||||
type = string
|
type = string
|
||||||
description = "The directory to open in the IDE. e.g. /home/coder/project"
|
description = "The directory to open in the IDE. e.g. /home/coder/project"
|
||||||
|
validation {
|
||||||
|
condition = can(regex("^(?:/[^/]+)+$", var.folder))
|
||||||
|
error_message = "The folder must be a full path and must not start with a ~."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "default" {
|
variable "default" {
|
||||||
@@ -30,10 +34,6 @@ variable "default" {
|
|||||||
description = "Default IDE"
|
description = "Default IDE"
|
||||||
}
|
}
|
||||||
|
|
||||||
locals {
|
|
||||||
supported_ides = ["IU", "PS", "WS", "PY", "CL", "GO", "RM"]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "jetbrains_ide_versions" {
|
variable "jetbrains_ide_versions" {
|
||||||
type = map(object({
|
type = map(object({
|
||||||
build_number = string
|
build_number = string
|
||||||
@@ -69,29 +69,28 @@ variable "jetbrains_ide_versions" {
|
|||||||
build_number = "232.10203.15"
|
build_number = "232.10203.15"
|
||||||
version = "2023.2.4"
|
version = "2023.2.4"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
validation {
|
validation {
|
||||||
condition = (
|
condition = (
|
||||||
alltrue([
|
alltrue([
|
||||||
for code in var.jetbrains_ide_versions : contains(local.supported_ides, code)
|
for code in keys(var.jetbrains_ide_versions) : contains(["IU", "PS", "WS", "PY", "CL", "GO", "RM"], code)
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
error_message = "The jetbrains_ide_versions must contain a map of valid product codes. Valid product codes are ${join(",", local.supported_ides)}."
|
error_message = "The jetbrains_ide_versions must contain a map of valid product codes. Valid product codes are ${join(",", ["IU", "PS", "WS", "PY", "CL", "GO", "RM"])}."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "jetbrains_ides" {
|
variable "jetbrains_ides" {
|
||||||
type = list(string)
|
type = list(string)
|
||||||
description = "The list of IDE product codes."
|
description = "The list of IDE product codes."
|
||||||
default = local.supported_ides
|
default = ["IU", "PS", "WS", "PY", "CL", "GO", "RM"]
|
||||||
validation {
|
validation {
|
||||||
condition = (
|
condition = (
|
||||||
alltrue([
|
alltrue([
|
||||||
for code in var.jetbrains_ides : contains(local.supported_ides, code)
|
for code in var.jetbrains_ides : contains(["IU", "PS", "WS", "PY", "CL", "GO", "RM"], code)
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
error_message = "The jetbrains_ides must be a list of valid product codes. Valid product codes are ${join(",", local.supported_ides)}."
|
error_message = "The jetbrains_ides must be a list of valid product codes. Valid product codes are ${join(",", ["IU", "PS", "WS", "PY", "CL", "GO", "RM"])}."
|
||||||
}
|
}
|
||||||
# check if the list is empty
|
# check if the list is empty
|
||||||
validation {
|
validation {
|
||||||
@@ -108,58 +107,71 @@ variable "jetbrains_ides" {
|
|||||||
locals {
|
locals {
|
||||||
jetbrains_ides = {
|
jetbrains_ides = {
|
||||||
"GO" = {
|
"GO" = {
|
||||||
icon = "/icon/goland.svg",
|
icon = "/icon/goland.svg",
|
||||||
name = "GoLand",
|
name = "GoLand",
|
||||||
value = jsonencode(["GO", var.jetbrains_ide_versions["GO"].build_number, "https://download.jetbrains.com/go/goland-${var.jetbrains_ide_versions["GO"].version}.tar.gz"])
|
identifier = "GO",
|
||||||
|
build_number = var.jetbrains_ide_versions["GO"].build_number,
|
||||||
|
download_link = "https://download.jetbrains.com/go/goland-${var.jetbrains_ide_versions["GO"].version}.tar.gz"
|
||||||
},
|
},
|
||||||
"WS" = {
|
"WS" = {
|
||||||
icon = "/icon/webstorm.svg",
|
icon = "/icon/webstorm.svg",
|
||||||
name = "WebStorm",
|
name = "WebStorm",
|
||||||
value = jsonencode(["WS", var.jetbrains_ide_versions["WS"].build_number, "https://download.jetbrains.com/webstorm/WebStorm-${var.jetbrains_ide_versions["WS"].version}.tar.gz"])
|
identifier = "WS",
|
||||||
|
build_number = var.jetbrains_ide_versions["WS"].build_number,
|
||||||
|
download_link = "https://download.jetbrains.com/webstorm/WebStorm-${var.jetbrains_ide_versions["WS"].version}.tar.gz"
|
||||||
},
|
},
|
||||||
"IU" = {
|
"IU" = {
|
||||||
icon = "/icon/intellij.svg",
|
icon = "/icon/intellij.svg",
|
||||||
name = "IntelliJ IDEA Ultimate",
|
name = "IntelliJ IDEA Ultimate",
|
||||||
value = jsonencode(["IU", var.jetbrains_ide_versions["IU"].build_number, "https://download.jetbrains.com/idea/ideaIU-${var.jetbrains_ide_versions["IU"].version}.tar.gz"])
|
identifier = "IU",
|
||||||
|
build_number = var.jetbrains_ide_versions["IU"].build_number,
|
||||||
|
download_link = "https://download.jetbrains.com/idea/ideaIU-${var.jetbrains_ide_versions["IU"].version}.tar.gz"
|
||||||
},
|
},
|
||||||
"PY" = {
|
"PY" = {
|
||||||
icon = "/icon/pycharm.svg",
|
icon = "/icon/pycharm.svg",
|
||||||
name = "PyCharm Professional",
|
name = "PyCharm Professional",
|
||||||
value = jsonencode(["PY", var.jetbrains_ide_versions["PY"].build_number, "https://download.jetbrains.com/python/pycharm-professional-${var.jetbrains_ide_versions["PY"].version}.tar.gz"])
|
identifier = "PY",
|
||||||
|
build_number = var.jetbrains_ide_versions["PY"].build_number,
|
||||||
|
download_link = "https://download.jetbrains.com/python/pycharm-professional-${var.jetbrains_ide_versions["PY"].version}.tar.gz"
|
||||||
},
|
},
|
||||||
"CL" = {
|
"CL" = {
|
||||||
icon = "/icon/clion.svg",
|
icon = "/icon/clion.svg",
|
||||||
name = "CLion",
|
name = "CLion",
|
||||||
value = jsonencode(["CL", var.jetbrains_ide_versions["CL"].build_number, "https://download.jetbrains.com/cpp/CLion-${var.jetbrains_ide_versions["CL"].version}.tar.gz"])
|
identifier = "CL",
|
||||||
|
build_number = var.jetbrains_ide_versions["CL"].build_number,
|
||||||
|
download_link = "https://download.jetbrains.com/cpp/CLion-${var.jetbrains_ide_versions["CL"].version}.tar.gz"
|
||||||
},
|
},
|
||||||
"PS" = {
|
"PS" = {
|
||||||
icon = "/icon/phpstorm.svg",
|
icon = "/icon/phpstorm.svg",
|
||||||
name = "PhpStorm",
|
name = "PhpStorm",
|
||||||
value = jsonencode(["PS", var.jetbrains_ide_versions["PS"].build_number, "https://download.jetbrains.com/webide/PhpStorm-${var.jetbrains_ide_versions["PS"].version}.tar.gz"])
|
identifier = "PS",
|
||||||
|
build_number = var.jetbrains_ide_versions["PS"].build_number,
|
||||||
|
download_link = "https://download.jetbrains.com/webide/PhpStorm-${var.jetbrains_ide_versions["PS"].version}.tar.gz"
|
||||||
},
|
},
|
||||||
"RM" = {
|
"RM" = {
|
||||||
icon = "/icon/rubymine.svg",
|
icon = "/icon/rubymine.svg",
|
||||||
name = "RubyMine",
|
name = "RubyMine",
|
||||||
value = jsonencode(["RM", var.jetbrains_ide_versions["RM"].build_number, "https://download.jetbrains.com/ruby/RubyMine-${var.jetbrains_ide_versions["RM"].version}.tar.gz"])
|
identifier = "RM",
|
||||||
|
build_number = var.jetbrains_ide_versions["RM"].build_number,
|
||||||
|
download_link = "https://download.jetbrains.com/ruby/RubyMine-${var.jetbrains_ide_versions["RM"].version}.tar.gz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data "coder_parameter" "jetbrains_ide" {
|
data "coder_parameter" "jetbrains_ide" {
|
||||||
type = "list(string)"
|
type = "string"
|
||||||
name = "jetbrains_ide"
|
name = "jetbrains_ide"
|
||||||
display_name = "JetBrains IDE"
|
display_name = "JetBrains IDE"
|
||||||
icon = "/icon/gateway.svg"
|
icon = "/icon/gateway.svg"
|
||||||
mutable = true
|
mutable = true
|
||||||
# check if default is in the jet_brains_ides list and if it is not empty or null otherwise set it to null
|
default = var.default == "" ? var.jetbrains_ides[0] : var.default
|
||||||
default = var.default != null && var.default != "" && contains(var.jetbrains_ides, var.default) ? local.jetbrains_ides[var.default].value : local.jetbrains_ides[var.jetbrains_ides[0]].value
|
|
||||||
|
|
||||||
dynamic "option" {
|
dynamic "option" {
|
||||||
for_each = { for key, value in local.jetbrains_ides : key => value if contains(var.jetbrains_ides, key) }
|
for_each = var.jetbrains_ides
|
||||||
content {
|
content {
|
||||||
icon = option.value.icon
|
icon = lookup(local.jetbrains_ides, option.value).icon
|
||||||
name = option.value.name
|
name = lookup(local.jetbrains_ides, option.value).name
|
||||||
value = option.value.value
|
value = lookup(local.jetbrains_ides, option.value).identifier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,9 +180,9 @@ data "coder_workspace" "me" {}
|
|||||||
|
|
||||||
resource "coder_app" "gateway" {
|
resource "coder_app" "gateway" {
|
||||||
agent_id = var.agent_id
|
agent_id = var.agent_id
|
||||||
display_name = data.coder_parameter.jetbrains_ide.option[index(data.coder_parameter.jetbrains_ide.option.*.value, data.coder_parameter.jetbrains_ide.value)].name
|
|
||||||
slug = "gateway"
|
slug = "gateway"
|
||||||
icon = data.coder_parameter.jetbrains_ide.option[index(data.coder_parameter.jetbrains_ide.option.*.value, data.coder_parameter.jetbrains_ide.value)].icon
|
display_name = try(lookup(local.jetbrains_ides, data.coder_parameter.jetbrains_ide.value).name, "JetBrains IDE")
|
||||||
|
icon = try(lookup(local.jetbrains_ides, data.coder_parameter.jetbrains_ide.value).icon, "/icon/gateway.svg")
|
||||||
external = true
|
external = true
|
||||||
url = join("", [
|
url = join("", [
|
||||||
"jetbrains-gateway://connect#type=coder&workspace=",
|
"jetbrains-gateway://connect#type=coder&workspace=",
|
||||||
@@ -184,14 +196,38 @@ resource "coder_app" "gateway" {
|
|||||||
"&token=",
|
"&token=",
|
||||||
"$SESSION_TOKEN",
|
"$SESSION_TOKEN",
|
||||||
"&ide_product_code=",
|
"&ide_product_code=",
|
||||||
jsondecode(data.coder_parameter.jetbrains_ide.value)[0],
|
local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].identifier,
|
||||||
"&ide_build_number=",
|
"&ide_build_number=",
|
||||||
jsondecode(data.coder_parameter.jetbrains_ide.value)[1],
|
local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].build_number,
|
||||||
"&ide_download_link=",
|
"&ide_download_link=",
|
||||||
jsondecode(data.coder_parameter.jetbrains_ide.value)[2],
|
local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].download_link
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
output "jetbrains_ides" {
|
output "identifier" {
|
||||||
value = data.coder_parameter.jetbrains_ide.value
|
value = data.coder_parameter.jetbrains_ide.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "name" {
|
||||||
|
value = coder_app.gateway.display_name
|
||||||
|
}
|
||||||
|
|
||||||
|
output "icon" {
|
||||||
|
value = coder_app.gateway.icon
|
||||||
|
}
|
||||||
|
|
||||||
|
output "download_link" {
|
||||||
|
value = lookup(local.jetbrains_ides, data.coder_parameter.jetbrains_ide.value).download_link
|
||||||
|
}
|
||||||
|
|
||||||
|
output "build_number" {
|
||||||
|
value = lookup(local.jetbrains_ides, data.coder_parameter.jetbrains_ide.value).build_number
|
||||||
|
}
|
||||||
|
|
||||||
|
output "version" {
|
||||||
|
value = var.jetbrains_ide_versions[data.coder_parameter.jetbrains_ide.value].version
|
||||||
|
}
|
||||||
|
|
||||||
|
output "url" {
|
||||||
|
value = coder_app.gateway.url
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ Install the JF CLI and authenticate package managers with Artifactory using OAut
|
|||||||
```tf
|
```tf
|
||||||
module "jfrog" {
|
module "jfrog" {
|
||||||
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
jfrog_url = "https://example.jfrog.io"
|
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"
|
||||||
@@ -44,7 +44,7 @@ Configure the Python pip package manager to fetch packages from Artifactory whil
|
|||||||
```tf
|
```tf
|
||||||
module "jfrog" {
|
module "jfrog" {
|
||||||
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
jfrog_url = "https://example.jfrog.io"
|
jfrog_url = "https://example.jfrog.io"
|
||||||
username_field = "email"
|
username_field = "email"
|
||||||
@@ -72,7 +72,7 @@ The [JFrog extension](https://open-vsx.org/extension/JFrog/jfrog-vscode-extensio
|
|||||||
```tf
|
```tf
|
||||||
module "jfrog" {
|
module "jfrog" {
|
||||||
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
source = "registry.coder.com/modules/jfrog-oauth/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
jfrog_url = "https://example.jfrog.io"
|
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"
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ variable "jfrog_url" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "jfrog_server_id" {
|
||||||
|
type = string
|
||||||
|
description = "The server ID of the JFrog instance for JFrog CLI configuration"
|
||||||
|
default = "0"
|
||||||
|
}
|
||||||
|
|
||||||
variable "username_field" {
|
variable "username_field" {
|
||||||
type = string
|
type = string
|
||||||
description = "The field to use for the artifactory username. i.e. Coder username or email."
|
description = "The field to use for the artifactory username. i.e. Coder username or email."
|
||||||
@@ -79,6 +85,7 @@ resource "coder_script" "jfrog" {
|
|||||||
script = templatefile("${path.module}/run.sh", {
|
script = templatefile("${path.module}/run.sh", {
|
||||||
JFROG_URL : var.jfrog_url,
|
JFROG_URL : var.jfrog_url,
|
||||||
JFROG_HOST : local.jfrog_host,
|
JFROG_HOST : local.jfrog_host,
|
||||||
|
JFROG_SERVER_ID : var.jfrog_server_id,
|
||||||
ARTIFACTORY_USERNAME : local.username,
|
ARTIFACTORY_USERNAME : local.username,
|
||||||
ARTIFACTORY_EMAIL : data.coder_workspace.me.owner_email,
|
ARTIFACTORY_EMAIL : data.coder_workspace.me.owner_email,
|
||||||
ARTIFACTORY_ACCESS_TOKEN : data.coder_external_auth.jfrog.access_token,
|
ARTIFACTORY_ACCESS_TOKEN : data.coder_external_auth.jfrog.access_token,
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ fi
|
|||||||
# flows.
|
# flows.
|
||||||
export CI=true
|
export CI=true
|
||||||
# Authenticate JFrog CLI with Artifactory.
|
# Authenticate JFrog CLI with Artifactory.
|
||||||
echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite 0
|
echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite "${JFROG_SERVER_ID}"
|
||||||
# Set the configured server as the default.
|
# Set the configured server as the default.
|
||||||
jf c use 0
|
jf c use "${JFROG_SERVER_ID}"
|
||||||
|
|
||||||
# Configure npm to use the Artifactory "npm" repository.
|
# Configure npm to use the Artifactory "npm" repository.
|
||||||
if [ -z "${REPOSITORY_NPM}" ]; then
|
if [ -z "${REPOSITORY_NPM}" ]; then
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Install the JF CLI and authenticate package managers with Artifactory using Arti
|
|||||||
```tf
|
```tf
|
||||||
module "jfrog" {
|
module "jfrog" {
|
||||||
source = "registry.coder.com/modules/jfrog-token/coder"
|
source = "registry.coder.com/modules/jfrog-token/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
jfrog_url = "https://XXXX.jfrog.io"
|
jfrog_url = "https://XXXX.jfrog.io"
|
||||||
artifactory_access_token = var.artifactory_access_token
|
artifactory_access_token = var.artifactory_access_token
|
||||||
@@ -41,7 +41,7 @@ For detailed instructions, please see this [guide](https://coder.com/docs/v2/lat
|
|||||||
```tf
|
```tf
|
||||||
module "jfrog" {
|
module "jfrog" {
|
||||||
source = "registry.coder.com/modules/jfrog-token/coder"
|
source = "registry.coder.com/modules/jfrog-token/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
jfrog_url = "https://YYYY.jfrog.io"
|
jfrog_url = "https://YYYY.jfrog.io"
|
||||||
artifactory_access_token = var.artifactory_access_token # An admin access token
|
artifactory_access_token = var.artifactory_access_token # An admin access token
|
||||||
@@ -74,7 +74,7 @@ The [JFrog extension](https://open-vsx.org/extension/JFrog/jfrog-vscode-extensio
|
|||||||
```tf
|
```tf
|
||||||
module "jfrog" {
|
module "jfrog" {
|
||||||
source = "registry.coder.com/modules/jfrog-token/coder"
|
source = "registry.coder.com/modules/jfrog-token/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.5"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
jfrog_url = "https://XXXX.jfrog.io"
|
jfrog_url = "https://XXXX.jfrog.io"
|
||||||
artifactory_access_token = var.artifactory_access_token
|
artifactory_access_token = var.artifactory_access_token
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ variable "jfrog_url" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "jfrog_server_id" {
|
||||||
|
type = string
|
||||||
|
description = "The server ID of the JFrog instance for JFrog CLI configuration"
|
||||||
|
default = "0"
|
||||||
|
}
|
||||||
|
|
||||||
variable "artifactory_access_token" {
|
variable "artifactory_access_token" {
|
||||||
type = string
|
type = string
|
||||||
description = "The admin-level access token to use for JFrog."
|
description = "The admin-level access token to use for JFrog."
|
||||||
@@ -112,6 +118,7 @@ resource "coder_script" "jfrog" {
|
|||||||
script = templatefile("${path.module}/run.sh", {
|
script = templatefile("${path.module}/run.sh", {
|
||||||
JFROG_URL : var.jfrog_url,
|
JFROG_URL : var.jfrog_url,
|
||||||
JFROG_HOST : local.jfrog_host,
|
JFROG_HOST : local.jfrog_host,
|
||||||
|
JFROG_SERVER_ID : var.jfrog_server_id,
|
||||||
ARTIFACTORY_USERNAME : local.username,
|
ARTIFACTORY_USERNAME : local.username,
|
||||||
ARTIFACTORY_EMAIL : data.coder_workspace.me.owner_email,
|
ARTIFACTORY_EMAIL : data.coder_workspace.me.owner_email,
|
||||||
ARTIFACTORY_ACCESS_TOKEN : artifactory_scoped_token.me.access_token,
|
ARTIFACTORY_ACCESS_TOKEN : artifactory_scoped_token.me.access_token,
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ fi
|
|||||||
# flows.
|
# flows.
|
||||||
export CI=true
|
export CI=true
|
||||||
# Authenticate JFrog CLI with Artifactory.
|
# Authenticate JFrog CLI with Artifactory.
|
||||||
echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite 0
|
echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite "${JFROG_SERVER_ID}"
|
||||||
# Set the configured server as the default.
|
# Set the configured server as the default.
|
||||||
jf c use 0
|
jf c use "${JFROG_SERVER_ID}"
|
||||||
|
|
||||||
# Configure npm to use the Artifactory "npm" repository.
|
# Configure npm to use the Artifactory "npm" repository.
|
||||||
if [ -z "${REPOSITORY_NPM}" ]; then
|
if [ -z "${REPOSITORY_NPM}" ]; then
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
"test": "bun test",
|
"test": "bun test",
|
||||||
"fmt": "bun x prettier -w **/*.sh .sample/run.sh new.sh **/*.ts **/*.md *.md && terraform fmt **/*.tf .sample/main.tf",
|
"fmt": "bun x prettier -w **/*.sh .sample/run.sh new.sh **/*.ts **/*.md *.md && terraform fmt **/*.tf .sample/main.tf",
|
||||||
"fmt:ci": "bun x prettier --check **/*.sh .sample/run.sh new.sh **/*.ts **/*.md *.md && terraform fmt -check **/*.tf .sample/main.tf",
|
"fmt:ci": "bun x prettier --check **/*.sh .sample/run.sh new.sh **/*.ts **/*.md *.md && terraform fmt -check **/*.tf .sample/main.tf",
|
||||||
"lint": "bun run lint.ts",
|
"lint": "bun run lint.ts && ./terraform_validate.sh",
|
||||||
"update-version": "./update-version.sh"
|
"update-version": "./update-version.sh"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bun-types": "^1.0.18",
|
"bun-types": "^1.0.18",
|
||||||
"gray-matter": "^4.0.3",
|
"gray-matter": "^4.0.3",
|
||||||
"marked": "^11.1.0",
|
"marked": "^12.0.0",
|
||||||
"prettier-plugin-sh": "^0.13.1",
|
"prettier-plugin-sh": "^0.13.1",
|
||||||
"prettier-plugin-terraform-formatter": "^1.2.1"
|
"prettier-plugin-terraform-formatter": "^1.2.1"
|
||||||
},
|
},
|
||||||
|
|||||||
29
terraform_validate.sh
Executable file
29
terraform_validate.sh
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Function to run terraform init and validate in a directory
|
||||||
|
run_terraform() {
|
||||||
|
local dir="$1"
|
||||||
|
echo "Running terraform init and validate in $dir"
|
||||||
|
pushd "$dir"
|
||||||
|
terraform init -upgrade
|
||||||
|
terraform validate
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main script
|
||||||
|
main() {
|
||||||
|
# Get the directory of the script
|
||||||
|
script_dir=$(dirname "$(readlink -f "$0")")
|
||||||
|
|
||||||
|
# Get all subdirectories in the repository
|
||||||
|
subdirs=$(find "$script_dir" -mindepth 1 -maxdepth 1 -type d -not -name ".*" | sort)
|
||||||
|
|
||||||
|
for dir in $subdirs; do
|
||||||
|
run_terraform "$dir"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run the main script
|
||||||
|
main
|
||||||
@@ -8,14 +8,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
current_tag=$(git describe --tags --abbrev=0)
|
current_tag=$(git describe --tags --abbrev=0)
|
||||||
previous_tag=$(git describe --tags --abbrev=0 $current_tag^)
|
previous_tag=$(git describe --tags --abbrev=0 $current_tag^)
|
||||||
mapfile -t changed_files < <(git diff --name-only "$previous_tag" "$current_tag" | xargs dirname | sort -u | grep -v '^\.')
|
mapfile -t changed_dirs < <(git diff --name-only "$previous_tag"..."$current_tag" -- ':!**/README.md' ':!**/*.test.ts' | xargs dirname | grep -v '^\.' | sort -u)
|
||||||
|
|
||||||
changed_dirs=()
|
|
||||||
for file in $changed_files; do
|
|
||||||
dir=$(dirname "$file")
|
|
||||||
changed_dirs+=("$dir")
|
|
||||||
done
|
|
||||||
changed_dirs=($(printf "%s\n" "${changed_dirs[@]}" | sort -u))
|
|
||||||
|
|
||||||
LATEST_TAG=$(git describe --abbrev=0 --tags | sed 's/^v//') || exit $?
|
LATEST_TAG=$(git describe --abbrev=0 --tags | sed 's/^v//') || exit $?
|
||||||
|
|
||||||
@@ -33,4 +26,4 @@ for dir in "${changed_dirs[@]}"; do
|
|||||||
}
|
}
|
||||||
}' "$file" > "$tmpfile" && mv "$tmpfile" "$file"
|
}' "$file" > "$tmpfile" && mv "$tmpfile" "$file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ This module lets you authenticate with [Hashicorp Vault](https://www.vaultprojec
|
|||||||
```tf
|
```tf
|
||||||
module "vault" {
|
module "vault" {
|
||||||
source = "registry.coder.com/modules/vault-github/coder"
|
source = "registry.coder.com/modules/vault-github/coder"
|
||||||
version = "1.0.3"
|
version = "1.0.7"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
vault_addr = "https://vault.example.com"
|
vault_addr = "https://vault.example.com"
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ To configure the Vault module, you must set up a Vault GitHub auth method. See t
|
|||||||
```tf
|
```tf
|
||||||
module "vault" {
|
module "vault" {
|
||||||
source = "registry.coder.com/modules/vault-github/coder"
|
source = "registry.coder.com/modules/vault-github/coder"
|
||||||
version = "1.0.3"
|
version = "1.0.7"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
vault_addr = "https://vault.example.com"
|
vault_addr = "https://vault.example.com"
|
||||||
coder_github_auth_id = "my-github-auth-id"
|
coder_github_auth_id = "my-github-auth-id"
|
||||||
@@ -58,7 +58,7 @@ module "vault" {
|
|||||||
```tf
|
```tf
|
||||||
module "vault" {
|
module "vault" {
|
||||||
source = "registry.coder.com/modules/vault-github/coder"
|
source = "registry.coder.com/modules/vault-github/coder"
|
||||||
version = "1.0.3"
|
version = "1.0.7"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
vault_addr = "https://vault.example.com"
|
vault_addr = "https://vault.example.com"
|
||||||
coder_github_auth_id = "my-github-auth-id"
|
coder_github_auth_id = "my-github-auth-id"
|
||||||
@@ -71,7 +71,7 @@ module "vault" {
|
|||||||
```tf
|
```tf
|
||||||
module "vault" {
|
module "vault" {
|
||||||
source = "registry.coder.com/modules/vault-github/coder"
|
source = "registry.coder.com/modules/vault-github/coder"
|
||||||
version = "1.0.3"
|
version = "1.0.7"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
vault_addr = "https://vault.example.com"
|
vault_addr = "https://vault.example.com"
|
||||||
vault_cli_version = "1.15.0"
|
vault_cli_version = "1.15.0"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { describe } from "bun:test";
|
import { describe } from "bun:test";
|
||||||
import { runTerraformInit, testRequiredVariables } from "../test";
|
import { runTerraformInit, testRequiredVariables } from "../test";
|
||||||
|
|
||||||
describe("vault-token", async () => {
|
describe("vault-github", async () => {
|
||||||
await runTerraformInit(import.meta.dir);
|
await runTerraformInit(import.meta.dir);
|
||||||
|
|
||||||
testRequiredVariables(import.meta.dir, {
|
testRequiredVariables(import.meta.dir, {
|
||||||
|
|||||||
@@ -32,9 +32,19 @@ unzip_safe() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
|
# Get the architecture of the system
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
if [ "$${ARCH}" = "x86_64" ]; then
|
||||||
|
ARCH="amd64"
|
||||||
|
elif [ "$${ARCH}" = "aarch64" ]; then
|
||||||
|
ARCH="arm64"
|
||||||
|
else
|
||||||
|
printf "Unsupported architecture: $${ARCH}\n"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
# Fetch the latest version of Vault if INSTALL_VERSION is 'latest'
|
# Fetch the latest version of Vault if INSTALL_VERSION is 'latest'
|
||||||
if [ "$${INSTALL_VERSION}" = "latest" ]; then
|
if [ "$${INSTALL_VERSION}" = "latest" ]; then
|
||||||
LATEST_VERSION=$(curl -s https://releases.hashicorp.com/vault/ | grep -oP 'vault/\K[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1)
|
LATEST_VERSION=$(curl -s https://releases.hashicorp.com/vault/ | grep -v 'rc' | grep -oE 'vault/[0-9]+\.[0-9]+\.[0-9]+' | sed 's/vault\///' | sort -V | tail -n 1)
|
||||||
printf "Latest version of Vault is %s.\n\n" "$${LATEST_VERSION}"
|
printf "Latest version of Vault is %s.\n\n" "$${LATEST_VERSION}"
|
||||||
if [ -z "$${LATEST_VERSION}" ]; then
|
if [ -z "$${LATEST_VERSION}" ]; then
|
||||||
printf "Failed to determine the latest Vault version.\n"
|
printf "Failed to determine the latest Vault version.\n"
|
||||||
@@ -60,7 +70,7 @@ install() {
|
|||||||
else
|
else
|
||||||
printf "Upgrading Vault CLI from version %s to %s ...\n\n" "$${CURRENT_VERSION}" "${INSTALL_VERSION}"
|
printf "Upgrading Vault CLI from version %s to %s ...\n\n" "$${CURRENT_VERSION}" "${INSTALL_VERSION}"
|
||||||
fi
|
fi
|
||||||
fetch vault.zip "https://releases.hashicorp.com/vault/$${INSTALL_VERSION}/vault_$${INSTALL_VERSION}_linux_amd64.zip"
|
fetch vault.zip "https://releases.hashicorp.com/vault/$${INSTALL_VERSION}/vault_$${INSTALL_VERSION}_linux_$${ARCH}.zip"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
printf "Failed to download Vault.\n"
|
printf "Failed to download Vault.\n"
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ variable "vault_token" {
|
|||||||
|
|
||||||
module "vault" {
|
module "vault" {
|
||||||
source = "registry.coder.com/modules/vault-token/coder"
|
source = "registry.coder.com/modules/vault-token/coder"
|
||||||
version = "1.0.3"
|
version = "1.0.7"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
vault_token = var.token
|
vault_token = var.token
|
||||||
vault_addr = "https://vault.example.com"
|
vault_addr = "https://vault.example.com"
|
||||||
@@ -74,7 +74,7 @@ variable "vault_token" {
|
|||||||
|
|
||||||
module "vault" {
|
module "vault" {
|
||||||
source = "registry.coder.com/modules/vault-token/coder"
|
source = "registry.coder.com/modules/vault-token/coder"
|
||||||
version = "1.0.3"
|
version = "1.0.7"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
vault_addr = "https://vault.example.com"
|
vault_addr = "https://vault.example.com"
|
||||||
vault_token = var.token
|
vault_token = var.token
|
||||||
|
|||||||
@@ -30,9 +30,19 @@ unzip_safe() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
|
# Get the architecture of the system
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
if [ "$${ARCH}" = "x86_64" ]; then
|
||||||
|
ARCH="amd64"
|
||||||
|
elif [ "$${ARCH}" = "aarch64" ]; then
|
||||||
|
ARCH="arm64"
|
||||||
|
else
|
||||||
|
printf "Unsupported architecture: $${ARCH}\n"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
# Fetch the latest version of Vault if INSTALL_VERSION is 'latest'
|
# Fetch the latest version of Vault if INSTALL_VERSION is 'latest'
|
||||||
if [ "$${INSTALL_VERSION}" = "latest" ]; then
|
if [ "$${INSTALL_VERSION}" = "latest" ]; then
|
||||||
LATEST_VERSION=$(curl -s https://releases.hashicorp.com/vault/ | grep -oP 'vault/\K[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1)
|
LATEST_VERSION=$(curl -s https://releases.hashicorp.com/vault/ | grep -v 'rc' | grep -oE 'vault/[0-9]+\.[0-9]+\.[0-9]+' | sed 's/vault\///' | sort -V | tail -n 1)
|
||||||
printf "Latest version of Vault is %s.\n\n" "$${LATEST_VERSION}"
|
printf "Latest version of Vault is %s.\n\n" "$${LATEST_VERSION}"
|
||||||
if [ -z "$${LATEST_VERSION}" ]; then
|
if [ -z "$${LATEST_VERSION}" ]; then
|
||||||
printf "Failed to determine the latest Vault version.\n"
|
printf "Failed to determine the latest Vault version.\n"
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ tags: [helper, ide, vscode, web]
|
|||||||
|
|
||||||
# VS Code Web
|
# VS Code Web
|
||||||
|
|
||||||
Automatically install [Visual Studio Code Server](https://code.visualstudio.com/docs/remote/vscode-server) in a workspace using the [VS Code CLI](https://code.visualstudio.com/docs/editor/command-line) and create an app to access it via the dashboard.
|
Automatically install [Visual Studio Code Server](https://code.visualstudio.com/docs/remote/vscode-server) in a workspace and create an app to access it via the dashboard.
|
||||||
|
|
||||||
```tf
|
```tf
|
||||||
module "vscode-web" {
|
module "vscode-web" {
|
||||||
source = "registry.coder.com/modules/vscode-web/coder"
|
source = "registry.coder.com/modules/vscode-web/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.6"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
accept_license = true
|
accept_license = true
|
||||||
}
|
}
|
||||||
@@ -29,10 +29,22 @@ module "vscode-web" {
|
|||||||
```tf
|
```tf
|
||||||
module "vscode-web" {
|
module "vscode-web" {
|
||||||
source = "registry.coder.com/modules/vscode-web/coder"
|
source = "registry.coder.com/modules/vscode-web/coder"
|
||||||
version = "1.0.2"
|
version = "1.0.6"
|
||||||
agent_id = coder_agent.example.id
|
agent_id = coder_agent.example.id
|
||||||
install_dir = "/home/coder/.vscode-web"
|
install_prefix = "/home/coder/.vscode-web"
|
||||||
folder = "/home/coder"
|
folder = "/home/coder"
|
||||||
accept_license = true
|
accept_license = true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Install Extensions
|
||||||
|
|
||||||
|
```tf
|
||||||
|
module "vscode-web" {
|
||||||
|
source = "registry.coder.com/modules/vscode-web/coder"
|
||||||
|
version = "1.0.6"
|
||||||
|
agent_id = coder_agent.example.id
|
||||||
|
extensions = ["github.copilot", "ms-python.python", "ms-toolsai.jupyter"]
|
||||||
|
accept_license = true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
import { describe, expect, it } from "bun:test";
|
|
||||||
import {
|
|
||||||
executeScriptInContainer,
|
|
||||||
runTerraformApply,
|
|
||||||
runTerraformInit,
|
|
||||||
} from "../test";
|
|
||||||
|
|
||||||
describe("vscode-web", async () => {
|
|
||||||
await runTerraformInit(import.meta.dir);
|
|
||||||
|
|
||||||
// replaces testRequiredVariables due to license variable
|
|
||||||
// may add a testRequiredVariablesWithLicense function later
|
|
||||||
it("missing agent_id", async () => {
|
|
||||||
try {
|
|
||||||
await runTerraformApply(import.meta.dir, {
|
|
||||||
accept_license: "true",
|
|
||||||
});
|
|
||||||
} catch (ex) {
|
|
||||||
expect(ex.message).toContain('input variable "agent_id" is not set');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("invalid license_agreement", async () => {
|
|
||||||
try {
|
|
||||||
await runTerraformApply(import.meta.dir, {
|
|
||||||
agent_id: "foo",
|
|
||||||
});
|
|
||||||
} catch (ex) {
|
|
||||||
expect(ex.message).toContain(
|
|
||||||
"You must accept the VS Code license agreement by setting accept_license=true",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("fails without curl", async () => {
|
|
||||||
const state = await runTerraformApply(import.meta.dir, {
|
|
||||||
agent_id: "foo",
|
|
||||||
accept_license: "true",
|
|
||||||
});
|
|
||||||
const output = await executeScriptInContainer(state, "alpine");
|
|
||||||
expect(output.exitCode).toBe(1);
|
|
||||||
expect(output.stdout).toEqual([
|
|
||||||
"\u001b[0;1mInstalling vscode-cli!",
|
|
||||||
"Failed to install vscode-cli:", // TODO: manually test error log
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("runs with curl", async () => {
|
|
||||||
const state = await runTerraformApply(import.meta.dir, {
|
|
||||||
agent_id: "foo",
|
|
||||||
accept_license: "true",
|
|
||||||
});
|
|
||||||
const output = await executeScriptInContainer(state, "alpine/curl");
|
|
||||||
expect(output.exitCode).toBe(0);
|
|
||||||
expect(output.stdout).toEqual([
|
|
||||||
"\u001b[0;1mInstalling vscode-cli!",
|
|
||||||
"🥳 vscode-cli has been installed.",
|
|
||||||
"",
|
|
||||||
"👷 Running /tmp/vscode-cli/bin/code serve-web --port 13338 --without-connection-token --accept-server-license-terms in the background...",
|
|
||||||
"Check logs at /tmp/vscode-web.log!",
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -53,15 +53,21 @@ variable "log_path" {
|
|||||||
default = "/tmp/vscode-web.log"
|
default = "/tmp/vscode-web.log"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "install_dir" {
|
variable "install_prefix" {
|
||||||
type = string
|
type = string
|
||||||
description = "The directory to install VS Code CLI"
|
description = "The prefix to install vscode-web to."
|
||||||
default = "/tmp/vscode-cli"
|
default = "/tmp/vscode-web"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "extensions" {
|
||||||
|
type = list(string)
|
||||||
|
description = "A list of extensions to install."
|
||||||
|
default = []
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "accept_license" {
|
variable "accept_license" {
|
||||||
type = bool
|
type = bool
|
||||||
description = "Accept the VS Code license. https://code.visualstudio.com/license"
|
description = "Accept the VS Code Server license. https://code.visualstudio.com/license/server"
|
||||||
default = false
|
default = false
|
||||||
validation {
|
validation {
|
||||||
condition = var.accept_license == true
|
condition = var.accept_license == true
|
||||||
@@ -69,6 +75,16 @@ variable "accept_license" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "telemetry_level" {
|
||||||
|
type = string
|
||||||
|
description = "Set the telemetry level for VS Code Web."
|
||||||
|
default = "error"
|
||||||
|
validation {
|
||||||
|
condition = var.telemetry_level == "off" || var.telemetry_level == "crash" || var.telemetry_level == "error" || var.telemetry_level == "all"
|
||||||
|
error_message = "Incorrect value. Please set either 'off', 'crash', 'error', or 'all'."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resource "coder_script" "vscode-web" {
|
resource "coder_script" "vscode-web" {
|
||||||
agent_id = var.agent_id
|
agent_id = var.agent_id
|
||||||
display_name = "VS Code Web"
|
display_name = "VS Code Web"
|
||||||
@@ -76,7 +92,9 @@ resource "coder_script" "vscode-web" {
|
|||||||
script = templatefile("${path.module}/run.sh", {
|
script = templatefile("${path.module}/run.sh", {
|
||||||
PORT : var.port,
|
PORT : var.port,
|
||||||
LOG_PATH : var.log_path,
|
LOG_PATH : var.log_path,
|
||||||
INSTALL_DIR : var.install_dir,
|
INSTALL_PREFIX : var.install_prefix,
|
||||||
|
EXTENSIONS : join(",", var.extensions),
|
||||||
|
TELEMETRY_LEVEL : var.telemetry_level,
|
||||||
})
|
})
|
||||||
run_on_start = true
|
run_on_start = true
|
||||||
}
|
}
|
||||||
|
|||||||
48
vscode-web/run.sh
Normal file → Executable file
48
vscode-web/run.sh
Normal file → Executable file
@@ -1,21 +1,49 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
BOLD='\033[0;1m'
|
BOLD='\033[0;1m'
|
||||||
|
EXTENSIONS=("${EXTENSIONS}")
|
||||||
|
|
||||||
# Create install directory if it doesn't exist
|
# Create install prefix
|
||||||
mkdir -p ${INSTALL_DIR}
|
mkdir -p ${INSTALL_PREFIX}
|
||||||
|
|
||||||
printf "$${BOLD}Installing vscode-cli!\n"
|
printf "$${BOLD}Installing Microsoft Visual Studio Code Server!\n"
|
||||||
|
|
||||||
# Download and extract code-cli tarball
|
# Download and extract vscode-server
|
||||||
output=$(curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output vscode_cli.tar.gz && tar -xf vscode_cli.tar.gz -C ${INSTALL_DIR} && rm vscode_cli.tar.gz)
|
ARCH=$(uname -m)
|
||||||
|
case "$ARCH" in
|
||||||
|
x86_64) ARCH="x64" ;;
|
||||||
|
aarch64) ARCH="arm64" ;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported architecture"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
HASH=$(curl https://update.code.visualstudio.com/api/commits/stable/server-linux-$ARCH-web | cut -d '"' -f 2)
|
||||||
|
output=$(curl -sL https://vscode.download.prss.microsoft.com/dbazure/download/stable/$HASH/vscode-server-linux-$ARCH-web.tar.gz | tar -xz -C ${INSTALL_PREFIX} --strip-components 1)
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to install vscode-cli: $output"
|
echo "Failed to install Microsoft Visual Studio Code Server: $output"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
printf "🥳 vscode-cli has been installed.\n\n"
|
printf "$${BOLD}Microsoft Visual Studio Code Server has been installed.\n"
|
||||||
|
|
||||||
echo "👷 Running ${INSTALL_DIR}/bin/code serve-web --port ${PORT} --without-connection-token --accept-server-license-terms in the background..."
|
VSCODE_SERVER="${INSTALL_PREFIX}/bin/code-server"
|
||||||
|
|
||||||
|
# Install each extension...
|
||||||
|
IFS=',' read -r -a EXTENSIONLIST <<< "$${EXTENSIONS}"
|
||||||
|
for extension in "$${EXTENSIONLIST[@]}"; do
|
||||||
|
if [ -z "$extension" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
printf "🧩 Installing extension $${CODE}$extension$${RESET}...\n"
|
||||||
|
output=$($VSCODE_SERVER --install-extension "$extension" --force)
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to install extension: $extension: $output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "👷 Running ${INSTALL_PREFIX}/bin/code-server serve-local --port ${PORT} --accept-server-license-terms serve-local --without-connection-token --telemetry-level ${TELEMETRY_LEVEL} in the background..."
|
||||||
echo "Check logs at ${LOG_PATH}!"
|
echo "Check logs at ${LOG_PATH}!"
|
||||||
${INSTALL_DIR}/code serve-web --port ${PORT} --without-connection-token --accept-server-license-terms > ${LOG_PATH} 2>&1 &
|
"${INSTALL_PREFIX}/bin/code-server" serve-local --port "${PORT}" --accept-server-license-terms serve-local --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" > "${LOG_PATH}" 2>&1 &
|
||||||
|
|||||||
Reference in New Issue
Block a user