-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathschema_machine_update_policy.go
57 lines (51 loc) · 1.68 KB
/
schema_machine_update_policy.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
package octopusdeploy
import (
"github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func expandMachineUpdatePolicy(values interface{}) *octopusdeploy.MachineUpdatePolicy {
flattenedValues := values.([]interface{})
flattenedMap := flattenedValues[0].(map[string]interface{})
return &octopusdeploy.MachineUpdatePolicy{
CalamariUpdateBehavior: flattenedMap["calamari_update_behavior"].(string),
TentacleUpdateAccountID: flattenedMap["tentacle_update_account_id"].(string),
TentacleUpdateBehavior: flattenedMap["tentacle_update_behavior"].(string),
}
}
func flattenMachineUpdatePolicy(machineUpdatePolicy *octopusdeploy.MachineUpdatePolicy) []interface{} {
if machineUpdatePolicy == nil {
return nil
}
return []interface{}{map[string]interface{}{
"calamari_update_behavior": machineUpdatePolicy.CalamariUpdateBehavior,
"tentacle_update_account_id": machineUpdatePolicy.TentacleUpdateAccountID,
"tentacle_update_behavior": machineUpdatePolicy.TentacleUpdateBehavior,
}}
}
func getMachineUpdatePolicySchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"calamari_update_behavior": {
Default: "UpdateOnDeployment",
Optional: true,
Type: schema.TypeString,
ValidateDiagFunc: validateValueFunc([]string{
"UpdateAlways",
"UpdateOnDeployment",
"UpdateOnNewMachine",
}),
},
"tentacle_update_account_id": {
Optional: true,
Type: schema.TypeString,
},
"tentacle_update_behavior": {
Default: "NeverUpdate",
Optional: true,
Type: schema.TypeString,
ValidateDiagFunc: validateValueFunc([]string{
"NeverUpdate",
"Update",
}),
},
}
}