Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(docs): move coder_parameter example#243

New issue

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

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

Already on GitHub?Sign in to your account

Merged
stirby merged 11 commits intomainfromcoder-parameter-example
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletionsdocs/data-sources/git_auth.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,8 +13,7 @@ Use this data source to require users to authenticate with a Git provider prior
## Example Usage

```terraform
provider "coder" {
}
provider "coder" {}

data "coder_git_auth" "github" {
# Matches the ID of the git auth provider in Coder.
Expand Down
122 changes: 121 additions & 1 deletiondocs/data-sources/parameter.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,127 @@ description: |-

Use this data source to configure editable options for workspaces.


## Example Usage

```terraform
provider "coder" {}

data "coder_parameter" "example" {
name = "Region"
description = "Specify a region to place your workspace."
mutable = false
type = "string"
default = "asia-central1-a"
option {
value = "us-central1-a"
name = "US Central"
icon = "/icon/usa.svg"
}
option {
value = "asia-central1-a"
name = "Asia"
icon = "/icon/asia.svg"
}
}

data "coder_parameter" "ami" {
name = "Machine Image"
description = <<-EOT
# Provide the machine image
See the [registry](https://container.registry.blah/namespace) for options.
EOT
option {
value = "ami-xxxxxxxx"
name = "Ubuntu"
icon = "/icon/ubuntu.svg"
}
}

data "coder_parameter" "is_public_instance" {
name = "Is public instance?"
type = "bool"
icon = "/icon/docker.svg"
default = false
}

data "coder_parameter" "cores" {
name = "CPU Cores"
type = "number"
icon = "/icon/cpu.svg"
default = 3
order = 10
}

data "coder_parameter" "disk_size" {
name = "Disk Size"
type = "number"
default = "5"
order = 8
validation {
# This can apply to number.
min = 0
max = 10
monotonic = "increasing"
}
}

data "coder_parameter" "cat_lives" {
name = "Cat Lives"
type = "number"
default = "9"
validation {
# This can apply to number.
min = 0
max = 10
monotonic = "decreasing"
}
}

data "coder_parameter" "fairy_tale" {
name = "Fairy Tale"
type = "string"
mutable = true
default = "Hansel and Gretel"
ephemeral = true
}

data "coder_parameter" "users" {
name = "system_users"
display_name = "System users"
type = "list(string)"
default = jsonencode(["root", "user1", "user2"])
}

data "coder_parameter" "home_volume_size" {
name = "Home Volume Size"
description = <<-EOF
How large should your home volume be?
EOF
type = "number"
default = 30
mutable = true
order = 3

option {
name = "30GB"
value = 30
}

option {
name = "60GB"
value = 60
}

option {
name = "100GB"
value = 100
}

validation {
monotonic = "increasing"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
53 changes: 53 additions & 0 deletionsdocs/data-sources/workspace_tags.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,60 @@ description: |-

Use this data source to configure workspace tags to select provisioners.

## Example Usage

```terraform
provider "coder" {}

data "coder_parameter" "os_selector" {
name = "os_selector"
display_name = "Operating System"
mutable = false

default = "osx"

option {
icon = "/icons/linux.png"
name = "Linux"
value = "linux"
}
option {
icon = "/icons/osx.png"
name = "OSX"
value = "osx"
}
option {
icon = "/icons/windows.png"
name = "Windows"
value = "windows"
}
}

data "coder_parameter" "feature_cache_enabled" {
name = "feature_cache_enabled"
display_name = "Enable cache?"
type = "bool"

default = false
}

data "coder_parameter" "feature_debug_enabled" {
name = "feature_debug_enabled"
display_name = "Enable debug?"
type = "bool"

default = true
}

data "coder_workspace_tags" "custom_workspace_tags" {
tags = {
"cluster" = "developers"
"os" = data.coder_parameter.os_selector.value
"debug" = "${data.coder_parameter.feature_debug_enabled.value}+12345"
"cache" = data.coder_parameter.feature_cache_enabled.value == "true" ? "nix-with-cache" : "no-cache"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
3 changes: 1 addition & 2 deletionsexamples/data-sources/coder_git_auth/data-source.tf
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
provider "coder" {
}
provider "coder" {}

data "coder_git_auth" "github" {
# Matches the ID of the git auth provider in Coder.
Expand Down
24 changes: 14 additions & 10 deletionsprovider/examples_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
package provider_test

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/stretchr/testify/require"

"github.com/coder/terraform-provider-coder/provider"
)

Expand All@@ -22,19 +22,23 @@ func TestExamples(t *testing.T) {
testDir := testDir
t.Parallel()

resource.Test(t, resource.TestCase{
Providers: map[string]*schema.Provider{
"coder": provider.New(),
},
IsUnitTest: true,
Steps: []resource.TestStep{{
Config: mustReadFile(t, "../examples/resources/"+testDir+"/resource.tf"),
}},
})
resourceTest(t, testDir)
})
}
}

func resourceTest(t *testing.T, testDir string) {
resource.Test(t, resource.TestCase{
Providers: map[string]*schema.Provider{
"coder": provider.New(),
},
IsUnitTest: true,
Steps: []resource.TestStep{{
Config: mustReadFile(t, fmt.Sprintf("../examples/data-sources/%s/data-source.tf", testDir)),
}},
})
}

func mustReadFile(t *testing.T, path string) string {
content, err := os.ReadFile(path)
require.NoError(t, err)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp