diff --git a/README.md b/README.md index 34e4aee4ae..18347c22ee 100644 --- a/README.md +++ b/README.md @@ -1088,6 +1088,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address' #### Features +* `scw -D login` displays a fake password * Syncing cache to disk after server creation when running `scw run` in a non-detached mode * Bump to Golang 1.5 * Support --tmp-ssh-key `scw {run,create}` option ([#99](https://github.com/scaleway/scaleway-cli/issues/99)) diff --git a/pkg/api/api.go b/pkg/api/api.go index 618fa88e71..6058632d73 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -47,6 +47,9 @@ type ScalewayAPI struct { // Token is the authentication token for the Scaleway organization Token string + // Password is the authentication password + password string + // Cache is used to quickly resolve identifiers from names Cache *ScalewayCache @@ -595,6 +598,7 @@ func NewScalewayAPI(apiEndPoint, accountEndPoint, organization, token string) (* Organization: organization, Token: token, Cache: cache, + password: "", // internal anonuuid: *anonuuid.New(), @@ -1459,6 +1463,9 @@ func (s *ScalewayAPI) HideAPICredentials(input string) string { if s.Organization != "" { output = strings.Replace(output, s.Organization, s.anonuuid.FakeUUID(s.Organization), -1) } + if s.password != "" { + output = strings.Replace(output, s.password, "XX-XX-XX-XX", -1) + } return output } @@ -1471,3 +1478,8 @@ func (s *ScalewayAPI) EnableAccountAPI() { func (s *ScalewayAPI) DisableAccountAPI() { s.APIUrl = s.ComputeAPI } + +// SetPassword register the password +func (s *ScalewayAPI) SetPassword(password string) { + s.password = password +} diff --git a/pkg/commands/login.go b/pkg/commands/login.go index 659e658c1f..7d5edb2c1e 100644 --- a/pkg/commands/login.go +++ b/pkg/commands/login.go @@ -85,6 +85,7 @@ func getToken(connect api.ScalewayConnect) (string, error) { return "", fmt.Errorf("Unable to create a fake ScalewayAPI: %s", err) } FakeConnection.EnableAccountAPI() + FakeConnection.SetPassword(connect.Password) resp, err := FakeConnection.PostResponse("tokens", connect) if err != nil {