Skip to content

feat(code-server): add machine settings option #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions registry/coder/modules/code-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ variable "settings" {
default = {}
}

variable "machine-settings" {
type = any
description = "A map of template level machine settings to apply to code-server. This will be overwritten at each container start."
default = {}
}

variable "folder" {
type = string
description = "The folder to open in code-server."
Expand Down Expand Up @@ -149,6 +155,7 @@ resource "coder_script" "code-server" {
INSTALL_PREFIX : var.install_prefix,
// This is necessary otherwise the quotes are stripped!
SETTINGS : replace(jsonencode(var.settings), "\"", "\\\""),
MACHINE_SETTINGS : replace(jsonencode(var.machine-settings), "\"", "\\\""),
OFFLINE : var.offline,
USE_CACHED : var.use_cached,
USE_CACHED_EXTENSIONS : var.use_cached_extensions,
Expand Down
15 changes: 14 additions & 1 deletion registry/coder/modules/code-server/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ function run_code_server() {
if [ ! -f ~/.local/share/code-server/User/settings.json ]; then
echo "⚙️ Creating settings file..."
mkdir -p ~/.local/share/code-server/User
echo "${SETTINGS}" > ~/.local/share/code-server/User/settings.json
if command -v jq &> /dev/null; then
echo "${SETTINGS}" | jq '.' > ~/.local/share/code-server/User/settings.json
else
echo "${SETTINGS}" > ~/.local/share/code-server/User/settings.json
fi
fi

# Apply/overwrite template based settings
echo "⚙️ Creating machine settings file..."
mkdir -p ~/.local/share/code-server/Machine
if command -v jq &> /dev/null; then
echo "${MACHINE_SETTINGS}" | jq '.' > ~/.local/share/code-server/Machine/settings.json
else
echo "${MACHINE_SETTINGS}" > ~/.local/share/code-server/Machine/settings.json
fi

# Check if code-server is already installed for offline
Expand Down