Skip to content

Commit

Permalink
fix(cli): outputs unique list of grants for each dest (#1140)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimskimchi committed Mar 14, 2022
1 parent 8c98028 commit 158bc9c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ require (
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/creack/pty v1.1.11 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/dghubble/go-twitter v0.0.0-20211115160449-93a8679adecb // indirect
github.com/dghubble/oauth1 v0.7.1 // indirect
github.com/dghubble/sling v1.4.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY=
github.com/dghubble/go-twitter v0.0.0-20211115160449-93a8679adecb h1:7ENzkH+O3juL+yj2undESLTaAeRllHwCs/b8z6aWSfc=
Expand Down
11 changes: 8 additions & 3 deletions internal/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

mapset "github.com/deckarep/golang-set"
"github.com/infrahq/infra/internal/api"
)

Expand Down Expand Up @@ -55,10 +56,14 @@ func list() error {
}
}

gs := make(map[string]string)
gs := make(map[string]mapset.Set)
for _, g := range grants {
// aggregate privileges
gs[g.Resource] = gs[g.Resource] + g.Privilege + " "
if gs[g.Resource] == nil {
gs[g.Resource] = mapset.NewSet()
}

gs[g.Resource].Add(g.Privilege)
}

type row struct {
Expand Down Expand Up @@ -87,7 +92,7 @@ func list() error {

rows = append(rows, row{
Name: k,
Access: v,
Access: v.String()[4 : len(v.String())-1],
})
}

Expand Down

0 comments on commit 158bc9c

Please sign in to comment.