generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 44
/
current_account_data_source.go
49 lines (42 loc) · 1.37 KB
/
current_account_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
package account
import (
"context"
"github.com/harness/terraform-provider-harness/internal"
"github.com/harness/terraform-provider-harness/internal/utils"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func DataSourceCurrentAccountConnector() *schema.Resource {
return &schema.Resource{
// This description is used by the documentation generator and the language server.
Description: "Data source for retrieving information about the current Harness account",
ReadContext: dataSourceGitConnectorCurrentAccount,
Schema: map[string]*schema.Schema{
"id": {
Description: "Id of the git connector.",
Type: schema.TypeString,
Optional: true,
},
"account_id": {
Description: "Id of the account.",
Type: schema.TypeString,
Computed: true,
},
"endpoint": {
Description: "The url of the Harness control plane.",
Type: schema.TypeString,
Computed: true,
},
},
}
}
func dataSourceGitConnectorCurrentAccount(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
c := meta.(*internal.Session).CDClient
if c == nil {
return diag.Errorf(utils.CDClientAPIKeyError)
}
d.SetId(c.Configuration.AccountId)
d.Set("account_id", c.Configuration.AccountId)
d.Set("endpoint", c.Configuration.Endpoint)
return nil
}