Skip to content

Commit

Permalink
RSDK-9452 - require logged in status for module generation (#4724)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuqdog authored Jan 21, 2025
1 parent 1a27697 commit 93970a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,6 @@ var app = &cli.App{
Name: "status",
Usage: "display part status",
UsageText: createUsageText("machines part status", []string{generalFlagPart}, true, false),
// TODO(RSDK-9286) do we need to ask for og and location and machine and part here?
Flags: []cli.Flag{
&AliasStringFlag{
cli.StringFlag{
Expand Down
9 changes: 9 additions & 0 deletions cli/module_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func GenerateModuleAction(cCtx *cli.Context, args generateModuleArgs) error {
}

func (c *viamClient) generateModuleAction(cCtx *cli.Context, args generateModuleArgs) error {
if err := c.ensureLoggedIn(); err != nil {
return err
}
var newModule *modulegen.ModuleInputs
var err error

Expand Down Expand Up @@ -326,6 +329,12 @@ func wrapResolveOrg(cCtx *cli.Context, c *viamClient, newModule *modulegen.Modul
return nil
}

// TODO(RSDK-9758) - this logic will never be relevant currently because we're now checking if
// we're logged in at the first opportunity in `viam module generate`, and returning an error if
// not. However, I (ethan) am leaving this logic here because we will likely want to revisit if
// and how to use it more broadly (not just for `viam module generate` but for _all_ CLI commands),
// and because disentangling it immediately may be complicated and delay the current attempt to
// solve the problems this causes (see RSDK-9452).
func catchResolveOrgErr(cCtx *cli.Context, c *viamClient, newModule *modulegen.ModuleInputs, caughtErr error) error {
if strings.Contains(caughtErr.Error(), "not logged in") || strings.Contains(caughtErr.Error(), "error while refreshing token") {
originalWriter := cCtx.App.Writer
Expand Down

0 comments on commit 93970a5

Please sign in to comment.