Skip to content

Commit

Permalink
add logout command for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
djelusic committed Mar 1, 2022
1 parent 388364e commit 9ada01b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func root() *cobra.Command {
examples.NewGithubAuthCommand,
examples.NewUserCommand,
examples.NewProjectCommand,
examples.NewLogoutCommand,
}
for _, sub := range subCommands {
add(sub)
Expand Down
26 changes: 26 additions & 0 deletions cli/controller/examples/node_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,29 @@ func nodeInvoker(node *domain.Node) (*invoke.HTTPClient, error) {
}
return invoke.Node(node.Endpoints.Rest, t, ui.NodeLogsSink), nil
}

func NewLogoutCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "logout",
Hidden: true,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
fs, err := domain.NewSingleDeveloperWorkspaceStore()
if err != nil {
return err
}
w := fs.Workspace()
if len(w.Nodes) == 0 {
return fmt.Errorf("no nodes avaiable")
}
n := w.FindNode(args[0])
if n == nil {
return fmt.Errorf("node not found")
}
n.JWT = ""
return fs.Store()
},
}
cmd.Flags().StringP("node", "", domain.DefaultNodeName, "")
return cmd
}

0 comments on commit 9ada01b

Please sign in to comment.