Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nexus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flg_projects
nexus_vdi
nexus
Commits
89f149b1
Commit
89f149b1
authored
1 month ago
by
Florent Gluck
Browse files
Options
Downloads
Patches
Plain Diff
minor changes to avoid golang compiler warnings
parent
99793d39
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libclient/client.go
+1
-1
1 addition, 1 deletion
libclient/client.go
libclient/template.go
+11
-18
11 additions, 18 deletions
libclient/template.go
libclient/user.go
+1
-1
1 addition, 1 deletion
libclient/user.go
with
13 additions
and
20 deletions
libclient/client.go
+
1
−
1
View file @
89f149b1
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
libclient/template.go
+
11
−
18
View file @
89f149b1
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
()
([]
t
emplate
.
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
)
(
*
t
emplate
.
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
)
([]
t
emplate
.
TemplateSerialized
,
error
)
{
templates
:=
[]
t
emplate
.
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
)
(
*
t
emplate
.
TemplateSerialized
,
error
)
{
tpl
:=
t
emplate
.
TemplateSerialized
{}
if
err
:=
json
.
Unmarshal
(
resp
.
Body
(),
&
tpl
);
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
libclient/user.go
+
1
−
1
View file @
89f149b1
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment