Onboard Argus (ACL): fix edge cases (#314)

* fix empty acl update/create, update CIDR validator

* fix sigsegv in test, acl description

* Split field mapping, better handle edge cases

* Update stackit/internal/services/argus/instance/resource.go

Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com>

---------

Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com>
This commit is contained in:
Diogo Ferrão 2024-03-26 13:54:09 +00:00 committed by GitHub
parent 056c000acc
commit 394d5bf8d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 99 additions and 24 deletions

View file

@ -227,11 +227,17 @@ func (d *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
return
}
err = mapFields(ctx, instanceResponse, aclList, &model)
// Map response body to schema
err = mapFields(ctx, instanceResponse, &model)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API payload: %v", err))
return
}
err = mapACLField(aclList, &model)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Processing API response for the ACL: %v", err))
return
}
diags = resp.State.Set(ctx, model)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {