-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.go
More file actions
43 lines (36 loc) · 1.17 KB
/
version.go
File metadata and controls
43 lines (36 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package webhookrelay
import (
"context"
"encoding/json"
)
// VersionInfo describes version and runtime info.
type VersionInfo struct {
Name string `json:"name"`
BuildDate string `json:"buildDate"`
Revision string `json:"revision"`
Version string `json:"version"`
APIVersion string `json:"apiVersion"`
GoVersion string `json:"goVersion"`
OS string `json:"os"`
Arch string `json:"arch"`
KernelVersion string `json:"kernelVersion"`
Experimental bool `json:"experimental"`
}
// ServerVersion is an alias for VersionInfo for backward compatibility.
type ServerVersion = VersionInfo
// GetVersion returns the server's version and runtime info without requiring a context.
func (api *API) GetVersion() (*ServerVersion, error) {
return api.ServerVersion(context.TODO())
}
// ServerVersion returns the server's version and runtime info.
func (api *API) ServerVersion(ctx context.Context) (*VersionInfo, error) {
resp, err := api.makeRequest("GET", "/version", nil)
if err != nil {
return nil, err
}
var version VersionInfo
if err := json.Unmarshal(resp, &version); err != nil {
return nil, err
}
return &version, nil
}