File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ func New() *schema.Provider {
64
64
"coder_external_auth" : externalAuthDataSource (),
65
65
"coder_workspace_owner" : workspaceOwnerDataSource (),
66
66
"coder_workspace_preset" : workspacePresetDataSource (),
67
+ "coder_secret" : secretDataSource (),
67
68
},
68
69
ResourcesMap : map [string ]* schema.Resource {
69
70
"coder_agent" : agentResource (),
Original file line number Diff line number Diff line change
1
+ package provider
2
+
3
+ import (
4
+ "context"
5
+
6
+ "github.com/coder/terraform-provider-coder/v2/provider/helpers"
7
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
8
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
9
+ )
10
+
11
+ func secretDataSource () * schema.Resource {
12
+ return & schema.Resource {
13
+ SchemaVersion : 1 ,
14
+
15
+ Description : "" ,
16
+ ReadContext : func (ctx context.Context , rd * schema.ResourceData , i interface {}) diag.Diagnostics {
17
+ envName , ok := rd .Get ("env_name" ).(string )
18
+ if ! ok || envName == "" {
19
+ return diag .Errorf ("env_name is required" )
20
+ }
21
+ envVal := helpers .OptionalEnv (envName )
22
+
23
+ rd .Set ("value" , envVal )
24
+ rd .SetId (envName )
25
+ return nil
26
+ },
27
+ Schema : map [string ]* schema.Schema {
28
+ "env_name" : {
29
+ Type : schema .TypeString ,
30
+ Description : "" ,
31
+ Required : true ,
32
+ },
33
+ "value" : {
34
+ Type : schema .TypeString ,
35
+ Description : "" ,
36
+ Computed : true ,
37
+ },
38
+ },
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments