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

New EnvUser #553

Merged
merged 2 commits into from Aug 28, 2014
Merged

New EnvUser #553

merged 2 commits into from Aug 28, 2014

Conversation

waigani
Copy link
Contributor

@waigani waigani commented Aug 20, 2014

Add:

  • the EnvUser doc
  • support for setting the last login time for the EnvUser
  • factory methods for adding the envuser

Create the Admin EnvUser at bootstrap time.

if err != nil {
return nil, errors.Annotate(err, "failed to create admin user")
}
return st.AddUser(admin.Id(), "", password, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be admin.Name() not Id()

@mattyw
Copy link
Contributor

mattyw commented Aug 20, 2014

Unless I'm missing something this pr is supposed to the envuser.go and envuser_test.go files in it?

if params.DisplayName == "" {
params.DisplayName = factory.UniqueString("display name")
}
if params.CreatedBy == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a chance of running into problems with createdBy not being a valid user id? Maybe this should be "admin"? Or, even better, make User and CreatedBy in EnvUserParams be *state.User - that way valid users can be inserted, or created on the fly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that if the CreatedBy isn't specified, we should create a new User, and then use them as the creator.

In the same way that we should create a User for the params.User in order for the name to be used in the environment user.

func (st *State) AddEnvironmentUser(user, createdBy names.UserTag, displayName, alias string) (*EnvironmentUser, error) {
envuuid := st.EnvironTag().Id()
username := user.Name()
creatorname := createdBy.Name()
Copy link
Contributor

Choose a reason for hiding this comment

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

For both of these, we'd want the fully qualified name: "user@provider"

We know we'll need it later, and it makes sense to get it right from the start.

@howbazaar
Copy link
Contributor

We also need an upgrade step that creates the env user for the admin user (and any other users there may be).

@waigani
Copy link
Contributor Author

waigani commented Aug 25, 2014

Comments addressed, tests passing. Putting up for review while I add the upgrade step.

@waigani
Copy link
Contributor Author

waigani commented Aug 26, 2014

PTAL

}

// EnvUUID returns the environment UUIID of the environment user.
func (e *EnvironmentUser) EnvUUID() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been thinking of this since I have done the changes for @davecheney in my branch. I think we should be returning a names.EnvironTag here not a bare string for UUID. The UUID identifies and environment, and the tag can be used to get the environment.

Please change to:

// EnvironmentTag identifies the environment for the environment user.
func (e *EnvironmentUser) EnvironmentTag() names.EnvironTag {
    return names.NewEnvironTag(e.doc.EnvUUID)
}

@waigani
Copy link
Contributor Author

waigani commented Aug 28, 2014

PTAL

Assert: txn.DocMissing,
Insert: &envUser.doc,
}}
err = st.ResumeTransactions()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure you don't need the ResumeTransactions here...

@waigani
Copy link
Contributor Author

waigani commented Aug 28, 2014

PTAL

@howbazaar
Copy link
Contributor

Let's Get This Merged!

There are minors, but we can address those in the follow up with state environ tag.

@waigani
Copy link
Contributor Author

waigani commented Aug 28, 2014

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Aug 28, 2014

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

jujubot added a commit that referenced this pull request Aug 28, 2014
New EnvUser

Add:
 - the EnvUser doc
 - support for setting the last login time for the EnvUser
 - factory methods for adding the envuser

Create the Admin EnvUser at bootstrap time.
@jujubot jujubot merged commit 0c6ec68 into juju:master Aug 28, 2014
waigani added a commit to waigani/juju that referenced this pull request Aug 28, 2014
This is a follow up branch to juju#553 (New EnvUser). Get the environ UUID
from the state environ tag.
@waigani waigani mentioned this pull request Aug 28, 2014
waigani added a commit to waigani/juju that referenced this pull request Aug 28, 2014
This is a follow up branch to juju#553 (New EnvUser). Get the environ UUID
from the state environ tag.
waigani added a commit to waigani/juju that referenced this pull request Aug 29, 2014
This is a follow up branch to juju#553 (New EnvUser). Get the environ UUID
from the state environ tag.
waigani added a commit to waigani/juju that referenced this pull request Aug 29, 2014
This is a follow up branch to juju#553 (New EnvUser). Get the environ UUID
from the state environ tag.
waigani added a commit to waigani/juju that referenced this pull request Aug 29, 2014
This is a follow up branch to juju#553 (New EnvUser). Get the environ UUID
from the state environ tag.
waigani added a commit to waigani/juju that referenced this pull request Aug 29, 2014
This is a follow up branch to juju#553 (New EnvUser). Get the environ UUID
from the state environ tag.
waigani added a commit to waigani/juju that referenced this pull request Aug 29, 2014
This is a follow up branch to juju#553 (New EnvUser). Get the environ UUID
from the state environ tag.
jujubot added a commit that referenced this pull request Sep 1, 2014
Use environ tag

This is a follow up branch to #553 (New EnvUser). Get the environ UUID
from the state environ tag.
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