-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75f030f
commit 587b480
Showing
13 changed files
with
1,277 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "coderd_template Resource - coderd" | ||
subcategory: "" | ||
description: |- | ||
A Coder template | ||
--- | ||
|
||
# coderd_template (Resource) | ||
|
||
A Coder template | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `acl` (Attributes) Access control list for the template. (see [below for nested schema](#nestedatt--acl)) | ||
- `name` (String) The name of the template. | ||
- `versions` (Attributes List) (see [below for nested schema](#nestedatt--versions)) | ||
|
||
### Optional | ||
|
||
- `allow_user_auto_start` (Boolean) | ||
- `allow_user_auto_stop` (Boolean) | ||
- `description` (String) A description of the template. | ||
- `display_name` (String) The display name of the template. Defaults to the template name. | ||
- `icon` (String) Relative path or external URL that specifes an icon to be displayed in the dashboard. | ||
- `organization_id` (String) The ID of the organization. Defaults to the provider's default organization | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of the template. | ||
|
||
<a id="nestedatt--acl"></a> | ||
### Nested Schema for `acl` | ||
|
||
Required: | ||
|
||
- `groups` (Attributes Set) (see [below for nested schema](#nestedatt--acl--groups)) | ||
- `users` (Attributes Set) (see [below for nested schema](#nestedatt--acl--users)) | ||
|
||
<a id="nestedatt--acl--groups"></a> | ||
### Nested Schema for `acl.groups` | ||
|
||
Required: | ||
|
||
- `id` (String) | ||
- `role` (String) | ||
|
||
|
||
<a id="nestedatt--acl--users"></a> | ||
### Nested Schema for `acl.users` | ||
|
||
Required: | ||
|
||
- `id` (String) | ||
- `role` (String) | ||
|
||
|
||
|
||
<a id="nestedatt--versions"></a> | ||
### Nested Schema for `versions` | ||
|
||
Required: | ||
|
||
- `directory` (String) A path to the directory to create the template version from. Changes in the directory contents will trigger the creation of a new template version. | ||
|
||
Optional: | ||
|
||
- `active` (Boolean) Whether this version is the active version of the template. Only one version can be active at a time. | ||
- `message` (String) A message describing the changes in this version of the template. Messages longer than 72 characters will be truncated. | ||
- `name` (String) The name of the template version. Automatically generated if not provided. | ||
- `provisioner_tags` (Attributes Set) Provisioner tags for the template version. (see [below for nested schema](#nestedatt--versions--provisioner_tags)) | ||
- `tf_vars` (Attributes Set) Terraform variables for the template version. (see [below for nested schema](#nestedatt--versions--tf_vars)) | ||
|
||
Read-Only: | ||
|
||
- `directory_hash` (String) | ||
- `id` (String) | ||
|
||
<a id="nestedatt--versions--provisioner_tags"></a> | ||
### Nested Schema for `versions.provisioner_tags` | ||
|
||
Required: | ||
|
||
- `name` (String) | ||
- `value` (String) | ||
|
||
|
||
<a id="nestedatt--versions--tf_vars"></a> | ||
### Nested Schema for `versions.tf_vars` | ||
|
||
Required: | ||
|
||
- `name` (String) | ||
- `value` (String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resource "local_file" "a" { | ||
filename = "${path.module}/a.txt" | ||
content = "hello world" | ||
} | ||
|
||
output "a" { | ||
value = local_file.a.content | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
variable "name" { | ||
type = string | ||
} | ||
|
||
resource "local_file" "a" { | ||
filename = "${path.module}/a.txt" | ||
content = "hello ${var.name}" | ||
} | ||
|
||
output "a" { | ||
value = local_file.a.content | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name = "world" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
terraform { | ||
required_providers { | ||
coderd = { | ||
source = "coder/coderd" | ||
version = ">=0.0.0" | ||
} | ||
} | ||
} | ||
|
||
resource "coderd_template" "sample" { | ||
name = "example-template" | ||
acl = { | ||
groups = [] | ||
users = [] | ||
} | ||
versions = [ | ||
{ | ||
name = "v1" | ||
directory = "./example-template" | ||
active = true | ||
tf_vars = [ | ||
{ | ||
name = "name" | ||
value = "world" | ||
}, | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
|
||
"cdr.dev/slog" | ||
"github.com/hashicorp/terraform-plugin-log/tflog" | ||
) | ||
|
||
var _ slog.Sink = &tfLogSink{} | ||
|
||
type tfLogSink struct { | ||
tfCtx context.Context | ||
} | ||
|
||
func newTFLogSink(tfCtx context.Context) *tfLogSink { | ||
return &tfLogSink{ | ||
tfCtx: tfCtx, | ||
} | ||
} | ||
|
||
func (s *tfLogSink) LogEntry(ctx context.Context, e slog.SinkEntry) { | ||
var logFn func(ctx context.Context, msg string, additionalFields ...map[string]interface{}) | ||
switch e.Level { | ||
case slog.LevelDebug: | ||
logFn = tflog.Debug | ||
case slog.LevelInfo: | ||
logFn = tflog.Info | ||
case slog.LevelWarn: | ||
logFn = tflog.Warn | ||
default: | ||
logFn = tflog.Error | ||
} | ||
logFn(s.tfCtx, e.Message, mapToFields(e.Fields)) | ||
} | ||
|
||
func (s *tfLogSink) Sync() {} | ||
|
||
func mapToFields(m slog.Map) map[string]interface{} { | ||
fields := make(map[string]interface{}, len(m)) | ||
for _, v := range m { | ||
fields[v.Name] = v.Value | ||
} | ||
return fields | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.