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