/
data_source_organization_run_task.go
63 lines (51 loc) · 1.2 KB
/
data_source_organization_run_task.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package tfe
import (
"github.com/hashicorp/go-tfe"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func dataSourceTFEOrganizationRunTask() *schema.Resource {
return &schema.Resource{
Read: dataSourceTFEOrganizationRunTaskRead,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"organization": {
Type: schema.TypeString,
Required: true,
},
"url": {
Type: schema.TypeString,
Optional: true,
},
"category": {
Type: schema.TypeString,
Optional: true,
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
},
"description": {
Type: schema.TypeString,
Optional: true,
},
},
}
}
func dataSourceTFEOrganizationRunTaskRead(d *schema.ResourceData, meta interface{}) error {
tfeClient := meta.(*tfe.Client)
name := d.Get("name").(string)
organization := d.Get("organization").(string)
task, err := fetchOrganizationRunTask(name, organization, tfeClient)
if err != nil {
return err
}
d.Set("url", task.URL)
d.Set("category", task.Category)
d.Set("enabled", task.Enabled)
d.Set("description", task.Description)
d.SetId(task.ID)
return nil
}