Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Secure solution for nexus infrastructure
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
Releases
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_masters
TM
Secure solution for nexus infrastructure
Commits
bce3a39d
Commit
bce3a39d
authored
4 months ago
by
Florent Gluck
Browse files
Options
Downloads
Patches
Plain Diff
libclient: updated nexus-exam to use it; added version support
parent
89f30045
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
src/client/cmdVersion/version.go
+3
-26
3 additions, 26 deletions
src/client/cmdVersion/version.go
src/client/nexus-exam/nexus-exam.go
+7
-34
7 additions, 34 deletions
src/client/nexus-exam/nexus-exam.go
src/libclient/version/version.go
+28
-0
28 additions, 0 deletions
src/libclient/version/version.go
with
38 additions
and
60 deletions
src/client/cmdVersion/version.go
+
3
−
26
View file @
bce3a39d
package
cmdVersion
package
cmdVersion
import
(
import
(
"encoding/json"
"errors"
u
"nexus-client/utils"
u
"nexus-client/utils"
"nexus-client/version"
"nexus-client/version"
"nexus-common/params"
libclient
"nexus-libclient/version"
g
"nexus-libclient/globals"
)
)
type
Version
struct
{
type
Version
struct
{
...
@@ -37,7 +34,7 @@ func (cmd *Version) Run(args []string) int {
...
@@ -37,7 +34,7 @@ func (cmd *Version) Run(args []string) int {
return
1
return
1
}
}
serverVersion
,
err
:=
g
etServerVersion
()
serverVersion
,
err
:=
libclient
.
G
etServerVersion
()
if
err
!=
nil
{
if
err
!=
nil
{
u
.
PrintlnErr
(
"Error: "
+
err
.
Error
())
u
.
PrintlnErr
(
"Error: "
+
err
.
Error
())
return
1
return
1
...
@@ -49,30 +46,10 @@ func (cmd *Version) Run(args []string) int {
...
@@ -49,30 +46,10 @@ func (cmd *Version) Run(args []string) int {
return
0
return
0
}
}
func
getServerVersion
()
(
*
params
.
Version
,
error
)
{
client
:=
g
.
GetInstance
()
.
Client
host
:=
g
.
GetInstance
()
.
Host
resp
,
err
:=
client
.
R
()
.
Get
(
host
+
"/version"
)
if
err
!=
nil
{
return
nil
,
err
}
else
{
if
resp
.
IsSuccess
()
{
version
:=
params
.
Version
{}
if
err
:=
json
.
Unmarshal
(
resp
.
Body
(),
&
version
);
err
!=
nil
{
return
nil
,
err
}
return
&
version
,
nil
}
else
{
return
nil
,
errors
.
New
(
resp
.
Status
()
+
": "
+
resp
.
String
())
}
}
}
// Checks the client version is compatible with the server's API.
// Checks the client version is compatible with the server's API.
func
CheckServerCompatibility
(
appname
string
)
bool
{
func
CheckServerCompatibility
(
appname
string
)
bool
{
// Checks the client version is compatible with the server's API.
// Checks the client version is compatible with the server's API.
serverVersion
,
err
:=
g
etServerVersion
()
serverVersion
,
err
:=
libclient
.
G
etServerVersion
()
if
err
!=
nil
{
if
err
!=
nil
{
u
.
PrintlnErr
(
"Error: "
+
err
.
Error
())
u
.
PrintlnErr
(
"Error: "
+
err
.
Error
())
return
false
return
false
...
...
This diff is collapsed.
Click to expand it.
src/client/nexus-exam/nexus-exam.go
+
7
−
34
View file @
bce3a39d
...
@@ -3,7 +3,6 @@ package main
...
@@ -3,7 +3,6 @@ package main
import
(
import
(
"bytes"
"bytes"
_
"embed"
_
"embed"
"encoding/json"
"errors"
"errors"
"nexus-client/cmdLogin"
"nexus-client/cmdLogin"
"nexus-client/cmdToken"
"nexus-client/cmdToken"
...
@@ -15,6 +14,7 @@ import (
...
@@ -15,6 +14,7 @@ import (
"nexus-common/params"
"nexus-common/params"
"nexus-common/vm"
"nexus-common/vm"
g
"nexus-libclient/globals"
g
"nexus-libclient/globals"
libclient
"nexus-libclient/vm"
"os"
"os"
"os/exec"
"os/exec"
"path"
"path"
...
@@ -26,7 +26,6 @@ import (
...
@@ -26,7 +26,6 @@ import (
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"fyne.io/fyne/v2/widget"
"github.com/go-playground/validator/v10"
"github.com/go-resty/resty/v2"
"github.com/go-resty/resty/v2"
)
)
...
@@ -60,46 +59,20 @@ func exit(code int) {
...
@@ -60,46 +59,20 @@ func exit(code int) {
}
}
func
attachVM
(
parent
fyne
.
Window
,
hostname
,
cert
,
pwd
string
)
{
func
attachVM
(
parent
fyne
.
Window
,
hostname
,
cert
,
pwd
string
)
{
client
:=
g
.
GetInstance
()
.
Client
host
:=
g
.
GetInstance
()
.
Host
setHeaderToken
()
setHeaderToken
()
p
:=
&
params
.
VMAttachCreds
{
Pwd
:
pwd
}
p
:=
params
.
VMAttachCreds
{
Pwd
:
pwd
}
res
p
,
err
:=
client
.
R
()
.
SetBody
(
p
)
.
Post
(
host
+
"/vms/s
pice
c
reds
"
)
c
re
d
s
,
err
:=
lib
client
.
VMGetAnyS
pice
C
reds
(
p
)
if
err
!=
nil
{
if
err
!=
nil
{
errorPopup
(
parent
,
"Failed attaching to VM
(code 4)"
)
errorPopup
(
parent
,
"Failed attaching to VM
: "
+
err
.
Error
()
)
return
return
}
}
else
{
if
resp
.
IsSuccess
()
{
var
creds
vm
.
VMSpiceCredentialsSerialized
if
err
:=
json
.
Unmarshal
(
resp
.
Body
(),
&
creds
);
err
!=
nil
{
errorPopup
(
parent
,
"Failed attaching to VM (code 5)"
)
return
}
if
err
:=
validator
.
New
(
validator
.
WithRequiredStructEnabled
())
.
Struct
(
creds
);
err
!=
nil
{
errorPopup
(
parent
,
"Failed attaching to VM (code 6)"
)
return
}
go
func
(
creds
vm
.
VMSpiceCredentialsSerialized
)
{
go
func
(
creds
vm
.
VMSpiceCredentialsSerialized
)
{
_
,
err
:=
e
.
RunRemoteViewer
(
hostname
,
cert
,
creds
.
Name
,
creds
.
SpicePort
,
creds
.
SpicePwd
,
true
)
_
,
err
:=
e
.
RunRemoteViewer
(
hostname
,
cert
,
creds
.
Name
,
creds
.
SpicePort
,
creds
.
SpicePwd
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
errorPopup
(
parent
,
"Failed attaching to VM (code 7)"
)
errorPopup
(
parent
,
"Failed executing remote-viewer: "
+
err
.
Error
())
return
}
}
}(
creds
)
}(
*
creds
)
}
else
{
type
msg
struct
{
Message
string
`json:"message"`
}
var
m
msg
if
err
:=
json
.
Unmarshal
(
resp
.
Body
(),
&
m
);
err
!=
nil
{
errorPopup
(
parent
,
"Failed attaching to VM (code 8)"
)
return
}
errorPopup
(
parent
,
m
.
Message
)
// errorPopup(parent, resp.Status()+": "+resp.String())
return
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/libclient/version/version.go
0 → 100644
+
28
−
0
View file @
bce3a39d
package
version
import
(
"encoding/json"
"errors"
"nexus-common/params"
g
"nexus-libclient/globals"
)
func
GetServerVersion
()
(
*
params
.
Version
,
error
)
{
client
:=
g
.
GetInstance
()
.
Client
host
:=
g
.
GetInstance
()
.
Host
resp
,
err
:=
client
.
R
()
.
Get
(
host
+
"/version"
)
if
err
!=
nil
{
return
nil
,
err
}
else
{
if
resp
.
IsSuccess
()
{
version
:=
params
.
Version
{}
if
err
:=
json
.
Unmarshal
(
resp
.
Body
(),
&
version
);
err
!=
nil
{
return
nil
,
err
}
return
&
version
,
nil
}
else
{
return
nil
,
errors
.
New
(
resp
.
Status
()
+
": "
+
resp
.
String
())
}
}
}
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