-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework the way eventing-rabbitmq does Rabbit codegen
Today we rerun codegen for the Rabbit clients to get injection, but because they use kubebuilder their layout is a bit strange. There's a hack to temporarily copy the api types into the right structure, and then undo it, which is a bit fragile (if codegen references that package, then it won't build!). We also try to contort so that we can use their existing client/informer/lister codegen, which isn't really necessary. With this change, we instead permanently copy the types into a suitable structure under `third_party/pkg/apis` and generate all of the clients we need under `third_party/pkg/client`. This is a slight superset of what Istio and Contour are already doing (we don't need to copy those types), and feels a bit simpler (and less fragile) than what we are currently doing. /kind cleanup
- Loading branch information
Showing
111 changed files
with
8,933 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
third_party/pkg/apis/rabbitmq.com/v1beta1/binding_types.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
RabbitMQ Messaging Topology Kubernetes Operator | ||
Copyright 2021 VMware, Inc. | ||
This product is licensed to you under the Mozilla Public License 2.0 license (the "License"). You may not use this product except in compliance with the Mozilla 2.0 License. | ||
This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. | ||
*/ | ||
|
||
package v1beta1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
// BindingSpec defines the desired state of Binding | ||
type BindingSpec struct { | ||
// Default to vhost '/' | ||
// +kubebuilder:default:=/ | ||
Vhost string `json:"vhost,omitempty"` | ||
// +kubebuilder:validation:Optional | ||
Source string `json:"source,omitempty"` | ||
// +kubebuilder:validation:Optional | ||
Destination string `json:"destination,omitempty"` | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:validation:Enum=exchange;queue | ||
DestinationType string `json:"destinationType,omitempty"` | ||
// +kubebuilder:validation:Optional | ||
RoutingKey string `json:"routingKey,omitempty"` | ||
// +kubebuilder:validation:Type=object | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
Arguments *runtime.RawExtension `json:"arguments,omitempty"` | ||
// Reference to the RabbitmqCluster that the binding will be created in. | ||
// Required property. | ||
// +kubebuilder:validation:Required | ||
RabbitmqClusterReference RabbitmqClusterReference `json:"rabbitmqClusterReference"` | ||
} | ||
|
||
// BindingStatus defines the observed state of Binding | ||
type BindingStatus struct { | ||
// observedGeneration is the most recent successful generation observed for this Binding. It corresponds to the | ||
// Binding'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 | ||
// +kubebuilder:subresource:status | ||
|
||
// Binding is the Schema for the bindings API | ||
type Binding struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec BindingSpec `json:"spec,omitempty"` | ||
Status BindingStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// BindingList contains a list of Binding | ||
type BindingList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Binding `json:"items"` | ||
} | ||
|
||
func (b *Binding) GroupResource() schema.GroupResource { | ||
return schema.GroupResource{ | ||
Group: b.GroupVersionKind().Group, | ||
Resource: b.GroupVersionKind().Kind, | ||
} | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Binding{}, &BindingList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package v1beta1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const ready ConditionType = "Ready" | ||
|
||
type ConditionType string | ||
|
||
type Condition struct { | ||
// Type indicates the scope of RabbitmqCluster status addressed by the condition. | ||
Type ConditionType `json:"type"` | ||
// True, False, or Unknown | ||
Status corev1.ConditionStatus `json:"status"` | ||
// The last time this Condition type changed. | ||
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` | ||
// One word, camel-case reason for current status of the condition. | ||
Reason string `json:"reason,omitempty"` | ||
// Full text reason for current status of the condition. | ||
Message string `json:"message,omitempty"` | ||
} | ||
|
||
// Ready indicates that the last Create/Update operator on the CR was successful. | ||
func Ready() Condition { | ||
return Condition{ | ||
Type: ready, | ||
Status: corev1.ConditionTrue, | ||
LastTransitionTime: metav1.Now(), | ||
Reason: "SuccessfulCreateOrUpdate", | ||
} | ||
} | ||
|
||
// NotReady indicates that the last Create/Update operator on the CR failed. | ||
func NotReady(msg string) Condition { | ||
return Condition{ | ||
Type: ready, | ||
Status: corev1.ConditionFalse, | ||
LastTransitionTime: metav1.Now(), | ||
Reason: "FailedCreateOrUpdate", | ||
Message: msg, | ||
} | ||
} |
Oops, something went wrong.