Fixes for CLI login
This commit is contained in:
parent
e0c7f48d20
commit
956029ae3d
@ -141,7 +141,7 @@ func (g *grpcClient) call(ctx context.Context, node *registry.Node, req client.R
|
|||||||
// fall back to using the authorization token set in config,
|
// fall back to using the authorization token set in config,
|
||||||
// this enables the CLI to provide a token
|
// this enables the CLI to provide a token
|
||||||
if len(header["authorization"]) == 0 {
|
if len(header["authorization"]) == 0 {
|
||||||
if token, err := config.Get("token"); err == nil && len(token) > 0 {
|
if token, err := config.Get("micro", "auth", "token"); err == nil && len(token) > 0 {
|
||||||
header["authorization"] = auth.BearerScheme + token
|
header["authorization"] = auth.BearerScheme + token
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@ const FileName = ".micro"
|
|||||||
var config = newConfig()
|
var config = newConfig()
|
||||||
|
|
||||||
// Get a value from the .micro file
|
// Get a value from the .micro file
|
||||||
func Get(key string) (string, error) {
|
func Get(path ...string) (string, error) {
|
||||||
tk := config.Get(key).String("")
|
tk := config.Get(path...).String("")
|
||||||
return strings.TrimSpace(tk), nil
|
return strings.TrimSpace(tk), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set a value in the .micro file
|
// Set a value in the .micro file
|
||||||
func Set(key, value string) error {
|
func Set(value string, path ...string) error {
|
||||||
// get the filepath
|
// get the filepath
|
||||||
fp, err := filePath()
|
fp, err := filePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -35,7 +35,7 @@ func Set(key, value string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the value
|
// set the value
|
||||||
config.Set(value, key)
|
config.Set(value, path...)
|
||||||
|
|
||||||
// write to the file
|
// write to the file
|
||||||
return ioutil.WriteFile(fp, config.Bytes(), 0644)
|
return ioutil.WriteFile(fp, config.Bytes(), 0644)
|
||||||
|
Loading…
Reference in New Issue
Block a user