Skip to content

Commit dda2be1

Browse files
authored
Merge pull request #447 from rabbitmq/rename
Rename client svc and headless svc, and drop `-rabbitmq` suffix from all child resources
2 parents d76175b + b5d7713 commit dda2be1

24 files changed

+161
-157
lines changed

api/v1beta1/rabbitmqcluster_types.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ type RabbitmqClusterSpec struct {
7272
}
7373

7474
type RabbitmqClusterOverrideSpec struct {
75-
StatefulSet *StatefulSet `json:"statefulSet,omitempty"`
76-
ClientService *ClientService `json:"clientService,omitempty"`
75+
StatefulSet *StatefulSet `json:"statefulSet,omitempty"`
76+
Service *Service `json:"service,omitempty"`
7777
}
7878

79-
type ClientService struct {
79+
type Service struct {
8080
// +optional
8181
*EmbeddedLabelsAnnotations `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
8282
// Spec defines the behavior of a service.
@@ -151,7 +151,7 @@ type StatefulSetSpec struct {
151151
UpdateStrategy *appsv1.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty" protobuf:"bytes,7,opt,name=updateStrategy"`
152152
}
153153

154-
// It is used in ClientService and StatefulSet
154+
// It is used in Service and StatefulSet
155155
type EmbeddedLabelsAnnotations struct {
156156
// Map of string keys and values that can be used to organize and categorize
157157
// (scope and select) objects. May match selectors of replication controllers
@@ -277,12 +277,12 @@ type RabbitmqClusterPersistenceSpec struct {
277277
Storage *k8sresource.Quantity `json:"storage,omitempty"`
278278
}
279279

280-
// Settable attributes for the Client Service resource.
280+
// Settable attributes for the Service resource.
281281
type RabbitmqClusterServiceSpec struct {
282282
// +kubebuilder:validation:Enum=ClusterIP;LoadBalancer;NodePort
283283
// +kubebuilder:default:="ClusterIP"
284284
Type corev1.ServiceType `json:"type,omitempty"`
285-
// Annotations to add to the Client Service.
285+
// Annotations to add to the Service.
286286
Annotations map[string]string `json:"annotations,omitempty"`
287287
}
288288

@@ -396,7 +396,7 @@ type RabbitmqClusterList struct {
396396
}
397397

398398
func (cluster RabbitmqCluster) ChildResourceName(name string) string {
399-
return strings.Join([]string{cluster.Name, "rabbitmq", name}, "-")
399+
return strings.TrimSuffix(strings.Join([]string{cluster.Name, name}, "-"), "-")
400400
}
401401

402402
func init() {

api/v1beta1/rabbitmqcluster_types_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ var _ = Describe("RabbitmqCluster", func() {
140140
Describe("ChildResourceName", func() {
141141
It("prefixes the passed string with the name of the RabbitmqCluster name", func() {
142142
resource := generateRabbitmqClusterObject("iam")
143-
Expect(resource.ChildResourceName("great")).To(Equal("iam-rabbitmq-great"))
143+
Expect(resource.ChildResourceName("great")).To(Equal("iam-great"))
144144
})
145145
})
146146

api/v1beta1/zz_generated.deepcopy.go

+28-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/tsmgr/bind.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
template: |
1010
local clientFilterFunc(j) = std.length(std.findSubstr("rabbitmq-client", j.name)) > 0;
11-
local clientService = std.filter(clientFilterFunc, $.services)[0];
11+
local service = std.filter(clientFilterFunc, $.services)[0];
1212
local secretFilterFunc(j) = std.length(std.findSubstr("rabbitmq-default-user", j.name)) > 0;
1313
local defaultUser = std.filter(secretFilterFunc, $.secrets);
1414
1515
local vhost = "%2F";
16-
local ingress = if clientService.spec.type == "LoadBalancer" then
17-
if std.objectHas(clientService.status.loadBalancer.ingress[0], "hostname") then
18-
clientService.status.loadBalancer.ingress[0].hostname
16+
local ingress = if service.spec.type == "LoadBalancer" then
17+
if std.objectHas(service.status.loadBalancer.ingress[0], "hostname") then
18+
service.status.loadBalancer.ingress[0].hostname
1919
else
20-
clientService.status.loadBalancer.ingress[0].ip
20+
service.status.loadBalancer.ingress[0].ip
2121
else
22-
clientService.spec.clusterIP;
22+
service.spec.clusterIP;
2323
local defaultUserUsername = defaultUser[0].data['username'];
2424
local defaultUserPassword = defaultUser[0].data['password'];
2525
local mgmtURI = "http://" + ingress + ":15672";

config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ spec:
663663
type: array
664664
override:
665665
properties:
666-
clientService:
666+
service:
667667
properties:
668668
metadata:
669669
properties:
@@ -3700,12 +3700,12 @@ spec:
37003700
service:
37013701
default:
37023702
type: ClusterIP
3703-
description: Settable attributes for the Client Service resource.
3703+
description: Settable attributes for the Service resource.
37043704
properties:
37053705
annotations:
37063706
additionalProperties:
37073707
type: string
3708-
description: Annotations to add to the Client Service.
3708+
description: Annotations to add to the Service.
37093709
type: object
37103710
type:
37113711
default: ClusterIP

controllers/rabbitmqcluster_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func (r *RabbitmqClusterReconciler) getChildResources(ctx context.Context, rmq r
268268
}
269269

270270
if err := r.Client.Get(ctx,
271-
types.NamespacedName{Name: rmq.ChildResourceName("client"), Namespace: rmq.Namespace},
271+
types.NamespacedName{Name: rmq.ChildResourceName(resource.ServiceSuffix), Namespace: rmq.Namespace},
272272
endPoints); err != nil && !errors.IsNotFound(err) {
273273
return nil, err
274274
} else if errors.IsNotFound(err) {

0 commit comments

Comments
 (0)