-
Notifications
You must be signed in to change notification settings - Fork 11
/
target.go
40 lines (34 loc) · 1.09 KB
/
target.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
package shared
import (
"github.com/OctopusDeploy/cli/pkg/cmd"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines"
"math"
)
type GetTargetsCallback func() ([]*machines.DeploymentTarget, error)
type GetTargetsOptions struct {
GetTargetsCallback
}
func NewGetTargetsOptions(dependencies *cmd.Dependencies, query machines.MachinesQuery) *GetTargetsOptions {
return &GetTargetsOptions{
GetTargetsCallback: func() ([]*machines.DeploymentTarget, error) {
return GetAllTargets(*dependencies.Client, query)
},
}
}
func NewGetTargetsOptionsForAllTargets(dependencies *cmd.Dependencies) *GetTargetsOptions {
return &GetTargetsOptions{
GetTargetsCallback: func() ([]*machines.DeploymentTarget, error) {
return GetAllTargets(*dependencies.Client, machines.MachinesQuery{})
},
}
}
func GetAllTargets(client client.Client, query machines.MachinesQuery) ([]*machines.DeploymentTarget, error) {
query.Skip = 0
query.Take = math.MaxInt32
res, err := client.Machines.Get(query)
if err != nil {
return nil, err
}
return res.Items, nil
}