Skip to content

Commit

Permalink
fix(cli): remove subaccount during configure (#474)
Browse files Browse the repository at this point in the history
If an org user runs `lacework configure` and selects the PRIMARY account,
the Lacework CLI will now remove the subaccount from the configuration.

Closes #440

Signed-off-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
afiune committed Jul 15, 2021
1 parent 6725a81 commit f228f08
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions cli/cmd/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,12 @@ func runConfigureSetup() error {
// get sub-accounts from organizational accounts
subaccount, err := getSubAccountForOrgAdmins()
if err != nil {
return err
}

// only configure the subaccount if it is not empty
if subaccount != "" {
// We do NOT error here since API v2 is sending 500 errors
// for mortal users, we need to fix this on the server side
cli.Log.Warnw("unable to get sub-accounts for org admins", "error", err)
} else {
newProfile.Subaccount = subaccount
}

cli.OutputHuman("\n")
}

Expand Down Expand Up @@ -309,12 +307,7 @@ func getSubAccountForOrgAdmins() (string, error) {
user, err := cli.LwApi.V2.UserProfile.Get()
cli.StopProgress()
if err != nil {
cli.Log.Warnw("unable to access UserProfile endpoint",
"error", err,
)
// We do NOT error here since API v2 is sending 500 errors
// for mortal users, we need to fix this on the server side
return "", nil
return "", errors.Wrap(err, "unable to access UserProfile endpoint")
}

// We only ask for the sub-account if the account is an organizational account
Expand Down

0 comments on commit f228f08

Please sign in to comment.