/
server_version.go
43 lines (34 loc) · 1.01 KB
/
server_version.go
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 gocd
import (
"context"
"github.com/hashicorp/go-version"
)
// ServerVersionService exposes calls for interacting with ServerVersion objects in the GoCD API.
type ServerVersionService service
var cachedServerVersion *ServerVersion
// ServerVersion of the GoCD installation
type ServerVersion struct {
Version string `json:"version"`
VersionParts *version.Version
BuildNumber string `json:"build_number"`
GitSha string `json:"git_sha"`
FullVersion string `json:"full_version"`
CommitURL string `json:"commit_url"`
}
// Get retrieves information about a specific plugin.
func (svs *ServerVersionService) Get(ctx context.Context) (v *ServerVersion, resp *APIResponse, err error) {
if cachedServerVersion != nil {
return cachedServerVersion, nil, nil
}
v = &ServerVersion{}
if _, resp, err = svs.client.getAction(ctx, &APIClientRequest{
Path: "version",
ResponseBody: v,
APIVersion: apiV1,
}); err != nil {
return
}
err = v.parseVersion()
cachedServerVersion = v
return
}