binbeobo / google-cloud-sdk

Automatically exported from code.google.com/p/google-cloud-sdk
0 stars 1 forks source link

gcloud sql set-root-password with a password file includes trailing newline in the password #419

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The documentation of `gcloud sql set-root-password` 
(https://cloud.google.com/sdk/gcloud/reference/sql/instances/set-root-password) 
for the --password-file flag says "The first line of the file will be 
interpreted as the password to be set". However, this includes a trailing 
newline if one exists!

What steps will reproduce the problem?
Consider this shell snippet:

printf "foo\nbar" > root_password_file
gcloud sql instances set-root-password "$my_instance_name" 
--password-file=root_password_file

instance_ip=$(
  gcloud --format=json sql instances describe "$my_instance_name" \
    | jq --raw-output ".ipAddresses | .[0] | .ipAddress"
)

# This fails.
mysql --host="$instance_ip" --user=root --password="foo"

# This succeeds!
mysql --host="$instance_ip" --user=root --password="foo
"

What is the expected output? What do you see instead?
In the shell snippet above, I would have expected "foo" (with no trailing 
newline) to be the new root password.

What is the output of 'gcloud info'?
Google Cloud SDK [0.9.89]

Platform: [Mac OS X, x86_64]
Python Version: [2.7.10 (default, Jul 13 2015, 12:05:58)  [GCC 4.2.1 Compatible 
Apple LLVM 6.1.0 (clang-602.0.53)]]
Python Location: 
[/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/Reso
urces/Python.app/Contents/MacOS/Python]
Site Packages: [Disabled]

Installation Root: 
[/opt/homebrew-cask/Caskroom/google-cloud-sdk/latest/google-cloud-sdk]
Installed Components:
  core: [2015.11.30]
  core-nix: [2015.11.24]
  kubectl: []
  gcloud: []
  gsutil-nix: [4.15]
  gsutil: [4.16]
  bq: [2.0.18]
  bq-nix: [2.0.18]
  kubectl-darwin-x86_64: [1.1.2]
System PATH: 
[/opt/homebrew-cask/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/Users
/mkantor/.rvm/gems/ruby-2.0.0-p451/bin:/Users/mkantor/.rvm/gems/ruby-2.0.0-p451@
global/bin:/Users/mkantor/.rvm/rubies/ruby-2.0.0-p451/bin:/Users/mkantor/Library
/Haskell/bin:/usr/local/heroku/bin:/usr/local/bin:/usr/local/opt/coreutils/libex
ec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/mkant
or/.rvm/bin]
Cloud SDK on PATH: [True]

WARNING: There are old versions of the Google Cloud Platform tools on your 
system PATH.
  /usr/local/Cellar/kubernetes-cli/1.1.2/bin/kubectl

Installation Properties: 
[/opt/homebrew-cask/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/properties
]
User Config Directory: [/Users/mkantor/.config/gcloud]
User Properties: [/Users/mkantor/.config/gcloud/properties]
Current Workspace: [None]
Workspace Config Directory: [None]
Workspace Properties: [None]

Account: [mkantor@kabaminc.com]
Project: [kasq-prod]

Current Properties:
  [core]
    project: [kasq-prod]
    account: [mkantor@kabaminc.com]
    disable_usage_reporting: [True]
  [compute]
    zone: [us-central1-a]

Logs Directory: [/Users/mkantor/.config/gcloud/logs]
Last Log File: 
[/Users/mkantor/.config/gcloud/logs/2015.12.08/10.56.45.375509.log]

Please provide any additional information below.
This occurs regardless of whether there is content on the second line of the 
file. Even `echo "foo" > root_password_file` produces the same behavior.

Original issue reported on code.google.com by mkan...@kabaminc.com on 8 Dec 2015 at 7:05

GoogleCodeExporter commented 8 years ago
Thank you for your feedback. We have registered an internal bug for this, and 
will get a fix out soon.

Original comment by vil...@google.com on 8 Dec 2015 at 9:13

GoogleCodeExporter commented 8 years ago
By the way, gcloud now provides some nifty formatting features. So you should 
be able to replace the following:

instance_ip=$(
  gcloud --format=json sql instances describe "$my_instance_name" \
    | jq --raw-output ".ipAddresses | .[0] | .ipAddress"
)

with:

instance_ip=$(gcloud sql instances describe "$my_instance_name" 
--format="value(ipAddresses[0].ipAddress)")

You can run 'gcloud help topic formats' and 'gcloud help topic projections' for 
more information about this capability.

Original comment by vil...@google.com on 9 Dec 2015 at 7:22

GoogleCodeExporter commented 8 years ago
This should be fixed in the Cloud SDK 92 release, which is expected shortly 
after the New Year.

Original comment by z...@google.com on 14 Dec 2015 at 8:33

GoogleCodeExporter commented 8 years ago
Issue 450 has been merged into this issue.

Original comment by z...@google.com on 30 Dec 2015 at 2:41