From c29960f5c873bd1186289be93edf82fc22b290aa Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 4 Apr 2023 14:10:42 +0300 Subject: [PATCH 1/8] add `display_name` --- examples/templates/aws-ecs-container/main.tf | 24 ++++--- examples/templates/aws-linux/main.tf | 20 +++--- examples/templates/aws-windows/main.tf | 20 +++--- examples/templates/azure-linux/main.tf | 19 +++--- examples/templates/do-linux/main.tf | 48 +++++++------ examples/templates/docker-code-server/main.tf | 2 +- .../templates/docker-image-builds/main.tf | 2 +- .../templates/docker-with-dotfiles/main.tf | 26 +++---- examples/templates/docker/main.tf | 2 +- examples/templates/fly-docker-image/main.tf | 68 ++++++++++--------- examples/templates/gcp-linux/main.tf | 13 ++-- examples/templates/gcp-vm-container/main.tf | 13 ++-- examples/templates/gcp-windows/main.tf | 13 ++-- .../templates/kubernetes-with-podman/main.tf | 17 +++-- examples/templates/kubernetes/main.tf | 31 +++++---- 15 files changed, 175 insertions(+), 143 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index e7869b1c270a5..bde58eca57278 100644 --- a/examples/templates/aws-ecs-container/main.tf +++ b/examples/templates/aws-ecs-container/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } aws = { source = "hashicorp/aws" @@ -20,19 +20,21 @@ variable "ecs-cluster" { } data "coder_parameter" "cpu" { - name = "cpu" - description = "The number of CPU units to reserve for the container" - type = "number" - default = "1024" - mutable = true + name = "cpu" + display_name = "CPU" + description = "The number of CPU units to reserve for the container" + type = "number" + default = "1024" + mutable = true } data "coder_parameter" "memory" { - name = "memory" - description = "The amount of memory (in MiB) to allow the container to use" - type = "number" - default = "2048" - mutable = true + name = "memory" + display_name = "Memory" + description = "The amount of memory (in MiB) to allow the container to use" + type = "number" + default = "2048" + mutable = true } # configure AWS provider with creds present on Coder server host diff --git a/examples/templates/aws-linux/main.tf b/examples/templates/aws-linux/main.tf index 986a1088a17cb..5fe0faa0d7072 100644 --- a/examples/templates/aws-linux/main.tf +++ b/examples/templates/aws-linux/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } aws = { source = "hashicorp/aws" @@ -14,10 +14,11 @@ terraform { # Last updated 2023-03-14 # aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort' data "coder_parameter" "region" { - name = "Region" - description = "The region to deploy the workspace in." - default = "us-east-1" - mutable = false + name = "region" + display_name = "Region" + description = "The region to deploy the workspace in." + default = "us-east-1" + mutable = false option { name = "Asia Pacific (Tokyo)" value = "ap-northeast-1" @@ -106,10 +107,11 @@ data "coder_parameter" "region" { } data "coder_parameter" "instance_type" { - name = "Instance Type" - description = "What instance type should your workspace use?" - default = "t3.micro" - mutable = false + name = "instance_type" + display_name = "Instance Type" + description = "What instance type should your workspace use?" + default = "t3.micro" + mutable = false option { name = "2 vCPU, 1 GiB RAM" value = "t3.micro" diff --git a/examples/templates/aws-windows/main.tf b/examples/templates/aws-windows/main.tf index 87c5b710a2c97..daf694d93b942 100644 --- a/examples/templates/aws-windows/main.tf +++ b/examples/templates/aws-windows/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } aws = { source = "hashicorp/aws" @@ -14,10 +14,11 @@ terraform { # Last updated 2023-03-14 # aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort' data "coder_parameter" "region" { - name = "Region" - description = "The region to deploy the workspace in." - default = "us-east-1" - mutable = false + name = "region" + display_name = "Region" + description = "The region to deploy the workspace in." + default = "us-east-1" + mutable = false option { name = "Asia Pacific (Tokyo)" value = "ap-northeast-1" @@ -106,10 +107,11 @@ data "coder_parameter" "region" { } data "coder_parameter" "instance_type" { - name = "Instance Type" - description = "What instance type should your workspace use?" - default = "t3.micro" - mutable = false + name = "instance_type" + dsiplay_name = "Instance Type" + description = "What instance type should your workspace use?" + default = "t3.micro" + mutable = false option { name = "2 vCPU, 1 GiB RAM" value = "t3.micro" diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf index 7360ac9381f70..5995b7f11604d 100644 --- a/examples/templates/azure-linux/main.tf +++ b/examples/templates/azure-linux/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } azurerm = { source = "hashicorp/azurerm" @@ -12,11 +12,12 @@ terraform { } data "coder_parameter" "location" { - name = "Location" - description = "What location should your workspace live in?" - default = "eastus" - icon = "/emojis/1f310.png" - mutable = false + name = "location" + display_name = "Location" + description = "What location should your workspace live in?" + default = "eastus" + icon = "/emojis/1f310.png" + mutable = false option { name = "US (Virginia)" value = "eastus" @@ -150,7 +151,8 @@ data "coder_parameter" "location" { } data "coder_parameter" "instance_type" { - name = "Instance Type" + name = "instance_type" + display = "Instance Type" description = "What instance type should your workspace use?" default = "Standard_B4ms" icon = "/icon/azure.png" @@ -202,7 +204,8 @@ data "coder_parameter" "instance_type" { } data "coder_parameter" "home_size" { - name = "Home Volume Size" + name = "home_size" + display = "Home Volume Size" description = "How large would you like your home volume to be (in GB)?" default = 20 type = "number" diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf index b87d91d0d4172..14e82904b86fa 100644 --- a/examples/templates/do-linux/main.tf +++ b/examples/templates/do-linux/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } digitalocean = { source = "digitalocean/digitalocean" @@ -52,10 +52,12 @@ variable "step2_do_admin_ssh_key" { } data "coder_parameter" "droplet_image" { - name = "Which Droplet image would you like to use for your workspace?" - default = "ubuntu-22-04-x64" - type = "string" - mutable = false + name = "droplet_image" + display_name = "Droplet Image" + description = "Which Droplet image would you like to use?" + default = "ubuntu-22-04-x64" + type = "string" + mutable = false option { name = "Ubuntu 22.04" value = "ubuntu-22-04-x64" @@ -109,11 +111,13 @@ data "coder_parameter" "droplet_image" { } data "coder_parameter" "droplet_size" { - name = "Which Droplet configuration would you like to use?" - default = "s-1vcpu-1gb" - type = "string" - icon = "/icon/memory.svg" - mutable = false + name = "droplet_size" + display_name = "Droplet Size" + description = "Which Droplet configuration would you like to use?" + default = "s-1vcpu-1gb" + type = "string" + icon = "/icon/memory.svg" + mutable = false option { name = "1 vCPU, 1 GB RAM" value = "s-1vcpu-1gb" @@ -142,11 +146,12 @@ data "coder_parameter" "droplet_size" { data "coder_parameter" "home_volume_size" { - name = "How large would you like your home volume to be (in GB)?" - description = "This volume will be mounted to /home/coder." - type = "number" - default = "20" - mutable = false + name = "home_volume_size" + display_name = "How large would you like your home volume to be (in GB)?" + description = "This volume will be mounted to /home/coder." + type = "number" + default = "20" + mutable = false validation { min = 1 max = 999999 @@ -154,12 +159,13 @@ data "coder_parameter" "home_volume_size" { } data "coder_parameter" "region" { - name = "Which region would you like to use?" - description = "This is the region where your workspace will be created." - icon = "/emojis/1f30e.png" - type = "string" - default = "ams3" - mutable = false + name = "region" + display_name = "Which region would you like to use?" + description = "This is the region where your workspace will be created." + icon = "/emojis/1f30e.png" + type = "string" + default = "ams3" + mutable = false option { name = "New York 1" value = "nyc1" diff --git a/examples/templates/docker-code-server/main.tf b/examples/templates/docker-code-server/main.tf index b8284fe99011c..7c4c754393bac 100644 --- a/examples/templates/docker-code-server/main.tf +++ b/examples/templates/docker-code-server/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } docker = { source = "kreuzwerker/docker" diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index a660cd2c5bc7e..a3b7c73f2e5d4 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -3,7 +3,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } docker = { source = "kreuzwerker/docker" diff --git a/examples/templates/docker-with-dotfiles/main.tf b/examples/templates/docker-with-dotfiles/main.tf index 5c655d704d779..95a6223bc95fe 100644 --- a/examples/templates/docker-with-dotfiles/main.tf +++ b/examples/templates/docker-with-dotfiles/main.tf @@ -9,7 +9,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } docker = { source = "kreuzwerker/docker" @@ -28,24 +28,26 @@ data "coder_workspace" "me" { } data "coder_parameter" "docker_image" { - name = "What Docker image would you like to use for your workspace?" - description = "The Docker image will be used to build your workspace." - default = "codercom/enterprise-base:ubuntu" - icon = "/icon/docker.png" - type = "string" - mutable = false + name = "docker_image" + display_name = "What Docker image would you like to use for your workspace?" + description = "The Docker image will be used to build your workspace." + default = "codercom/enterprise-base:ubuntu" + icon = "/icon/docker.png" + type = "string" + mutable = false } data "coder_parameter" "dotfiles_uri" { - name = "What dotfiles repo would you like to use for your workspace?" - description = <<-EOF + name = "dotfiles_uri" + display_name = "What dotfiles repo would you like to use for your workspace?" + description = <<-EOF Dotfiles repo URI (optional) see https://dotfiles.github.io EOF - default = "" - type = "string" - mutable = true + default = "" + type = "string" + mutable = true } resource "coder_agent" "main" { diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index 6df6868f5a978..c595b0052ecbe 100644 --- a/examples/templates/docker/main.tf +++ b/examples/templates/docker/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } docker = { source = "kreuzwerker/docker" diff --git a/examples/templates/fly-docker-image/main.tf b/examples/templates/fly-docker-image/main.tf index 11629217c9c47..28f48411416ef 100644 --- a/examples/templates/fly-docker-image/main.tf +++ b/examples/templates/fly-docker-image/main.tf @@ -6,7 +6,7 @@ terraform { } coder = { source = "coder/coder" - version = "~>0.6.17" + version = "~>0.7.0" } } } @@ -108,19 +108,21 @@ EOF } data "coder_parameter" "docker-image" { - name = "Docker Image" - description = "The docker image to use for the workspace" - default = "codercom/code-server:latest" - icon = "https://raw.githubusercontent.com/matifali/logos/main/docker.svg" + name = "docker-image" + display_name = "Docker Image" + description = "The docker image to use for the workspace" + default = "codercom/code-server:latest" + icon = "https://raw.githubusercontent.com/matifali/logos/main/docker.svg" } data "coder_parameter" "cpu" { - name = "CPU" - description = "The number of CPUs to allocate to the workspace (1-8)" - type = "number" - default = "1" - icon = "https://raw.githubusercontent.com/matifali/logos/main/cpu-3.svg" - mutable = true + name = "cpu" + display_name = "CPU" + description = "The number of CPUs to allocate to the workspace (1-8)" + type = "number" + default = "1" + icon = "https://raw.githubusercontent.com/matifali/logos/main/cpu-3.svg" + mutable = true validation { min = 1 max = 8 @@ -128,11 +130,12 @@ data "coder_parameter" "cpu" { } data "coder_parameter" "cputype" { - name = "CPU Type" - description = "Which CPU type do you want?" - default = "shared" - icon = "https://raw.githubusercontent.com/matifali/logos/main/cpu-1.svg" - mutable = true + name = "cputype" + display_name = "CPU Type" + description = "Which CPU type do you want?" + default = "shared" + icon = "https://raw.githubusercontent.com/matifali/logos/main/cpu-1.svg" + mutable = true option { name = "Shared" value = "shared" @@ -144,12 +147,13 @@ data "coder_parameter" "cputype" { } data "coder_parameter" "memory" { - name = "Memory (GB)" - description = "The amount of memory to allocate to the workspace in GB (up to 16GB)" - type = "number" - default = "2" - icon = "/icon/memory.svg" - mutable = true + name = "memory" + display_name = "Memory (GB)" + description = "The amount of memory to allocate to the workspace in GB (up to 16GB)" + type = "number" + default = "2" + icon = "/icon/memory.svg" + mutable = true validation { min = data.coder_parameter.cputype.value == "performance" ? 2 : 1 # if the CPU type is performance, the minimum memory is 2GB max = 16 @@ -157,11 +161,12 @@ data "coder_parameter" "memory" { } data "coder_parameter" "volume-size" { - name = "Volume Size" - description = "The size of the volume to create for the workspace in GB (1-20)" - type = "number" - default = "1" - icon = "https://raw.githubusercontent.com/matifali/logos/main/database.svg" + name = "volume-size" + display_name = "Volume Size" + description = "The size of the volume to create for the workspace in GB (1-20)" + type = "number" + default = "1" + icon = "https://raw.githubusercontent.com/matifali/logos/main/database.svg" validation { min = 1 max = 20 @@ -170,10 +175,11 @@ data "coder_parameter" "volume-size" { # You can see all available regions here: https://fly.io/docs/reference/regions/ data "coder_parameter" "region" { - name = "Region" - description = "The region to deploy the workspace in" - default = "ams" - icon = "/emojis/1f30e.png" + name = "region" + display_name = "Region" + description = "The region to deploy the workspace in" + default = "ams" + icon = "/emojis/1f30e.png" option { name = "Amsterdam, Netherlands" value = "ams" diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf index 41c8387a494fe..26fd9fe540420 100644 --- a/examples/templates/gcp-linux/main.tf +++ b/examples/templates/gcp-linux/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } google = { source = "hashicorp/google" @@ -20,11 +20,12 @@ variable "project_id" { } data "coder_parameter" "zone" { - name = "What region should your workspace live in?" - type = "string" - icon = "/emojis/1f30e.png" - default = "us-central1-a" - mutable = false + name = "zone" + display_name = "What region should your workspace live in?" + type = "string" + icon = "/emojis/1f30e.png" + default = "us-central1-a" + mutable = false option { name = "North America (Northeast)" value = "northamerica-northeast1-a" diff --git a/examples/templates/gcp-vm-container/main.tf b/examples/templates/gcp-vm-container/main.tf index 447de56a1822d..6bde64b4a14cd 100644 --- a/examples/templates/gcp-vm-container/main.tf +++ b/examples/templates/gcp-vm-container/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } google = { source = "hashicorp/google" @@ -20,11 +20,12 @@ variable "project_id" { } data "coder_parameter" "zone" { - name = "What region should your workspace live in?" - type = "string" - default = "us-central1-a" - icon = "/emojis/1f30e.png" - mutable = false + name = "zone" + display_name = "What region should your workspace live in?" + type = "string" + default = "us-central1-a" + icon = "/emojis/1f30e.png" + mutable = false option { name = "North America (Northeast)" value = "northamerica-northeast1-a" diff --git a/examples/templates/gcp-windows/main.tf b/examples/templates/gcp-windows/main.tf index e57a7adb5732e..5e2b22be56f7c 100644 --- a/examples/templates/gcp-windows/main.tf +++ b/examples/templates/gcp-windows/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } google = { source = "hashicorp/google" @@ -20,11 +20,12 @@ variable "project_id" { } data "coder_parameter" "zone" { - name = "What region should your workspace live in?" - type = "string" - default = "us-central1-a" - icon = "/emojis/1f30e.png" - mutable = false + name = "zone" + display_name = "What region should your workspace live in?" + type = "string" + default = "us-central1-a" + icon = "/emojis/1f30e.png" + mutable = false option { name = "North America (Northeast)" value = "northamerica-northeast1-a" diff --git a/examples/templates/kubernetes-with-podman/main.tf b/examples/templates/kubernetes-with-podman/main.tf index 01ea4f52adea6..8a46fd61c0ad1 100644 --- a/examples/templates/kubernetes-with-podman/main.tf +++ b/examples/templates/kubernetes-with-podman/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } kubernetes = { source = "hashicorp/kubernetes" @@ -18,8 +18,9 @@ provider "kubernetes" { data "coder_workspace" "me" {} data "coder_parameter" "os" { - name = "Operating system" - default = "ubuntu" + name = "os" + display_name = "Operating system" + default = "ubuntu" option { name = "Ubuntu" value = "ubuntu" @@ -33,8 +34,9 @@ data "coder_parameter" "os" { } data "coder_parameter" "cpu" { - name = "CPU (cores)" - default = "2" + name = "cpu" + display_name = "CPU (cores)" + default = "2" option { name = "2 Cores" value = "2" @@ -54,8 +56,9 @@ data "coder_parameter" "cpu" { } data "coder_parameter" "memory" { - name = "Memory (GB)" - default = "2" + name = "memory" + display_name = "Memory (GB)" + default = "2" option { name = "2 GB" value = "2" diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index b373dc5744205..bbf54ecf1a9f6 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.17" + version = "~> 0.7.0" } kubernetes = { source = "hashicorp/kubernetes" @@ -35,10 +35,11 @@ variable "namespace" { } data "coder_parameter" "cpu" { - name = "CPU (cores)" - default = "2" - icon = "/icon/memory.svg" - mutable = true + name = "cpu" + display_name = "CPU (cores)" + default = "2" + icon = "/icon/memory.svg" + mutable = true option { name = "2 Cores" value = "2" @@ -58,10 +59,11 @@ data "coder_parameter" "cpu" { } data "coder_parameter" "memory" { - name = "Memory (GB)" - default = "2" - icon = "/icon/memory.svg" - mutable = true + name = "memory" + display_name = "Memory (GB)" + default = "2" + icon = "/icon/memory.svg" + mutable = true option { name = "2 GB" value = "2" @@ -81,11 +83,12 @@ data "coder_parameter" "memory" { } data "coder_parameter" "home_disk_size" { - name = "Home Disk Size (GB)" - default = "10" - type = "number" - icon = "/emojis/1f4be.png" - mutable = false + name = "home_disk_size" + display_name = "Home Disk Size (GB)" + default = "10" + type = "number" + icon = "/emojis/1f4be.png" + mutable = false validation { min = 1 max = 99999 From 1fec6442711baf88a5f0d64e391d589734b6f13d Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 4 Apr 2023 14:20:08 +0300 Subject: [PATCH 2/8] fix typos and `terraform validate` --- examples/templates/aws-windows/main.tf | 2 +- examples/templates/azure-linux/main.tf | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/templates/aws-windows/main.tf b/examples/templates/aws-windows/main.tf index daf694d93b942..ee27898cd2c27 100644 --- a/examples/templates/aws-windows/main.tf +++ b/examples/templates/aws-windows/main.tf @@ -108,7 +108,7 @@ data "coder_parameter" "region" { data "coder_parameter" "instance_type" { name = "instance_type" - dsiplay_name = "Instance Type" + display_name = "Instance Type" description = "What instance type should your workspace use?" default = "t3.micro" mutable = false diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf index 5995b7f11604d..db2742946588b 100644 --- a/examples/templates/azure-linux/main.tf +++ b/examples/templates/azure-linux/main.tf @@ -151,12 +151,12 @@ data "coder_parameter" "location" { } data "coder_parameter" "instance_type" { - name = "instance_type" - display = "Instance Type" - description = "What instance type should your workspace use?" - default = "Standard_B4ms" - icon = "/icon/azure.png" - mutable = false + name = "instance_type" + display_name = "Instance Type" + description = "What instance type should your workspace use?" + default = "Standard_B4ms" + icon = "/icon/azure.png" + mutable = false option { name = "Standard_B1ms (1 vCPU, 2 GiB RAM)" value = "Standard_B1ms" @@ -204,13 +204,13 @@ data "coder_parameter" "instance_type" { } data "coder_parameter" "home_size" { - name = "home_size" - display = "Home Volume Size" - description = "How large would you like your home volume to be (in GB)?" - default = 20 - type = "number" - icon = "/icon/azure.png" - mutable = false + name = "home_size" + display_name = "Home Volume Size" + description = "How large would you like your home volume to be (in GB)?" + default = 20 + type = "number" + icon = "/icon/azure.png" + mutable = false validation { min = 1 max = 1024 From 6c9959e5c001db802296275db1942b115a425fc9 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 7 Apr 2023 11:57:22 +0300 Subject: [PATCH 3/8] update display_name --- examples/templates/do-linux/main.tf | 6 +++--- examples/templates/docker-image-builds/main.tf | 2 +- examples/templates/docker-with-dotfiles/main.tf | 4 ++-- examples/templates/fly-docker-image/main.tf | 6 +++--- examples/templates/gcp-linux/main.tf | 3 ++- examples/templates/gcp-vm-container/main.tf | 3 ++- examples/templates/gcp-windows/main.tf | 3 ++- examples/templates/kubernetes-with-podman/main.tf | 9 ++++++--- examples/templates/kubernetes/main.tf | 9 ++++++--- 9 files changed, 27 insertions(+), 18 deletions(-) diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf index 14e82904b86fa..69ab5f342e026 100644 --- a/examples/templates/do-linux/main.tf +++ b/examples/templates/do-linux/main.tf @@ -147,8 +147,8 @@ data "coder_parameter" "droplet_size" { data "coder_parameter" "home_volume_size" { name = "home_volume_size" - display_name = "How large would you like your home volume to be (in GB)?" - description = "This volume will be mounted to /home/coder." + display_name = "Home Volume Size" + description = "How large would you like your home volume to be (in GB)?" type = "number" default = "20" mutable = false @@ -160,7 +160,7 @@ data "coder_parameter" "home_volume_size" { data "coder_parameter" "region" { name = "region" - display_name = "Which region would you like to use?" + display_name = "Region" description = "This is the region where your workspace will be created." icon = "/emojis/1f30e.png" type = "string" diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index a3b7c73f2e5d4..8c8dc1615eb57 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -52,7 +52,7 @@ resource "coder_app" "code-server" { } data "coder_parameter" "docker_image" { - name = "What Docker image would you like to use for your workspace?" + name = "Docker Image" description = "The Docker image will be used to build your workspace. You can choose from a list of pre-built images or provide your own." default = "base" icon = "/icon/docker.png" diff --git a/examples/templates/docker-with-dotfiles/main.tf b/examples/templates/docker-with-dotfiles/main.tf index 95a6223bc95fe..5f51d700bf11b 100644 --- a/examples/templates/docker-with-dotfiles/main.tf +++ b/examples/templates/docker-with-dotfiles/main.tf @@ -29,7 +29,7 @@ data "coder_workspace" "me" { data "coder_parameter" "docker_image" { name = "docker_image" - display_name = "What Docker image would you like to use for your workspace?" + display_name = "Docker Image" description = "The Docker image will be used to build your workspace." default = "codercom/enterprise-base:ubuntu" icon = "/icon/docker.png" @@ -39,7 +39,7 @@ data "coder_parameter" "docker_image" { data "coder_parameter" "dotfiles_uri" { name = "dotfiles_uri" - display_name = "What dotfiles repo would you like to use for your workspace?" + display_name = "dotfiles URI" description = <<-EOF Dotfiles repo URI (optional) diff --git a/examples/templates/fly-docker-image/main.tf b/examples/templates/fly-docker-image/main.tf index 28f48411416ef..16fd667a444c1 100644 --- a/examples/templates/fly-docker-image/main.tf +++ b/examples/templates/fly-docker-image/main.tf @@ -148,7 +148,7 @@ data "coder_parameter" "cputype" { data "coder_parameter" "memory" { name = "memory" - display_name = "Memory (GB)" + display_name = "Memory" description = "The amount of memory to allocate to the workspace in GB (up to 16GB)" type = "number" default = "2" @@ -162,7 +162,7 @@ data "coder_parameter" "memory" { data "coder_parameter" "volume-size" { name = "volume-size" - display_name = "Volume Size" + display_name = "Home Volume Size" description = "The size of the volume to create for the workspace in GB (1-20)" type = "number" default = "1" @@ -260,7 +260,7 @@ data "coder_parameter" "region" { resource "coder_app" "code-server" { count = 1 agent_id = coder_agent.main.id - display_name = "Code Server" + display_name = "code-server" slug = "code-server" url = "http://localhost:8080?folder=/home/coder/" icon = "/icon/code.svg" diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf index 26fd9fe540420..234219db35b0c 100644 --- a/examples/templates/gcp-linux/main.tf +++ b/examples/templates/gcp-linux/main.tf @@ -21,7 +21,8 @@ variable "project_id" { data "coder_parameter" "zone" { name = "zone" - display_name = "What region should your workspace live in?" + display_name = "Zone" + description = "Which zone should your workspace live in?" type = "string" icon = "/emojis/1f30e.png" default = "us-central1-a" diff --git a/examples/templates/gcp-vm-container/main.tf b/examples/templates/gcp-vm-container/main.tf index 6bde64b4a14cd..51d82c1da6407 100644 --- a/examples/templates/gcp-vm-container/main.tf +++ b/examples/templates/gcp-vm-container/main.tf @@ -21,7 +21,8 @@ variable "project_id" { data "coder_parameter" "zone" { name = "zone" - display_name = "What region should your workspace live in?" + display_name = "Zone" + description = "Which zone should your workspace live in?" type = "string" default = "us-central1-a" icon = "/emojis/1f30e.png" diff --git a/examples/templates/gcp-windows/main.tf b/examples/templates/gcp-windows/main.tf index 5e2b22be56f7c..c7ef3e175c974 100644 --- a/examples/templates/gcp-windows/main.tf +++ b/examples/templates/gcp-windows/main.tf @@ -21,7 +21,8 @@ variable "project_id" { data "coder_parameter" "zone" { name = "zone" - display_name = "What region should your workspace live in?" + display_name = "Zone" + description = "Which zone should your workspace live in?" type = "string" default = "us-central1-a" icon = "/emojis/1f30e.png" diff --git a/examples/templates/kubernetes-with-podman/main.tf b/examples/templates/kubernetes-with-podman/main.tf index 8a46fd61c0ad1..254352ab030ad 100644 --- a/examples/templates/kubernetes-with-podman/main.tf +++ b/examples/templates/kubernetes-with-podman/main.tf @@ -20,6 +20,7 @@ data "coder_workspace" "me" {} data "coder_parameter" "os" { name = "os" display_name = "Operating system" + description = "The operating system to use for your workspace." default = "ubuntu" option { name = "Ubuntu" @@ -35,7 +36,8 @@ data "coder_parameter" "os" { data "coder_parameter" "cpu" { name = "cpu" - display_name = "CPU (cores)" + display_name = "CPU" + description = "The number of CPU cores" default = "2" option { name = "2 Cores" @@ -57,7 +59,8 @@ data "coder_parameter" "cpu" { data "coder_parameter" "memory" { name = "memory" - display_name = "Memory (GB)" + display_name = "Memory" + description = "The amount of memory (in GB)" default = "2" option { name = "2 GB" @@ -96,7 +99,7 @@ resource "coder_agent" "dev" { # code-server resource "coder_app" "code-server" { agent_id = coder_agent.dev.id - display_name = "Code Server" + display_name = "code-server" slug = "code-server" icon = "/icon/code.svg" url = "http://localhost:13337" diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index bbf54ecf1a9f6..f1d819a619837 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -36,7 +36,8 @@ variable "namespace" { data "coder_parameter" "cpu" { name = "cpu" - display_name = "CPU (cores)" + display_name = "CPU" + description = "The number of CPU cores" default = "2" icon = "/icon/memory.svg" mutable = true @@ -60,7 +61,8 @@ data "coder_parameter" "cpu" { data "coder_parameter" "memory" { name = "memory" - display_name = "Memory (GB)" + display_name = "Memory" + description = "The amount of memory in GB" default = "2" icon = "/icon/memory.svg" mutable = true @@ -84,7 +86,8 @@ data "coder_parameter" "memory" { data "coder_parameter" "home_disk_size" { name = "home_disk_size" - display_name = "Home Disk Size (GB)" + display_name = "Home Disk Size" + description = "The size of the home disk in GB" default = "10" type = "number" icon = "/emojis/1f4be.png" From 7fb6e5a4c07978358ca70f2cbb3f2ec0fa549b98 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 7 Apr 2023 14:06:27 +0300 Subject: [PATCH 4/8] Add agent metadata --- examples/templates/aws-ecs-container/main.tf | 34 ++++++++++++++++++ examples/templates/aws-linux/main.tf | 34 ++++++++++++++++++ examples/templates/azure-linux/main.tf | 34 ++++++++++++++++++ examples/templates/do-linux/main.tf | 35 +++++++++++++++++++ examples/templates/docker-code-server/main.tf | 34 ++++++++++++++++++ .../templates/docker-image-builds/main.tf | 34 ++++++++++++++++++ .../templates/docker-with-dotfiles/main.tf | 34 ++++++++++++++++++ examples/templates/docker/main.tf | 34 ++++++++++++++++++ examples/templates/fly-docker-image/main.tf | 34 ++++++++++++++++++ examples/templates/gcp-linux/main.tf | 34 ++++++++++++++++++ examples/templates/gcp-vm-container/main.tf | 23 ++++++++++++ .../templates/kubernetes-with-podman/main.tf | 34 ++++++++++++++++++ examples/templates/kubernetes/main.tf | 34 ++++++++++++++++++ 13 files changed, 432 insertions(+) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index bde58eca57278..2212ed5b7dc7e 100644 --- a/examples/templates/aws-ecs-container/main.tf +++ b/examples/templates/aws-ecs-container/main.tf @@ -119,6 +119,40 @@ resource "coder_agent" "coder" { curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } } resource "coder_app" "code-server" { diff --git a/examples/templates/aws-linux/main.tf b/examples/templates/aws-linux/main.tf index 5fe0faa0d7072..333bb081c71b8 100644 --- a/examples/templates/aws-linux/main.tf +++ b/examples/templates/aws-linux/main.tf @@ -171,6 +171,40 @@ resource "coder_agent" "main" { curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } } resource "coder_app" "code-server" { diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf index db2742946588b..88538569c54b1 100644 --- a/examples/templates/azure-linux/main.tf +++ b/examples/templates/azure-linux/main.tf @@ -229,6 +229,40 @@ resource "coder_agent" "main" { os = "linux" auth = "azure-instance-identity" login_before_ready = false + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } } locals { diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf index 69ab5f342e026..4d56b2e710d43 100644 --- a/examples/templates/do-linux/main.tf +++ b/examples/templates/do-linux/main.tf @@ -246,6 +246,41 @@ resource "coder_agent" "main" { arch = "amd64" login_before_ready = false + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } + } resource "digitalocean_volume" "home_volume" { diff --git a/examples/templates/docker-code-server/main.tf b/examples/templates/docker-code-server/main.tf index 7c4c754393bac..b5ae962953707 100644 --- a/examples/templates/docker-code-server/main.tf +++ b/examples/templates/docker-code-server/main.tf @@ -40,6 +40,40 @@ resource "coder_agent" "main" { GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}" GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}" } + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } } resource "coder_app" "code-server" { diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index 8c8dc1615eb57..604ea82396a40 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -33,6 +33,40 @@ resource "coder_agent" "main" { curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } } resource "coder_app" "code-server" { diff --git a/examples/templates/docker-with-dotfiles/main.tf b/examples/templates/docker-with-dotfiles/main.tf index 5f51d700bf11b..5efc427352eeb 100644 --- a/examples/templates/docker-with-dotfiles/main.tf +++ b/examples/templates/docker-with-dotfiles/main.tf @@ -63,6 +63,40 @@ resource "coder_agent" "main" { coder dotfiles -y "$DOTFILES_URI" fi EOT + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } } resource "docker_volume" "home_volume" { diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index c595b0052ecbe..8169b5da1f4fa 100644 --- a/examples/templates/docker/main.tf +++ b/examples/templates/docker/main.tf @@ -47,6 +47,40 @@ resource "coder_agent" "main" { GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}" GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}" } + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } } resource "coder_app" "code-server" { diff --git a/examples/templates/fly-docker-image/main.tf b/examples/templates/fly-docker-image/main.tf index 16fd667a444c1..50a521ce37673 100644 --- a/examples/templates/fly-docker-image/main.tf +++ b/examples/templates/fly-docker-image/main.tf @@ -290,6 +290,40 @@ resource "coder_agent" "main" { echo "export PATH=$PATH:/home/coder/.fly/bin" >> ~/.bashrc source ~/.bashrc EOT + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } } resource "coder_metadata" "workspace" { diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf index 234219db35b0c..7fcfeb34d2c40 100644 --- a/examples/templates/gcp-linux/main.tf +++ b/examples/templates/gcp-linux/main.tf @@ -88,6 +88,40 @@ resource "coder_agent" "main" { curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } } # code-server diff --git a/examples/templates/gcp-vm-container/main.tf b/examples/templates/gcp-vm-container/main.tf index 51d82c1da6407..2bd4d788011ad 100644 --- a/examples/templates/gcp-vm-container/main.tf +++ b/examples/templates/gcp-vm-container/main.tf @@ -79,6 +79,29 @@ resource "coder_agent" "main" { curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } } # code-server diff --git a/examples/templates/kubernetes-with-podman/main.tf b/examples/templates/kubernetes-with-podman/main.tf index 254352ab030ad..6336dd2b00245 100644 --- a/examples/templates/kubernetes-with-podman/main.tf +++ b/examples/templates/kubernetes-with-podman/main.tf @@ -94,6 +94,40 @@ resource "coder_agent" "dev" { # Run once to avoid unnecessary warning: "/" is not a shared mount podman ps EOF + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/podman"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } } # code-server diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index f1d819a619837..f98f73a8fa919 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -117,6 +117,40 @@ resource "coder_agent" "main" { curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT + + metadata { + key = "cpu" + display_name = "CPU Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + EOT + } + metadata { + key = "memory" + display_name = "Memory Usage" + interval = 5 + timeout = 5 + script = <<-EOT + #!/bin/bash + set -e + free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' + EOT + } + metadata { + key = "disk" + display_name = "Disk Usage" + interval = 600 # every 10 minutes + timeout = 30 # df can take a while on large filesystems + script = <<-EOT + #!/bin/bash + set -e + df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + EOT + } } # code-server From d648d3fd676556e0c579f8de8c28853e54dc98bb Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 7 Apr 2023 14:33:17 +0300 Subject: [PATCH 5/8] add % to cpu usage --- examples/templates/aws-ecs-container/main.tf | 2 +- examples/templates/aws-linux/main.tf | 2 +- examples/templates/azure-linux/main.tf | 2 +- examples/templates/do-linux/main.tf | 2 +- examples/templates/docker-code-server/main.tf | 2 +- examples/templates/docker-image-builds/main.tf | 2 +- examples/templates/docker-with-dotfiles/main.tf | 2 +- examples/templates/docker/main.tf | 2 +- examples/templates/fly-docker-image/main.tf | 2 +- examples/templates/gcp-linux/main.tf | 2 +- examples/templates/gcp-vm-container/main.tf | 2 +- examples/templates/kubernetes-with-podman/main.tf | 2 +- examples/templates/kubernetes/main.tf | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index 2212ed5b7dc7e..122a532ce189f 100644 --- a/examples/templates/aws-ecs-container/main.tf +++ b/examples/templates/aws-ecs-container/main.tf @@ -128,7 +128,7 @@ resource "coder_agent" "coder" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/aws-linux/main.tf b/examples/templates/aws-linux/main.tf index 333bb081c71b8..29aee71cfd9b1 100644 --- a/examples/templates/aws-linux/main.tf +++ b/examples/templates/aws-linux/main.tf @@ -180,7 +180,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf index 88538569c54b1..50ff31c1e978c 100644 --- a/examples/templates/azure-linux/main.tf +++ b/examples/templates/azure-linux/main.tf @@ -238,7 +238,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf index 4d56b2e710d43..555f129750185 100644 --- a/examples/templates/do-linux/main.tf +++ b/examples/templates/do-linux/main.tf @@ -255,7 +255,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/docker-code-server/main.tf b/examples/templates/docker-code-server/main.tf index b5ae962953707..b48aa8c2029e3 100644 --- a/examples/templates/docker-code-server/main.tf +++ b/examples/templates/docker-code-server/main.tf @@ -49,7 +49,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index 604ea82396a40..86d3a8ef55968 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -42,7 +42,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/docker-with-dotfiles/main.tf b/examples/templates/docker-with-dotfiles/main.tf index 5efc427352eeb..de7f3bdf68a88 100644 --- a/examples/templates/docker-with-dotfiles/main.tf +++ b/examples/templates/docker-with-dotfiles/main.tf @@ -72,7 +72,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index 8169b5da1f4fa..6d25968f329f0 100644 --- a/examples/templates/docker/main.tf +++ b/examples/templates/docker/main.tf @@ -56,7 +56,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/fly-docker-image/main.tf b/examples/templates/fly-docker-image/main.tf index 50a521ce37673..c4a0eec044b04 100644 --- a/examples/templates/fly-docker-image/main.tf +++ b/examples/templates/fly-docker-image/main.tf @@ -299,7 +299,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf index 7fcfeb34d2c40..f776a923a6a1e 100644 --- a/examples/templates/gcp-linux/main.tf +++ b/examples/templates/gcp-linux/main.tf @@ -97,7 +97,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/gcp-vm-container/main.tf b/examples/templates/gcp-vm-container/main.tf index 2bd4d788011ad..c454e881a21c8 100644 --- a/examples/templates/gcp-vm-container/main.tf +++ b/examples/templates/gcp-vm-container/main.tf @@ -88,7 +88,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/kubernetes-with-podman/main.tf b/examples/templates/kubernetes-with-podman/main.tf index 6336dd2b00245..9662a9c8a26e5 100644 --- a/examples/templates/kubernetes-with-podman/main.tf +++ b/examples/templates/kubernetes-with-podman/main.tf @@ -103,7 +103,7 @@ resource "coder_agent" "dev" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index f98f73a8fa919..198c521842701 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -126,7 +126,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}' + top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' EOT } metadata { From 7c4a750b27a848b2f4eea4547c3f07fc239db9d5 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 7 Apr 2023 14:34:57 +0300 Subject: [PATCH 6/8] update disk usage check script --- examples/templates/aws-ecs-container/main.tf | 2 +- examples/templates/aws-linux/main.tf | 2 +- examples/templates/azure-linux/main.tf | 2 +- examples/templates/do-linux/main.tf | 2 +- examples/templates/docker-code-server/main.tf | 2 +- examples/templates/docker-image-builds/main.tf | 2 +- examples/templates/docker-with-dotfiles/main.tf | 2 +- examples/templates/docker/main.tf | 2 +- examples/templates/fly-docker-image/main.tf | 2 +- examples/templates/gcp-linux/main.tf | 2 +- examples/templates/kubernetes-with-podman/main.tf | 2 +- examples/templates/kubernetes/main.tf | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index 122a532ce189f..4073ccf5de5c1 100644 --- a/examples/templates/aws-ecs-container/main.tf +++ b/examples/templates/aws-ecs-container/main.tf @@ -150,7 +150,7 @@ resource "coder_agent" "coder" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/coder | awk '$NF=="/"{printf "%s", $5}' EOT } } diff --git a/examples/templates/aws-linux/main.tf b/examples/templates/aws-linux/main.tf index 29aee71cfd9b1..582c15aacfd0d 100644 --- a/examples/templates/aws-linux/main.tf +++ b/examples/templates/aws-linux/main.tf @@ -202,7 +202,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/coder | awk '$NF=="/"{printf "%s", $5}' EOT } } diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf index 50ff31c1e978c..24e10deac98b5 100644 --- a/examples/templates/azure-linux/main.tf +++ b/examples/templates/azure-linux/main.tf @@ -260,7 +260,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/coder | awk '$NF=="/"{printf "%s", $5}' EOT } } diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf index 555f129750185..733f48bea472b 100644 --- a/examples/templates/do-linux/main.tf +++ b/examples/templates/do-linux/main.tf @@ -277,7 +277,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/coder | awk '$NF=="/"{printf "%s", $5}' EOT } diff --git a/examples/templates/docker-code-server/main.tf b/examples/templates/docker-code-server/main.tf index b48aa8c2029e3..e50a70a303b0a 100644 --- a/examples/templates/docker-code-server/main.tf +++ b/examples/templates/docker-code-server/main.tf @@ -71,7 +71,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/coder | awk '$NF=="/"{printf "%s", $5}' EOT } } diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index 86d3a8ef55968..5cc277672a68c 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -64,7 +64,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/coder | awk '$NF=="/"{printf "%s", $5}' EOT } } diff --git a/examples/templates/docker-with-dotfiles/main.tf b/examples/templates/docker-with-dotfiles/main.tf index de7f3bdf68a88..43a4ae0aca791 100644 --- a/examples/templates/docker-with-dotfiles/main.tf +++ b/examples/templates/docker-with-dotfiles/main.tf @@ -94,7 +94,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/coder | awk '$NF=="/"{printf "%s", $5}' EOT } } diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index 6d25968f329f0..a8c055460d8b3 100644 --- a/examples/templates/docker/main.tf +++ b/examples/templates/docker/main.tf @@ -78,7 +78,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/coder | awk '$NF=="/"{printf "%s", $5}' EOT } } diff --git a/examples/templates/fly-docker-image/main.tf b/examples/templates/fly-docker-image/main.tf index c4a0eec044b04..f1233d45a56b4 100644 --- a/examples/templates/fly-docker-image/main.tf +++ b/examples/templates/fly-docker-image/main.tf @@ -321,7 +321,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/coder | awk '$NF=="/"{printf "%s", $5}' EOT } } diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf index f776a923a6a1e..f7c29b76598f5 100644 --- a/examples/templates/gcp-linux/main.tf +++ b/examples/templates/gcp-linux/main.tf @@ -119,7 +119,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/coder | awk '$NF=="/"{printf "%s", $5}' EOT } } diff --git a/examples/templates/kubernetes-with-podman/main.tf b/examples/templates/kubernetes-with-podman/main.tf index 9662a9c8a26e5..3fa428bd9e893 100644 --- a/examples/templates/kubernetes-with-podman/main.tf +++ b/examples/templates/kubernetes-with-podman/main.tf @@ -125,7 +125,7 @@ resource "coder_agent" "dev" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/podman"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/podman | awk '$NF=="/"{printf "%s", $5}' EOT } } diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index 198c521842701..7df2d2a91566b 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -148,7 +148,7 @@ resource "coder_agent" "main" { script = <<-EOT #!/bin/bash set -e - df -h | awk '$NF=="/home/coder"{printf "%d/%dGB (%s)\t", $3,$2,$5}' + df /home/coder | awk '$NF=="/"{printf "%s", $5}' EOT } } From eda79400dc827c08394592f11e7bdb15338a8bcf Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Sat, 8 Apr 2023 13:49:54 +0300 Subject: [PATCH 7/8] remove metadata from containers and pods workspaces --- examples/templates/docker-code-server/main.tf | 34 ------------------- .../templates/docker-image-builds/main.tf | 34 ------------------- .../templates/docker-with-dotfiles/main.tf | 34 ------------------- examples/templates/docker/main.tf | 34 ------------------- examples/templates/gcp-vm-container/main.tf | 23 ------------- .../templates/kubernetes-with-podman/main.tf | 22 ------------ examples/templates/kubernetes/main.tf | 22 ------------ 7 files changed, 203 deletions(-) diff --git a/examples/templates/docker-code-server/main.tf b/examples/templates/docker-code-server/main.tf index e50a70a303b0a..7c4c754393bac 100644 --- a/examples/templates/docker-code-server/main.tf +++ b/examples/templates/docker-code-server/main.tf @@ -40,40 +40,6 @@ resource "coder_agent" "main" { GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}" GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}" } - - metadata { - key = "cpu" - display_name = "CPU Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' - EOT - } - metadata { - key = "memory" - display_name = "Memory Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' - EOT - } - metadata { - key = "disk" - display_name = "Disk Usage" - interval = 600 # every 10 minutes - timeout = 30 # df can take a while on large filesystems - script = <<-EOT - #!/bin/bash - set -e - df /home/coder | awk '$NF=="/"{printf "%s", $5}' - EOT - } } resource "coder_app" "code-server" { diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index 5cc277672a68c..8c8dc1615eb57 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -33,40 +33,6 @@ resource "coder_agent" "main" { curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT - - metadata { - key = "cpu" - display_name = "CPU Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' - EOT - } - metadata { - key = "memory" - display_name = "Memory Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' - EOT - } - metadata { - key = "disk" - display_name = "Disk Usage" - interval = 600 # every 10 minutes - timeout = 30 # df can take a while on large filesystems - script = <<-EOT - #!/bin/bash - set -e - df /home/coder | awk '$NF=="/"{printf "%s", $5}' - EOT - } } resource "coder_app" "code-server" { diff --git a/examples/templates/docker-with-dotfiles/main.tf b/examples/templates/docker-with-dotfiles/main.tf index 43a4ae0aca791..5f51d700bf11b 100644 --- a/examples/templates/docker-with-dotfiles/main.tf +++ b/examples/templates/docker-with-dotfiles/main.tf @@ -63,40 +63,6 @@ resource "coder_agent" "main" { coder dotfiles -y "$DOTFILES_URI" fi EOT - - metadata { - key = "cpu" - display_name = "CPU Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' - EOT - } - metadata { - key = "memory" - display_name = "Memory Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' - EOT - } - metadata { - key = "disk" - display_name = "Disk Usage" - interval = 600 # every 10 minutes - timeout = 30 # df can take a while on large filesystems - script = <<-EOT - #!/bin/bash - set -e - df /home/coder | awk '$NF=="/"{printf "%s", $5}' - EOT - } } resource "docker_volume" "home_volume" { diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index a8c055460d8b3..c595b0052ecbe 100644 --- a/examples/templates/docker/main.tf +++ b/examples/templates/docker/main.tf @@ -47,40 +47,6 @@ resource "coder_agent" "main" { GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}" GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}" } - - metadata { - key = "cpu" - display_name = "CPU Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' - EOT - } - metadata { - key = "memory" - display_name = "Memory Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' - EOT - } - metadata { - key = "disk" - display_name = "Disk Usage" - interval = 600 # every 10 minutes - timeout = 30 # df can take a while on large filesystems - script = <<-EOT - #!/bin/bash - set -e - df /home/coder | awk '$NF=="/"{printf "%s", $5}' - EOT - } } resource "coder_app" "code-server" { diff --git a/examples/templates/gcp-vm-container/main.tf b/examples/templates/gcp-vm-container/main.tf index c454e881a21c8..51d82c1da6407 100644 --- a/examples/templates/gcp-vm-container/main.tf +++ b/examples/templates/gcp-vm-container/main.tf @@ -79,29 +79,6 @@ resource "coder_agent" "main" { curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT - - metadata { - key = "cpu" - display_name = "CPU Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' - EOT - } - metadata { - key = "memory" - display_name = "Memory Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' - EOT - } } # code-server diff --git a/examples/templates/kubernetes-with-podman/main.tf b/examples/templates/kubernetes-with-podman/main.tf index 3fa428bd9e893..2774cbe795f85 100644 --- a/examples/templates/kubernetes-with-podman/main.tf +++ b/examples/templates/kubernetes-with-podman/main.tf @@ -95,28 +95,6 @@ resource "coder_agent" "dev" { podman ps EOF - metadata { - key = "cpu" - display_name = "CPU Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' - EOT - } - metadata { - key = "memory" - display_name = "Memory Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' - EOT - } metadata { key = "disk" display_name = "Disk Usage" diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index 7df2d2a91566b..c147a2a9d0daf 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -118,28 +118,6 @@ resource "coder_agent" "main" { /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT - metadata { - key = "cpu" - display_name = "CPU Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' - EOT - } - metadata { - key = "memory" - display_name = "Memory Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' - EOT - } metadata { key = "disk" display_name = "Disk Usage" From e4ebef4372f2fe2918d1c29e0c48fedef51591a7 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Sat, 8 Apr 2023 13:54:21 +0300 Subject: [PATCH 8/8] removes disk metadata from container workspaces --- examples/templates/aws-ecs-container/main.tf | 34 -------------------- 1 file changed, 34 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index 4073ccf5de5c1..bde58eca57278 100644 --- a/examples/templates/aws-ecs-container/main.tf +++ b/examples/templates/aws-ecs-container/main.tf @@ -119,40 +119,6 @@ resource "coder_agent" "coder" { curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT - - metadata { - key = "cpu" - display_name = "CPU Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}' - EOT - } - metadata { - key = "memory" - display_name = "Memory Usage" - interval = 5 - timeout = 5 - script = <<-EOT - #!/bin/bash - set -e - free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }' - EOT - } - metadata { - key = "disk" - display_name = "Disk Usage" - interval = 600 # every 10 minutes - timeout = 30 # df can take a while on large filesystems - script = <<-EOT - #!/bin/bash - set -e - df /home/coder | awk '$NF=="/"{printf "%s", $5}' - EOT - } } resource "coder_app" "code-server" {