@@ -9,20 +9,29 @@ import (
9
9
10
10
const defaultVersionExtension = "json"
11
11
12
- func GetVersion (ctx context.Context , cfg Config , client * openapi. APIClient ) (string , bool ) {
12
+ func GetVersion (ctx context.Context , cfg Config ) (string , bool ) {
13
13
result := fmt .Sprintf (`CLI: %s` , Version )
14
14
15
+ if cfg .UIEndpoint != "" {
16
+ scheme , endpoint , path , _ := ParseServerURL (cfg .UIEndpoint )
17
+ cfg .Scheme = scheme
18
+ cfg .Endpoint = endpoint
19
+ cfg .ServerPath = path
20
+ }
21
+ client := GetAPIClient (cfg )
22
+
15
23
if cfg .IsEmpty () {
16
24
return result + `
17
25
Server: Not Configured` , false
18
26
}
19
27
20
- version , err := getServerVersion (ctx , client )
28
+ meta , err := getVersionMetadata (ctx , client )
21
29
if err != nil {
22
30
return result + fmt .Sprintf (`
23
31
Server: Failed to get the server version - %s` , err .Error ()), false
24
32
}
25
33
34
+ version := meta .GetVersion ()
26
35
isVersionMatch := version == Version
27
36
if isVersionMatch {
28
37
version += `
@@ -33,17 +42,6 @@ Server: Failed to get the server version - %s`, err.Error()), false
33
42
Server: %s` , version ), isVersionMatch
34
43
}
35
44
36
- func getServerVersion (ctx context.Context , client * openapi.APIClient ) (string , error ) {
37
- resp , _ , err := client .ApiApi .
38
- GetVersion (ctx , defaultVersionExtension ).
39
- Execute ()
40
- if err != nil {
41
- return "" , err
42
- }
43
-
44
- return resp .GetVersion (), nil
45
- }
46
-
47
45
func getVersionMetadata (ctx context.Context , client * openapi.APIClient ) (* openapi.Version , error ) {
48
46
resp , _ , err := client .ApiApi .
49
47
GetVersion (ctx , defaultVersionExtension ).
0 commit comments