Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

break: rename disable_public_ip to disable_dynamic_ip #293

Merged
merged 2 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions scaleway/resource_instance_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ func resourceScalewayInstanceServer() *schema.Resource {
Computed: true,
Description: "The public IPv4 address of the server",
},
"disable_public_ip": {
"disable_dynamic_ip": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Disable dynamic ip on the server",
Description: "Disable dynamic IP on the server",
},
"state": {
Type: schema.TypeString,
Expand Down Expand Up @@ -172,6 +172,14 @@ func resourceScalewayInstanceServer() *schema.Resource {
},
"zone": zoneSchema(),
"organization_id": organizationIDSchema(),

// Deprecated and removed.
"disable_public_ip": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Removed: "Please use disable_dynamic_ip instead",
},
},
}
}
Expand Down Expand Up @@ -214,7 +222,7 @@ func resourceScalewayInstanceServerCreate(d *schema.ResourceData, m interface{})
CommercialType: commercialType,
EnableIPv6: d.Get("enable_ipv6").(bool),
SecurityGroup: expandID(d.Get("security_group_id")),
DynamicIPRequired: Bool(!d.Get("disable_public_ip").(bool)),
DynamicIPRequired: Bool(!d.Get("disable_dynamic_ip").(bool)),
}

if placementGroupID, ok := d.GetOk("placement_group_id"); ok {
Expand Down Expand Up @@ -324,7 +332,7 @@ func resourceScalewayInstanceServerRead(d *schema.ResourceData, m interface{}) e
d.Set("tags", response.Server.Tags)
d.Set("security_group_id", response.Server.SecurityGroup.ID)
d.Set("enable_ipv6", response.Server.EnableIPv6)
d.Set("disable_public_ip", !response.Server.DynamicIPRequired)
d.Set("disable_dynamic_ip", !response.Server.DynamicIPRequired)

// TODO: If image is a label, check that response.Server.Image.ID match the label.
// It could be useful if the user edit the image with another tool.
Expand Down Expand Up @@ -443,8 +451,8 @@ func resourceScalewayInstanceServerUpdate(d *schema.ResourceData, m interface{})
updateRequest.EnableIPv6 = scw.BoolPtr(d.Get("enable_ipv6").(bool))
}

if d.HasChange("disable_public_ip") {
updateRequest.DynamicIPRequired = scw.BoolPtr(!d.Get("disable_public_ip").(bool))
if d.HasChange("disable_dynamic_ip") {
updateRequest.DynamicIPRequired = scw.BoolPtr(!d.Get("disable_dynamic_ip").(bool))
}

volumes := map[string]*instance.VolumeTemplate{}
Expand Down
2 changes: 1 addition & 1 deletion scaleway/resource_instance_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestAccScalewayInstanceServerMinimal1(t *testing.T) {
resource.TestCheckResourceAttr("scaleway_instance_server.base", "root_volume.0.delete_on_termination", "true"),
resource.TestCheckResourceAttr("scaleway_instance_server.base", "root_volume.0.size_in_gb", "20"),
resource.TestCheckResourceAttrSet("scaleway_instance_server.base", "root_volume.0.volume_id"),
resource.TestCheckResourceAttr("scaleway_instance_server.base", "disable_public_ip", "false"),
resource.TestCheckResourceAttr("scaleway_instance_server.base", "disable_dynamic_ip", "false"),
resource.TestCheckResourceAttr("scaleway_instance_server.base", "tags.0", "terraform-test"),
resource.TestCheckResourceAttr("scaleway_instance_server.base", "tags.1", "scaleway_instance_server"),
resource.TestCheckResourceAttr("scaleway_instance_server.base", "tags.2", "minimal"),
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/instance_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ attached to the server. Updates to this field will trigger a stop/start of the s

- `enable_ipv6` - (Defaults to `false`) Determines if IPv6 is enabled for the server.

- `disable_dynamic_ip` - (Defaults to `false`) Disable dynamic IP on the server.

- `state` - (Defaults to `started`) The state of the server. Possible values are: `started`, `stopped` or `standby`.

- `cloud_init` - (Optional) The cloud init script associated with this server. Updates to this field will trigger a stop/start of the server.
Expand Down