-
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
2632693
commit a7601b2
Showing
13 changed files
with
727 additions
and
1 deletion.
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,48 @@ | ||
--- | ||
# 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 | ||
|
||
- `name` (String) The name of the template. | ||
|
||
### Optional | ||
|
||
- `description` (String) A description of the template. | ||
- `display_name` (String) The display name of the template. Defaults to the template name. | ||
- `organization_id` (String) The ID of the organization. Defaults to the provider's default organization | ||
- `version` (Block List) (see [below for nested schema](#nestedblock--version)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of the template. | ||
|
||
<a id="nestedblock--version"></a> | ||
### Nested Schema for `version` | ||
|
||
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. | ||
|
||
Read-Only: | ||
|
||
- `directory_hash` (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 @@ | ||
a |
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,18 @@ | ||
terraform { | ||
required_providers { | ||
coderd = { | ||
source = "coder/coderd" | ||
version = ">=0.0.0" | ||
} | ||
} | ||
} | ||
|
||
resource "coderd_template" "sample" { | ||
name = "example-template" | ||
versions = [ | ||
{ | ||
name = "v1" | ||
directory = "./example-template" | ||
} | ||
] | ||
} |
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.