Handle Scaleway tags correctly (#7682)
This commit is contained in:
parent
9dbf998d23
commit
697828f81f
|
@ -82,8 +82,10 @@ func resourceScalewayServerCreate(d *schema.ResourceData, m interface{}) error {
|
|||
server.Bootscript = String(bootscript.(string))
|
||||
}
|
||||
|
||||
if tags, ok := d.GetOk("tags"); ok {
|
||||
server.Tags = tags.([]string)
|
||||
if raw, ok := d.GetOk("tags"); ok {
|
||||
for _, tag := range raw.([]interface{}) {
|
||||
server.Tags = append(server.Tags, tag.(string))
|
||||
}
|
||||
}
|
||||
|
||||
id, err := scaleway.PostServer(server)
|
||||
|
@ -129,6 +131,7 @@ func resourceScalewayServerRead(d *schema.ResourceData, m interface{}) error {
|
|||
d.Set("ipv4_address_public", server.PublicAddress.IP)
|
||||
d.Set("state", server.State)
|
||||
d.Set("state_detail", server.StateDetail)
|
||||
d.Set("tags", server.Tags)
|
||||
|
||||
d.SetConnInfo(map[string]string{
|
||||
"type": "ssh",
|
||||
|
@ -148,6 +151,16 @@ func resourceScalewayServerUpdate(d *schema.ResourceData, m interface{}) error {
|
|||
req.Name = &name
|
||||
}
|
||||
|
||||
if d.HasChange("tags") {
|
||||
if raw, ok := d.GetOk("tags"); ok {
|
||||
var tags []string
|
||||
for _, tag := range raw.([]interface{}) {
|
||||
tags = append(tags, tag.(string))
|
||||
}
|
||||
req.Tags = &tags
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("dynamic_ip_required") {
|
||||
req.DynamicIPRequired = Bool(d.Get("dynamic_ip_required").(bool))
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ func TestAccScalewayServer_Basic(t *testing.T) {
|
|||
"scaleway_server.base", "type", "C1"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"scaleway_server.base", "name", "test"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"scaleway_server.base", "tags.0", "terraform-test"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -110,4 +112,5 @@ resource "scaleway_server" "base" {
|
|||
# ubuntu 14.04
|
||||
image = "%s"
|
||||
type = "C1"
|
||||
tags = [ "terraform-test" ]
|
||||
}`, armImageIdentifier)
|
||||
|
|
Loading…
Reference in New Issue