From 5cf20d6f70fbe769fbc051f1237492a0b658ab63 Mon Sep 17 00:00:00 2001 From: Eric Paulsen Date: Mon, 3 Oct 2022 14:33:55 -0500 Subject: [PATCH 1/8] chore: clean up example templates & add quickstarts --- examples/templates/bare/README.md | 7 - examples/templates/bare/main.tf | 58 --------- .../templates/docker-code-server/README.md | 25 ---- examples/templates/docker-code-server/main.tf | 78 ----------- .../docker-code-server/params.sample.yaml | 2 - examples/templates/gcp-vm-container/README.md | 51 -------- examples/templates/gcp-vm-container/main.tf | 123 ------------------ {examples => templates}/examples.go | 105 ++++++++------- .../examples}/README.md | 2 +- .../examples}/community-templates.md | 0 .../examples}/docker-image-builds/README.md | 0 .../images/base.Dockerfile | 0 .../images/java.Dockerfile | 0 .../images/node.Dockerfile | 0 .../examples}/docker-image-builds/main.tf | 0 .../examples}/docker-with-dotfiles/README.md | 0 .../examples}/docker-with-dotfiles/main.tf | 0 .../examples}/lima/README.md | 0 .../examples}/lima/coder.yaml | 0 .../examples}/update_template_versions.sh | 0 {examples => templates}/examples_test.go | 3 +- .../containers}/aws-ecs-container/README.md | 0 .../containers}/aws-ecs-container/main.tf | 0 .../quickstart/containers}/docker/README.md | 0 .../containers}/docker/build/Dockerfile | 0 .../quickstart/containers}/docker/main.tf | 0 .../containers}/kubernetes/README.md | 0 .../quickstart/containers}/kubernetes/main.tf | 0 .../virtual-machines}/aws-linux/README.md | 0 .../virtual-machines}/aws-linux/main.tf | 0 .../virtual-machines}/aws-windows/README.md | 0 .../virtual-machines}/aws-windows/main.tf | 0 .../virtual-machines}/azure-linux/README.md | 0 .../azure-linux/cloud-config.yaml.tftpl | 0 .../virtual-machines}/azure-linux/main.tf | 0 .../virtual-machines}/do-linux/README.md | 0 .../do-linux/cloud-config.yaml.tftpl | 0 .../virtual-machines}/do-linux/main.tf | 0 .../virtual-machines}/gcp-linux/README.md | 0 .../virtual-machines}/gcp-linux/main.tf | 0 .../virtual-machines}/gcp-windows/README.md | 0 .../virtual-machines}/gcp-windows/main.tf | 0 42 files changed, 60 insertions(+), 394 deletions(-) delete mode 100644 examples/templates/bare/README.md delete mode 100644 examples/templates/bare/main.tf delete mode 100644 examples/templates/docker-code-server/README.md delete mode 100644 examples/templates/docker-code-server/main.tf delete mode 100644 examples/templates/docker-code-server/params.sample.yaml delete mode 100644 examples/templates/gcp-vm-container/README.md delete mode 100644 examples/templates/gcp-vm-container/main.tf rename {examples => templates}/examples.go (63%) rename {examples/templates => templates/examples}/README.md (95%) rename {examples/templates => templates/examples}/community-templates.md (100%) rename {examples/templates => templates/examples}/docker-image-builds/README.md (100%) rename {examples/templates => templates/examples}/docker-image-builds/images/base.Dockerfile (100%) rename {examples/templates => templates/examples}/docker-image-builds/images/java.Dockerfile (100%) rename {examples/templates => templates/examples}/docker-image-builds/images/node.Dockerfile (100%) rename {examples/templates => templates/examples}/docker-image-builds/main.tf (100%) rename {examples/templates => templates/examples}/docker-with-dotfiles/README.md (100%) rename {examples/templates => templates/examples}/docker-with-dotfiles/main.tf (100%) rename {examples => templates/examples}/lima/README.md (100%) rename {examples => templates/examples}/lima/coder.yaml (100%) rename {examples => templates/examples}/update_template_versions.sh (100%) rename {examples => templates}/examples_test.go (96%) rename {examples/templates => templates/quickstart/containers}/aws-ecs-container/README.md (100%) rename {examples/templates => templates/quickstart/containers}/aws-ecs-container/main.tf (100%) rename {examples/templates => templates/quickstart/containers}/docker/README.md (100%) rename {examples/templates => templates/quickstart/containers}/docker/build/Dockerfile (100%) rename {examples/templates => templates/quickstart/containers}/docker/main.tf (100%) rename {examples/templates => templates/quickstart/containers}/kubernetes/README.md (100%) rename {examples/templates => templates/quickstart/containers}/kubernetes/main.tf (100%) rename {examples/templates => templates/quickstart/virtual-machines}/aws-linux/README.md (100%) rename {examples/templates => templates/quickstart/virtual-machines}/aws-linux/main.tf (100%) rename {examples/templates => templates/quickstart/virtual-machines}/aws-windows/README.md (100%) rename {examples/templates => templates/quickstart/virtual-machines}/aws-windows/main.tf (100%) rename {examples/templates => templates/quickstart/virtual-machines}/azure-linux/README.md (100%) rename {examples/templates => templates/quickstart/virtual-machines}/azure-linux/cloud-config.yaml.tftpl (100%) rename {examples/templates => templates/quickstart/virtual-machines}/azure-linux/main.tf (100%) rename {examples/templates => templates/quickstart/virtual-machines}/do-linux/README.md (100%) rename {examples/templates => templates/quickstart/virtual-machines}/do-linux/cloud-config.yaml.tftpl (100%) rename {examples/templates => templates/quickstart/virtual-machines}/do-linux/main.tf (100%) rename {examples/templates => templates/quickstart/virtual-machines}/gcp-linux/README.md (100%) rename {examples/templates => templates/quickstart/virtual-machines}/gcp-linux/main.tf (100%) rename {examples/templates => templates/quickstart/virtual-machines}/gcp-windows/README.md (100%) rename {examples/templates => templates/quickstart/virtual-machines}/gcp-windows/main.tf (100%) diff --git a/examples/templates/bare/README.md b/examples/templates/bare/README.md deleted file mode 100644 index fff556b7e0a2e..0000000000000 --- a/examples/templates/bare/README.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -name: Bare (custom template) -description: Use this template as a starting point for writing custom templates with Terraform -tags: [bare] ---- - -See diff --git a/examples/templates/bare/main.tf b/examples/templates/bare/main.tf deleted file mode 100644 index b51b3e777c3e9..0000000000000 --- a/examples/templates/bare/main.tf +++ /dev/null @@ -1,58 +0,0 @@ -terraform { - required_providers { - coder = { - source = "coder/coder" - } - } -} - -# This example does not provision any resources. Use this -# template as a starting point for writing custom templates -# using any Terraform resource/provider. -# -# See: https://coder.com/docs/coder-oss/latest/templates - -data "coder_workspace" "me" { -} - -resource "coder_agent" "main" { - os = "linux" - arch = "amd64" - auth = "token" -} - -resource "null_resource" "fake-compute" { - # When a workspace is stopped, this resource is destroyed. - count = data.coder_workspace.me.transition == "start" ? 1 : 0 - - provisioner "local-exec" { - command = "echo 🔊 ${data.coder_workspace.me.owner} has started a workspace named ${data.coder_workspace.me.name}" - } - - # Run the Coder agent init script on resources - # to access web apps and SSH: - # - # export CODER_AGENT_TOKEN=${coder_agent.main.token} - # ${coder_agent.main.init_script} -} - -resource "null_resource" "fake-disk" { - # This resource will remain even when workspaces are restarted. - count = 1 -} - -resource "coder_app" "fake-app" { - # Access :8080 in the workspace from the Coder dashboard. - name = "VS Code" - icon = "/icon/code.svg" - agent_id = "fake-compute" - url = "http://localhost:8080" - subdomain = false - share = "owner" - - healthcheck { - url = "http://localhost:8080/healthz" - interval = 3 - threshold = 10 - } -} diff --git a/examples/templates/docker-code-server/README.md b/examples/templates/docker-code-server/README.md deleted file mode 100644 index 6d9045ad2d84e..0000000000000 --- a/examples/templates/docker-code-server/README.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -name: Develop code-server in Docker -description: Run code-server in a Docker development environment -tags: [local, docker] ---- - -# code-server in Docker - -## Getting started - -Run `coder templates init` and select this template. Follow the instructions that appear. - -## Supported Parameters - -You can create a file containing parameters and pass the argument -`--parameter-file` to `coder templates create`. -See `params.sample.yaml` for more information. - -This template has the following predefined parameters: - -- `docker_host`: Path to (or address of) the Docker socket. - > You can determine the correct value for this by running - > `docker context ls`. -- `docker_arch`: Architecture of the host running Docker. - This can be `amd64`, `arm64`, or `armv7`. diff --git a/examples/templates/docker-code-server/main.tf b/examples/templates/docker-code-server/main.tf deleted file mode 100644 index 2e4f4f5b488bc..0000000000000 --- a/examples/templates/docker-code-server/main.tf +++ /dev/null @@ -1,78 +0,0 @@ -terraform { - required_providers { - coder = { - source = "coder/coder" - version = "0.5.3" - } - docker = { - source = "kreuzwerker/docker" - version = "~> 2.20.2" - } - } -} - -data "coder_provisioner" "me" { -} - -provider "docker" { -} - -data "coder_workspace" "me" { -} - -resource "coder_agent" "main" { - arch = data.coder_provisioner.me.arch - os = "linux" - startup_script = "code-server --auth none" - - # These environment variables allow you to make Git commits right away after creating a - # workspace. Note that they take precedence over configuration defined in ~/.gitconfig! - # You can remove this block if you'd prefer to configure Git manually or using - # dotfiles. (see docs/dotfiles.md) - env = { - GIT_AUTHOR_NAME = "${data.coder_workspace.me.owner}" - GIT_COMMITTER_NAME = "${data.coder_workspace.me.owner}" - GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}" - GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}" - } -} - -resource "coder_app" "code-server" { - agent_id = coder_agent.main.id - name = "code-server" - url = "http://localhost:8080/?folder=/home/coder" - icon = "/icon/code.svg" - subdomain = false - share = "owner" - - healthcheck { - url = "http://localhost:8080/healthz" - interval = 3 - threshold = 10 - } -} - -resource "docker_volume" "home_volume" { - name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-root" -} - -resource "docker_container" "workspace" { - count = data.coder_workspace.me.start_count - image = "codercom/code-server:latest" - # Uses lower() to avoid Docker restriction on container names. - name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}" - hostname = lower(data.coder_workspace.me.name) - dns = ["1.1.1.1"] - # Use the docker gateway if the access URL is 127.0.0.1 - entrypoint = ["sh", "-c", replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")] - env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"] - host { - host = "host.docker.internal" - ip = "host-gateway" - } - volumes { - container_path = "/home/coder/" - volume_name = docker_volume.home_volume.name - read_only = false - } -} diff --git a/examples/templates/docker-code-server/params.sample.yaml b/examples/templates/docker-code-server/params.sample.yaml deleted file mode 100644 index 580e0ed137d30..0000000000000 --- a/examples/templates/docker-code-server/params.sample.yaml +++ /dev/null @@ -1,2 +0,0 @@ -docker_host: "unix:///var/run/docker.sock" -docker_arch: "amd64" diff --git a/examples/templates/gcp-vm-container/README.md b/examples/templates/gcp-vm-container/README.md deleted file mode 100644 index 72c5d20fc9b7f..0000000000000 --- a/examples/templates/gcp-vm-container/README.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -name: Develop in a container on a Google Cloud VM -description: Get started with Linux development on Google Cloud. -tags: [cloud, google, container] ---- - -# gcp-vm-container - -To get started, run `coder templates init`. When prompted, select this template, -and follow the on-screen instructions to proceed. - -## Authentication - -This template assumes that coderd is run in an environment that is authenticated -with Google Cloud. For example, run `gcloud auth application-default login` to -import credentials on the system and user running coderd. For other ways to -authenticate [consult the Terraform -docs](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/getting_started#adding-credentials). - -## Service account - -Coder requires a Google Cloud Service Account to provision workspaces. To create -a service account: - -1. Navigate to the [CGP - console](https://console.cloud.google.com/projectselector/iam-admin/serviceaccounts/create), - and select your Cloud project (if you have more than one project associated - with your account) - -1. Provide a service account name (this name is used to generate the service - account ID) - -1. Click **Create and continue**, and choose the following IAM roles to grant to - the service account: - - Compute Admin - - Service Account User - - Click **Continue**. - -1. Click on the created key, and navigate to the **Keys** tab. - -1. Click **Add key** > **Create new key**. - -1. Generate a **JSON private key**, which will be what you provide to Coder - during the setup process. - -## code-server - -`code-server` is installed via the `startup_script` argument in the `coder_agent` -resource block. The `coder_app` resource is defined to access `code-server` through -the dashboard UI over `localhost:13337`. diff --git a/examples/templates/gcp-vm-container/main.tf b/examples/templates/gcp-vm-container/main.tf deleted file mode 100644 index 753a2535fe0a9..0000000000000 --- a/examples/templates/gcp-vm-container/main.tf +++ /dev/null @@ -1,123 +0,0 @@ -terraform { - required_providers { - coder = { - source = "coder/coder" - version = "0.5.3" - } - google = { - source = "hashicorp/google" - version = "~> 4.34.0" - } - } -} - -variable "project_id" { - description = "Which Google Compute Project should your workspace live in?" -} - -variable "zone" { - description = "What region should your workspace live in?" - default = "us-central1-a" - validation { - condition = contains(["northamerica-northeast1-a", "us-central1-a", "us-west2-c", "europe-west4-b", "southamerica-east1-a"], var.zone) - error_message = "Invalid zone!" - } -} - -provider "google" { - zone = var.zone - project = var.project_id -} - -data "google_compute_default_service_account" "default" { -} - -data "coder_workspace" "me" { -} - -resource "coder_agent" "main" { - auth = "google-instance-identity" - arch = "amd64" - os = "linux" - startup_script = < Date: Mon, 3 Oct 2022 16:05:30 -0400 Subject: [PATCH 2/8] feat: Allow nesting of directories for examples Only looks inside quickstart directory now --- templates/examples.go | 169 +++++++++++++++++++++---------------- templates/examples_test.go | 8 +- 2 files changed, 100 insertions(+), 77 deletions(-) diff --git a/templates/examples.go b/templates/examples.go index f4cb3f08cf673..aba958b1f712f 100644 --- a/templates/examples.go +++ b/templates/examples.go @@ -4,10 +4,11 @@ import ( "archive/tar" "bytes" "embed" + "fmt" "io" "io/fs" - "path" "path/filepath" + "strings" "sync" "github.com/gohugoio/hugo/parser/pageparser" @@ -26,92 +27,115 @@ var ( ) type Example struct { - ID string `json:"id"` - URL string `json:"url"` - Name string `json:"name"` - Description string `json:"description"` - Markdown string `json:"markdown"` + ID string `json:"id"` + URL string `json:"url"` + Name string `json:"name"` + Description string `json:"description"` + Markdown string `json:"markdown"` + DirectoryPath string `json:"directory_path"` } const rootDir = "quickstart" -// List returns all embedded examples. -func List() ([]Example, error) { - var returnError error - parseExamples.Do(func() { - files, err := fs.Sub(files, rootDir) - if err != nil { - returnError = xerrors.Errorf("get example fs: %w", err) - } +// WalkForExamples will walk recursively through the examples directory and call +// exampleDirectory() on each directory that contains a main.tf file. +func WalkForExamples(files fs.FS, rootDir string, exampleDirectory func(path string)) error { + return walkDir(exampleDirectory, files, rootDir) +} - groups, err := fs.ReadDir(files, ".") - if err != nil { - returnError = xerrors.Errorf("read dir: %w", err) - return - } +func walkDir(exampleDirectory func(path string), fileFS fs.FS, path string) error { + file, err := fileFS.Open(path) + if err != nil { + return xerrors.Errorf("open file %q: %w", path, err) + } + info, err := file.Stat() + if err != nil { + return xerrors.Errorf("stat file %q: %w", path, err) + } - var dirs []Example - for _, group := range groups { - if group.IsDir() { - groupDirs, err := fs.Sub(files, filepath.Join(rootDir, group.Name())) - } + if info.IsDir() { + files, err := fs.ReadDir(files, path) + if err != nil { + return xerrors.Errorf("read dir %q: %w", path, err) } - for true { - for _, dir := range dirs { - if !dir.IsDir() { - continue - } - exampleID := dir.Name() - exampleURL := exampleBasePath + exampleID - // Each one of these is a example! - readme, err := fs.ReadFile(files, path.Join(dir.Name(), "README.md")) + for _, file := range files { + n := file.Name() + if strings.EqualFold(file.Name(), "main.tf") { + // This is an example dir + exampleDirectory(path) + return nil + } else if file.IsDir() { + fmt.Println("walk", filepath.Join(path, file.Name()), n) + err := walkDir(exampleDirectory, fileFS, filepath.Join(path, file.Name())) if err != nil { - returnError = xerrors.Errorf("example %q does not contain README.md", exampleID) - return + return err } + } + } + } + return nil +} - frontMatter, err := pageparser.ParseFrontMatterAndContent(bytes.NewReader(readme)) - if err != nil { - returnError = xerrors.Errorf("parse example %q front matter: %w", exampleID, err) - return - } +// List returns all embedded examples. +func List() ([]Example, error) { + var returnError error + parseExamples.Do(func() { + err := WalkForExamples(files, rootDir, func(path string) { + exampleID := filepath.Base(path) + exampleURL := exampleBasePath + exampleID + // Each one of these is a example! + readme, err := fs.ReadFile(files, filepath.Join(path, "README.md")) + if err != nil { + returnError = xerrors.Errorf("example %q does not contain README.md", exampleID) + return + } - nameRaw, exists := frontMatter.FrontMatter["name"] - if !exists { - returnError = xerrors.Errorf("example %q front matter does not contain name", exampleID) - return - } + frontMatter, err := pageparser.ParseFrontMatterAndContent(bytes.NewReader(readme)) + if err != nil { + returnError = xerrors.Errorf("parse example %q front matter: %w", exampleID, err) + return + } - name, valid := nameRaw.(string) - if !valid { - returnError = xerrors.Errorf("example %q name isn't a string", exampleID) - return - } + nameRaw, exists := frontMatter.FrontMatter["name"] + if !exists { + returnError = xerrors.Errorf("example %q front matter does not contain name", exampleID) + return + } - descriptionRaw, exists := frontMatter.FrontMatter["description"] - if !exists { - returnError = xerrors.Errorf("example %q front matter does not contain name", exampleID) - return - } + name, valid := nameRaw.(string) + if !valid { + returnError = xerrors.Errorf("example %q name isn't a string", exampleID) + return + } - description, valid := descriptionRaw.(string) - if !valid { - returnError = xerrors.Errorf("example %q description isn't a string", exampleID) - return - } + descriptionRaw, exists := frontMatter.FrontMatter["description"] + if !exists { + returnError = xerrors.Errorf("example %q front matter does not contain name", exampleID) + return + } - examples = append(examples, Example{ - ID: exampleID, - URL: exampleURL, - Name: name, - Description: description, - Markdown: string(frontMatter.Content), - }) + description, valid := descriptionRaw.(string) + if !valid { + returnError = xerrors.Errorf("example %q description isn't a string", exampleID) + return } - } + examples = append(examples, Example{ + ID: exampleID, + URL: exampleURL, + Name: name, + Description: description, + Markdown: string(frontMatter.Content), + DirectoryPath: path, + }) + }) + if err != nil { + returnError = xerrors.Errorf("walking embedded files: %w", err) + return + } }) + return examples, returnError } @@ -125,18 +149,17 @@ func Archive(exampleID string) ([]byte, error) { var selected Example for _, example := range examples { - if example.ID != exampleID { - continue + if example.ID == exampleID { + selected = example + break } - selected = example - break } if selected.ID == "" { return nil, xerrors.Errorf("example with id %q not found", exampleID) } - exampleFiles, err := fs.Sub(files, path.Join(rootDir, exampleID)) + exampleFiles, err := fs.Sub(files, selected.DirectoryPath) if err != nil { return nil, xerrors.Errorf("get example fs: %w", err) } diff --git a/templates/examples_test.go b/templates/examples_test.go index 73c8bcac8914c..fad9192f85ae2 100644 --- a/templates/examples_test.go +++ b/templates/examples_test.go @@ -7,7 +7,7 @@ import ( "io" "testing" - "github.com/coder/coder/templates/examples" + examples "github.com/coder/coder/templates" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -34,7 +34,7 @@ func TestTemplate(t *testing.T) { func TestSubdirs(t *testing.T) { t.Parallel() - tarData, err := examples.Archive("docker-image-builds") + tarData, err := examples.Archive("docker") require.NoError(t, err) tarReader := tar.NewReader(bytes.NewReader(tarData)) @@ -49,6 +49,6 @@ func TestSubdirs(t *testing.T) { entryPaths[header.Typeflag] = append(entryPaths[header.Typeflag], header.Name) } - require.Subset(t, entryPaths[tar.TypeDir], []string{"./", "images/"}) - require.Subset(t, entryPaths[tar.TypeReg], []string{"README.md", "main.tf", "images/base.Dockerfile"}) + require.Subset(t, entryPaths[tar.TypeDir], []string{"./", "build/"}) + require.Subset(t, entryPaths[tar.TypeReg], []string{"README.md", "main.tf", "build/Dockerfile"}) } From 40c8e1bd6f87288af609dae4c5f0eeff1ddefbc2 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Mon, 3 Oct 2022 16:06:59 -0400 Subject: [PATCH 3/8] remove prints --- templates/examples.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/templates/examples.go b/templates/examples.go index aba958b1f712f..742daf4e442e3 100644 --- a/templates/examples.go +++ b/templates/examples.go @@ -4,7 +4,6 @@ import ( "archive/tar" "bytes" "embed" - "fmt" "io" "io/fs" "path/filepath" @@ -60,13 +59,11 @@ func walkDir(exampleDirectory func(path string), fileFS fs.FS, path string) erro } for _, file := range files { - n := file.Name() if strings.EqualFold(file.Name(), "main.tf") { // This is an example dir exampleDirectory(path) return nil } else if file.IsDir() { - fmt.Println("walk", filepath.Join(path, file.Name()), n) err := walkDir(exampleDirectory, fileFS, filepath.Join(path, file.Name())) if err != nil { return err From edd0aabcbd15b0528186b18ef81d20c1a9154180 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Mon, 3 Oct 2022 17:15:33 -0400 Subject: [PATCH 4/8] Fix imports for example templates --- cli/templateinit.go | 2 +- coderd/users.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/templateinit.go b/cli/templateinit.go index ad936024a9f11..9c2075964493c 100644 --- a/cli/templateinit.go +++ b/cli/templateinit.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/cobra" "github.com/coder/coder/cli/cliui" - "github.com/coder/coder/examples" "github.com/coder/coder/provisionersdk" + examples "github.com/coder/coder/templates" ) func templateInit() *cobra.Command { diff --git a/coderd/users.go b/coderd/users.go index 5b56509786d6c..6f792123694da 100644 --- a/coderd/users.go +++ b/coderd/users.go @@ -27,7 +27,7 @@ import ( "github.com/coder/coder/coderd/userpassword" "github.com/coder/coder/coderd/util/slice" "github.com/coder/coder/codersdk" - "github.com/coder/coder/examples" + examples "github.com/coder/coder/templates" ) // Returns whether the initial user has been created or not. From 392b23f47bdae148f346eb497979db8af4883e9d Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 18 Oct 2022 21:29:38 +0000 Subject: [PATCH 5/8] change structure --- {templates/examples => docs/recipes}/lima/README.md | 0 {templates/examples => docs/recipes}/lima/coder.yaml | 0 templates/{examples => }/README.md | 2 +- templates/{examples => }/community-templates.md | 0 templates/{examples => }/update_template_versions.sh | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename {templates/examples => docs/recipes}/lima/README.md (100%) rename {templates/examples => docs/recipes}/lima/coder.yaml (100%) rename templates/{examples => }/README.md (95%) rename templates/{examples => }/community-templates.md (100%) rename templates/{examples => }/update_template_versions.sh (100%) diff --git a/templates/examples/lima/README.md b/docs/recipes/lima/README.md similarity index 100% rename from templates/examples/lima/README.md rename to docs/recipes/lima/README.md diff --git a/templates/examples/lima/coder.yaml b/docs/recipes/lima/coder.yaml similarity index 100% rename from templates/examples/lima/coder.yaml rename to docs/recipes/lima/coder.yaml diff --git a/templates/examples/README.md b/templates/README.md similarity index 95% rename from templates/examples/README.md rename to templates/README.md index 88022e6601289..ce16ffb1d38b6 100644 --- a/templates/examples/README.md +++ b/templates/README.md @@ -1,4 +1,4 @@ -# Example templates +~# Example templates List template examples in our CLI with `coder templates init`. diff --git a/templates/examples/community-templates.md b/templates/community-templates.md similarity index 100% rename from templates/examples/community-templates.md rename to templates/community-templates.md diff --git a/templates/examples/update_template_versions.sh b/templates/update_template_versions.sh similarity index 100% rename from templates/examples/update_template_versions.sh rename to templates/update_template_versions.sh From bea6c197b9dbbc8046be7fe2c147ee4f2cb1c606 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 18 Oct 2022 21:32:24 +0000 Subject: [PATCH 6/8] build binary with proper templates dir --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6accef31c5432..144c33e8d8717 100644 --- a/Makefile +++ b/Makefile @@ -172,7 +172,7 @@ endef # calling this manually. $(CODER_ALL_BINARIES): go.mod go.sum \ $(shell find . -not -path './vendor/*' -type f -name '*.go') \ - $(shell find ./examples/templates) + $(shell find ./templates/examples) $(get-mode-os-arch-ext) if [[ "$$os" != "windows" ]] && [[ "$$ext" != "" ]]; then From 9c526de1266f13b800d7d5b78dbf93ef64728a93 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 18 Oct 2022 21:41:13 +0000 Subject: [PATCH 7/8] use quickstart dir instead --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 144c33e8d8717..2835780761fc4 100644 --- a/Makefile +++ b/Makefile @@ -172,7 +172,7 @@ endef # calling this manually. $(CODER_ALL_BINARIES): go.mod go.sum \ $(shell find . -not -path './vendor/*' -type f -name '*.go') \ - $(shell find ./templates/examples) + $(shell find ./templates/quickstart) $(get-mode-os-arch-ext) if [[ "$$os" != "windows" ]] && [[ "$$ext" != "" ]]; then From de4b3fbdc1c39ddd1bf411cf69bc35b6801771e0 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 26 Oct 2022 16:42:38 +0000 Subject: [PATCH 8/8] change quickstart dir --- templates/examples.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/examples.go b/templates/examples.go index 742daf4e442e3..b0ca141bd9a2d 100644 --- a/templates/examples.go +++ b/templates/examples.go @@ -19,7 +19,7 @@ var ( //go:embed quickstart files embed.FS - exampleBasePath = "https://github.com/coder/coder/tree/main/examples" + exampleBasePath = "https://github.com/coder/coder/tree/main/templates/quickstart" examples = make([]Example, 0) parseExamples sync.Once archives = singleflight.Group{}