Skip to content

Commit

Permalink
chore: upgrade salt printer
Browse files Browse the repository at this point in the history
  • Loading branch information
ravisuhag committed Aug 21, 2022
1 parent 7629f48 commit 08c1e08
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ To pull a specific version:
docker pull odpf/guardian:v0.3.2
```

If you like to have a shell alias that runs the latest version of pscale from docker whenever you type `pscale`:
If you like to have a shell alias that runs the latest version of guardian from docker whenever you type `guardian`:

```
mkdir -p $HOME/.config/odpf
Expand Down
10 changes: 3 additions & 7 deletions cli/appeal.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ func listAppealsCommand() *cobra.Command {
spinner := printer.Spin("")
defer spinner.Stop()

cs := term.NewColorScheme()

client, cancel, err := createClient(cmd)
if err != nil {
return err
Expand All @@ -93,7 +91,7 @@ func listAppealsCommand() *cobra.Command {
report = append(report, []string{"ID", "USER", "RESOURCE ID", "ROLE", "STATUS"})
for _, a := range appeals {
report = append(report, []string{
cs.Greenf("%v", a.GetId()),
term.Greenf("%v", a.GetId()),
a.GetAccountId(),
fmt.Sprintf("%v", a.GetResourceId()),
a.GetRole(),
Expand Down Expand Up @@ -160,7 +158,7 @@ func createAppealCommand() *cobra.Command {
spinner.Stop()

appealID := res.GetAppeals()[0].GetId()
fmt.Printf("appeal created with id: %v", appealID)
printer.Successf("appeal created with id: %v", appealID)
return nil
},
}
Expand Down Expand Up @@ -248,8 +246,6 @@ func bulkRevokeAppealCommand() *cobra.Command {
spinner := printer.Spin("")
defer spinner.Stop()

cs := term.NewColorScheme()

client, cancel, err := createClient(cmd)
if err != nil {
return err
Expand Down Expand Up @@ -277,7 +273,7 @@ func bulkRevokeAppealCommand() *cobra.Command {
report = append(report, []string{"ID", "USER", "RESOURCE ID", "ROLE", "STATUS"})
for _, a := range appeals {
report = append(report, []string{
cs.Greenf("%v", a.GetId()),
term.Greenf("%v", a.GetId()),
a.GetAccountId(),
fmt.Sprintf("%v", a.GetResourceId()),
a.GetRole(),
Expand Down
6 changes: 2 additions & 4 deletions cli/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ func listPoliciesCmd() *cobra.Command {
spinner := printer.Spin("")
defer spinner.Stop()

cs := term.NewColorScheme()

client, cancel, err := createClient(cmd)
if err != nil {
return err
Expand All @@ -96,7 +94,7 @@ func listPoliciesCmd() *cobra.Command {
report = append(report, []string{"ID", "NAME", "DESCRIPTION", "VERSION", "STEPS"})
for _, p := range policies {
report = append(report, []string{
cs.Greenf("%02d", index),
term.Greenf("%02d", index),
fmt.Sprintf("%v", p.GetId()),
p.GetDescription(),
fmt.Sprintf("%v", p.GetVersion()),
Expand Down Expand Up @@ -163,7 +161,7 @@ func getPolicyCmd(adapter handlerv1beta1.ProtoAdapter) *cobra.Command {

spinner.Stop()

if err := printer.Text(p, format); err != nil {
if err := printer.File(p, format); err != nil {
return fmt.Errorf("failed to format policy: %v", err)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cli/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func viewProviderCmd(adapter handlerv1beta1.ProtoAdapter) *cobra.Command {

spinner.Stop()

if err := printer.Text(p, format); err != nil {
if err := printer.File(p, format); err != nil {
return fmt.Errorf("failed to format provider: %v", err)
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions cli/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func listResourcesCmd(adapter handlerv1beta1.ProtoAdapter) *cobra.Command {

spinner.Stop()

if err := printer.Text(resources, format); err != nil {
if err := printer.File(resources, format); err != nil {
return fmt.Errorf("failed to parse resources: %v", err)
}
return nil
Expand Down Expand Up @@ -167,7 +167,7 @@ func viewResourceCmd(adapter handlerv1beta1.ProtoAdapter) *cobra.Command {
if format != "" {
r := adapter.FromResourceProto(res.GetResource())
spinner.Stop()
if err := printer.Text(r, format); err != nil {
if err := printer.File(r, format); err != nil {
return fmt.Errorf("failed to parse resources: %v", err)
}
} else {
Expand Down
6 changes: 2 additions & 4 deletions cli/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ func VersionCmd() *cobra.Command {
Aliases: []string{"v"},
Short: "Print version information",
RunE: func(cmd *cobra.Command, args []string) error {
cs := term.NewColorScheme()

if core.Version == "" {
fmt.Println(cs.Yellow("guardian version (built from source)"))
fmt.Println(term.Yellow("guardian version (built from source)"))
return nil
}

fmt.Printf("guardian version %s (%s)\n\n", core.Version, core.BuildDate)
fmt.Println(cs.Yellow(version.UpdateNotice(core.Version, "odpf/guardian")))
fmt.Println(term.Yellow(version.UpdateNotice(core.Version, "odpf/guardian")))
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/mcuadros/go-defaults v1.2.0
github.com/mcuadros/go-lookup v0.0.0-20200831155250-80f87a4fa5ee
github.com/mitchellh/mapstructure v1.4.3
github.com/odpf/salt v0.0.0-20220820210649-284059fe57e6
github.com/odpf/salt v0.1.1-0.20220821030850-77ce10e39145
github.com/robfig/cron/v3 v3.0.1
github.com/sergi/go-diff v1.0.0
github.com/sirupsen/logrus v1.8.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,8 @@ github.com/odpf/salt v0.0.0-20220530022224-80e391d2e38a h1:c0jaoXLGTITEqmROjOIei
github.com/odpf/salt v0.0.0-20220530022224-80e391d2e38a/go.mod h1:ZY9yXIHZYlYbQGKV5WSGmyYnw+NtQEzl6z0Tj0dto8M=
github.com/odpf/salt v0.0.0-20220820210649-284059fe57e6 h1:mzEt6On7rWj7fzKZs0ZdOcuHQFxB3MxurhbA2JHr1YI=
github.com/odpf/salt v0.0.0-20220820210649-284059fe57e6/go.mod h1:iH1ZB+lBmI5E5DgSCu9HjMmNcSvUe0zCusZJzOF2Yfk=
github.com/odpf/salt v0.1.1-0.20220821030850-77ce10e39145 h1:MML18OvRZhDDdh/m9u3LGutieRnPZPuGOJMtKkbSl+I=
github.com/odpf/salt v0.1.1-0.20220821030850-77ce10e39145/go.mod h1:iH1ZB+lBmI5E5DgSCu9HjMmNcSvUe0zCusZJzOF2Yfk=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
Expand Down

0 comments on commit 08c1e08

Please sign in to comment.