Skip to content

Commit

Permalink
feat(rdb): improve ACL deletion message (#2669)
Browse files Browse the repository at this point in the history
  • Loading branch information
yfodil authored Dec 6, 2022
1 parent 77ff45b commit 85c1bfb
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 248 deletions.
15 changes: 11 additions & 4 deletions internal/namespaces/rdb/v1/custom_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package rdb

import (
"context"
"fmt"
"reflect"
"strings"

"github.com/fatih/color"
"github.com/scaleway/scaleway-cli/v2/internal/core"
Expand Down Expand Up @@ -92,9 +94,14 @@ func aclDeleteBuilder(c *core.Command) *core.Command {
}

aclDeleteResponse := aclDeleteResponseI.(*rdb.DeleteInstanceACLRulesResponse)
return rdb.ListInstanceACLRulesResponse{
Rules: aclDeleteResponse.Rules,
TotalCount: uint32(len(aclDeleteResponse.Rules)),
aclResult := make([]string, 0, len(aclDeleteResponse.Rules))

for i := 0; i < len(aclDeleteResponse.Rules); i++ {
aclResult = append(aclResult, aclDeleteResponse.Rules[i].IP.String())
}

return &core.SuccessResult{
Message: fmt.Sprintf("ACL rule(s) %s successfully deleted", strings.Trim(fmt.Sprint(aclResult), "[]")),
}, nil
}

Expand All @@ -112,7 +119,7 @@ func aclDeleteBuilder(c *core.Command) *core.Command {
return nil, err
}

return respI.(rdb.ListInstanceACLRulesResponse), nil
return respI.(*core.SuccessResult), nil
}

return c
Expand Down
Loading

0 comments on commit 85c1bfb

Please sign in to comment.