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

'add-credential' ask-or-tell #10604

Merged
merged 5 commits into from Sep 6, 2019

Conversation

anastasiamac
Copy link
Contributor

Description of change

In previous iteration, 'add-credential' command has been upgraded to operate on both local client and on controller. This PR ensures that a user is prompted to confirm to upload a credential to the current controller if one is detected.

Drive-by:
(*) File can be specified with an -f or --file option for both add-cloud and add-credential commands.

QA steps

(*) Add credential interactively (local since no current nor specified controller)

$ juju add-credential aws
Enter credential name: sample

Regions
  us-east-1
  us-east-2
  us-west-1
  us-west-2
  ca-central-1
  eu-west-1
  eu-west-2
  eu-west-3
  eu-central-1
  ap-south-1
  ap-southeast-1
  ap-southeast-2
  ap-northeast-1
  ap-northeast-2
  sa-east-1

Select region [any region, credential is not region specific]: 

Using auth-type "access-key".

Enter access-key: 7efgugfygr

Enter secret-key: 

Credential "sample" added locally for cloud "aws".

(*) Add credential with file (local since no current nor specified controller)

$ juju add-credential aws -f ~/creds.yaml
WARNING credential "sample" for cloud "aws" already exists locally, use 'juju update-credential aws sample' to update it
No local credentials for cloud "aws" changed.

$ juju add-credential aws -f ~/creds.yaml                                                                                         
Credentials "example" added locally for cloud "aws".                       

(*) Add credential to a specified controller with file

$ juju add-credential aws -f ~/creds.yaml -c mycontroller                                                                         
Using  remote cloud "aws" from the controller to verify credentials.                                                                                                                                         
Credential "special" added locally for cloud "aws".                                                                                                                                                          
                                                                                                                                                                                                             
Controller credential "special" for user "admin" for cloud "aws" on controller "mycontroller" added.                                                                                                                                       
For more information, see ‘juju show-credential aws special’.               

(*) Add credential to a current controller with file (prompt)

$ juju add-credential aws -f ~/creds.yaml                                                                                         
Do you want to add a credential to current controller "mycontroller"? (Y/n):                                                                                                                                 

Using  remote cloud "aws" from the controller to verify credentials.
Credential "news" added locally for cloud "aws".

Controller credential "news" for user "admin" for cloud "aws" on controller "mycontroller" added.
For more information, see ‘juju show-credential aws news’.

(*) Add credential to a current controller with file (skip prompt)

$ juju add-credential aws -f ~/creds.yaml --no-prompt
Using  remote cloud "aws" from the controller to verify credentials.
Credential "again" added locally for cloud "aws".

Controller credential "again" for user "admin" for cloud "aws" on controller "mycontroller" added.
For more information, see ‘juju show-credential aws again’.

(*) Add credential (remote since credential exists locally)

$ juju add-credential aws -f ~/creds.yaml -c mycontroller
Using  remote cloud "aws" from the controller to verify credentials.
WARNING credential "trial" for cloud "aws" already exists locally, use 'juju update-credential aws trial' to update it
No local credentials for cloud "aws" changed.
Controller credential "trial" for user "admin" for cloud "aws" on controller "mycontroller" added.
For more information, see ‘juju show-credential aws trial’.

(*) Add credential to a specified controller interactively

$ juju add-credential aws -c mycontroller
Using  remote cloud "aws" from the controller to verify credentials.
Enter credential name: okay

Regions
  ap-northeast-1
  ap-northeast-2
  ap-south-1
  ap-southeast-1
  ap-southeast-2
  ca-central-1
  eu-central-1
  eu-west-1
  eu-west-2
  eu-west-3
  sa-east-1
  us-east-1
  us-east-2
  us-west-1
  us-west-2

Select region [any region, credential is not region specific]: 

Using auth-type "access-key".

Enter access-key: dscsc

Enter secret-key: 

Credential "okay" added locally for cloud "aws".

Controller credential "okay" for user "admin" for cloud "aws" on controller "mycontroller" added.
For more information, see ‘juju show-credential aws okay’.

(*) Add credential to a current controller interactively (prompt)

$ juju add-credential aws
Do you want to add a credential to current controller "mycontroller"? (Y/n): 

Using  remote cloud "aws" from the controller to verify credentials.
Enter credential name: fuunny

Regions
  ap-northeast-1
  ap-northeast-2
  ap-south-1
  ap-southeast-1
  ap-southeast-2
  ca-central-1
  eu-central-1
  eu-west-1
  eu-west-2
  eu-west-3
  sa-east-1
  us-east-1
  us-east-2
  us-west-1
  us-west-2

Select region [any region, credential is not region specific]: 

Using auth-type "access-key".

Enter access-key: asdsds

Enter secret-key: 

Credential "fuunny" added locally for cloud "aws".

Controller credential "fuunny" for user "admin" for cloud "aws" on controller "mycontroller" added.
For more information, see ‘juju show-credential aws fuunny’.

(*) Add credential to a current controller interactively (skip prompt)

$ juju add-credential aws --no-prompt
Using  remote cloud "aws" from the controller to verify credentials.
Enter credential name: buteme 

Regions
  ap-northeast-1
  ap-northeast-2
  ap-south-1
  ap-southeast-1
  ap-southeast-2
  ca-central-1
  eu-central-1
  eu-west-1
  eu-west-2
  eu-west-3
  sa-east-1
  us-east-1
  us-east-2
  us-west-1
  us-west-2

Select region [any region, credential is not region specific]: 

Using auth-type "access-key".

Enter access-key: dfcdv

Enter secret-key: 

Credential "buteme" added locally for cloud "aws".

Controller credential "buteme" for user "admin" for cloud "aws" on controller "mycontroller" added.
For more information, see ‘juju show-credential aws buteme’.

(*) Add credential exists both locally and remotely

$ juju add-credential aws -f ~/creds.yaml -c mycontroller
Using  remote cloud "aws" from the controller to verify credentials.
WARNING credential "amtest" for cloud "aws" already exists locally, use 'juju update-credential aws amtest' to update it
No local credentials for cloud "aws" changed.
No remote credentials for cloud "aws" added.

@anastasiamac
Copy link
Contributor Author

Copy link
Member

@wallyworld wallyworld left a comment

Choose a reason for hiding this comment

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

Thank you

cmd/juju/cloud/addcredential.go Outdated Show resolved Hide resolved
cmd/juju/cloud/addcredential.go Outdated Show resolved Hide resolved
cmd/juju/cloud/addcredential_test.go Outdated Show resolved Hide resolved
cmd/juju/cloud/addcredential_test.go Outdated Show resolved Hide resolved
@anastasiamac
Copy link
Contributor Author

$$merge$$

@jujubot jujubot merged commit d7b574b into juju:develop Sep 6, 2019
@anastasiamac anastasiamac deleted the askortell-addcredential branch September 6, 2019 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants