Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/juju/user: set controller name properly #7092

Merged

Conversation

rogpeppe
Copy link
Contributor

Because the controller wasn't being set, the ListControllers
call was failing. The tests still passed because the ListControllers
call was entirely mocked.

Also make a backwardly incompatible change so that the old
"juju login $user" behaviour is no longer the default - to log in as
a user, the "--user" (or "-u") flag is required.

Copy link

@mjs mjs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loginDoc needs to be updated to reflect this change

@@ -128,6 +129,7 @@ func (c *loginCommand) Init(args []string) error {

// Run implements Command.Run.
func (c *loginCommand) Run(ctx *cmd.Context) error {
logger.Infof("in loginCommand.Run")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debugging remnant, deleted

@@ -76,7 +76,7 @@ func (s *LoginCommandSuite) TestInitError(c *gc.C) {
}

func (s *LoginCommandSuite) TestLogin(c *gc.C) {
stdout, stderr, code := runLogin(c, "current-user\nsekrit\n")
stdout, stderr, code := runLogin(c, "current-user\nsekrit\n", "-u")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking, are there still some tests which check user logins without -u?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't do a user login without -u any more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, no problems

@mjs
Copy link

mjs commented Mar 13, 2017

Looks good overall.

@juju/docs: Possible minor docs impact here.

@rogpeppe rogpeppe force-pushed the 136-fix-login-set-controller branch 2 times, most recently from dbf7d6d to 71ba0ff Compare March 14, 2017 09:03
Copy link
Contributor

@mhilton mhilton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if controllerHost == "" {
if !c.forceHost {
return errNotControllerLogin
logger.Infof("controllerLogin")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Info looks high for this message, left over debugging?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed that this probably shouldn't be here

@rogpeppe rogpeppe force-pushed the 136-fix-login-set-controller branch 2 times, most recently from 6db30d6 to a2ad6bb Compare March 14, 2017 09:37
(either a known public controller or the host name of a public
controller). In this case, the -c flag can be used to choose a name for
the new controller. The -u flag causes it to log into a controller as a
local user instead - the -c flag names a current controller in this case.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be clearer for the above paragraph:

By default, the juju login command logs the user into a public controller. If the controller is already known it can be specified by name. Alternatively, the host name of a public controller can be specified. The -c flag can be used to specify a name for the controller when a host name is provided.

If the -u flag is provided, the juju login command will attempt to log into a controller as a local user. In this case, the -c flag names the controller to log in to.

This still assumes a fair bit of knowledge (e.g. the "public controller" and "local user" concepts) but I think it's clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better, thanks. Done.

if controllerHost == "" {
if !c.forceHost {
return errNotControllerLogin
logger.Infof("controllerLogin")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed that this probably shouldn't be here

@@ -76,7 +76,7 @@ func (s *LoginCommandSuite) TestInitError(c *gc.C) {
}

func (s *LoginCommandSuite) TestLogin(c *gc.C) {
stdout, stderr, code := runLogin(c, "current-user\nsekrit\n")
stdout, stderr, code := runLogin(c, "current-user\nsekrit\n", "-u")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, no problems

@rogpeppe rogpeppe force-pushed the 136-fix-login-set-controller branch from a2ad6bb to e83f06d Compare March 14, 2017 09:46
@rogpeppe
Copy link
Contributor Author

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Mar 14, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot
Copy link
Collaborator

jujubot commented Mar 14, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/10456

@rogpeppe
Copy link
Contributor Author

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Mar 14, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants