-
Notifications
You must be signed in to change notification settings - Fork 65
/
schema_kubernetes_aws_authentication.go
77 lines (71 loc) · 2.78 KB
/
schema_kubernetes_aws_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
77
package octopusdeploy
import (
"github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func expandKubernetesAwsAuthentication(values interface{}) *octopusdeploy.KubernetesAwsAuthentication {
flattenedValues := values.([]interface{})
flattenedAuthentication := flattenedValues[0].(map[string]interface{})
authentication := octopusdeploy.NewKubernetesAwsAuthentication()
authentication.AccountID = flattenedAuthentication["account_id"].(string)
authentication.AssumedRoleARN = flattenedAuthentication["assumed_role_arn"].(string)
authentication.AssumedRoleSession = flattenedAuthentication["assumed_role_session"].(string)
authentication.AssumeRole = flattenedAuthentication["assume_role"].(bool)
authentication.AssumeRoleExternalID = flattenedAuthentication["assume_role_external_id"].(string)
authentication.AssumeRoleSessionDuration = flattenedAuthentication["assume_role_session_duration"].(int)
authentication.AuthenticationType = "KubernetesAws"
authentication.ClusterName = flattenedAuthentication["cluster_name"].(string)
authentication.UseInstanceRole = flattenedAuthentication["use_instance_role"].(bool)
return authentication
}
func flattenKubernetesAwsAuthentication(kubernetesAwsAuthentication *octopusdeploy.KubernetesAwsAuthentication) []interface{} {
if kubernetesAwsAuthentication == nil {
return nil
}
return []interface{}{map[string]interface{}{
"account_id": kubernetesAwsAuthentication.AccountID,
"assumed_role_arn": kubernetesAwsAuthentication.AssumedRoleARN,
"assumed_role_session": kubernetesAwsAuthentication.AssumedRoleSession,
"assume_role": kubernetesAwsAuthentication.AssumeRole,
"assume_role_external_id": kubernetesAwsAuthentication.AssumeRoleExternalID,
"assume_role_session_duration": kubernetesAwsAuthentication.AssumeRoleSessionDuration,
"cluster_name": kubernetesAwsAuthentication.ClusterName,
"use_instance_role": kubernetesAwsAuthentication.UseInstanceRole,
}}
}
func getKubernetesAwsAuthenticationSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Required: true,
Type: schema.TypeString,
},
"assumed_role_arn": {
Optional: true,
Type: schema.TypeString,
},
"assumed_role_session": {
Optional: true,
Type: schema.TypeString,
},
"assume_role": {
Optional: true,
Type: schema.TypeBool,
},
"assume_role_external_id": {
Optional: true,
Type: schema.TypeString,
},
"assume_role_session_duration": {
Optional: true,
Type: schema.TypeInt,
},
"cluster_name": {
Required: true,
Type: schema.TypeString,
},
"use_instance_role": {
Optional: true,
Type: schema.TypeBool,
},
}
}