-
Notifications
You must be signed in to change notification settings - Fork 65
/
schema_kubernetes_azure_authentication.go
47 lines (41 loc) · 1.56 KB
/
schema_kubernetes_azure_authentication.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
package octopusdeploy
import (
"github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func expandKubernetesAzureAuthentication(values interface{}) *octopusdeploy.KubernetesAzureAuthentication {
flattenedValues := values.([]interface{})
flattenedAuthentication := flattenedValues[0].(map[string]interface{})
authentication := octopusdeploy.NewKubernetesAzureAuthentication()
authentication.AccountID = flattenedAuthentication["account_id"].(string)
authentication.AuthenticationType = "KubernetesAzure"
authentication.ClusterName = flattenedAuthentication["cluster_name"].(string)
authentication.ClusterResourceGroup = flattenedAuthentication["cluster_resource_group"].(string)
return authentication
}
func flattenKubernetesAzureAuthentication(kubernetesAzureAuthentication *octopusdeploy.KubernetesAzureAuthentication) []interface{} {
if kubernetesAzureAuthentication == nil {
return nil
}
return []interface{}{map[string]interface{}{
"account_id": kubernetesAzureAuthentication.AccountID,
"cluster_name": kubernetesAzureAuthentication.ClusterName,
"cluster_resource_group": kubernetesAzureAuthentication.ClusterResourceGroup,
}}
}
func getKubernetesAzureAuthenticationSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Required: true,
Type: schema.TypeString,
},
"cluster_name": {
Required: true,
Type: schema.TypeString,
},
"cluster_resource_group": {
Required: true,
Type: schema.TypeString,
},
}
}