Skip to content

Commit f09b0a3

Browse files
committed
add v2 apis
Signed-off-by: Erhan Cagirici <[email protected]>
1 parent f5f608c commit f09b0a3

28 files changed

+920
-4047
lines changed

apis/common/v1/connection_details.go

Lines changed: 0 additions & 167 deletions
This file was deleted.

apis/common/v1/resource.go

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ const (
4343
ResourceCredentialsSecretKubeconfigKey = "kubeconfig"
4444
)
4545

46+
// LabelKeyProviderKind is added to ProviderConfigUsages to relate them to their
47+
// ProviderConfig.
48+
const LabelKeyProviderKind = "crossplane.io/provider-config-kind"
49+
4650
// LabelKeyProviderName is added to ProviderConfigUsages to relate them to their
4751
// ProviderConfig.
4852
const LabelKeyProviderName = "crossplane.io/provider-config"
@@ -63,7 +67,6 @@ type LocalSecretReference struct {
6367
type SecretReference struct {
6468
// Name of the secret.
6569
Name string `json:"name"`
66-
6770
// Namespace of the secret.
6871
Namespace string `json:"namespace"`
6972
}
@@ -76,6 +79,26 @@ type SecretKeySelector struct {
7679
Key string `json:"key"`
7780
}
7881

82+
// A LocalSecretKeySelector is a reference to a secret key
83+
// in the same namespace with the referencing object.
84+
type LocalSecretKeySelector struct {
85+
LocalSecretReference `json:",inline"`
86+
87+
Key string `json:"key"`
88+
}
89+
90+
// ToSecretKeySelector is a convenience method for converting the
91+
// LocalSecretKeySelector to a SecretKeySelector with the given namespace.
92+
func (ls *LocalSecretKeySelector) ToSecretKeySelector(namespace string) *SecretKeySelector {
93+
return &SecretKeySelector{
94+
SecretReference: SecretReference{
95+
Name: ls.Name,
96+
Namespace: namespace,
97+
},
98+
Key: ls.Key,
99+
}
100+
}
101+
79102
// Policy represents the Resolve and Resolution policies of Reference instance.
80103
type Policy struct {
81104
// Resolve specifies when this reference should be resolved. The default
@@ -124,6 +147,19 @@ type Reference struct {
124147
Policy *Policy `json:"policy,omitempty"`
125148
}
126149

150+
// A NamespacedReference to a named object.
151+
type NamespacedReference struct {
152+
// Name of the referenced object.
153+
Name string `json:"name"`
154+
155+
// Namespace of the referenced object
156+
// +optional
157+
Namespace string `json:"namespace,omitempty"`
158+
// Policies for referencing.
159+
// +optional
160+
Policy *Policy `json:"policy,omitempty"`
161+
}
162+
127163
// A TypedReference refers to an object by Name, Kind, and APIVersion. It is
128164
// commonly used to reference cluster-scoped objects or objects where the
129165
// namespace is already known.
@@ -156,6 +192,34 @@ type Selector struct {
156192
Policy *Policy `json:"policy,omitempty"`
157193
}
158194

195+
// NamespacedSelector selects a namespaced object.
196+
type NamespacedSelector struct {
197+
// MatchLabels ensures an object with matching labels is selected.
198+
MatchLabels map[string]string `json:"matchLabels,omitempty"`
199+
200+
// MatchControllerRef ensures an object with the same controller reference
201+
// as the selecting object is selected.
202+
MatchControllerRef *bool `json:"matchControllerRef,omitempty"`
203+
204+
// Policies for selection.
205+
// +optional
206+
Policy *Policy `json:"policy,omitempty"`
207+
208+
// Namespace for the selector
209+
// +optional
210+
Namespace string `json:"namespace,omitempty"`
211+
}
212+
213+
// ProviderConfigReference is a typed reference to a ProviderConfig
214+
// object, with a known api group.
215+
type ProviderConfigReference struct {
216+
// Kind of the referenced object.
217+
Kind string `json:"kind"`
218+
219+
// Name of the referenced object.
220+
Name string `json:"name"`
221+
}
222+
159223
// SetGroupVersionKind sets the Kind and APIVersion of a TypedReference.
160224
func (obj *TypedReference) SetGroupVersionKind(gvk schema.GroupVersionKind) {
161225
obj.APIVersion, obj.Kind = gvk.ToAPIVersionAndKind()
@@ -178,21 +242,9 @@ type ResourceSpec struct {
178242
// Secret to which any connection details for this managed resource should
179243
// be written. Connection details frequently include the endpoint, username,
180244
// and password required to connect to the managed resource.
181-
// This field is planned to be replaced in a future release in favor of
182-
// PublishConnectionDetailsTo. Currently, both could be set independently
183-
// and connection details would be published to both without affecting
184-
// each other.
185245
// +optional
186246
WriteConnectionSecretToReference *SecretReference `json:"writeConnectionSecretToRef,omitempty"`
187247

188-
// PublishConnectionDetailsTo specifies the connection secret config which
189-
// contains a name, metadata and a reference to secret store config to
190-
// which any connection details for this managed resource should be written.
191-
// Connection details frequently include the endpoint, username,
192-
// and password required to connect to the managed resource.
193-
// +optional
194-
PublishConnectionDetailsTo *PublishConnectionDetailsTo `json:"publishConnectionDetailsTo,omitempty"`
195-
196248
// ProviderConfigReference specifies how the provider that will be used to
197249
// create, observe, update, and delete this managed resource should be
198250
// configured.

0 commit comments

Comments
 (0)