Skip to content

Commit 7795e99

Browse files
committed
Fix
1 parent 9b49c68 commit 7795e99

12 files changed

+5802
-22
lines changed

scaleway/helpers_lb.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,13 @@ func expandLbACL(i interface{}) *lb.ACL {
7171
return acl
7272
}
7373
func flattenLbACLAction(action *lb.ACLAction) interface{} {
74-
return map[string]interface{}{
75-
"type": action.Type,
74+
return []map[string]interface{}{
75+
{
76+
"type": action.Type,
77+
},
7678
}
7779
}
80+
7881
func expandLbACLAction(raw interface{}) *lb.ACLAction {
7982
if raw == nil || len(raw.([]interface{})) != 1 {
8083
return nil
@@ -85,13 +88,16 @@ func expandLbACLAction(raw interface{}) *lb.ACLAction {
8588
}
8689
}
8790
func flattenLbACLMatch(match *lb.ACLMatch) interface{} {
88-
return map[string]interface{}{
89-
"ip_subnet": flattenSliceStringPtr(match.IPSubnet),
90-
"http_filter": match.HTTPFilter.String(),
91-
"http_filter_value": flattenSliceStringPtr(match.HTTPFilterValue),
92-
"invert": match.Invert,
91+
return []map[string]interface{}{
92+
{
93+
"ip_subnet": flattenSliceStringPtr(match.IPSubnet),
94+
"http_filter": match.HTTPFilter.String(),
95+
"http_filter_value": flattenSliceStringPtr(match.HTTPFilterValue),
96+
"invert": match.Invert,
97+
},
9398
}
9499
}
100+
95101
func expandLbACLMatch(raw interface{}) *lb.ACLMatch {
96102
if raw == nil || len(raw.([]interface{})) != 1 {
97103
return nil

scaleway/resource_lb_backend_beta_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func TestAccScalewayLbBackend_Basic(t *testing.T) {
3434
name = "bkd01"
3535
forward_protocol = "tcp"
3636
forward_port = 80
37+
proxy_protocol = "none"
3738
server_ips = [ scaleway_instance_ip.ip01.address ]
3839
}
3940
`,

scaleway/resource_lb_certificate_beta.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,18 @@ func resourceScalewayLbCertificateBeta() *schema.Resource {
8080
Description: "The main domain name of the certificate",
8181
},
8282
"subject_alternative_name": {
83-
Type: schema.TypeString,
83+
Type: schema.TypeList,
8484
Computed: true,
8585
Description: "The alternative domain names of the certificate",
86+
Elem: &schema.Resource{
87+
Schema: map[string]*schema.Schema{
88+
"name": {
89+
Type: schema.TypeString,
90+
Required: true,
91+
Description: "The domain name",
92+
},
93+
},
94+
},
8695
},
8796
"fingerprint": {
8897
Type: schema.TypeString,

scaleway/resource_lb_frontend_beta.go

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,18 +218,23 @@ func resourceScalewayLbFrontendBetaRead(ctx context.Context, d *schema.ResourceD
218218
if err != nil {
219219
return diag.FromErr(err)
220220
}
221-
sort.Slice(resACL.ACLs, func(i, j int) bool {
222-
return resACL.ACLs[i].Index < resACL.ACLs[j].Index
223-
})
224-
stateAcls := make([]interface{}, 0, len(resACL.ACLs))
225-
for _, apiACL := range resACL.ACLs {
226-
stateAcls = append(stateAcls, flattenLbACL(apiACL))
227-
}
228-
_ = d.Set("acl", stateAcls)
221+
222+
_ = d.Set("acl", flattenLBACLs(resACL.ACLs))
229223

230224
return nil
231225
}
232226

227+
func flattenLBACLs(ACLs []*lb.ACL) interface{} {
228+
sort.Slice(ACLs, func(i, j int) bool {
229+
return ACLs[i].Index < ACLs[j].Index
230+
})
231+
rawACLs := make([]interface{}, 0, len(ACLs))
232+
for _, apiACL := range ACLs {
233+
rawACLs = append(rawACLs, flattenLbACL(apiACL))
234+
}
235+
return rawACLs
236+
}
237+
233238
func resourceScalewayLbFrontendBetaUpdateACL(ctx context.Context, d *schema.ResourceData, lbAPI *lb.API, region scw.Region, frontendID string) diag.Diagnostics {
234239
//Fetch existing acl from the api. and convert it to a hashmap with index as key
235240
resACL, err := lbAPI.ListACLs(&lb.ListACLsRequest{
@@ -245,10 +250,7 @@ func resourceScalewayLbFrontendBetaUpdateACL(ctx context.Context, d *schema.Reso
245250
}
246251

247252
//convert state acl and sanitize them a bit
248-
newACL := make([]*lb.ACL, 0)
249-
for _, rawACL := range d.Get("acl").([]interface{}) {
250-
newACL = append(newACL, expandLbACL(rawACL))
251-
}
253+
newACL := expandsLBACLs(d.Get("acl"))
252254

253255
//loop
254256
for index, stateACL := range newACL {
@@ -304,6 +306,15 @@ func resourceScalewayLbFrontendBetaUpdateACL(ctx context.Context, d *schema.Reso
304306
return nil
305307
}
306308

309+
func expandsLBACLs(raw interface{}) []*lb.ACL {
310+
d := raw.([]interface{})
311+
newACL := make([]*lb.ACL, 0)
312+
for _, rawACL := range d {
313+
newACL = append(newACL, expandLbACL(rawACL))
314+
}
315+
return newACL
316+
}
317+
307318
func resourceScalewayLbFrontendBetaUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
308319
lbAPI, region, ID, err := lbAPIWithRegionAndID(m, d.Id())
309320
if err != nil {

scaleway/resource_lb_frontend_beta_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func TestAccScalewayLbFrontend_Basic(t *testing.T) {
3131
lb_id = scaleway_lb_beta.lb01.id
3232
forward_protocol = "tcp"
3333
forward_port = 80
34+
proxy_protocol = "none"
3435
}
3536
resource scaleway_lb_frontend_beta frt01 {
3637
lb_id = scaleway_lb_beta.lb01.id
@@ -56,6 +57,7 @@ func TestAccScalewayLbFrontend_Basic(t *testing.T) {
5657
lb_id = scaleway_lb_beta.lb01.id
5758
forward_protocol = "tcp"
5859
forward_port = 80
60+
proxy_protocol = "none"
5961
}
6062
resource scaleway_lb_frontend_beta frt01 {
6163
lb_id = scaleway_lb_beta.lb01.id
@@ -96,6 +98,7 @@ func TestAccScalewayLbAcl_Basic(t *testing.T) {
9698
lb_id = scaleway_lb_beta.lb01.id
9799
forward_protocol = "http"
98100
forward_port = 80
101+
proxy_protocol = "none"
99102
}
100103
resource scaleway_lb_frontend_beta frt01 {
101104
lb_id = scaleway_lb_beta.lb01.id
@@ -214,6 +217,7 @@ func TestAccScalewayLbAcl_Basic(t *testing.T) {
214217
lb_id = scaleway_lb_beta.lb01.id
215218
forward_protocol = "http"
216219
forward_port = 80
220+
proxy_protocol = "none"
217221
}
218222
resource scaleway_lb_frontend_beta frt01 {
219223
lb_id = scaleway_lb_beta.lb01.id

scaleway/resource_lb_ip_beta.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ func resourceScalewayLbIPBetaRead(ctx context.Context, d *schema.ResourceData, m
8989
_ = d.Set("region", string(region))
9090
_ = d.Set("organization_id", res.OrganizationID)
9191
_ = d.Set("project_id", res.ProjectID)
92-
_ = d.Set("ip_id", res.ID)
9392
_ = d.Set("ip_address", res.IPAddress)
9493
_ = d.Set("reverse", res.Reverse)
95-
_ = d.Set("lb_ip", flattenStringPtr(res.LBID))
94+
_ = d.Set("lb_id", flattenStringPtr(res.LBID))
9695

9796
return nil
9897
}

0 commit comments

Comments
 (0)