-
Notifications
You must be signed in to change notification settings - Fork 15
/
operation.go
41 lines (35 loc) · 979 Bytes
/
operation.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
package cke
import (
"context"
"fmt"
)
// Operator is the interface for operations
type Operator interface {
// Name returns the operation name.
Name() string
// NextCommand returns the next command or nil if completed.
NextCommand() Commander
// Targets returns the ip which will be affected by the operation
Targets() []string
}
// InfoOperator is an extension of Operator that provides some information after the operation
type InfoOperator interface {
Operator
Info() string
}
// Commander is a single step to proceed an operation
type Commander interface {
// Run executes the command
Run(ctx context.Context, inf Infrastructure, leaderKey string) error
// Command returns the command information
Command() Command
}
// Command represents some command
type Command struct {
Name string `json:"name"`
Target string `json:"target"`
}
// String implements fmt.Stringer
func (c Command) String() string {
return fmt.Sprintf("%s %s", c.Name, c.Target)
}