generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 41
/
input_set_data_source.go
57 lines (45 loc) · 1.38 KB
/
input_set_data_source.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
package input_set
import (
"context"
"github.com/harness/harness-go-sdk/harness/nextgen"
"github.com/harness/terraform-provider-harness/helpers"
"github.com/harness/terraform-provider-harness/internal"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func DataSourceInputSet() *schema.Resource {
resource := &schema.Resource{
Description: "Data source for retrieving a Harness input set.",
ReadContext: dataSourceInputSetRead,
Schema: map[string]*schema.Schema{
"pipeline_id": {
Description: "Identifier of the pipeline",
Type: schema.TypeString,
Required: true,
},
"yaml": {
Description: "Input Set YAML",
Type: schema.TypeString,
Computed: true,
},
},
}
helpers.SetProjectLevelDataSourceSchema(resource.Schema)
return resource
}
func dataSourceInputSetRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
c, ctx := meta.(*internal.Session).GetPlatformClientWithContext(ctx)
resp, httpResp, err := c.InputSetsApi.GetInputSet(ctx,
d.Get("identifier").(string),
c.AccountId,
d.Get("org_id").(string),
d.Get("project_id").(string),
d.Get("pipeline_id").(string),
&nextgen.InputSetsApiGetInputSetOpts{},
)
if err != nil {
return helpers.HandleApiError(err, d, httpResp)
}
readInputSet(d, resp.Data)
return nil
}