-
Notifications
You must be signed in to change notification settings - Fork 55
/
version.go
46 lines (39 loc) · 1.08 KB
/
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
44
45
46
package commands
import (
"fmt"
"github.com/jfrog/jfrog-cli-core/v2/pipelines/manager"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/log"
)
type VersionCommand struct {
serverDetails *config.ServerDetails
}
func NewVersionCommand() *VersionCommand {
return &VersionCommand{}
}
func (vc *VersionCommand) CommandName() string {
return "pl_version"
}
func (vc *VersionCommand) ServerDetails() (*config.ServerDetails, error) {
return vc.serverDetails, nil
}
func (vc *VersionCommand) SetServerDetails(serverDetails *config.ServerDetails) *VersionCommand {
vc.serverDetails = serverDetails
return vc
}
func (vc *VersionCommand) Run() error {
serviceManager, err := manager.CreateServiceManager(vc.serverDetails)
if err != nil {
return err
}
info, err := serviceManager.GetSystemInfo()
if err != nil {
return err
}
if info == nil {
return errorutils.CheckError(fmt.Errorf("unable to fetch pipelines version"))
}
log.Output("Pipelines Server version:", info.Version)
return nil
}