File tree 3 files changed +75
-0
lines changed
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_host Data Source - terraform-provider-coder"
4
+ subcategory : " "
5
+ description : |-
6
+ Use this data source to get information about the host.
7
+ ---
8
+
9
+ # coder_host (Data Source)
10
+
11
+ Use this data source to get information about the host.
12
+
13
+
14
+
15
+ <!-- schema generated by tfplugindocs -->
16
+ ## Schema
17
+
18
+ ### Read-Only
19
+
20
+ - ` arch ` (String) The architecture of the host.
21
+ - ` id ` (String) The ID of this resource.
22
+ - ` os ` (String) The operating system of the host.
23
+
24
+
Original file line number Diff line number Diff line change 7
7
"net/url"
8
8
"os"
9
9
"reflect"
10
+ "runtime"
10
11
"strings"
11
12
12
13
"github.com/google/uuid"
@@ -150,6 +151,28 @@ func New() *schema.Provider {
150
151
},
151
152
},
152
153
},
154
+ "coder_host" : {
155
+ Description : "Use this data source to get information about the host." ,
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." ,
168
+ },
169
+ "arch" : {
170
+ Type : schema .TypeString ,
171
+ Computed : true ,
172
+ Description : "The architecture of the host." ,
173
+ },
174
+ },
175
+ },
153
176
},
154
177
ResourcesMap : map [string ]* schema.Resource {
155
178
"coder_agent" : {
Original file line number Diff line number Diff line change 1
1
package provider_test
2
2
3
3
import (
4
+ "runtime"
4
5
"testing"
5
6
6
7
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -52,6 +53,33 @@ func TestWorkspace(t *testing.T) {
52
53
})
53
54
}
54
55
56
+ func TestHost (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_host" "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_host.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
+
55
83
func TestAgent (t * testing.T ) {
56
84
t .Parallel ()
57
85
resource .Test (t , resource.TestCase {
You can’t perform that action at this time.
0 commit comments