Skip to content

Commit

Permalink
check permission (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
gertd authored Dec 16, 2022
1 parent 48e5e5a commit 8608e5b
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 571 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module github.com/aserto-dev/topaz
go 1.19

// replace github.com/aserto-dev/go-edge-ds => ../go-edge-ds
// replace github.com/aserto-dev/go-directory-cli => ../go-directory-cli
// replace github.com/aserto-dev/go-aserto => ../go-aserto

require (
github.com/alecthomas/kong v0.7.1
Expand All @@ -12,7 +14,7 @@ require (
github.com/aserto-dev/go-aserto v0.20.2
github.com/aserto-dev/go-authorizer v0.20.2
github.com/aserto-dev/go-directory v0.20.4
github.com/aserto-dev/go-directory-cli v0.20.10
github.com/aserto-dev/go-directory-cli v0.20.11
github.com/aserto-dev/go-edge-ds v0.20.6
github.com/aserto-dev/go-http-metrics v0.10.1-20221024-1
github.com/aserto-dev/logger v0.0.2
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@ github.com/aserto-dev/go-authorizer v0.20.2 h1:jDjPeaD3lyJmgWFDL6+B8ebG9nrRsqFyM
github.com/aserto-dev/go-authorizer v0.20.2/go.mod h1:RTpBixDT2WIPOkXcewCXG3NxOWDt22yiXMb+qvdxucM=
github.com/aserto-dev/go-directory v0.20.4 h1:vZlgrirt9o/9p20aJSuQ7DZgKWiAJku2Aqy3p0XF6Ho=
github.com/aserto-dev/go-directory v0.20.4/go.mod h1:gjg6wZezLGXJj1LBEXaJUS9kpOnaDWeFUYhDG1TAkTY=
github.com/aserto-dev/go-directory-cli v0.20.10 h1:uUAjKW6ebLcj3ntAblPqwrzCrUw1UmlbTl2orMdRvXg=
github.com/aserto-dev/go-directory-cli v0.20.10/go.mod h1:XbOGPGxHQkF9nEBdJEaED1WA/mrFC+w/BZNkAv/hcRU=
github.com/aserto-dev/go-edge-ds v0.20.5 h1:JK45ksJDE7SpGwQK88fVp2muNT+ndqWdeSKoqrQig84=
github.com/aserto-dev/go-edge-ds v0.20.5/go.mod h1:gzmA8zvvfKYYIA2neO6WQBk8d5RYNBR0b2DP2coZ79A=
github.com/aserto-dev/go-directory-cli v0.20.11 h1:0Q5KDOi5c1eyXjyBSEM50UxXuBPdSti2y57lybnvOgI=
github.com/aserto-dev/go-directory-cli v0.20.11/go.mod h1:XbOGPGxHQkF9nEBdJEaED1WA/mrFC+w/BZNkAv/hcRU=
github.com/aserto-dev/go-edge-ds v0.20.6 h1:B9A+0Va1btCMRqxgF4oXVuvpo8gEZ/9l6IPMmw9ySc0=
github.com/aserto-dev/go-edge-ds v0.20.6/go.mod h1:EDiQCeW24D95dsJvTXrVsxoi4U2VyrDtPgqFA+xo2Gw=
github.com/aserto-dev/go-http-metrics v0.10.1-20221024-1 h1:nONd24V5nyJ0IIw8QE+OKv30YuHOTNbJ4FsvczLaM8o=
Expand Down
276 changes: 216 additions & 60 deletions go.work.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion magefiles/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aserto-dev/topaz/magefiles

go 1.17
go 1.19

require (
github.com/aserto-dev/mage-loot v0.8.11
Expand Down
497 changes: 0 additions & 497 deletions magefiles/go.sum

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions pkg/cli/clients/directory_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ import (

const localhostDirectory = "localhost:9292"

type Config struct {
Host string `flag:"host" short:"H" help:"" env:"TOPAZ_DIRECTORY_SVC" default:"localhost:9292"`
APIKey string `flag:"api-key" short:"k" help:"" env:"TOPAZ_DIRECTORY_KEY"`
Insecure bool `flag:"insecure" short:"i" help:""`
SessionID string `flag:"session-id" help:""`
TenantID string `flag:"tenant-id" help:""`
}

func NewDirectoryClient(c *cc.CommonCtx, cfg *Config) (*client.Client, error) {

if cfg.Host == "" {
Expand Down Expand Up @@ -50,14 +58,6 @@ func NewDirectoryClient(c *cc.CommonCtx, cfg *Config) (*client.Client, error) {
return client.New(conn.Conn, c.UI)
}

type Config struct {
Host string `flag:"host" short:"H" help:"" env:"TOPAZ_DIRECTORY_SVC" default:"localhost:9292"`
APIKey string `flag:"api-key" short:"k" help:"" env:"TOPAZ_DIRECTORY_KEY"`
Insecure bool `flag:"insecure" short:"i" help:""`
SessionID string `flag:"session-id" help:""`
TenantID string `flag:"tenant-id" help:""`
}

func validate(cfg *Config) error {
ctx := context.Background()

Expand Down
1 change: 1 addition & 0 deletions pkg/cli/cmd/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func (cmd *ExportCmd) Run(c *cc.CommonCtx) error {
}

color.Green(">>> exporting data to %s", cmd.Directory)

objectsFile := filepath.Join(cmd.Directory, "objects.json")
relationsFile := filepath.Join(cmd.Directory, "relations.json")

Expand Down
1 change: 1 addition & 0 deletions pkg/cli/cmd/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func (cmd *ImportCmd) Run(c *cc.CommonCtx) error {
}

color.Green(">>> importing data from %s", cmd.Directory)

files, err := filepath.Glob(filepath.Join(cmd.Directory, "*.json"))
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/cmd/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/aserto-dev/topaz/pkg/cli/cc"
"github.com/aserto-dev/topaz/pkg/cli/clients"
"github.com/fatih/color"
"github.com/google/uuid"
)

Expand Down Expand Up @@ -35,5 +36,6 @@ func (cmd *LoadCmd) Run(c *cc.CommonCtx) error {
cmd.File = path.Join(currentDir, defaultManifestName)
}

color.Green(">>> load manifest from %s", cmd.File)
return dirClient.Load(c.Context, cmd.File)
}
2 changes: 2 additions & 0 deletions pkg/cli/cmd/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/aserto-dev/topaz/pkg/cli/cc"
"github.com/aserto-dev/topaz/pkg/cli/clients"
"github.com/fatih/color"
)

type SaveCmd struct {
Expand All @@ -31,5 +32,6 @@ func (cmd *SaveCmd) Run(c *cc.CommonCtx) error {
cmd.File = path.Join(currentDir, defaultManifestName)
}

color.Green(">>> save manifest to %s", cmd.File)
return dirClient.Save(c.Context, cmd.File)
}

0 comments on commit 8608e5b

Please sign in to comment.