File tree Expand file tree Collapse file tree 3 files changed +75
-0
lines changed
Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ # generated by https://github.com/hashicorp/terraform-plugin-docs
3+ page_title : " coder_provisioner Data Source - terraform-provider-coder"
4+ subcategory : " "
5+ description : |-
6+ Use this data source to get information about the Coder provisioner.
7+ ---
8+
9+ # coder_provisioner (Data Source)
10+
11+ Use this data source to get information about the Coder provisioner.
12+
13+
14+
15+ <!-- schema generated by tfplugindocs -->
16+ ## Schema
17+
18+ ### Read-Only
19+
20+ - ` arch ` (String) The architecture of the host. This exposes ` runtime.GOARCH ` (see https://pkg.go.dev/runtime#pkg-constants ).
21+ - ` id ` (String) The ID of this resource.
22+ - ` os ` (String) The operating system of the host. This exposes ` runtime.GOOS ` (see https://pkg.go.dev/runtime#pkg-constants ).
23+
24+
Original file line number Diff line number Diff line change 77 "net/url"
88 "os"
99 "reflect"
10+ "runtime"
1011 "strings"
1112
1213 "github.com/google/uuid"
@@ -150,6 +151,28 @@ func New() *schema.Provider {
150151 },
151152 },
152153 },
154+ "coder_provisioner" : {
155+ Description : "Use this data source to get information about the Coder provisioner." ,
156+ ReadContext : func (c context.Context , rd * schema.ResourceData , i interface {}) diag.Diagnostics {
157+ rd .SetId (uuid .NewString ())
158+ rd .Set ("os" , runtime .GOOS )
159+ rd .Set ("arch" , runtime .GOARCH )
160+
161+ return nil
162+ },
163+ Schema : map [string ]* schema.Schema {
164+ "os" : {
165+ Type : schema .TypeString ,
166+ Computed : true ,
167+ Description : "The operating system of the host. This exposes `runtime.GOOS` (see https://pkg.go.dev/runtime#pkg-constants)." ,
168+ },
169+ "arch" : {
170+ Type : schema .TypeString ,
171+ Computed : true ,
172+ Description : "The architecture of the host. This exposes `runtime.GOARCH` (see https://pkg.go.dev/runtime#pkg-constants)." ,
173+ },
174+ },
175+ },
153176 },
154177 ResourcesMap : map [string ]* schema.Resource {
155178 "coder_agent" : {
Original file line number Diff line number Diff line change 11package provider_test
22
33import (
4+ "runtime"
45 "testing"
56
67 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -52,6 +53,33 @@ func TestWorkspace(t *testing.T) {
5253 })
5354}
5455
56+ func TestProvisioner (t * testing.T ) {
57+ resource .Test (t , resource.TestCase {
58+ Providers : map [string ]* schema.Provider {
59+ "coder" : provider .New (),
60+ },
61+ IsUnitTest : true ,
62+ Steps : []resource.TestStep {{
63+ Config : `
64+ provider "coder" {
65+ }
66+ data "coder_provisioner" "me" {
67+ }` ,
68+ Check : func (state * terraform.State ) error {
69+ require .Len (t , state .Modules , 1 )
70+ require .Len (t , state .Modules [0 ].Resources , 1 )
71+ resource := state .Modules [0 ].Resources ["data.coder_provisioner.me" ]
72+ require .NotNil (t , resource )
73+
74+ attribs := resource .Primary .Attributes
75+ require .Equal (t , runtime .GOOS , attribs ["os" ])
76+ require .Equal (t , runtime .GOARCH , attribs ["arch" ])
77+ return nil
78+ },
79+ }},
80+ })
81+ }
82+
5583func TestAgent (t * testing.T ) {
5684 t .Parallel ()
5785 resource .Test (t , resource.TestCase {
You can’t perform that action at this time.
0 commit comments