1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00
kube-arangodb/internal/actions.go.tmpl

97 lines
2.5 KiB
Cheetah
Raw Permalink Normal View History

2022-09-19 15:24:54 +00:00
{{- $root := . -}}
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
2022-09-19 15:24:54 +00:00
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package v1
import "time"
const (
// Timeouts
// ActionsDefaultTimeout define default timeout
ActionsDefaultTimeout time.Duration = {{ $root.defaultTimeout }}
2023-08-18 07:51:51 +00:00
{{ range .actions -}}
2022-09-19 15:24:54 +00:00
// Action{{ . }}DefaultTimeout define default timeout for action Action{{ . }}
Action{{ . }}DefaultTimeout time.Duration = {{ index $root.timeouts . }}
2023-08-18 07:51:51 +00:00
{{ end }}
2022-09-19 15:24:54 +00:00
// Actions
2023-08-18 07:51:51 +00:00
{{ range .actions -}}
2022-09-19 15:24:54 +00:00
// ActionType{{ . }} in scopes {{ index $root.scopes . }}. {{ index $root.descriptions . }}
2023-08-18 07:51:51 +00:00
{{ if (index $root.deprecated .) -}}
//
// Deprecated: {{ index $root.deprecated . }}
{{ end -}}
2022-09-19 15:24:54 +00:00
ActionType{{ . }} ActionType = "{{ . }}"
2023-08-18 07:51:51 +00:00
{{ end -}}
2022-09-19 15:24:54 +00:00
)
func (a ActionType) DefaultTimeout() time.Duration {
switch a {
2022-09-19 15:24:54 +00:00
{{- range .actions }}
case ActionType{{ . }}:
return Action{{ . }}DefaultTimeout
{{- end }}
default:
return ActionsDefaultTimeout
}
}
// Priority returns action priority
func (a ActionType) Priority() ActionPriority {
switch a {
2022-09-19 15:24:54 +00:00
{{- range .actions }}
case ActionType{{ . }}:
return ActionPriority{{ index $root.highestScopes . }}
{{- end }}
default:
return ActionPriorityUnknown
}
}
// Internal returns true if action is considered to be internal
func (a ActionType) Internal() bool {
switch a {
{{- range $key, $value := .internal }}
case ActionType{{ $key }}:
return true
2023-02-20 11:20:01 +00:00
{{- end }}
default:
return false
}
}
// Optional returns true if action execution wont abort Plan
func (a ActionType) Optional() bool {
switch a {
{{- range $key, $value := .optionals }}
case ActionType{{ $key }}:
{{- if $value }}
return true
{{- else }}
return false
{{- end }}
{{- end }}
default:
return false
}
2022-09-19 15:24:54 +00:00
}