-
Notifications
You must be signed in to change notification settings - Fork 66
/
schema_kubernetes_gcp_authentication.go
76 lines (70 loc) · 2.62 KB
/
schema_kubernetes_gcp_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package octopusdeploy
import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func expandKubernetesGcpAuthentication(values interface{}) *machines.KubernetesGcpAuthentication {
flattenedValues := values.([]interface{})
flattenedAuthentication := flattenedValues[0].(map[string]interface{})
authentication := machines.NewKubernetesGcpAuthentication()
authentication.AccountID = flattenedAuthentication["account_id"].(string)
authentication.ClusterName = flattenedAuthentication["cluster_name"].(string)
authentication.ImpersonateServiceAccount = flattenedAuthentication["impersonate_service_account"].(bool)
authentication.Project = flattenedAuthentication["project"].(string)
authentication.Region = flattenedAuthentication["region"].(string)
authentication.ServiceAccountEmails = flattenedAuthentication["service_account_emails"].(string)
authentication.UseVmServiceAccount = flattenedAuthentication["use_vm_service_account"].(bool)
authentication.Zone = flattenedAuthentication["zone"].(string)
return authentication
}
func flattenKubernetesGcpAuthentication(kubernetesGcpAuthentication *machines.KubernetesGcpAuthentication) []interface{} {
if kubernetesGcpAuthentication == nil {
return nil
}
return []interface{}{map[string]interface{}{
"account_id": kubernetesGcpAuthentication.AccountID,
"cluster_name": kubernetesGcpAuthentication.ClusterName,
"impersonate_service_account": kubernetesGcpAuthentication.ImpersonateServiceAccount,
"project": kubernetesGcpAuthentication.Project,
"region": kubernetesGcpAuthentication.Region,
"service_account_emails": kubernetesGcpAuthentication.ServiceAccountEmails,
"use_vm_service_account": kubernetesGcpAuthentication.UseVmServiceAccount,
"zone": kubernetesGcpAuthentication.Zone,
}}
}
func getKubernetesGcpAuthenticationSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Required: true,
Type: schema.TypeString,
},
"cluster_name": {
Required: true,
Type: schema.TypeString,
},
"impersonate_service_account": {
Optional: true,
Type: schema.TypeBool,
},
"project": {
Required: true,
Type: schema.TypeString,
},
"region": {
Optional: true,
Type: schema.TypeString,
},
"service_account_emails": {
Optional: true,
Type: schema.TypeString,
},
"use_vm_service_account": {
Optional: true,
Type: schema.TypeBool,
},
"zone": {
Optional: true,
Type: schema.TypeString,
},
}
}