Skip to content

Commit 2c78ba4

Browse files
author
Anna Blendermann
authored
Merge pull request #890 from annablender/drain-before-delete-terraform
Add drain before delete to cluster_v2 resource
2 parents b875ecd + a98b7bf commit 2c78ba4

3 files changed

Lines changed: 17 additions & 5 deletions

rancher2/schema_cluster_v2_rke_config_machine_pool.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ func clusterV2RKEConfigMachinePoolFields() map[string]*schema.Schema {
7272
Optional: true,
7373
Description: "Machine pool etcd role",
7474
},
75+
"drain_before_delete": {
76+
Type: schema.TypeBool,
77+
Optional: true,
78+
Default: false,
79+
Description: "Machine pool drain before delete",
80+
},
7581
"paused": {
7682
Type: schema.TypeBool,
7783
Optional: true,

rancher2/structure_cluster_v2_rke_config_machine_pool.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func flattenClusterV2RKEConfigMachinePools(p []provisionv1.RKEMachinePool) []int
5555
}
5656
obj["control_plane_role"] = in.ControlPlaneRole
5757
obj["etcd_role"] = in.EtcdRole
58+
obj["drain_before_delete"] = in.DrainBeforeDelete
5859

5960
if len(in.MachineDeploymentAnnotations) > 0 {
6061
obj["annotations"] = toMapInterface(in.MachineDeploymentAnnotations)
@@ -147,6 +148,9 @@ func expandClusterV2RKEConfigMachinePools(p []interface{}) []provisionv1.RKEMach
147148
if v, ok := in["etcd_role"].(bool); ok {
148149
obj.EtcdRole = v
149150
}
151+
if v, ok := in["drain_before_delete"].(bool); ok {
152+
obj.DrainBeforeDelete = v
153+
}
150154
if v, ok := in["annotations"].(map[string]interface{}); ok && len(v) > 0 {
151155
obj.MachineDeploymentAnnotations = toMapString(v)
152156
}

rancher2/structure_cluster_v2_rke_config_machine_pool_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ func init() {
4545
quantity := int32(10)
4646
testClusterV2RKEConfigMachinePoolsConf = []provisionv1.RKEMachinePool{
4747
{
48-
Name: "test",
49-
DisplayName: "test",
50-
NodeConfig: testClusterV2RKEConfigMachinePoolMachineConfigConf,
51-
ControlPlaneRole: true,
52-
EtcdRole: true,
48+
Name: "test",
49+
DisplayName: "test",
50+
NodeConfig: testClusterV2RKEConfigMachinePoolMachineConfigConf,
51+
ControlPlaneRole: true,
52+
EtcdRole: true,
53+
DrainBeforeDelete: true,
5354
MachineDeploymentAnnotations: map[string]string{
5455
"anno_one": "one",
5556
"anno_two": "two",
@@ -79,6 +80,7 @@ func init() {
7980
"machine_config": testClusterV2RKEConfigMachinePoolMachineConfigInterface,
8081
"control_plane_role": true,
8182
"etcd_role": true,
83+
"drain_before_delete": true,
8284
"annotations": map[string]interface{}{
8385
"anno_one": "one",
8486
"anno_two": "two",

0 commit comments

Comments
 (0)