Documentation
¶
Index ¶
- Constants
- Variables
- func GetMaintenancePolicyPool() (map[string]*[]byte, error)
- type FallbackDefault
- type FirstMatchOnly
- type MaintenancePolicyMatch
- type MaintenancePolicyRule
- type MaintenanceWindow
- type MaintenanceWindowPolicy
- type MaintenanceWindows
- type MinWindowSize
- type OngoingWindow
- type Regexp
- type ResolvedWindow
- type Runtime
- type TimeStamp
- type WindowTime
Constants ¶
const (
PolicyPathENV = "MAINTENANCE_POLICY_PATH"
)
Variables ¶
var ( ErrPolicyNotExists = errors.New("maintenance policy doesn't exist") ErrUnknownOption = errors.New("unknown option") ErrNoWindowInPolicies = errors.New("matched policies did not provide a window") ErrNoWindowFound = errors.New("matches and defaults also failed to provide a window") ErrJSONUnmarshal = errors.New("error during unmarshal") )
var ( ErrNoPolicyPathEnvVar = errors.New("no environment variable set for the maintenance policy path") ErrReadingDirectory = errors.New("error while reading the directory") )
Functions ¶
func GetMaintenancePolicyPool ¶
GetMaintenancePolicyPool extracts and returns the maintenance policies we have under the policy directory.
Types ¶
type FallbackDefault ¶
type FallbackDefault bool
If matched policies had no available windows whether to fall back to the default, or bail out with an error.
type MaintenancePolicyMatch ¶
type MaintenancePolicyMatch struct {
GlobalAccountID Regexp `json:"globalAccountID,omitempty"` //nolint:tagliatelle,revive //changing that now would break the API
Plan Regexp `json:"plan,omitempty"`
Region Regexp `json:"region,omitempty"`
PlatformRegion Regexp `json:"platformRegion,omitempty"`
}
func (MaintenancePolicyMatch) Match ¶
func (mpm MaintenancePolicyMatch) Match(runtime *Runtime) bool
func (MaintenancePolicyMatch) String ¶
func (mpm MaintenancePolicyMatch) String() string
type MaintenancePolicyRule ¶
type MaintenancePolicyRule struct {
Match MaintenancePolicyMatch `json:"match"`
Windows MaintenanceWindows `json:"windows"`
}
type MaintenanceWindow ¶
type MaintenanceWindow struct {
Days []string `json:"days"`
Begin WindowTime `json:"begin"`
End WindowTime `json:"end"`
}
If days is empty, then begin and end are ISO8601 strings with exact times, otherwise if days is specified it's a time-only (with timezone).
func (*MaintenanceWindow) NextWindow ¶
func (mw *MaintenanceWindow) NextWindow(opts *resolveOptions) *ResolvedWindow
this has two main modes: whether we have days or not.
type MaintenanceWindowPolicy ¶
type MaintenanceWindowPolicy struct {
Rules []MaintenancePolicyRule `json:"rules"`
Default MaintenanceWindow `json:"default"`
}
func GetMaintenancePolicy ¶
func GetMaintenancePolicy(pool map[string]*[]byte, name string) (*MaintenanceWindowPolicy, error)
GetMaintenancePolicy gets the maintenance window policy based on the policy name we specify * non-nil error returned if meeting one of below conditions: * - the speficied maintenance policy doesn't exist. * - error during unmarshal the policy data.
func NewMaintenanceWindowPolicyFromJSON ¶
func NewMaintenanceWindowPolicyFromJSON(raw []byte) (MaintenanceWindowPolicy, error)
* This function parse a JSON document from a byte array into a * MaintenanceWindowPolicy structure, and returns it. If any errors * are encountered, the error is returned, and the structured return data * is undefined. * * Once a MaintenanceWindowPolicy is returned its Resolve method can be used to find * A suitable maintenance window.
func (*MaintenanceWindowPolicy) Resolve ¶
func (mwp *MaintenanceWindowPolicy) Resolve(runtime *Runtime, opts ...interface{}) (*ResolvedWindow, error)
* Finds the next applicatable maintenance window for a given runtime on the plan. * * The algorithm can be parameterized using the following typed varargs: * - TimeStamp: A time.Time, to specify the resolving's time instead of now * - OngoingWindow: A boolean, if true then already started windows are returned * if long enough. Defaults to false. * - MinWindowSize: A time.Duration, when OngoingWindow is true, this holds the * minimum size for the windows. Defaults to 1h. * - FirstMatchOnly: A boolean indicating wether or not to stop at the first * matching rule in the ruleset before proceeding to the defaults. * Defaults to true. * - FallbackDefault: A boolean indicating whether or not fall back to the default * rules if no specific matching rules are found. Defaults to true. * * If a match is found then a ResolvedWindow pointer is returned with a nil error. * Otherwise an error is returned and the ResolvedWindow pointer is expected to be * nil.
type MaintenanceWindows ¶
type MaintenanceWindows []MaintenanceWindow
func (*MaintenanceWindows) LookupAvailable ¶
func (mws *MaintenanceWindows) LookupAvailable(opts *resolveOptions) *ResolvedWindow
type MinWindowSize ¶
If taking ongoing windows into account, minimum duration.
type ResolvedWindow ¶
func (ResolvedWindow) String ¶
func (rw ResolvedWindow) String() string
type Runtime ¶
type Runtime struct {
InstanceID string
RuntimeID string
GlobalAccountID string
SubAccountID string
ShootName string
Plan string
Region string
PlatformRegion string
MaintenanceWindowBegin time.Time
MaintenanceWindowEnd time.Time
MaintenanceDays []string
}
Runtime is the data type which captures the needed runtime specific attributes to perform orchestrations on a given runtime.
type WindowTime ¶
type alias for (un)marshalling.
func (*WindowTime) T ¶
func (wt *WindowTime) T() time.Time
func (*WindowTime) UnmarshalJSON ¶
func (wt *WindowTime) UnmarshalJSON(data []byte) error