Update FinalizeCredential, use in add-credential #6265

Merged
merged 1 commit into from Sep 16, 2016

Conversation

Projects
None yet
3 participants
Member

axw commented Sep 16, 2016

This diff updates the FinalizeCredential provider
method to take cloud endpoints, so that providers
can communicate with the cloud in order to finalize
the credential. Specifically, Azure needs to connect
to Active Directory to perform interactive authentication,
and then configure the service principal.

QA

With a follow-up branch that adds interactive auth-type
for azure, I have done the following:

  1. juju add-credential azure
  2. specify credential name, and select "interactive" auth-type
  3. go to microsoft login page as directed, wait while Juju
    sets up the service principal
  4. bootstrap with the new credential
  5. bob's your uncle

It is also possible, even if undesirable, to add an
interactive auth-type credential in credentials.yaml by
hand, and go through the above steps at bootstrap or
add-model time. The service principal password will not
be persisted to disk then.

cmd/juju/cloud/addcredential_test.go
+ "somecloud": {
+ AuthCredentials: map[string]jujucloud.Credential{
+ "fred": jujucloud.NewCredential(jujucloud.UserPassAuthType, map[string]string{
+ "username": "user",
@anastasiamac

anastasiamac Sep 16, 2016

Member

I know it's a test and this is test data but username = "user" caught me off-guard \o/
Could this be "username" too for clarity?

@axw

axw Sep 16, 2016

Member

Done.

@@ -35,7 +35,8 @@ func formatControllersTabular(writer io.Writer, set ControllerSet, promptRefresh
w := output.Wrapper{tw}
if promptRefresh && len(set.Controllers) > 0 {
- fmt.Fprintln(writer, "Use --refresh to see the latest information.\n")
+ fmt.Fprintln(writer, "Use --refresh to see the latest information.")
+ fmt.Fprintln(writer)
@anastasiamac

anastasiamac Sep 16, 2016

Member

Is this a drive-by?

@axw

axw Sep 16, 2016

Member

Yes, to fix a govet warning.

+ CloudName string
+
+ // CloudRegion is the name of the region that the user has specified.
+ // If this is empty, then GetCredentials will determine the default
@anastasiamac

anastasiamac Sep 16, 2016

Member

Could we please be a bit more precise of what "default" means here? Maybe even say that it's the first region in a list that is sorted in alphabetical order? :D

@axw

axw Sep 16, 2016

Member

Expanded comment.

+
+ cloudEndpoint := args.Cloud.Endpoint
+ cloudIdentityEndpoint := args.Cloud.IdentityEndpoint
+ if regionName != "" {
@anastasiamac

anastasiamac Sep 16, 2016

Member

From the reading of above code, the possibility that regionName == "" is slim. Either we do not need this check or we need to do something for the case if it is "". No?

@anastasiamac

anastasiamac Sep 16, 2016

Member

We should definitely have tests for each of these if- conditions.

@axw

axw Sep 16, 2016

Member

regionName will be "" if there are no regions in the cloud. I've added more tests.

Code looks awesome \o/

+1 from me
However, you might also get a stamp from someone with Azure account to verify with QA steps.

Update FinalizeCredential, use in add-credential
This diff updates the FinalizeCredential provider
method to take cloud endpoints, so that providers
can communicate with the cloud in order to finalize
the credential. Specifically, Azure needs to connect
to Active Directory to perform interactive authentication,
and then configure the service principal.
Member

axw commented Sep 16, 2016

$$merge$$

Contributor

jujubot commented Sep 16, 2016

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

Contributor

jujubot commented Sep 16, 2016

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

Member

axw commented Sep 16, 2016

$$merge$$

Contributor

jujubot commented Sep 16, 2016

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

Contributor

jujubot commented Sep 16, 2016

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

Member

axw commented Sep 16, 2016

$$merge$$

Contributor

jujubot commented Sep 16, 2016

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

@jujubot jujubot merged commit e24fd72 into juju:master Sep 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment