Skip to content

Commit

Permalink
fix(instance): fix empty tags list (#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone committed Mar 11, 2022
1 parent e8abd32 commit 8a4b890
Show file tree
Hide file tree
Showing 11 changed files with 1,967 additions and 1,974 deletions.
10 changes: 4 additions & 6 deletions scaleway/resource_instance_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func resourceScalewayInstanceSecurityGroupCreate(ctx context.Context, d *schema.
return diag.FromErr(err)
}

res, err := instanceAPI.CreateSecurityGroup(&instance.CreateSecurityGroupRequest{
req := &instance.CreateSecurityGroupRequest{
Name: expandOrGenerateString(d.Get("name"), "sg"),
Zone: zone,
Project: expandStringPtr(d.Get("project_id")),
Expand All @@ -119,7 +119,8 @@ func resourceScalewayInstanceSecurityGroupCreate(ctx context.Context, d *schema.
OutboundDefaultPolicy: instance.SecurityGroupPolicy(d.Get("outbound_default_policy").(string)),
EnableDefaultSecurity: expandBoolPtr(d.Get("enable_default_security")),
Tags: expandStrings(d.Get("tags")),
}, scw.WithContext(ctx))
}
res, err := instanceAPI.CreateSecurityGroup(req, scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -263,16 +264,13 @@ func resourceScalewayInstanceSecurityGroupUpdate(ctx context.Context, d *schema.
Description: expandStringPtr(description),
InboundDefaultPolicy: &inboundDefaultPolicy,
OutboundDefaultPolicy: &outboundDefaultPolicy,
Tags: scw.StringsPtr(expandStrings(d.Get("tags"))),
}

if d.HasChange("enable_default_security") {
updateReq.EnableDefaultSecurity = expandBoolPtr(d.Get("enable_default_security"))
}

if d.HasChange("tags") {
updateReq.Tags = scw.StringsPtr(expandStrings(d.Get("tags")))
}

// Only update name if one is provided in the state
if d.Get("name") != nil && d.Get("name").(string) != "" {
updateReq.Name = expandStringPtr(d.Get("name"))
Expand Down
11 changes: 2 additions & 9 deletions scaleway/resource_instance_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,8 @@ func resourceScalewayInstanceSnapshotUpdate(ctx context.Context, d *schema.Resou
req := &instance.UpdateSnapshotRequest{
SnapshotID: id,
Zone: zone,
}

if d.HasChange("name") {
newName := d.Get("name").(string)
req.Name = &newName
}

if d.HasChange("tags") {
req.Tags = scw.StringsPtr(expandStrings(d.Get("tags")))
Tags: scw.StringsPtr(expandStrings(d.Get("tags"))),
Name: scw.StringPtr(d.Get("name").(string)),
}

_, err = instanceAPI.UpdateSnapshot(req, scw.WithContext(ctx))
Expand Down
1,250 changes: 625 additions & 625 deletions scaleway/testdata/data-source-instance-security-group-basic.cassette.yaml

Large diffs are not rendered by default.

178 changes: 89 additions & 89 deletions scaleway/testdata/instance-security-group-any.cassette.yaml

Large diffs are not rendered by default.

596 changes: 298 additions & 298 deletions scaleway/testdata/instance-security-group-basic.cassette.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

326 changes: 163 additions & 163 deletions scaleway/testdata/instance-security-group-icmp.cassette.yaml

Large diffs are not rendered by default.

328 changes: 164 additions & 164 deletions scaleway/testdata/instance-security-group-remove-port.cassette.yaml

Large diffs are not rendered by default.

164 changes: 82 additions & 82 deletions scaleway/testdata/instance-security-group-with-no-port.cassette.yaml

Large diffs are not rendered by default.

468 changes: 234 additions & 234 deletions scaleway/testdata/instance-security-group-with-port-range.cassette.yaml

Large diffs are not rendered by default.

350 changes: 176 additions & 174 deletions scaleway/testdata/instance-snapshot-rename-snapshot.cassette.yaml

Large diffs are not rendered by default.

0 comments on commit 8a4b890

Please sign in to comment.