From 89f149b12c7920e2856f56053ee930b8fb39410a Mon Sep 17 00:00:00 2001
From: Florent Gluck <florent.gluck@hesge.ch>
Date: Mon, 24 Mar 2025 23:41:10 +0100
Subject: [PATCH] minor changes to avoid golang compiler warnings

---
 libclient/client.go   |  2 +-
 libclient/template.go | 29 +++++++++++------------------
 libclient/user.go     |  2 +-
 3 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/libclient/client.go b/libclient/client.go
index 0ffbd6fd..7a09dec6 100644
--- a/libclient/client.go
+++ b/libclient/client.go
@@ -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
diff --git a/libclient/template.go b/libclient/template.go
index 20c32407..5c2d981e 100644
--- a/libclient/template.go
+++ b/libclient/template.go
@@ -1,22 +1,15 @@
 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
 	}
diff --git a/libclient/user.go b/libclient/user.go
index 8888d9c6..1dc97df5 100644
--- a/libclient/user.go
+++ b/libclient/user.go
@@ -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
-- 
GitLab