forked from kyma-project/control-plane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ext.go
50 lines (44 loc) · 2.36 KB
/
ext.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
47
48
49
50
package orchestration
import (
"time"
)
// Runtime is the data type which captures the needed runtime specific attributes to perform orchestrations on a given runtime.
type Runtime struct {
InstanceID string `json:"instanceId,omitempty"`
RuntimeID string `json:"runtimeId"`
GlobalAccountID string `json:"globalAccountId"`
SubAccountID string `json:"subaccountId"`
// The corresponding shoot cluster's .metadata.name value
ShootName string `json:"shootName"`
// The corresponding shoot cluster's .spec.maintenance.timeWindow.Begin value, which is in in "HHMMSS+[HHMM TZ]" format, e.g. "040000+0000"
MaintenanceWindowBegin time.Time `json:"maintenanceWindowBegin"`
// The corresponding shoot cluster's .spec.maintenance.timeWindow.End value, which is in "HHMMSS+[HHMM TZ]" format, e.g. "040000+0000"
MaintenanceWindowEnd time.Time `json:"maintenanceWindowEnd"`
}
// RuntimeOperation holds information about operation performed on a runtime
type RuntimeOperation struct {
Runtime `json:""`
ID string `json:"-"`
DryRun bool `json:"dryRun"`
}
//go:generate mockery --name=RuntimeResolver --output=automock --outpkg=automock --case=underscore
// RuntimeResolver given an input slice of target specs to include and exclude, resolves and returns a list of unique Runtime objects.
type RuntimeResolver interface {
Resolve(targets TargetSpec) ([]Runtime, error)
}
// OperationExecutor implements methods to perform the operation corresponding to a Runtime.
type OperationExecutor interface {
Execute(operationID string) (time.Duration, error)
Reschedule(operationID string, maintenanceWindowBegin, maintenanceWindowEnd time.Time) error
}
//go:generate mockery --name=Strategy --output=automock --outpkg=automock --case=underscore
// Strategy interface encapsulates the strategy how the orchestration is performed.
type Strategy interface {
// Execute invokes OperationExecutor's Execute(operationID string) method for each operation according to the encapsulated strategy.
// The strategy is executed asynchronously. Successful call to the function returns a unique identifier, which can be used in a subsequent call to Wait().
Execute(operations []RuntimeOperation, strategySpec StrategySpec) (string, error)
// Wait blocks and waits until the execution with the given ID is finished.
Wait(executionID string)
// Cancel shutdowns a given execution.
Cancel(executionID string)
}