Skip to content

Commit

Permalink
move node commands out of examples
Browse files Browse the repository at this point in the history
  • Loading branch information
djelusic committed Mar 7, 2022
1 parent 5959b7b commit 48c7489
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 258 deletions.
50 changes: 50 additions & 0 deletions cli/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,53 @@ func newReportCommand() *cobra.Command {
cmd.Flags().IntVarP(&days, "days", "d", 3, "Days of logs to include in report")
return cmd
}

func newNodeCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "node",
Hidden: true,
}
addCommand(cmd, newNodeUserAddCommand())
addCommand(cmd, newNodeLoginCommand())
addCommand(cmd, newNodeLogoutCommand())
return cmd
}

func newNodeUserAddCommand() *cobra.Command {
var a controller.NodeUserAddArgs
cmd := &cobra.Command{
Use: "user-add",
RunE: func(cmd *cobra.Command, args []string) error {
return controller.NodeUserAdd(a)
},
}
setUsageTemplate(cmd, texts.Deploy.Arguments)
cmd.Flags().StringVarP(&a.Node, "node", "n", "", "Node in which the user will be added")
cmd.Flags().StringVarP(&a.GithubUser, "github-user", "u", "", "The GitHub username of the user")
cmd.Flags().StringVarP(&a.Role, "role", "r", "user", "The role that will be assigned to the user, can be `admin` or `user`")
return cmd
}

func newNodeLoginCommand() *cobra.Command {
var a controller.NodeLoginArgs
cmd := &cobra.Command{
Use: "login",
RunE: func(cmd *cobra.Command, args []string) error {
a.NodeURL = args[0]
return controller.NodeLogin(a)
},
}
return cmd
}

func newNodeLogoutCommand() *cobra.Command {
var a controller.NodeLogoutArgs
cmd := &cobra.Command{
Use: "logout",
RunE: func(cmd *cobra.Command, args []string) error {
a.NodeName = args[0]
return controller.NodeLogout(a)
},
}
return cmd
}
4 changes: 1 addition & 3 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"github.com/mantil-io/mantil/cli/controller"
"github.com/mantil-io/mantil/cli/controller/examples"
"github.com/mantil-io/mantil/cli/log"
"github.com/mantil-io/mantil/cli/ui"
"github.com/mantil-io/mantil/domain"
Expand Down Expand Up @@ -72,12 +71,11 @@ func root() *cobra.Command {
newAwsCommand,
newStageCommand,
newReportCommand,
newNodeCommand,

// for testing:
//examples.NewErrorsCommand,
//examples.NewArgsCommand,
examples.NewGithubAuthCommand,
examples.NewNodeCommand,
}
for _, sub := range subCommands {
add(sub)
Expand Down
116 changes: 0 additions & 116 deletions cli/controller/examples/github_auth_example.go

This file was deleted.

126 changes: 0 additions & 126 deletions cli/controller/examples/node_example.go

This file was deleted.

Loading

0 comments on commit 48c7489

Please sign in to comment.