Michael Smith 376664ca04
chore: migrate all Coder modules to Registry repo (#4)
Addresses part of https://github.com/coder/internal/issues/532 (but doesn't fully close it out).

This is a huge PR, but chunking it up seemed pointless, since we're largely copying over existing files. I'm going to try commenting on the main areas I think are worth paying attention to

## Changes made
- Migrated over all Coder modules from coder/modules, and put them in their correct user namespaces.
- Added README.md files to all newly-created user namespaces
- Updated all image paths for every image used, to make sure they don't break (I switched the paths programmatically, and then manually verified every README to guarantee this).
- Added README.md files for each contributor who previously made a module
- Updated our `tsconfig.json` file to use modern libraries when run from the server, and made a custom `tsconfig.json` just for the `windows-rdp` module (which has more restrictive browser concerns)
- Added CI step to run all the module tests we currently have

## Notes
- There were a lot of Bash script files that weren't carried over in this PR, partly because I don't know Bash well enough to know (1) whether they're still needed, or (2) modify them to account for the new file structure. Those can be brought over later.
- We had a `lint.ts` file that provided some light validation of some of the modules. After going through it, there were so many bugs and issues with the code that I legitimately think that it barely provided a safety net at all. I got rid of it entirely, with the intention of adding the functionality that was originally intended to the current validation logic (to be handled in a separate PR).
- I changed how we set up the `.images` directory, because it felt like it would be chaos if a bunch of users try to throw all their images in one giant directory, with no guidelines on how to do it. I instead made it so that images should be scoped by namespace, which felt a lot more manageable. The `.icons` directory is still at the top level, because realistically, there are only going to be so many types of icons referenced, so it's fine for those to be shared.
- I don't think the `maintainer_github` and `contributor_github` fields make sense anymore, but those can be stripped out once we've updated the Registry site build step to use the new Registry repo
   - My gut instinct is to use the user namespace to determine the main owner of the module, and then add a `contributors` string list to indicate which other users have contributed meaningfully to it. We can then add validation to make sure that every value in that list exists as another namespace in the repo

## What still needs to be migrated (in separate PRs)
These are the main files of interest that still probably need to be copied over from the `/modules` repo:
- `new.sh`
- `terraform_validate.sh`
- `update-version.sh`

They're probably going to require enough changes that it's worth handling them in a separate PR.
2025-04-17 09:49:54 -04:00

287 lines
7.0 KiB
HCL

terraform {
required_version = ">= 1.0"
required_providers {
coder = {
source = "coder/coder"
version = ">= 0.12"
}
}
}
variable "display_name" {
default = "Fly.io Region"
description = "The display name of the parameter."
type = string
}
variable "description" {
default = "The region to deploy workspace infrastructure."
description = "The description of the parameter."
type = string
}
variable "default" {
default = null
description = "The default region to use if no region is specified."
type = string
}
variable "mutable" {
default = false
description = "Whether the parameter can be changed after creation."
type = bool
}
variable "custom_names" {
default = {}
description = "A map of custom display names for region IDs."
type = map(string)
}
variable "custom_icons" {
default = {}
description = "A map of custom icons for region IDs."
type = map(string)
}
variable "regions" {
default = []
description = "List of regions to include for region selection."
type = list(string)
}
locals {
regions = {
"ams" = {
name = "Amsterdam, Netherlands"
gateway = true
paid_only = false
icon = "/emojis/1f1f3-1f1f1.png"
}
"arn" = {
name = "Stockholm, Sweden"
gateway = false
paid_only = false
icon = "/emojis/1f1f8-1f1ea.png"
}
"atl" = {
name = "Atlanta, Georgia (US)"
gateway = false
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"bog" = {
name = "Bogotá, Colombia"
gateway = false
paid_only = false
icon = "/emojis/1f1e8-1f1f4.png"
}
"bom" = {
name = "Mumbai, India"
gateway = true
paid_only = true
icon = "/emojis/1f1ee-1f1f3.png"
}
"bos" = {
name = "Boston, Massachusetts (US)"
gateway = false
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"cdg" = {
name = "Paris, France"
gateway = true
paid_only = false
icon = "/emojis/1f1eb-1f1f7.png"
}
"den" = {
name = "Denver, Colorado (US)"
gateway = false
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"dfw" = {
name = "Dallas, Texas (US)"
gateway = true
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"ewr" = {
name = "Secaucus, NJ (US)"
gateway = false
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"eze" = {
name = "Ezeiza, Argentina"
gateway = false
paid_only = false
icon = "/emojis/1f1e6-1f1f7.png"
}
"fra" = {
name = "Frankfurt, Germany"
gateway = true
paid_only = true
icon = "/emojis/1f1e9-1f1ea.png"
}
"gdl" = {
name = "Guadalajara, Mexico"
gateway = false
paid_only = false
icon = "/emojis/1f1f2-1f1fd.png"
}
"gig" = {
name = "Rio de Janeiro, Brazil"
gateway = false
paid_only = false
icon = "/emojis/1f1e7-1f1f7.png"
}
"gru" = {
name = "Sao Paulo, Brazil"
gateway = false
paid_only = false
icon = "/emojis/1f1e7-1f1f7.png"
}
"hkg" = {
name = "Hong Kong, Hong Kong"
gateway = true
paid_only = false
icon = "/emojis/1f1ed-1f1f0.png"
}
"iad" = {
name = "Ashburn, Virginia (US)"
gateway = true
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"jnb" = {
name = "Johannesburg, South Africa"
gateway = false
paid_only = false
icon = "/emojis/1f1ff-1f1e6.png"
}
"lax" = {
name = "Los Angeles, California (US)"
gateway = true
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"lhr" = {
name = "London, United Kingdom"
gateway = true
paid_only = false
icon = "/emojis/1f1ec-1f1e7.png"
}
"mad" = {
name = "Madrid, Spain"
gateway = false
paid_only = false
icon = "/emojis/1f1ea-1f1f8.png"
}
"mia" = {
name = "Miami, Florida (US)"
gateway = false
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"nrt" = {
name = "Tokyo, Japan"
gateway = true
paid_only = false
icon = "/emojis/1f1ef-1f1f5.png"
}
"ord" = {
name = "Chicago, Illinois (US)"
gateway = true
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"otp" = {
name = "Bucharest, Romania"
gateway = false
paid_only = false
icon = "/emojis/1f1f7-1f1f4.png"
}
"phx" = {
name = "Phoenix, Arizona (US)"
gateway = false
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"qro" = {
name = "Querétaro, Mexico"
gateway = false
paid_only = false
icon = "/emojis/1f1f2-1f1fd.png"
}
"scl" = {
name = "Santiago, Chile"
gateway = true
paid_only = false
icon = "/emojis/1f1e8-1f1f1.png"
}
"sea" = {
name = "Seattle, Washington (US)"
gateway = true
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"sin" = {
name = "Singapore, Singapore"
gateway = true
paid_only = false
icon = "/emojis/1f1f8-1f1ec.png"
}
"sjc" = {
name = "San Jose, California (US)"
gateway = true
paid_only = false
icon = "/emojis/1f1fa-1f1f8.png"
}
"syd" = {
name = "Sydney, Australia"
gateway = true
paid_only = false
icon = "/emojis/1f1e6-1f1fa.png"
}
"waw" = {
name = "Warsaw, Poland"
gateway = false
paid_only = false
icon = "/emojis/1f1f5-1f1f1.png"
}
"yul" = {
name = "Montreal, Canada"
gateway = false
paid_only = false
icon = "/emojis/1f1e8-1f1e6.png"
}
"yyz" = {
name = "Toronto, Canada"
gateway = true
paid_only = false
icon = "/emojis/1f1e8-1f1e6.png"
}
}
}
data "coder_parameter" "fly_region" {
name = "flyio_region"
display_name = var.display_name
description = var.description
default = (var.default != null && var.default != "") && ((var.default != null ? contains(var.regions, var.default) : false) || length(var.regions) == 0) ? var.default : null
mutable = var.mutable
dynamic "option" {
for_each = { for k, v in local.regions : k => v if anytrue([for d in var.regions : k == d]) || length(var.regions) == 0 }
content {
name = try(var.custom_names[option.key], option.value.name)
icon = try(var.custom_icons[option.key], option.value.icon)
value = option.key
}
}
}
output "value" {
value = data.coder_parameter.fly_region.value
}