-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathinterfaces.go
284 lines (233 loc) · 8.43 KB
/
interfaces.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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*
Copyright 2019 The Crossplane 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 resource
import (
"context"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
"github.com/crossplane/crossplane-runtime/pkg/resource/unstructured/reference"
)
// A Conditioned may have conditions set or retrieved. Conditions are typically
// indicate the status of both a resource and its reconciliation process.
type Conditioned interface {
SetConditions(c ...xpv1.Condition)
GetCondition(ct xpv1.ConditionType) xpv1.Condition
}
// A ClaimReferencer may reference a resource claim.
type ClaimReferencer interface {
SetClaimReference(r *reference.Claim)
GetClaimReference() *reference.Claim
}
// A ManagedResourceReferencer may reference a concrete managed resource.
type ManagedResourceReferencer interface {
SetResourceReference(r *corev1.ObjectReference)
GetResourceReference() *corev1.ObjectReference
}
// A LocalConnectionSecretWriterTo may write a connection secret to its own
// namespace.
type LocalConnectionSecretWriterTo interface {
SetWriteConnectionSecretToReference(r *xpv1.LocalSecretReference)
GetWriteConnectionSecretToReference() *xpv1.LocalSecretReference
}
// A ConnectionSecretWriterTo may write a connection secret to an arbitrary
// namespace.
type ConnectionSecretWriterTo interface {
SetWriteConnectionSecretToReference(r *xpv1.SecretReference)
GetWriteConnectionSecretToReference() *xpv1.SecretReference
}
// A ConnectionDetailsPublisherTo may write a connection details secret to a
// secret store.
type ConnectionDetailsPublisherTo interface {
SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo)
GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo
}
// A Manageable resource may specify a ManagementPolicies.
type Manageable interface {
SetManagementPolicies(p xpv1.ManagementPolicies)
GetManagementPolicies() xpv1.ManagementPolicies
}
// An Orphanable resource may specify a DeletionPolicy.
type Orphanable interface {
SetDeletionPolicy(p xpv1.DeletionPolicy)
GetDeletionPolicy() xpv1.DeletionPolicy
}
// A ProviderConfigReferencer may reference a provider config resource.
type ProviderConfigReferencer interface {
GetProviderConfigReference() *xpv1.Reference
SetProviderConfigReference(p *xpv1.Reference)
}
// A RequiredProviderConfigReferencer may reference a provider config resource.
// Unlike ProviderConfigReferencer, the reference is required (i.e. not nil).
type RequiredProviderConfigReferencer interface {
GetProviderConfigReference() xpv1.Reference
SetProviderConfigReference(p xpv1.Reference)
}
// A RequiredTypedResourceReferencer can reference a resource.
type RequiredTypedResourceReferencer interface {
SetResourceReference(r xpv1.TypedReference)
GetResourceReference() xpv1.TypedReference
}
// A Finalizer manages the finalizers on the resource.
type Finalizer interface {
AddFinalizer(ctx context.Context, obj Object) error
RemoveFinalizer(ctx context.Context, obj Object) error
}
// A CompositionSelector may select a composition of resources.
type CompositionSelector interface {
SetCompositionSelector(s *metav1.LabelSelector)
GetCompositionSelector() *metav1.LabelSelector
}
// A CompositionReferencer may reference a composition of resources.
type CompositionReferencer interface {
SetCompositionReference(ref *corev1.ObjectReference)
GetCompositionReference() *corev1.ObjectReference
}
// A CompositionRevisionReferencer may reference a specific revision of a
// composition of resources.
type CompositionRevisionReferencer interface {
SetCompositionRevisionReference(ref *corev1.LocalObjectReference)
GetCompositionRevisionReference() *corev1.LocalObjectReference
}
// A CompositionRevisionSelector may reference a set of
// composition revisions.
type CompositionRevisionSelector interface {
SetCompositionRevisionSelector(selector *metav1.LabelSelector)
GetCompositionRevisionSelector() *metav1.LabelSelector
}
// A CompositionUpdater uses a composition, and may update which revision of
// that composition it uses.
type CompositionUpdater interface {
SetCompositionUpdatePolicy(p *xpv1.UpdatePolicy)
GetCompositionUpdatePolicy() *xpv1.UpdatePolicy
}
// A CompositeResourceDeleter creates a composite, and controls the policy
// used to delete the composite.
type CompositeResourceDeleter interface {
SetCompositeDeletePolicy(policy *xpv1.CompositeDeletePolicy)
GetCompositeDeletePolicy() *xpv1.CompositeDeletePolicy
}
// A ComposedResourcesReferencer may reference the resources it composes.
type ComposedResourcesReferencer interface {
SetResourceReferences(refs []corev1.ObjectReference)
GetResourceReferences() []corev1.ObjectReference
}
// A CompositeResourceReferencer can reference a composite resource.
type CompositeResourceReferencer interface {
SetResourceReference(r *reference.Composite)
GetResourceReference() *reference.Composite
}
// An EnvironmentConfigReferencer references a list of EnvironmentConfigs.
type EnvironmentConfigReferencer interface {
SetEnvironmentConfigReferences(refs []corev1.ObjectReference)
GetEnvironmentConfigReferences() []corev1.ObjectReference
}
// A UserCounter can count how many users it has.
type UserCounter interface {
SetUsers(i int64)
GetUsers() int64
}
// A ConnectionDetailsPublishedTimer can record the last time its connection
// details were published.
type ConnectionDetailsPublishedTimer interface {
SetConnectionDetailsLastPublishedTime(t *metav1.Time)
GetConnectionDetailsLastPublishedTime() *metav1.Time
}
// ReconciliationObserver can track data observed by resource reconciler.
type ReconciliationObserver interface {
SetObservedGeneration(generation int64)
GetObservedGeneration() int64
}
// An Object is a Kubernetes object.
type Object interface {
metav1.Object
runtime.Object
}
// A Managed is a Kubernetes object representing a concrete managed
// resource (e.g. a CloudSQL instance).
type Managed interface { //nolint:interfacebloat // This interface has to be big.
Object
ProviderConfigReferencer
ConnectionSecretWriterTo
ConnectionDetailsPublisherTo
Manageable
Orphanable
Conditioned
}
// A ManagedList is a list of managed resources.
type ManagedList interface {
client.ObjectList
// GetItems returns the list of managed resources.
GetItems() []Managed
}
// A ProviderConfig configures a Crossplane provider.
type ProviderConfig interface {
Object
UserCounter
Conditioned
}
// A ProviderConfigUsage indicates a usage of a Crossplane provider config.
type ProviderConfigUsage interface {
Object
RequiredProviderConfigReferencer
RequiredTypedResourceReferencer
}
// A ProviderConfigUsageList is a list of provider config usages.
type ProviderConfigUsageList interface {
client.ObjectList
// GetItems returns the list of provider config usages.
GetItems() []ProviderConfigUsage
}
// A Composite resource composes one or more Composed resources.
type Composite interface { //nolint:interfacebloat // This interface has to be big.
Object
CompositionSelector
CompositionReferencer
CompositionUpdater
CompositionRevisionReferencer
CompositionRevisionSelector
ComposedResourcesReferencer
EnvironmentConfigReferencer
ClaimReferencer
ConnectionSecretWriterTo
ConnectionDetailsPublisherTo
Conditioned
ConnectionDetailsPublishedTimer
ReconciliationObserver
}
// Composed resources can be a composed into a Composite resource.
type Composed interface {
Object
Conditioned
ConnectionSecretWriterTo
ConnectionDetailsPublisherTo
ReconciliationObserver
}
// A CompositeClaim for a Composite resource.
type CompositeClaim interface { //nolint:interfacebloat // This interface has to be big.
Object
CompositionSelector
CompositionReferencer
CompositionUpdater
CompositionRevisionReferencer
CompositionRevisionSelector
CompositeResourceDeleter
CompositeResourceReferencer
LocalConnectionSecretWriterTo
ConnectionDetailsPublisherTo
Conditioned
ConnectionDetailsPublishedTimer
ReconciliationObserver
}