Skip to content
Snippets Groups Projects
Commit b40dfbcb authored by Florent Gluck's avatar Florent Gluck
Browse files

WIP nexus-cli

parent 5badac8f
Branches
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@ func (cmd *Refresh) Run(nc *nc.NexusClient, args []string) int {
return 1
}
err := nc.RefreshToken()
err := nc.RefreshAuthToken()
if err != nil {
u.PrintlnErr(err)
return 1
......
......@@ -112,6 +112,7 @@ func run() int {
u.PrintlnErr("Environment variable \"" + g.ENV_NEXUS_TOKEN + "\" must be set!")
return 1
}
nc.SetAuthToken(token)
}
return cmd.Run(nc, cmdArgs)
}
......
......@@ -198,7 +198,7 @@ Type: "help" for help on commands
found, cmd := cmd.Match(typedCmd, cmdList)
if found {
if typedCmd == "refresh" {
err := nc.RefreshToken()
err := nc.RefreshAuthToken()
if err != nil {
u.PrintlnErr("refresh error: " + err.Error())
break
......
......@@ -31,7 +31,7 @@ func (nc *NexusClient) Authenticate(user, pwd string) (string, error) {
}
// Obtain a new JWT token.
func (nc *NexusClient) RefreshToken() error {
func (nc *NexusClient) RefreshAuthToken() error {
resp, err := nc.client.R().Get("/token/refresh")
if err != nil {
return err
......@@ -49,3 +49,8 @@ func (nc *NexusClient) RefreshToken() error {
}
}
}
// Set the JWT token in the client.
func (nc *NexusClient) SetAuthToken(token string) {
nc.client.SetAuthToken(token)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment