Skip to content

Commit

Permalink
chore: improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed May 4, 2022
1 parent ecec710 commit 0578423
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 42 deletions.
2 changes: 0 additions & 2 deletions rhoc/pkg/cmd/clusters/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
func NeClustersCommand(f *factory.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "clusters",
Short: "clusters",
Long: "clusters",
Aliases: []string{"cc"},
Args: cobra.MinimumNArgs(1),
}
Expand Down
7 changes: 3 additions & 4 deletions rhoc/pkg/cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ type itemRow struct {

func NewConfigCommand(f *factory.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "config",
Short: "config",
Long: "config",
Args: cobra.NoArgs,
Use: "config",
Aliases: []string{"cfg"},
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
Expand Down
35 changes: 20 additions & 15 deletions rhoc/pkg/cmd/config/show/show.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
package show

import (
"github.com/redhat-developer/app-services-cli/pkg/core/ioutil/dump"
"github.com/bf2fc6cc711aee1a0c2a/cos-tools/rhoc/pkg/util/dumper"
"github.com/redhat-developer/app-services-cli/pkg/shared/factory"
"github.com/spf13/cobra"
)

type keyVal struct {
key string
val string
}

func NewConfigShowCommand(f *factory.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "show",
Short: "show",
Long: "show",
Args: cobra.NoArgs,
Use: "show",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
c, err := f.Config.Load()
if err != nil {
return err
}

rows := []struct {
Key string `json:"key" header:"Key"`
Val string `json:"val" header:"Val"`
}{
{Key: "APIUrl", Val: c.APIUrl},
{Key: "AuthURL", Val: c.AuthURL},
{Key: "MasAuthURL", Val: c.MasAuthURL},
}
t := dumper.Table[keyVal]{}
t.Field("Key", func(in *keyVal) string {
return in.key
})
t.Field("Val", func(in *keyVal) string {
return in.val
})

dump.Table(f.IOStreams.Out, rows)
f.Logger.Info("")
t.Dump(f.IOStreams.Out, []keyVal{
{key: "API URL", val: c.APIUrl},
{key: "Auth URL", val: c.AuthURL},
{key: "Mas Auth URL", val: c.MasAuthURL},
})

return nil
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@ package token

import (
"github.com/bf2fc6cc711aee1a0c2a/cos-tools/rhoc/pkg/service"
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/flagutil"
"github.com/redhat-developer/app-services-cli/pkg/shared/factory"
"github.com/spf13/cobra"
)

func NewConfigTokenCommand(f *factory.Factory) *cobra.Command {
var mas bool

cmd := &cobra.Command{
Use: "token",
Short: "token",
Long: "token",
Args: cobra.NoArgs,
Use: "token",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
a, err := service.API(&service.Config{
F: f,
Expand All @@ -23,6 +18,11 @@ func NewConfigTokenCommand(f *factory.Factory) *cobra.Command {
return err
}

mas, err := cmd.Flags().GetBool("mas")
if err != nil {
return err
}

if mas {
_, _ = f.IOStreams.Out.Write([]byte(a.GetConfig().MasAccessToken))
} else {
Expand All @@ -33,8 +33,7 @@ func NewConfigTokenCommand(f *factory.Factory) *cobra.Command {
},
}

flags := flagutil.NewFlagSet(cmd, f.Localizer)
flags.BoolVarP(&mas, "mas", "m", false, "mas")
cmd.Flags().BoolP("mas", "m", false, "mas")

return cmd
}
4 changes: 1 addition & 3 deletions rhoc/pkg/cmd/connectors/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (
func NewConnectorsCommand(f *factory.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "connectors",
Aliases: []string{"mctr"},
Short: "connectors",
Long: "connectors",
Aliases: []string{"ctr"},
Args: cobra.MinimumNArgs(1),
}

Expand Down
2 changes: 1 addition & 1 deletion rhoc/pkg/cmd/connectors/list/list_dumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func dumpAsTable(f *factory.Factory, items admin.ConnectorAdminViewList, wide bo
})

if wide {
t.Field("ResourceVersion", func(in *admin.ConnectorAdminView) string {
t.Field("Version", func(in *admin.ConnectorAdminView) string {
return strconv.FormatInt(in.ResourceVersion, 10)
})
}
Expand Down
7 changes: 3 additions & 4 deletions rhoc/pkg/cmd/deployments/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import (

func NewDeploymentsCommand(f *factory.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "deployments",
Short: "deployments",
Long: "deployments",
Args: cobra.MinimumNArgs(1),
Use: "deployments",
Aliases: []string{"cd"},
Args: cobra.MinimumNArgs(1),
}

cmdutil.Bind(
Expand Down
4 changes: 2 additions & 2 deletions rhoc/pkg/cmd/deployments/list/list_dumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ func dumpAsTable(f *factory.Factory, items admin.ConnectorDeploymentAdminViewLis

if wide {

t.Field("ResourceVersion", func(in *admin.ConnectorDeploymentAdminView) string {
t.Field("Version", func(in *admin.ConnectorDeploymentAdminView) string {
return strconv.FormatInt(in.Metadata.ResourceVersion, 10)
})

t.Field("ConnectorResourceVersion", func(in *admin.ConnectorDeploymentAdminView) string {
t.Field("ConnectorVersion", func(in *admin.ConnectorDeploymentAdminView) string {
return strconv.FormatInt(in.Spec.ConnectorResourceVersion, 10)
})
}
Expand Down
2 changes: 0 additions & 2 deletions rhoc/pkg/cmd/namespaces/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ func NewNamespacesCommand(f *factory.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "namespaces",
Aliases: []string{"ns"},
Short: "namespaces",
Long: "namespaces",
Args: cobra.MinimumNArgs(1),
}

Expand Down

0 comments on commit 0578423

Please sign in to comment.