-
Notifications
You must be signed in to change notification settings - Fork 365
/
data_current_config.go
38 lines (34 loc) · 1.03 KB
/
data_current_config.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
package mws
import (
"context"
"github.com/databricks/terraform-provider-databricks/common"
)
type currentConfig struct {
IsAccount bool `json:"is_account,omitempty" tf:"computed"`
AccountId string `json:"account_id,omitempty" tf:"computed"`
Host string `json:"host,omitempty" tf:"computed"`
CloudType string `json:"cloud_type,omitempty" tf:"computed"`
AuthType string `json:"auth_type,omitempty" tf:"computed"`
}
func DataSourceCurrentConfiguration() common.Resource {
return common.DataResource(currentConfig{}, func(ctx context.Context, e any, c *common.DatabricksClient) error {
data := e.(*currentConfig)
data.IsAccount = false
if c.Config.IsAccountClient() {
data.AccountId = c.Config.AccountID
data.IsAccount = true
}
data.Host = c.Config.Host
if c.Config.IsAws() {
data.CloudType = "aws"
} else if c.Config.IsAzure() {
data.CloudType = "azure"
} else if c.Config.IsGcp() {
data.CloudType = "gcp"
} else {
data.CloudType = "unknown"
}
data.AuthType = c.Config.AuthType
return nil
})
}