/
federation_types.go
88 lines (76 loc) · 3.07 KB
/
federation_types.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
package v1beta1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// FederationSpec defines the desired state of Federation
// For how to configure federation upstreams, see: https://www.rabbitmq.com/federation-reference.html.
type FederationSpec struct {
// Required property; cannot be updated
// +kubebuilder:validation:Required
Name string `json:"name"`
// Default to vhost '/'; cannot be updated
// +kubebuilder:default:=/
Vhost string `json:"vhost,omitempty"`
// Reference to the RabbitmqCluster that this federation upstream will be created in.
// Required property.
// +kubebuilder:validation:Required
RabbitmqClusterReference RabbitmqClusterReference `json:"rabbitmqClusterReference"`
// Secret contains the AMQP URI(s) for the upstream.
// The Secret must contain the key `uri` or operator will error.
// `uri` should be one or multiple uris separated by ','.
// Required property.
// +kubebuilder:validation:Required
UriSecret *corev1.LocalObjectReference `json:"uriSecret"`
PrefetchCount int `json:"prefetch-count,omitempty"`
// +kubebuilder:validation:Enum=on-confirm;on-publish;no-ack
AckMode string `json:"ackMode,omitempty"`
Expires int `json:"expires,omitempty"`
MessageTTL int `json:"messageTTL,omitempty"`
MaxHops int `json:"maxHops,omitempty"`
ReconnectDelay int `json:"reconnectDelay,omitempty"`
TrustUserId bool `json:"trustUserId,omitempty"`
Exchange string `json:"exchange,omitempty"`
Queue string `json:"queue,omitempty"`
}
// FederationStatus defines the observed state of Federation
type FederationStatus struct {
// observedGeneration is the most recent successful generation observed for this Federation. It corresponds to the
// Federation's generation, which is updated on mutation by the API Server.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Conditions []Condition `json:"conditions,omitempty"`
}
// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=all;rabbitmq
// +kubebuilder:subresource:status
// Federation is the Schema for the federations API
type Federation struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec FederationSpec `json:"spec,omitempty"`
Status FederationStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// FederationList contains a list of Federation
type FederationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Federation `json:"items"`
}
func (f *Federation) GroupResource() schema.GroupResource {
return schema.GroupResource{
Group: f.GroupVersionKind().Group,
Resource: f.GroupVersionKind().Kind,
}
}
func (f *Federation) RabbitReference() RabbitmqClusterReference {
return f.Spec.RabbitmqClusterReference
}
func (f *Federation) SetStatusConditions(c []Condition) {
f.Status.Conditions = c
}
func init() {
SchemeBuilder.Register(&Federation{}, &FederationList{})
}