-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathcontroller_options.go
More file actions
91 lines (74 loc) · 3.02 KB
/
controller_options.go
File metadata and controls
91 lines (74 loc) · 3.02 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
Copyright 2024 The ORC Authors.
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.
*/
package v1alpha1
import (
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +kubebuilder:validation:Enum:=managed;unmanaged
type ManagementPolicy string
const (
// ManagementPolicyManaged specifies that the controller will reconcile the
// state of the referenced OpenStack resource with the state of the ORC
// object.
ManagementPolicyManaged ManagementPolicy = "managed"
// ManagementPolicyUnmanaged specifies that the controller will expect the
// resource to either exist already or to be created externally. The
// controller will not make any changes to the referenced OpenStack
// resource.
ManagementPolicyUnmanaged ManagementPolicy = "unmanaged"
)
// +kubebuilder:validation:Enum:=delete;detach
type OnDelete string
const (
// OnDeleteDelete specifies that the OpenStack resource will be deleted
// when the managed ORC object is deleted.
OnDeleteDelete OnDelete = "delete"
// OnDeleteDetach specifies that the OpenStack resource will not be
// deleted when the managed ORC object is deleted.
OnDeleteDetach OnDelete = "detach"
)
type ManagedOptions struct {
// onDelete specifies the behaviour of the controller when the ORC
// object is deleted. Options are `delete` - delete the OpenStack resource;
// `detach` - do not delete the OpenStack resource. If not specified, the
// default is `delete`.
// +kubebuilder:default:=delete
// +optional
OnDelete OnDelete `json:"onDelete,omitempty"`
// resyncPeriod specifies the interval after which a successfully
// reconciled resource will be reconciled again to detect drift from the
// desired state. Set to 0 to disable periodic resync. If not specified,
// the default is 10 hours.
// +kubebuilder:default:="10h"
// +optional
ResyncPeriod *metav1.Duration `json:"resyncPeriod,omitempty"` //nolint:kubeapilinter
}
// GetOnDelete returns the delete behaviour from ManagedOptions. If called on a
// nil receiver it safely returns the default.
func (o *ManagedOptions) GetOnDelete() OnDelete {
if o == nil {
return OnDeleteDelete
}
return o.OnDelete
}
// DefaultResyncPeriod is the default interval for periodic resync to detect drift (10 hours).
const DefaultResyncPeriod = 10 * time.Hour
// GetResyncPeriod returns the resync period from ManagedOptions. If called on a
// nil receiver or if ResyncPeriod is not set, it returns the default of 10 hours.
func (o *ManagedOptions) GetResyncPeriod() time.Duration {
if o == nil || o.ResyncPeriod == nil {
return DefaultResyncPeriod
}
return o.ResyncPeriod.Duration
}