Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f312ced5e | ||
|
|
fd985bedac | ||
|
|
b0c14be846 | ||
|
|
18efe83b89 | ||
|
|
33dbae6ea0 | ||
|
|
f14e6838e4 | ||
|
|
2a30982d1a | ||
|
|
47e995f636 | ||
|
|
56fdf096c1 | ||
|
|
49df203bd6 | ||
|
|
8766c670e6 | ||
|
|
43304e5d4e | ||
|
|
d8f71e4571 | ||
|
|
d8102e62ec | ||
|
|
ed16ba59a9 | ||
|
|
a8c659ad6f | ||
|
|
c4df384f4b | ||
|
|
892174da7c | ||
|
|
24e50e2bbb | ||
|
|
dfe69f25ce | ||
|
|
e8f6578ece | ||
|
|
838ec95875 | ||
|
|
5a0efdf867 | ||
|
|
4debc3200d | ||
|
|
5476f819ce | ||
|
|
9a5ff6df64 | ||
|
|
bab0f7d24d |
19
.icons/airflow.svg
Normal file
19
.icons/airflow.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 15 KiB |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 6.8 KiB |
BIN
.images/airflow.png
Normal file
BIN
.images/airflow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 603 KiB |
71
apache-airflow/README.md
Normal file
71
apache-airflow/README.md
Normal file
@@ -0,0 +1,71 @@
|
||||
---
|
||||
display_name: airflow
|
||||
description: A module that adds Apache Airflow in your Coder template
|
||||
icon: ../.icons/airflow.svg
|
||||
maintainer_github: coder
|
||||
partner_github: nataindata
|
||||
verified: true
|
||||
tags: [airflow, idea, web, helper]
|
||||
---
|
||||
|
||||
# airflow
|
||||
|
||||
A module that adds Apache Airflow in your Coder template.
|
||||
|
||||
```tf
|
||||
module "airflow" {
|
||||
source = "registry.coder.com/modules/apache-airflow/coder"
|
||||
version = "1.0.2"
|
||||
agent_id = coder_agent.example.id
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1
|
||||
|
||||
Install the Dracula theme from [OpenVSX](https://open-vsx.org/):
|
||||
|
||||
```tf
|
||||
module "airflow" {
|
||||
source = "registry.coder.com/modules/apache-airflow/coder"
|
||||
version = "1.0.2"
|
||||
agent_id = coder_agent.example.id
|
||||
extensions = [
|
||||
"dracula-theme.theme-dracula"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Enter the `<author>.<name>` into the extensions array and code-server will automatically install on start.
|
||||
|
||||
### Example 2
|
||||
|
||||
Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarted/settings#_settingsjson) file:
|
||||
|
||||
```tf
|
||||
module "airflow" {
|
||||
source = "registry.coder.com/modules/apache-airflow/coder"
|
||||
version = "1.0.2"
|
||||
agent_id = coder_agent.example.id
|
||||
extensions = ["dracula-theme.theme-dracula"]
|
||||
settings = {
|
||||
"workbench.colorTheme" = "Dracula"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Example 3
|
||||
|
||||
Run code-server in the background, don't fetch it from GitHub:
|
||||
|
||||
```tf
|
||||
module "airflow" {
|
||||
source = "registry.coder.com/modules/apache-airflow/coder"
|
||||
version = "1.0.2"
|
||||
agent_id = coder_agent.example.id
|
||||
offline = true
|
||||
}
|
||||
```
|
||||
65
apache-airflow/main.tf
Normal file
65
apache-airflow/main.tf
Normal file
@@ -0,0 +1,65 @@
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
coder = {
|
||||
source = "coder/coder"
|
||||
version = ">= 0.17"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Add required variables for your modules and remove any unneeded variables
|
||||
variable "agent_id" {
|
||||
type = string
|
||||
description = "The ID of a Coder agent."
|
||||
}
|
||||
|
||||
variable "log_path" {
|
||||
type = string
|
||||
description = "The path to log airflow to."
|
||||
default = "/tmp/airflow.log"
|
||||
}
|
||||
|
||||
variable "port" {
|
||||
type = number
|
||||
description = "The port to run airflow on."
|
||||
default = 8080
|
||||
}
|
||||
|
||||
variable "share" {
|
||||
type = string
|
||||
default = "owner"
|
||||
validation {
|
||||
condition = var.share == "owner" || var.share == "authenticated" || var.share == "public"
|
||||
error_message = "Incorrect value. Please set either 'owner', 'authenticated', or 'public'."
|
||||
}
|
||||
}
|
||||
|
||||
variable "order" {
|
||||
type = number
|
||||
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
|
||||
default = null
|
||||
}
|
||||
|
||||
resource "coder_script" "airflow" {
|
||||
agent_id = var.agent_id
|
||||
display_name = "airflow"
|
||||
icon = "/icon/apache-guacamole.svg"
|
||||
script = templatefile("${path.module}/run.sh", {
|
||||
LOG_PATH : var.log_path,
|
||||
PORT : var.port
|
||||
})
|
||||
run_on_start = true
|
||||
}
|
||||
|
||||
resource "coder_app" "airflow" {
|
||||
agent_id = var.agent_id
|
||||
slug = "airflow"
|
||||
display_name = "airflow"
|
||||
url = "http://localhost:${var.port}"
|
||||
icon = "/icon/apache-guacamole.svg"
|
||||
subdomain = true
|
||||
share = var.share
|
||||
order = var.order
|
||||
}
|
||||
19
apache-airflow/run.sh
Normal file
19
apache-airflow/run.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
BOLD='\033[0;1m'
|
||||
|
||||
PATH=$PATH:~/.local/bin
|
||||
pip install --upgrade apache-airflow
|
||||
|
||||
filename=~/airflow/airflow.db
|
||||
if ! [ -f $filename ] || ! [ -s $filename ]; then
|
||||
airflow db init
|
||||
fi
|
||||
|
||||
export AIRFLOW__CORE__LOAD_EXAMPLES=false
|
||||
|
||||
airflow webserver > ${LOG_PATH} 2>&1 &
|
||||
|
||||
airflow scheduler >> /tmp/airflow_scheduler.log 2>&1 &
|
||||
|
||||
airflow users create -u admin -p admin -r Admin -e admin@admin.com -f Coder -l User
|
||||
@@ -17,7 +17,7 @@ Customize the preselected parameter value:
|
||||
```tf
|
||||
module "aws-region" {
|
||||
source = "registry.coder.com/modules/aws-region/coder"
|
||||
version = "1.0.10"
|
||||
version = "1.0.12"
|
||||
default = "us-east-1"
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ Change the display name and icon for a region using the corresponding maps:
|
||||
```tf
|
||||
module "aws-region" {
|
||||
source = "registry.coder.com/modules/aws-region/coder"
|
||||
version = "1.0.10"
|
||||
version = "1.0.12"
|
||||
default = "ap-south-1"
|
||||
|
||||
custom_names = {
|
||||
@@ -63,7 +63,7 @@ Hide the Asia Pacific regions Seoul and Osaka:
|
||||
```tf
|
||||
module "aws-region" {
|
||||
source = "registry.coder.com/modules/aws-region/coder"
|
||||
version = "1.0.10"
|
||||
version = "1.0.12"
|
||||
exclude = ["ap-northeast-2", "ap-northeast-3"]
|
||||
}
|
||||
|
||||
|
||||
@@ -22,4 +22,13 @@ describe("aws-region", async () => {
|
||||
});
|
||||
expect(state.outputs.value.value).toBe("us-west-2");
|
||||
});
|
||||
|
||||
it("set custom order for coder_parameter", async () => {
|
||||
const order = 99;
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
coder_parameter_order: order.toString(),
|
||||
});
|
||||
expect(state.resources).toHaveLength(1);
|
||||
expect(state.resources[0].instances[0].attributes.order).toBe(order);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,6 +51,12 @@ variable "exclude" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "coder_parameter_order" {
|
||||
type = number
|
||||
description = "The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order)."
|
||||
default = null
|
||||
}
|
||||
|
||||
locals {
|
||||
# This is a static list because the regions don't change _that_
|
||||
# frequently and including the `aws_regions` data source requires
|
||||
@@ -176,6 +182,7 @@ data "coder_parameter" "region" {
|
||||
display_name = var.display_name
|
||||
description = var.description
|
||||
default = var.default == "" ? null : var.default
|
||||
order = var.coder_parameter_order
|
||||
mutable = var.mutable
|
||||
dynamic "option" {
|
||||
for_each = { for k, v in local.regions : k => v if !(contains(var.exclude, k)) }
|
||||
|
||||
@@ -14,7 +14,7 @@ This module adds a parameter with all Azure regions, allowing developers to sele
|
||||
```tf
|
||||
module "azure_region" {
|
||||
source = "registry.coder.com/modules/azure-region/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
default = "eastus"
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ Change the display name and icon for a region using the corresponding maps:
|
||||
```tf
|
||||
module "azure-region" {
|
||||
source = "registry.coder.com/modules/azure-region/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
custom_names = {
|
||||
"australia" : "Go Australia!"
|
||||
}
|
||||
@@ -57,7 +57,7 @@ Hide all regions in Australia except australiacentral:
|
||||
```tf
|
||||
module "azure-region" {
|
||||
source = "registry.coder.com/modules/azure-region/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
exclude = [
|
||||
"australia",
|
||||
"australiacentral2",
|
||||
|
||||
@@ -22,4 +22,13 @@ describe("azure-region", async () => {
|
||||
});
|
||||
expect(state.outputs.value.value).toBe("westus");
|
||||
});
|
||||
|
||||
it("set custom order for coder_parameter", async () => {
|
||||
const order = 99;
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
coder_parameter_order: order.toString(),
|
||||
});
|
||||
expect(state.resources).toHaveLength(1);
|
||||
expect(state.resources[0].instances[0].attributes.order).toBe(order);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,6 +50,12 @@ variable "exclude" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "coder_parameter_order" {
|
||||
type = number
|
||||
description = "The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order)."
|
||||
default = null
|
||||
}
|
||||
|
||||
locals {
|
||||
# Note: Options are limited to 64 regions, some redundant regions have been removed.
|
||||
all_regions = {
|
||||
@@ -309,6 +315,7 @@ data "coder_parameter" "region" {
|
||||
display_name = var.display_name
|
||||
description = var.description
|
||||
default = var.default == "" ? null : var.default
|
||||
order = var.coder_parameter_order
|
||||
mutable = var.mutable
|
||||
icon = "/icon/azure.png"
|
||||
dynamic "option" {
|
||||
|
||||
@@ -14,7 +14,7 @@ Automatically install [code-server](https://github.com/coder/code-server) in a w
|
||||
```tf
|
||||
module "code-server" {
|
||||
source = "registry.coder.com/modules/code-server/coder"
|
||||
version = "1.0.8"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
}
|
||||
```
|
||||
@@ -28,7 +28,7 @@ module "code-server" {
|
||||
```tf
|
||||
module "code-server" {
|
||||
source = "registry.coder.com/modules/code-server/coder"
|
||||
version = "1.0.8"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
install_version = "4.8.3"
|
||||
}
|
||||
@@ -41,7 +41,7 @@ Install the Dracula theme from [OpenVSX](https://open-vsx.org/):
|
||||
```tf
|
||||
module "code-server" {
|
||||
source = "registry.coder.com/modules/code-server/coder"
|
||||
version = "1.0.8"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
extensions = [
|
||||
"dracula-theme.theme-dracula"
|
||||
@@ -58,7 +58,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte
|
||||
```tf
|
||||
module "code-server" {
|
||||
source = "registry.coder.com/modules/code-server/coder"
|
||||
version = "1.0.8"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
extensions = ["dracula-theme.theme-dracula"]
|
||||
settings = {
|
||||
@@ -74,7 +74,7 @@ Just run code-server in the background, don't fetch it from GitHub:
|
||||
```tf
|
||||
module "code-server" {
|
||||
source = "registry.coder.com/modules/code-server/coder"
|
||||
version = "1.0.8"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
extensions = ["dracula-theme.theme-dracula", "ms-azuretools.vscode-docker"]
|
||||
}
|
||||
@@ -89,7 +89,7 @@ Run an existing copy of code-server if found, otherwise download from GitHub:
|
||||
```tf
|
||||
module "code-server" {
|
||||
source = "registry.coder.com/modules/code-server/coder"
|
||||
version = "1.0.8"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
use_cached = true
|
||||
extensions = ["dracula-theme.theme-dracula", "ms-azuretools.vscode-docker"]
|
||||
@@ -101,7 +101,7 @@ Just run code-server in the background, don't fetch it from GitHub:
|
||||
```tf
|
||||
module "code-server" {
|
||||
source = "registry.coder.com/modules/code-server/coder"
|
||||
version = "1.0.8"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
offline = true
|
||||
}
|
||||
|
||||
@@ -95,6 +95,12 @@ variable "use_cached" {
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "extensions_dir" {
|
||||
type = string
|
||||
description = "Override the directory to store extensions in."
|
||||
default = ""
|
||||
}
|
||||
|
||||
resource "coder_script" "code-server" {
|
||||
agent_id = var.agent_id
|
||||
display_name = "code-server"
|
||||
@@ -110,6 +116,7 @@ resource "coder_script" "code-server" {
|
||||
SETTINGS : replace(jsonencode(var.settings), "\"", "\\\""),
|
||||
OFFLINE : var.offline,
|
||||
USE_CACHED : var.use_cached,
|
||||
EXTENSIONS_DIR : var.extensions_dir,
|
||||
})
|
||||
run_on_start = true
|
||||
|
||||
|
||||
@@ -6,10 +6,16 @@ CODE='\033[36;40;1m'
|
||||
RESET='\033[0m'
|
||||
CODE_SERVER="${INSTALL_PREFIX}/bin/code-server"
|
||||
|
||||
# Set extension directory
|
||||
EXTENSION_ARG=""
|
||||
if [ -n "${EXTENSIONS_DIR}" ]; then
|
||||
EXTENSION_ARG="--extensions-dir=${EXTENSIONS_DIR}"
|
||||
fi
|
||||
|
||||
function run_code_server() {
|
||||
echo "👷 Running code-server in the background..."
|
||||
echo "Check logs at ${LOG_PATH}!"
|
||||
$CODE_SERVER --auth none --port "${PORT}" --app-name "${APP_NAME}" > "${LOG_PATH}" 2>&1 &
|
||||
$CODE_SERVER "$EXTENSION_ARG" --auth none --port "${PORT}" --app-name "${APP_NAME}" > "${LOG_PATH}" 2>&1 &
|
||||
}
|
||||
|
||||
# Check if the settings file exists...
|
||||
@@ -57,7 +63,7 @@ for extension in "$${EXTENSIONLIST[@]}"; do
|
||||
continue
|
||||
fi
|
||||
printf "🧩 Installing extension $${CODE}$extension$${RESET}...\n"
|
||||
output=$($CODE_SERVER --install-extension "$extension")
|
||||
output=$($CODE_SERVER "$EXTENSION_ARG" --install-extension "$extension")
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to install extension: $extension: $output"
|
||||
exit 1
|
||||
|
||||
@@ -14,7 +14,20 @@ Allow developers to optionally bring their own [dotfiles repository](https://dot
|
||||
```tf
|
||||
module "dotfiles" {
|
||||
source = "registry.coder.com/modules/dotfiles/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
}
|
||||
```
|
||||
|
||||
## Setting a default dotfiles repository
|
||||
|
||||
You can set a default dotfiles repository for all users by setting the `default_dotfiles_uri` variable:
|
||||
|
||||
```tf
|
||||
module "dotfiles" {
|
||||
source = "registry.coder.com/modules/dotfiles/coder"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
default_dotfiles_uri = "https://github.com/coder/dotfiles"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -18,4 +18,23 @@ describe("dotfiles", async () => {
|
||||
});
|
||||
expect(state.outputs.dotfiles_uri.value).toBe("");
|
||||
});
|
||||
|
||||
it("set a default dotfiles_uri", async () => {
|
||||
const default_dotfiles_uri = "foo";
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
default_dotfiles_uri,
|
||||
});
|
||||
expect(state.outputs.dotfiles_uri.value).toBe(default_dotfiles_uri);
|
||||
});
|
||||
|
||||
it("set custom order for coder_parameter", async () => {
|
||||
const order = 99;
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
coder_parameter_order: order.toString(),
|
||||
});
|
||||
expect(state.resources).toHaveLength(2);
|
||||
expect(state.resources[0].instances[0].attributes.order).toBe(order);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,11 +14,24 @@ variable "agent_id" {
|
||||
description = "The ID of a Coder agent."
|
||||
}
|
||||
|
||||
variable "default_dotfiles_uri" {
|
||||
type = string
|
||||
description = "The default dotfiles URI if the workspace user does not provide one."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "coder_parameter_order" {
|
||||
type = number
|
||||
description = "The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order)."
|
||||
default = null
|
||||
}
|
||||
|
||||
data "coder_parameter" "dotfiles_uri" {
|
||||
type = "string"
|
||||
name = "dotfiles_uri"
|
||||
display_name = "Dotfiles URL (optional)"
|
||||
default = ""
|
||||
order = var.coder_parameter_order
|
||||
default = var.default_dotfiles_uri
|
||||
description = "Enter a URL for a [dotfiles repository](https://dotfiles.github.io) to personalize your workspace"
|
||||
mutable = true
|
||||
icon = "/icon/dotfiles.svg"
|
||||
@@ -40,4 +53,4 @@ resource "coder_script" "personalize" {
|
||||
output "dotfiles_uri" {
|
||||
description = "Dotfiles URI"
|
||||
value = data.coder_parameter.dotfiles_uri.value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ Customize the preselected parameter value:
|
||||
```tf
|
||||
module "exoscale-instance-type" {
|
||||
source = "registry.coder.com/modules/exoscale-instance-type/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
default = "standard.medium"
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ Change the display name a type using the corresponding maps:
|
||||
```tf
|
||||
module "exoscale-instance-type" {
|
||||
source = "registry.coder.com/modules/exoscale-instance-type/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
default = "standard.medium"
|
||||
|
||||
custom_names = {
|
||||
@@ -79,7 +79,7 @@ Show only gpu1 types
|
||||
```tf
|
||||
module "exoscale-instance-type" {
|
||||
source = "registry.coder.com/modules/exoscale-instance-type/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
default = "gpu.large"
|
||||
type_category = ["gpu"]
|
||||
exclude = [
|
||||
|
||||
@@ -31,4 +31,13 @@ describe("exoscale-instance-type", async () => {
|
||||
});
|
||||
}).toThrow('default value "gpu3.huge" must be defined as one of options');
|
||||
});
|
||||
|
||||
it("set custom order for coder_parameter", async () => {
|
||||
const order = 99;
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
coder_parameter_order: order.toString(),
|
||||
});
|
||||
expect(state.resources).toHaveLength(1);
|
||||
expect(state.resources[0].instances[0].attributes.order).toBe(order);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -56,6 +56,12 @@ variable "exclude" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "coder_parameter_order" {
|
||||
type = number
|
||||
description = "The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order)."
|
||||
default = null
|
||||
}
|
||||
|
||||
locals {
|
||||
# https://www.exoscale.com/pricing/
|
||||
|
||||
@@ -257,6 +263,7 @@ data "coder_parameter" "instance_type" {
|
||||
display_name = var.display_name
|
||||
description = var.description
|
||||
default = var.default == "" ? null : var.default
|
||||
order = var.coder_parameter_order
|
||||
mutable = var.mutable
|
||||
dynamic "option" {
|
||||
for_each = [for k, v in concat(
|
||||
|
||||
@@ -17,7 +17,7 @@ Customize the preselected parameter value:
|
||||
```tf
|
||||
module "exoscale-zone" {
|
||||
source = "registry.coder.com/modules/exoscale-zone/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
default = "ch-dk-2"
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ Change the display name and icon for a zone using the corresponding maps:
|
||||
```tf
|
||||
module "exoscale-zone" {
|
||||
source = "registry.coder.com/modules/exoscale-zone/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
default = "at-vie-1"
|
||||
|
||||
custom_names = {
|
||||
@@ -76,7 +76,7 @@ Hide the Switzerland zones Geneva and Zurich
|
||||
```tf
|
||||
module "exoscale-zone" {
|
||||
source = "registry.coder.com/modules/exoscale-zone/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
exclude = ["ch-gva-2", "ch-dk-2"]
|
||||
}
|
||||
|
||||
|
||||
@@ -22,4 +22,13 @@ describe("exoscale-zone", async () => {
|
||||
});
|
||||
expect(state.outputs.value.value).toBe("at-vie-1");
|
||||
});
|
||||
|
||||
it("set custom order for coder_parameter", async () => {
|
||||
const order = 99;
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
coder_parameter_order: order.toString(),
|
||||
});
|
||||
expect(state.resources).toHaveLength(1);
|
||||
expect(state.resources[0].instances[0].attributes.order).toBe(order);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,6 +51,11 @@ variable "exclude" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "coder_parameter_order" {
|
||||
type = number
|
||||
description = "The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order)."
|
||||
default = null
|
||||
}
|
||||
|
||||
locals {
|
||||
# This is a static list because the zones don't change _that_
|
||||
@@ -94,6 +99,7 @@ data "coder_parameter" "zone" {
|
||||
display_name = var.display_name
|
||||
description = var.description
|
||||
default = var.default == "" ? null : var.default
|
||||
order = var.coder_parameter_order
|
||||
mutable = var.mutable
|
||||
dynamic "option" {
|
||||
for_each = { for k, v in local.zones : k => v if !(contains(var.exclude, k)) }
|
||||
|
||||
@@ -14,7 +14,7 @@ This module adds Google Cloud Platform regions to your Coder template.
|
||||
```tf
|
||||
module "gcp_region" {
|
||||
source = "registry.coder.com/modules/gcp-region/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
regions = ["us", "europe"]
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ Note: setting `gpu_only = true` and using a default region without GPU support,
|
||||
```tf
|
||||
module "gcp_region" {
|
||||
source = "registry.coder.com/modules/gcp-region/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
default = ["us-west1-a"]
|
||||
regions = ["us-west1"]
|
||||
gpu_only = false
|
||||
@@ -50,7 +50,7 @@ resource "google_compute_instance" "example" {
|
||||
```tf
|
||||
module "gcp_region" {
|
||||
source = "registry.coder.com/modules/gcp-region/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
regions = ["europe-west"]
|
||||
single_zone_per_region = false
|
||||
}
|
||||
@@ -65,7 +65,7 @@ resource "google_compute_instance" "example" {
|
||||
```tf
|
||||
module "gcp_region" {
|
||||
source = "registry.coder.com/modules/gcp-region/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
regions = ["us", "europe"]
|
||||
gpu_only = true
|
||||
single_zone_per_region = true
|
||||
|
||||
@@ -40,4 +40,13 @@ describe("gcp-region", async () => {
|
||||
});
|
||||
expect(state.outputs.value.value).toBe("us-west2-b");
|
||||
});
|
||||
|
||||
it("set custom order for coder_parameter", async () => {
|
||||
const order = 99;
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
coder_parameter_order: order.toString(),
|
||||
});
|
||||
expect(state.resources).toHaveLength(1);
|
||||
expect(state.resources[0].instances[0].attributes.order).toBe(order);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -63,6 +63,12 @@ variable "single_zone_per_region" {
|
||||
type = bool
|
||||
}
|
||||
|
||||
variable "coder_parameter_order" {
|
||||
type = number
|
||||
description = "The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order)."
|
||||
default = null
|
||||
}
|
||||
|
||||
locals {
|
||||
zones = {
|
||||
# US Central
|
||||
@@ -715,6 +721,7 @@ data "coder_parameter" "region" {
|
||||
icon = "/icon/gcp.png"
|
||||
mutable = var.mutable
|
||||
default = var.default != null && var.default != "" && (!var.gpu_only || try(local.zones[var.default].gpu, false)) ? var.default : null
|
||||
order = var.coder_parameter_order
|
||||
dynamic "option" {
|
||||
for_each = {
|
||||
for k, v in local.zones : k => v
|
||||
|
||||
@@ -14,7 +14,7 @@ This module allows you to automatically clone a repository by URL and skip if it
|
||||
```tf
|
||||
module "git-clone" {
|
||||
source = "registry.coder.com/modules/git-clone/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
url = "https://github.com/coder/coder"
|
||||
}
|
||||
@@ -27,7 +27,7 @@ module "git-clone" {
|
||||
```tf
|
||||
module "git-clone" {
|
||||
source = "registry.coder.com/modules/git-clone/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
url = "https://github.com/coder/coder"
|
||||
base_dir = "~/projects/coder"
|
||||
@@ -41,7 +41,7 @@ To use with [Git Authentication](https://coder.com/docs/v2/latest/admin/git-prov
|
||||
```tf
|
||||
module "git-clone" {
|
||||
source = "registry.coder.com/modules/git-clone/coder"
|
||||
version = "1.0.2"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
url = "https://github.com/coder/coder"
|
||||
}
|
||||
@@ -50,3 +50,106 @@ data "coder_git_auth" "github" {
|
||||
id = "github"
|
||||
}
|
||||
```
|
||||
|
||||
## GitHub clone with branch name
|
||||
|
||||
To GitHub clone with a specific branch like `feat/example`
|
||||
|
||||
```tf
|
||||
# Prompt the user for the git repo URL
|
||||
data "coder_parameter" "git_repo" {
|
||||
name = "git_repo"
|
||||
display_name = "Git repository"
|
||||
default = "https://github.com/coder/coder/tree/feat/example"
|
||||
}
|
||||
|
||||
# Clone the repository for branch `feat/example`
|
||||
module "git_clone" {
|
||||
source = "registry.coder.com/modules/git-clone/coder"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
url = data.coder_parameter.git_repo.value
|
||||
}
|
||||
|
||||
# Create a code-server instance for the cloned repository
|
||||
module "code-server" {
|
||||
source = "registry.coder.com/modules/code-server/coder"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
order = 1
|
||||
folder = "/home/${local.username}/${module.git_clone.folder_name}"
|
||||
}
|
||||
|
||||
# Create a Coder app for the website
|
||||
resource "coder_app" "website" {
|
||||
agent_id = coder_agent.example.id
|
||||
order = 2
|
||||
slug = "website"
|
||||
external = true
|
||||
display_name = module.git_clone.folder_name
|
||||
url = module.git_clone.web_url
|
||||
icon = module.git_clone.git_provider != "" ? "/icon/${module.git_clone.git_provider}.svg" : "/icon/git.svg"
|
||||
count = module.git_clone.web_url != "" ? 1 : 0
|
||||
}
|
||||
```
|
||||
|
||||
Configuring `git-clone` for a self-hosted GitHub Enterprise Server running at `github.example.com`
|
||||
|
||||
```tf
|
||||
module "git-clone" {
|
||||
source = "registry.coder.com/modules/git-clone/coder"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
url = "https://github.example.com/coder/coder/tree/feat/example"
|
||||
git_providers = {
|
||||
"https://github.example.com/" = {
|
||||
provider = "github"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## GitLab clone with branch name
|
||||
|
||||
To GitLab clone with a specific branch like `feat/example`
|
||||
|
||||
```tf
|
||||
module "git-clone" {
|
||||
source = "registry.coder.com/modules/git-clone/coder"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
url = "https://gitlab.com/coder/coder/-/tree/feat/example"
|
||||
}
|
||||
```
|
||||
|
||||
Configuring `git-clone` for a self-hosted GitLab running at `gitlab.example.com`
|
||||
|
||||
```tf
|
||||
module "git-clone" {
|
||||
source = "registry.coder.com/modules/git-clone/coder"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
url = "https://gitlab.example.com/coder/coder/-/tree/feat/example"
|
||||
git_providers = {
|
||||
"https://gitlab.example.com/" = {
|
||||
provider = "gitlab"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Git clone with branch_name set
|
||||
|
||||
Alternatively, you can set the `branch_name` attribute to clone a specific branch.
|
||||
|
||||
For example, to clone the `feat/example` branch:
|
||||
|
||||
```tf
|
||||
module "git-clone" {
|
||||
source = "registry.coder.com/modules/git-clone/coder"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
url = "https://github.com/coder/coder"
|
||||
branch_name = "feat/example"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -36,4 +36,196 @@ describe("git-clone", async () => {
|
||||
"Cloning fake-url to ~/fake-url...",
|
||||
]);
|
||||
});
|
||||
|
||||
it("repo_dir should match repo name for https", async () => {
|
||||
const url = "https://github.com/coder/coder.git";
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
base_dir: "/tmp",
|
||||
url,
|
||||
});
|
||||
expect(state.outputs.repo_dir.value).toEqual("/tmp/coder");
|
||||
expect(state.outputs.folder_name.value).toEqual("coder");
|
||||
expect(state.outputs.clone_url.value).toEqual(url);
|
||||
expect(state.outputs.web_url.value).toEqual(url);
|
||||
expect(state.outputs.branch_name.value).toEqual("");
|
||||
});
|
||||
|
||||
it("repo_dir should match repo name for https without .git", async () => {
|
||||
const url = "https://github.com/coder/coder";
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
base_dir: "/tmp",
|
||||
url,
|
||||
});
|
||||
expect(state.outputs.repo_dir.value).toEqual("/tmp/coder");
|
||||
expect(state.outputs.clone_url.value).toEqual(url);
|
||||
expect(state.outputs.web_url.value).toEqual(url);
|
||||
expect(state.outputs.branch_name.value).toEqual("");
|
||||
});
|
||||
|
||||
it("repo_dir should match repo name for ssh", async () => {
|
||||
const url = "git@github.com:coder/coder.git";
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
base_dir: "/tmp",
|
||||
url,
|
||||
});
|
||||
expect(state.outputs.repo_dir.value).toEqual("/tmp/coder");
|
||||
expect(state.outputs.git_provider.value).toEqual("");
|
||||
expect(state.outputs.clone_url.value).toEqual(url);
|
||||
const https_url = "https://github.com/coder/coder.git";
|
||||
expect(state.outputs.web_url.value).toEqual(https_url);
|
||||
expect(state.outputs.branch_name.value).toEqual("");
|
||||
});
|
||||
|
||||
it("branch_name should not include query string", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
url: "https://gitlab.com/mike.brew/repo-tests.log/-/tree/feat/branch?ref_type=heads",
|
||||
});
|
||||
expect(state.outputs.repo_dir.value).toEqual("~/repo-tests.log");
|
||||
expect(state.outputs.folder_name.value).toEqual("repo-tests.log");
|
||||
const https_url = "https://gitlab.com/mike.brew/repo-tests.log";
|
||||
expect(state.outputs.clone_url.value).toEqual(https_url);
|
||||
expect(state.outputs.web_url.value).toEqual(https_url);
|
||||
expect(state.outputs.branch_name.value).toEqual("feat/branch");
|
||||
});
|
||||
|
||||
it("branch_name should not include fragments", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
base_dir: "/tmp",
|
||||
url: "https://gitlab.com/mike.brew/repo-tests.log/-/tree/feat/branch#name",
|
||||
});
|
||||
expect(state.outputs.repo_dir.value).toEqual("/tmp/repo-tests.log");
|
||||
const https_url = "https://gitlab.com/mike.brew/repo-tests.log";
|
||||
expect(state.outputs.clone_url.value).toEqual(https_url);
|
||||
expect(state.outputs.web_url.value).toEqual(https_url);
|
||||
expect(state.outputs.branch_name.value).toEqual("feat/branch");
|
||||
});
|
||||
|
||||
it("gitlab url with branch should match", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
base_dir: "/tmp",
|
||||
url: "https://gitlab.com/mike.brew/repo-tests.log/-/tree/feat/branch",
|
||||
});
|
||||
expect(state.outputs.repo_dir.value).toEqual("/tmp/repo-tests.log");
|
||||
expect(state.outputs.git_provider.value).toEqual("gitlab");
|
||||
const https_url = "https://gitlab.com/mike.brew/repo-tests.log";
|
||||
expect(state.outputs.clone_url.value).toEqual(https_url);
|
||||
expect(state.outputs.web_url.value).toEqual(https_url);
|
||||
expect(state.outputs.branch_name.value).toEqual("feat/branch");
|
||||
});
|
||||
|
||||
it("github url with branch should match", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
base_dir: "/tmp",
|
||||
url: "https://github.com/michaelbrewer/repo-tests.log/tree/feat/branch",
|
||||
});
|
||||
expect(state.outputs.repo_dir.value).toEqual("/tmp/repo-tests.log");
|
||||
expect(state.outputs.git_provider.value).toEqual("github");
|
||||
const https_url = "https://github.com/michaelbrewer/repo-tests.log";
|
||||
expect(state.outputs.clone_url.value).toEqual(https_url);
|
||||
expect(state.outputs.web_url.value).toEqual(https_url);
|
||||
expect(state.outputs.branch_name.value).toEqual("feat/branch");
|
||||
});
|
||||
|
||||
it("self-host git url with branch should match", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
base_dir: "/tmp",
|
||||
url: "https://git.example.com/example/project/-/tree/feat/example",
|
||||
git_providers: `
|
||||
{
|
||||
"https://git.example.com/" = {
|
||||
provider = "gitlab"
|
||||
}
|
||||
}`,
|
||||
});
|
||||
expect(state.outputs.repo_dir.value).toEqual("/tmp/project");
|
||||
expect(state.outputs.git_provider.value).toEqual("gitlab");
|
||||
const https_url = "https://git.example.com/example/project";
|
||||
expect(state.outputs.clone_url.value).toEqual(https_url);
|
||||
expect(state.outputs.web_url.value).toEqual(https_url);
|
||||
expect(state.outputs.branch_name.value).toEqual("feat/example");
|
||||
});
|
||||
|
||||
it("handle unsupported git provider configuration", async () => {
|
||||
const t = async () => {
|
||||
await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
url: "foo",
|
||||
git_providers: `
|
||||
{
|
||||
"https://git.example.com/" = {
|
||||
provider = "bitbucket"
|
||||
}
|
||||
}`,
|
||||
});
|
||||
};
|
||||
expect(t).toThrow('Allowed values for provider are "github" or "gitlab".');
|
||||
});
|
||||
|
||||
it("handle unknown git provider url", async () => {
|
||||
const url = "https://git.unknown.com/coder/coder";
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
base_dir: "/tmp",
|
||||
url,
|
||||
});
|
||||
expect(state.outputs.repo_dir.value).toEqual("/tmp/coder");
|
||||
expect(state.outputs.clone_url.value).toEqual(url);
|
||||
expect(state.outputs.web_url.value).toEqual(url);
|
||||
expect(state.outputs.branch_name.value).toEqual("");
|
||||
});
|
||||
|
||||
it("runs with github clone with switch to feat/branch", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
url: "https://github.com/michaelbrewer/repo-tests.log/tree/feat/branch",
|
||||
});
|
||||
const output = await executeScriptInContainer(state, "alpine/git");
|
||||
expect(output.exitCode).toBe(0);
|
||||
expect(output.stdout).toEqual([
|
||||
"Creating directory ~/repo-tests.log...",
|
||||
"Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch...",
|
||||
]);
|
||||
});
|
||||
|
||||
it("runs with gitlab clone with switch to feat/branch", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
url: "https://gitlab.com/mike.brew/repo-tests.log/-/tree/feat/branch",
|
||||
});
|
||||
const output = await executeScriptInContainer(state, "alpine/git");
|
||||
expect(output.exitCode).toBe(0);
|
||||
expect(output.stdout).toEqual([
|
||||
"Creating directory ~/repo-tests.log...",
|
||||
"Cloning https://gitlab.com/mike.brew/repo-tests.log to ~/repo-tests.log on branch feat/branch...",
|
||||
]);
|
||||
});
|
||||
|
||||
it("runs with github clone with branch_name set to feat/branch", async () => {
|
||||
const url = "https://github.com/michaelbrewer/repo-tests.log";
|
||||
const branch_name = "feat/branch";
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
url,
|
||||
branch_name,
|
||||
});
|
||||
expect(state.outputs.repo_dir.value).toEqual("~/repo-tests.log");
|
||||
expect(state.outputs.clone_url.value).toEqual(url);
|
||||
expect(state.outputs.web_url.value).toEqual(url);
|
||||
expect(state.outputs.branch_name.value).toEqual(branch_name);
|
||||
|
||||
const output = await executeScriptInContainer(state, "alpine/git");
|
||||
expect(output.exitCode).toBe(0);
|
||||
expect(output.stdout).toEqual([
|
||||
"Creating directory ~/repo-tests.log...",
|
||||
"Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch...",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,8 +25,50 @@ variable "agent_id" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "git_providers" {
|
||||
type = map(object({
|
||||
provider = string
|
||||
}))
|
||||
description = "A mapping of URLs to their git provider."
|
||||
default = {
|
||||
"https://github.com/" = {
|
||||
provider = "github"
|
||||
},
|
||||
"https://gitlab.com/" = {
|
||||
provider = "gitlab"
|
||||
},
|
||||
}
|
||||
validation {
|
||||
error_message = "Allowed values for provider are \"github\" or \"gitlab\"."
|
||||
condition = alltrue([for provider in var.git_providers : contains(["github", "gitlab"], provider.provider)])
|
||||
}
|
||||
}
|
||||
|
||||
variable "branch_name" {
|
||||
description = "The branch name to clone. If not provided, the default branch will be cloned."
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
locals {
|
||||
clone_path = var.base_dir != "" ? join("/", [var.base_dir, replace(basename(var.url), ".git", "")]) : join("/", ["~", replace(basename(var.url), ".git", "")])
|
||||
# Remove query parameters and fragments from the URL
|
||||
url = replace(replace(var.url, "/\\?.*/", ""), "/#.*/", "")
|
||||
|
||||
# Find the git provider based on the URL and determine the tree path
|
||||
provider_key = try(one([for key in keys(var.git_providers) : key if startswith(local.url, key)]), null)
|
||||
provider = try(lookup(var.git_providers, local.provider_key).provider, "")
|
||||
tree_path = local.provider == "gitlab" ? "/-/tree/" : local.provider == "github" ? "/tree/" : ""
|
||||
|
||||
# Remove tree and branch name from the URL
|
||||
clone_url = var.branch_name == "" && local.tree_path != "" ? replace(local.url, "/${local.tree_path}.*/", "") : local.url
|
||||
# Extract the branch name from the URL
|
||||
branch_name = var.branch_name == "" && local.tree_path != "" ? replace(replace(local.url, local.clone_url, ""), "/.*${local.tree_path}/", "") : var.branch_name
|
||||
# Extract the folder name from the URL
|
||||
folder_name = replace(basename(local.clone_url), ".git", "")
|
||||
# Construct the path to clone the repository
|
||||
clone_path = var.base_dir != "" ? join("/", [var.base_dir, local.folder_name]) : join("/", ["~", local.folder_name])
|
||||
# Construct the web URL
|
||||
web_url = startswith(local.clone_url, "git@") ? replace(replace(local.clone_url, ":", "/"), "git@", "https://") : local.clone_url
|
||||
}
|
||||
|
||||
output "repo_dir" {
|
||||
@@ -34,11 +76,37 @@ output "repo_dir" {
|
||||
description = "Full path of cloned repo directory"
|
||||
}
|
||||
|
||||
output "git_provider" {
|
||||
value = local.provider
|
||||
description = "The git provider of the repository"
|
||||
}
|
||||
|
||||
output "folder_name" {
|
||||
value = local.folder_name
|
||||
description = "The name of the folder that will be created"
|
||||
}
|
||||
|
||||
output "clone_url" {
|
||||
value = local.clone_url
|
||||
description = "The exact Git repository URL that will be cloned"
|
||||
}
|
||||
|
||||
output "web_url" {
|
||||
value = local.web_url
|
||||
description = "Git https repository URL (may be invalid for unsupported providers)"
|
||||
}
|
||||
|
||||
output "branch_name" {
|
||||
value = local.branch_name
|
||||
description = "Git branch name (may be empty)"
|
||||
}
|
||||
|
||||
resource "coder_script" "git_clone" {
|
||||
agent_id = var.agent_id
|
||||
script = templatefile("${path.module}/run.sh", {
|
||||
CLONE_PATH = local.clone_path
|
||||
REPO_URL : var.url,
|
||||
CLONE_PATH = local.clone_path,
|
||||
REPO_URL : local.clone_url,
|
||||
BRANCH_NAME : local.branch_name,
|
||||
})
|
||||
display_name = "Git Clone"
|
||||
icon = "/icon/git.svg"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
REPO_URL="${REPO_URL}"
|
||||
CLONE_PATH="${CLONE_PATH}"
|
||||
BRANCH_NAME="${BRANCH_NAME}"
|
||||
# Expand home if it's specified!
|
||||
CLONE_PATH="$${CLONE_PATH/#\~/$${HOME}}"
|
||||
|
||||
@@ -33,8 +34,13 @@ fi
|
||||
# Check if the directory is empty
|
||||
# and if it is, clone the repo, otherwise skip cloning
|
||||
if [ -z "$(ls -A "$CLONE_PATH")" ]; then
|
||||
echo "Cloning $REPO_URL to $CLONE_PATH..."
|
||||
git clone "$REPO_URL" "$CLONE_PATH"
|
||||
if [ -z "$BRANCH_NAME" ]; then
|
||||
echo "Cloning $REPO_URL to $CLONE_PATH..."
|
||||
git clone "$REPO_URL" "$CLONE_PATH"
|
||||
else
|
||||
echo "Cloning $REPO_URL to $CLONE_PATH on branch $BRANCH_NAME..."
|
||||
git clone "$REPO_URL" -b "$BRANCH_NAME" "$CLONE_PATH"
|
||||
fi
|
||||
else
|
||||
echo "$CLONE_PATH already exists and isn't empty, skipping clone!"
|
||||
exit 0
|
||||
|
||||
@@ -19,7 +19,7 @@ This module has a chance of conflicting with the user's dotfiles / the personali
|
||||
```tf
|
||||
module "git-commit-signing" {
|
||||
source = "registry.coder.com/modules/git-commit-signing/coder"
|
||||
version = "1.0.9"
|
||||
version = "1.0.11"
|
||||
agent_id = coder_agent.example.id
|
||||
}
|
||||
```
|
||||
|
||||
@@ -16,7 +16,7 @@ variable "agent_id" {
|
||||
|
||||
resource "coder_script" "git-commit-signing" {
|
||||
display_name = "Git commit signing"
|
||||
icon = "https://raw.githubusercontent.com/coder/modules/main/.icons/git.svg"
|
||||
icon = "/icon/git.svg"
|
||||
|
||||
script = file("${path.module}/run.sh")
|
||||
run_on_start = true
|
||||
|
||||
@@ -14,7 +14,7 @@ Runs a script that updates git credentials in the workspace to match the user's
|
||||
```tf
|
||||
module "git-config" {
|
||||
source = "registry.coder.com/modules/git-config/coder"
|
||||
version = "1.0.3"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
}
|
||||
```
|
||||
@@ -28,7 +28,7 @@ TODO: Add screenshot
|
||||
```tf
|
||||
module "git-config" {
|
||||
source = "registry.coder.com/modules/git-config/coder"
|
||||
version = "1.0.3"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
allow_email_change = true
|
||||
}
|
||||
@@ -41,7 +41,7 @@ TODO: Add screenshot
|
||||
```tf
|
||||
module "git-config" {
|
||||
source = "registry.coder.com/modules/git-config/coder"
|
||||
version = "1.0.3"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
allow_username_change = false
|
||||
allow_email_change = false
|
||||
|
||||
99
git-config/main.test.ts
Normal file
99
git-config/main.test.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import {
|
||||
runTerraformApply,
|
||||
runTerraformInit,
|
||||
testRequiredVariables,
|
||||
} from "../test";
|
||||
|
||||
describe("git-config", async () => {
|
||||
await runTerraformInit(import.meta.dir);
|
||||
|
||||
testRequiredVariables(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
});
|
||||
|
||||
it("can run apply allow_username_change and allow_email_change disabled", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
allow_username_change: "false",
|
||||
allow_email_change: "false",
|
||||
});
|
||||
|
||||
const resources = state.resources;
|
||||
expect(resources).toHaveLength(3);
|
||||
expect(resources).toMatchObject([
|
||||
{ type: "coder_workspace", name: "me" },
|
||||
{ type: "coder_env", name: "git_author_name" },
|
||||
{ type: "coder_env", name: "git_commmiter_name" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("can run apply allow_email_change enabled", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
allow_email_change: "true",
|
||||
});
|
||||
|
||||
const resources = state.resources;
|
||||
expect(resources).toHaveLength(5);
|
||||
expect(resources).toMatchObject([
|
||||
{ type: "coder_parameter", name: "user_email" },
|
||||
{ type: "coder_parameter", name: "username" },
|
||||
{ type: "coder_workspace", name: "me" },
|
||||
{ type: "coder_env", name: "git_author_name" },
|
||||
{ type: "coder_env", name: "git_commmiter_name" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("can run apply allow_email_change enabled", async () => {
|
||||
const state = await runTerraformApply(
|
||||
import.meta.dir,
|
||||
{
|
||||
agent_id: "foo",
|
||||
allow_username_change: "false",
|
||||
allow_email_change: "false",
|
||||
},
|
||||
{ CODER_WORKSPACE_OWNER_EMAIL: "foo@emai.com" },
|
||||
);
|
||||
|
||||
const resources = state.resources;
|
||||
expect(resources).toHaveLength(5);
|
||||
expect(resources).toMatchObject([
|
||||
{ type: "coder_workspace", name: "me" },
|
||||
{ type: "coder_env", name: "git_author_email" },
|
||||
{ type: "coder_env", name: "git_author_name" },
|
||||
{ type: "coder_env", name: "git_commmiter_email" },
|
||||
{ type: "coder_env", name: "git_commmiter_name" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("set custom order for coder_parameter for both fields", async () => {
|
||||
const order = 20;
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
allow_username_change: "true",
|
||||
allow_email_change: "true",
|
||||
coder_parameter_order: order.toString(),
|
||||
});
|
||||
expect(state.resources).toHaveLength(5);
|
||||
// user_email order is the same as the order
|
||||
expect(state.resources[0].instances[0].attributes.order).toBe(order);
|
||||
// username order is incremented by 1
|
||||
// @ts-ignore: Object is possibly 'null'.
|
||||
expect(state.resources[1].instances[0]?.attributes.order).toBe(order + 1);
|
||||
});
|
||||
|
||||
it("set custom order for coder_parameter for just username", async () => {
|
||||
const order = 30;
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
allow_email_change: "false",
|
||||
allow_username_change: "true",
|
||||
coder_parameter_order: order.toString(),
|
||||
});
|
||||
expect(state.resources).toHaveLength(4);
|
||||
// user_email was not created
|
||||
// username order is incremented by 1
|
||||
expect(state.resources[0].instances[0].attributes.order).toBe(order + 1);
|
||||
});
|
||||
});
|
||||
@@ -26,6 +26,11 @@ variable "allow_email_change" {
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "coder_parameter_order" {
|
||||
type = number
|
||||
description = "The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order)."
|
||||
default = null
|
||||
}
|
||||
|
||||
data "coder_workspace" "me" {}
|
||||
|
||||
@@ -34,6 +39,7 @@ data "coder_parameter" "user_email" {
|
||||
name = "user_email"
|
||||
type = "string"
|
||||
default = ""
|
||||
order = var.coder_parameter_order != null ? var.coder_parameter_order + 0 : null
|
||||
description = "Git user.email to be used for commits. Leave empty to default to Coder user's email."
|
||||
display_name = "Git config user.email"
|
||||
mutable = true
|
||||
@@ -44,6 +50,7 @@ data "coder_parameter" "username" {
|
||||
name = "username"
|
||||
type = "string"
|
||||
default = ""
|
||||
order = var.coder_parameter_order != null ? var.coder_parameter_order + 1 : null
|
||||
description = "Git user.name to be used for commits. Leave empty to default to Coder user's Full Name."
|
||||
display_name = "Full Name for Git config"
|
||||
mutable = true
|
||||
@@ -65,10 +72,12 @@ resource "coder_env" "git_author_email" {
|
||||
agent_id = var.agent_id
|
||||
name = "GIT_AUTHOR_EMAIL"
|
||||
value = coalesce(try(data.coder_parameter.user_email[0].value, ""), data.coder_workspace.me.owner_email)
|
||||
count = data.coder_workspace.me.owner_email != "" ? 1 : 0
|
||||
}
|
||||
|
||||
resource "coder_env" "git_commmiter_email" {
|
||||
agent_id = var.agent_id
|
||||
name = "GIT_COMMITTER_EMAIL"
|
||||
value = coalesce(try(data.coder_parameter.user_email[0].value, ""), data.coder_workspace.me.owner_email)
|
||||
count = data.coder_workspace.me.owner_email != "" ? 1 : 0
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ This module adds a JetBrains Gateway Button to open any workspace with a single
|
||||
```tf
|
||||
module "jetbrains_gateway" {
|
||||
source = "registry.coder.com/modules/jetbrains-gateway/coder"
|
||||
version = "1.0.9"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
agent_name = "example"
|
||||
folder = "/home/coder/example"
|
||||
@@ -27,12 +27,12 @@ module "jetbrains_gateway" {
|
||||
|
||||
## Examples
|
||||
|
||||
### Add GoLand and WebStorm with the default set to GoLand
|
||||
### Add GoLand and WebStorm as options with the default set to GoLand
|
||||
|
||||
```tf
|
||||
module "jetbrains_gateway" {
|
||||
source = "registry.coder.com/modules/jetbrains-gateway/coder"
|
||||
version = "1.0.9"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
agent_name = "example"
|
||||
folder = "/home/coder/example"
|
||||
@@ -41,6 +41,37 @@ module "jetbrains_gateway" {
|
||||
}
|
||||
```
|
||||
|
||||
### Use the latest release version
|
||||
|
||||
```tf
|
||||
module "jetbrains_gateway" {
|
||||
source = "registry.coder.com/modules/jetbrains-gateway/coder"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
agent_name = "example"
|
||||
folder = "/home/coder/example"
|
||||
jetbrains_ides = ["GO", "WS"]
|
||||
default = "GO"
|
||||
latest = true
|
||||
}
|
||||
```
|
||||
|
||||
### Use the latest EAP version
|
||||
|
||||
```tf
|
||||
module "jetbrains_gateway" {
|
||||
source = "registry.coder.com/modules/jetbrains-gateway/coder"
|
||||
version = "1.0.12"
|
||||
agent_id = coder_agent.example.id
|
||||
agent_name = "example"
|
||||
folder = "/home/coder/example"
|
||||
jetbrains_ides = ["GO", "WS"]
|
||||
default = "GO"
|
||||
latest = true
|
||||
channel = "eap"
|
||||
}
|
||||
```
|
||||
|
||||
## Supported IDEs
|
||||
|
||||
This module and JetBrains Gateway support the following JetBrains IDEs:
|
||||
|
||||
@@ -6,6 +6,10 @@ terraform {
|
||||
source = "coder/coder"
|
||||
version = ">= 0.17"
|
||||
}
|
||||
http = {
|
||||
source = "hashicorp/http"
|
||||
version = ">= 3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +44,28 @@ variable "order" {
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "coder_parameter_order" {
|
||||
type = number
|
||||
description = "The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order)."
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "latest" {
|
||||
type = bool
|
||||
description = "Whether to fetch the latest version of the IDE."
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "channel" {
|
||||
type = string
|
||||
description = "JetBrains IDE release channel. Valid values are release and eap."
|
||||
default = "release"
|
||||
validation {
|
||||
condition = can(regex("^(release|eap)$", var.channel))
|
||||
error_message = "The channel must be either release or eap."
|
||||
}
|
||||
}
|
||||
|
||||
variable "jetbrains_ide_versions" {
|
||||
type = map(object({
|
||||
build_number = string
|
||||
@@ -48,36 +74,36 @@ variable "jetbrains_ide_versions" {
|
||||
description = "The set of versions for each jetbrains IDE"
|
||||
default = {
|
||||
"IU" = {
|
||||
build_number = "233.14808.21"
|
||||
version = "2023.3.5"
|
||||
build_number = "241.14494.240"
|
||||
version = "2024.1"
|
||||
}
|
||||
"PS" = {
|
||||
build_number = "233.14808.18"
|
||||
version = "2023.3.5"
|
||||
build_number = "241.14494.237"
|
||||
version = "2024.1"
|
||||
}
|
||||
"WS" = {
|
||||
build_number = "233.14475.40"
|
||||
version = "2023.3.4"
|
||||
build_number = "241.14494.235"
|
||||
version = "2024.1"
|
||||
}
|
||||
"PY" = {
|
||||
build_number = "233.14475.56"
|
||||
version = "2023.3.4"
|
||||
build_number = "241.14494.241"
|
||||
version = "2024.1"
|
||||
}
|
||||
"CL" = {
|
||||
build_number = "233.14475.31"
|
||||
version = "2023.3.4"
|
||||
build_number = "241.14494.288"
|
||||
version = "2024.1"
|
||||
}
|
||||
"GO" = {
|
||||
build_number = "233.14808.20"
|
||||
version = "2023.3.5"
|
||||
build_number = "241.14494.238"
|
||||
version = "2024.1"
|
||||
}
|
||||
"RM" = {
|
||||
build_number = "233.14808.14"
|
||||
version = "2023.3.5"
|
||||
build_number = "241.14494.234"
|
||||
version = "2024.1"
|
||||
}
|
||||
"RD" = {
|
||||
build_number = "233.14475.66"
|
||||
version = "2023.3.4"
|
||||
build_number = "241.14494.307"
|
||||
version = "2024.1"
|
||||
}
|
||||
}
|
||||
validation {
|
||||
@@ -114,6 +140,11 @@ variable "jetbrains_ides" {
|
||||
}
|
||||
}
|
||||
|
||||
data "http" "jetbrains_ide_versions" {
|
||||
for_each = var.latest ? toset(var.jetbrains_ides) : toset([])
|
||||
url = "https://data.services.jetbrains.com/products/releases?code=${each.key}&latest=true&type=${var.channel}"
|
||||
}
|
||||
|
||||
locals {
|
||||
jetbrains_ides = {
|
||||
"GO" = {
|
||||
@@ -122,6 +153,7 @@ locals {
|
||||
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"
|
||||
version = var.jetbrains_ide_versions["GO"].version
|
||||
},
|
||||
"WS" = {
|
||||
icon = "/icon/webstorm.svg",
|
||||
@@ -129,6 +161,7 @@ locals {
|
||||
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"
|
||||
version = var.jetbrains_ide_versions["WS"].version
|
||||
},
|
||||
"IU" = {
|
||||
icon = "/icon/intellij.svg",
|
||||
@@ -136,6 +169,7 @@ locals {
|
||||
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"
|
||||
version = var.jetbrains_ide_versions["IU"].version
|
||||
},
|
||||
"PY" = {
|
||||
icon = "/icon/pycharm.svg",
|
||||
@@ -143,6 +177,7 @@ locals {
|
||||
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"
|
||||
version = var.jetbrains_ide_versions["PY"].version
|
||||
},
|
||||
"CL" = {
|
||||
icon = "/icon/clion.svg",
|
||||
@@ -150,6 +185,7 @@ locals {
|
||||
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"
|
||||
version = var.jetbrains_ide_versions["CL"].version
|
||||
},
|
||||
"PS" = {
|
||||
icon = "/icon/phpstorm.svg",
|
||||
@@ -157,6 +193,7 @@ locals {
|
||||
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"
|
||||
version = var.jetbrains_ide_versions["PS"].version
|
||||
},
|
||||
"RM" = {
|
||||
icon = "/icon/rubymine.svg",
|
||||
@@ -164,6 +201,7 @@ locals {
|
||||
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"
|
||||
version = var.jetbrains_ide_versions["RM"].version
|
||||
}
|
||||
"RD" = {
|
||||
icon = "/icon/rider.svg",
|
||||
@@ -171,8 +209,18 @@ locals {
|
||||
identifier = "RD",
|
||||
build_number = var.jetbrains_ide_versions["RD"].build_number,
|
||||
download_link = "https://download.jetbrains.com/rider/JetBrains.Rider-${var.jetbrains_ide_versions["RD"].version}.tar.gz"
|
||||
version = var.jetbrains_ide_versions["RD"].version
|
||||
}
|
||||
}
|
||||
|
||||
icon = local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].icon
|
||||
json_data = var.latest ? jsondecode(data.http.jetbrains_ide_versions[data.coder_parameter.jetbrains_ide.value].response_body) : {}
|
||||
key = var.latest ? keys(local.json_data)[0] : ""
|
||||
display_name = local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].name
|
||||
identifier = data.coder_parameter.jetbrains_ide.value
|
||||
download_link = var.latest ? local.json_data[local.key][0].downloads.linux.link : local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].download_link
|
||||
build_number = var.latest ? local.json_data[local.key][0].build : local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].build_number
|
||||
version = var.latest ? local.json_data[local.key][0].version : var.jetbrains_ide_versions[data.coder_parameter.jetbrains_ide.value].version
|
||||
}
|
||||
|
||||
data "coder_parameter" "jetbrains_ide" {
|
||||
@@ -182,13 +230,14 @@ data "coder_parameter" "jetbrains_ide" {
|
||||
icon = "/icon/gateway.svg"
|
||||
mutable = true
|
||||
default = var.default == "" ? var.jetbrains_ides[0] : var.default
|
||||
order = var.coder_parameter_order
|
||||
|
||||
dynamic "option" {
|
||||
for_each = var.jetbrains_ides
|
||||
content {
|
||||
icon = lookup(local.jetbrains_ides, option.value).icon
|
||||
name = lookup(local.jetbrains_ides, option.value).name
|
||||
value = lookup(local.jetbrains_ides, option.value).identifier
|
||||
icon = local.jetbrains_ides[option.value].icon
|
||||
name = local.jetbrains_ides[option.value].name
|
||||
value = option.value
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,8 +247,8 @@ data "coder_workspace" "me" {}
|
||||
resource "coder_app" "gateway" {
|
||||
agent_id = var.agent_id
|
||||
slug = "gateway"
|
||||
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")
|
||||
display_name = local.display_name
|
||||
icon = local.icon
|
||||
external = true
|
||||
order = var.order
|
||||
url = join("", [
|
||||
@@ -214,36 +263,36 @@ resource "coder_app" "gateway" {
|
||||
"&token=",
|
||||
"$SESSION_TOKEN",
|
||||
"&ide_product_code=",
|
||||
local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].identifier,
|
||||
data.coder_parameter.jetbrains_ide.value,
|
||||
"&ide_build_number=",
|
||||
local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].build_number,
|
||||
local.build_number,
|
||||
"&ide_download_link=",
|
||||
local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].download_link
|
||||
local.download_link,
|
||||
])
|
||||
}
|
||||
|
||||
output "identifier" {
|
||||
value = data.coder_parameter.jetbrains_ide.value
|
||||
value = local.identifier
|
||||
}
|
||||
|
||||
output "name" {
|
||||
value = coder_app.gateway.display_name
|
||||
output "display_name" {
|
||||
value = local.display_name
|
||||
}
|
||||
|
||||
output "icon" {
|
||||
value = coder_app.gateway.icon
|
||||
value = local.icon
|
||||
}
|
||||
|
||||
output "download_link" {
|
||||
value = lookup(local.jetbrains_ides, data.coder_parameter.jetbrains_ide.value).download_link
|
||||
value = local.download_link
|
||||
}
|
||||
|
||||
output "build_number" {
|
||||
value = lookup(local.jetbrains_ides, data.coder_parameter.jetbrains_ide.value).build_number
|
||||
value = local.build_number
|
||||
}
|
||||
|
||||
output "version" {
|
||||
value = var.jetbrains_ide_versions[data.coder_parameter.jetbrains_ide.value].version
|
||||
value = local.version
|
||||
}
|
||||
|
||||
output "url" {
|
||||
|
||||
263
package-lock.json
generated
Normal file
263
package-lock.json
generated
Normal file
@@ -0,0 +1,263 @@
|
||||
{
|
||||
"name": "modules",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "modules",
|
||||
"devDependencies": {
|
||||
"bun-types": "^1.0.18",
|
||||
"gray-matter": "^4.0.3",
|
||||
"marked": "^12.0.0",
|
||||
"prettier": "^3.2.5",
|
||||
"prettier-plugin-sh": "^0.13.1",
|
||||
"prettier-plugin-terraform-formatter": "^1.2.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.11.30",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz",
|
||||
"integrity": "sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/ws": {
|
||||
"version": "8.5.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.10.tgz",
|
||||
"integrity": "sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/argparse": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/bun-types": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/bun-types/-/bun-types-1.1.4.tgz",
|
||||
"integrity": "sha512-E1kk0FNpxpkSSlCVXEa4HfyhSUEpKtCFrybPVyz1A4TEnBGy5bqqtSYkyjKTfKScdyZTBeFrTxJLiKGOIRWgwg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "~20.11.3",
|
||||
"@types/ws": "~8.5.10"
|
||||
}
|
||||
},
|
||||
"node_modules/esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"esparse": "bin/esparse.js",
|
||||
"esvalidate": "bin/esvalidate.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/extend-shallow": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
|
||||
"integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"is-extendable": "^0.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/gray-matter": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.3.tgz",
|
||||
"integrity": "sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"js-yaml": "^3.13.1",
|
||||
"kind-of": "^6.0.2",
|
||||
"section-matter": "^1.0.0",
|
||||
"strip-bom-string": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-extendable": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
|
||||
"integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/kind-of": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
|
||||
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/marked": {
|
||||
"version": "12.0.2",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-12.0.2.tgz",
|
||||
"integrity": "sha512-qXUm7e/YKFoqFPYPa3Ukg9xlI5cyAtGmyEIzMfW//m6kXwCy2Ps9DYf5ioijFKQ8qyuscrHoY04iJGctu2Kg0Q==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"marked": "bin/marked.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/mvdan-sh": {
|
||||
"version": "0.10.1",
|
||||
"resolved": "https://registry.npmjs.org/mvdan-sh/-/mvdan-sh-0.10.1.tgz",
|
||||
"integrity": "sha512-kMbrH0EObaKmK3nVRKUIIya1dpASHIEusM13S4V1ViHFuxuNxCo+arxoa6j/dbV22YBGjl7UKJm9QQKJ2Crzhg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.2.5",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz",
|
||||
"integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier-plugin-sh": {
|
||||
"version": "0.13.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier-plugin-sh/-/prettier-plugin-sh-0.13.1.tgz",
|
||||
"integrity": "sha512-ytMcl1qK4s4BOFGvsc9b0+k9dYECal7U29bL/ke08FEUsF/JLN0j6Peo0wUkFDG4y2UHLMhvpyd6Sd3zDXe/eg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"mvdan-sh": "^0.10.1",
|
||||
"sh-syntax": "^0.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/unts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"prettier": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier-plugin-terraform-formatter": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier-plugin-terraform-formatter/-/prettier-plugin-terraform-formatter-1.2.1.tgz",
|
||||
"integrity": "sha512-rdzV61Bs/Ecnn7uAS/vL5usTX8xUWM+nQejNLZxt3I1kJH5WSeLEmq7LYu1wCoEQF+y7Uv1xGvPRfl3lIe6+tA==",
|
||||
"dev": true,
|
||||
"peerDependencies": {
|
||||
"prettier": ">= 1.16.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"prettier": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/section-matter": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz",
|
||||
"integrity": "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"extend-shallow": "^2.0.1",
|
||||
"kind-of": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/sh-syntax": {
|
||||
"version": "0.4.2",
|
||||
"resolved": "https://registry.npmjs.org/sh-syntax/-/sh-syntax-0.4.2.tgz",
|
||||
"integrity": "sha512-/l2UZ5fhGZLVZa16XQM9/Vq/hezGGbdHeVEA01uWjOL1+7Ek/gt6FquW0iKKws4a9AYPYvlz6RyVvjh3JxOteg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/unts"
|
||||
}
|
||||
},
|
||||
"node_modules/sprintf-js": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/strip-bom-string": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz",
|
||||
"integrity": "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.4.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz",
|
||||
"integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "5.26.5",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
"bun-types": "^1.0.18",
|
||||
"gray-matter": "^4.0.3",
|
||||
"marked": "^12.0.0",
|
||||
"prettier": "^3.2.5",
|
||||
"prettier-plugin-sh": "^0.13.1",
|
||||
"prettier-plugin-terraform-formatter": "^1.2.1"
|
||||
},
|
||||
@@ -23,4 +24,4 @@
|
||||
"prettier-plugin-terraform-formatter"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
test.ts
2
test.ts
@@ -171,9 +171,9 @@ export const testRequiredVariables = (
|
||||
export const runTerraformApply = async (
|
||||
dir: string,
|
||||
vars: Record<string, string>,
|
||||
env: Record<string, string> = {},
|
||||
): Promise<TerraformState> => {
|
||||
const stateFile = `${dir}/${crypto.randomUUID()}.tfstate`;
|
||||
const env = {};
|
||||
Object.keys(vars).forEach((key) => (env[`TF_VAR_${key}`] = vars[key]));
|
||||
const proc = spawn(
|
||||
[
|
||||
|
||||
@@ -14,7 +14,7 @@ Automatically install [Visual Studio Code Server](https://code.visualstudio.com/
|
||||
```tf
|
||||
module "vscode-web" {
|
||||
source = "registry.coder.com/modules/vscode-web/coder"
|
||||
version = "1.0.10"
|
||||
version = "1.0.11"
|
||||
agent_id = coder_agent.example.id
|
||||
accept_license = true
|
||||
}
|
||||
@@ -29,7 +29,7 @@ module "vscode-web" {
|
||||
```tf
|
||||
module "vscode-web" {
|
||||
source = "registry.coder.com/modules/vscode-web/coder"
|
||||
version = "1.0.10"
|
||||
version = "1.0.11"
|
||||
agent_id = coder_agent.example.id
|
||||
install_prefix = "/home/coder/.vscode-web"
|
||||
folder = "/home/coder"
|
||||
@@ -42,7 +42,7 @@ module "vscode-web" {
|
||||
```tf
|
||||
module "vscode-web" {
|
||||
source = "registry.coder.com/modules/vscode-web/coder"
|
||||
version = "1.0.10"
|
||||
version = "1.0.11"
|
||||
agent_id = coder_agent.example.id
|
||||
extensions = ["github.copilot", "ms-python.python", "ms-toolsai.jupyter"]
|
||||
accept_license = true
|
||||
@@ -56,7 +56,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte
|
||||
```tf
|
||||
module "vscode-web" {
|
||||
source = "registry.coder.com/modules/vscode-web/coder"
|
||||
version = "1.0.10"
|
||||
version = "1.0.11"
|
||||
agent_id = coder_agent.example.id
|
||||
extensions = ["dracula-theme.theme-dracula"]
|
||||
settings = {
|
||||
|
||||
@@ -51,6 +51,6 @@ if [ ! -f ~/.vscode-server/data/Machine/settings.json ]; then
|
||||
echo "${SETTINGS}" > ~/.vscode-server/data/Machine/settings.json
|
||||
fi
|
||||
|
||||
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 "👷 Running ${INSTALL_PREFIX}/bin/code-server serve-local --port ${PORT} --host 127.0.0.1 --accept-server-license-terms serve-local --without-connection-token --telemetry-level ${TELEMETRY_LEVEL} in the background..."
|
||||
echo "Check logs at ${LOG_PATH}!"
|
||||
"${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 &
|
||||
"${INSTALL_PREFIX}/bin/code-server" serve-local --port "${PORT}" --host 127.0.0.1 --accept-server-license-terms serve-local --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" > "${LOG_PATH}" 2>&1 &
|
||||
|
||||
Reference in New Issue
Block a user