-
Notifications
You must be signed in to change notification settings - Fork 6
/
object_switch.go
39 lines (35 loc) · 969 Bytes
/
object_switch.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
package omcmd
import (
"strings"
"github.com/opensvc/om3/core/instance"
"github.com/opensvc/om3/core/objectaction"
)
type (
CmdObjectSwitch struct {
OptsGlobal
OptsAsync
OptsLock
To string
}
)
func (t *CmdObjectSwitch) Run(selector, kind string) error {
mergedSelector := mergeSelector(selector, t.ObjectSelector, kind, "")
target := instance.MonitorGlobalExpectPlacedAt.String()
options := instance.MonitorGlobalExpectOptionsPlacedAt{}
if t.To != "" {
options.Destination = strings.Split(t.To, ",")
} else {
options.Destination = []string{}
}
return objectaction.New(
objectaction.WithObjectSelector(mergedSelector),
objectaction.WithLocal(t.Local),
objectaction.WithOutput(t.Output),
objectaction.WithColor(t.Color),
objectaction.WithAsyncTarget(target),
objectaction.WithAsyncTargetOptions(options),
objectaction.WithAsyncTime(t.Time),
objectaction.WithAsyncWait(t.Wait),
objectaction.WithAsyncWatch(t.Watch),
).Do()
}