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

minor changes to avoid golang compiler warnings

parent 99793d39
No related branches found
No related tags found
No related merge requests found
......@@ -50,7 +50,7 @@ func New(host string) (*NexusClient, error) {
// Returns an JWT token if authentication succeeded or an error if it failed.
// IMPORTANT: caller MUST call the Cleanup() function before exiting!
func (nc *NexusClient) Authenticate(user, pwd string) (string, error) {
loginArgs := &params.Login{user, pwd}
loginArgs := &params.Login{Email: user, Pwd: pwd}
resp, err := nc.client.R().SetBody(loginArgs).Post("/login")
if err != nil {
return "", err
......
package nexusclient
import (
"errors"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/response"
"encoding/json"
t "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/template"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/utils"
"errors"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/params"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/template"
"github.com/google/uuid"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/response"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/utils"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
)
func (nc *NexusClient) TemplateDel(tplID string) error {
......@@ -32,7 +25,7 @@ func (nc *NexusClient) TemplateDel(tplID string) error {
}
func (nc *NexusClient) TemplateCreate(vmID uuid.UUID, name, access string) (*template.TemplateSerialized, error) {
p := &params.TplCreate{vmID, name, access}
p := &params.TplCreate{VMID: vmID, Name: name, Access: access}
resp, err := nc.client.R().SetBody(p).Post("/templates/vm")
if err != nil {
return nil, err
......@@ -48,7 +41,7 @@ func (nc *NexusClient) TemplateCreate(vmID uuid.UUID, name, access string) (*tem
}
}
func (nc *NexusClient) GetTemplates() ([]t.TemplateSerialized, error) {
func (nc *NexusClient) GetTemplates() ([]template.TemplateSerialized, error) {
resp, err := nc.client.R().Get("/templates")
if err != nil {
return nil, err
......@@ -65,7 +58,7 @@ func (nc *NexusClient) GetTemplates() ([]t.TemplateSerialized, error) {
}
}
func (nc *NexusClient) GetTemplate(uuid string) (*t.TemplateSerialized, error) {
func (nc *NexusClient) GetTemplate(uuid string) (*template.TemplateSerialized, error) {
resp, err := nc.client.R().Get("/templates/" + uuid)
if err != nil {
return nil, err
......@@ -113,8 +106,8 @@ func (nc *NexusClient) TemplateExportDisk(tplID, outputFile string) error {
}
// Deserialize a list of templates from an http response (no filtering).
func deserializeTemplates(resp *resty.Response) ([]t.TemplateSerialized, error) {
templates := []t.TemplateSerialized{}
func deserializeTemplates(resp *resty.Response) ([]template.TemplateSerialized, error) {
templates := []template.TemplateSerialized{}
if err := json.Unmarshal(resp.Body(), &templates); err != nil {
return nil, err
}
......@@ -122,8 +115,8 @@ func deserializeTemplates(resp *resty.Response) ([]t.TemplateSerialized, error)
}
// Deserialize a single template from an http response.
func deserializeTemplate(resp *resty.Response) (*t.TemplateSerialized, error) {
tpl := t.TemplateSerialized{}
func deserializeTemplate(resp *resty.Response) (*template.TemplateSerialized, error) {
tpl := template.TemplateSerialized{}
if err := json.Unmarshal(resp.Body(), &tpl); err != nil {
return nil, err
}
......
......@@ -76,7 +76,7 @@ func (nc *NexusClient) UserUnlock(email string) error {
}
func (nc *NexusClient) UserUpdatePwd(newPwd string) error {
p := &params.UserSetPwd{newPwd}
p := &params.UserSetPwd{Pwd: newPwd}
resp, err := nc.client.R().SetBody(p).Put("/users/pwd")
if err != nil {
return err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment