Skip to content

Commit

Permalink
Merge pull request #447 from rabbitmq/rename
Browse files Browse the repository at this point in the history
Rename client svc and headless svc, and drop `-rabbitmq` suffix from all child resources
  • Loading branch information
ChunyiLyu committed Nov 6, 2020
2 parents d76175b + b5d7713 commit dda2be1
Show file tree
Hide file tree
Showing 24 changed files with 161 additions and 157 deletions.
14 changes: 7 additions & 7 deletions api/v1beta1/rabbitmqcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ type RabbitmqClusterSpec struct {
}

type RabbitmqClusterOverrideSpec struct {
StatefulSet *StatefulSet `json:"statefulSet,omitempty"`
ClientService *ClientService `json:"clientService,omitempty"`
StatefulSet *StatefulSet `json:"statefulSet,omitempty"`
Service *Service `json:"service,omitempty"`
}

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

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

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

Expand Down Expand Up @@ -396,7 +396,7 @@ type RabbitmqClusterList struct {
}

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

func init() {
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/rabbitmqcluster_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ var _ = Describe("RabbitmqCluster", func() {
Describe("ChildResourceName", func() {
It("prefixes the passed string with the name of the RabbitmqCluster name", func() {
resource := generateRabbitmqClusterObject("iam")
Expect(resource.ChildResourceName("great")).To(Equal("iam-rabbitmq-great"))
Expect(resource.ChildResourceName("great")).To(Equal("iam-great"))
})
})

Expand Down
56 changes: 28 additions & 28 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions charts/tsmgr/bind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

template: |
local clientFilterFunc(j) = std.length(std.findSubstr("rabbitmq-client", j.name)) > 0;
local clientService = std.filter(clientFilterFunc, $.services)[0];
local service = std.filter(clientFilterFunc, $.services)[0];
local secretFilterFunc(j) = std.length(std.findSubstr("rabbitmq-default-user", j.name)) > 0;
local defaultUser = std.filter(secretFilterFunc, $.secrets);
local vhost = "%2F";
local ingress = if clientService.spec.type == "LoadBalancer" then
if std.objectHas(clientService.status.loadBalancer.ingress[0], "hostname") then
clientService.status.loadBalancer.ingress[0].hostname
local ingress = if service.spec.type == "LoadBalancer" then
if std.objectHas(service.status.loadBalancer.ingress[0], "hostname") then
service.status.loadBalancer.ingress[0].hostname
else
clientService.status.loadBalancer.ingress[0].ip
service.status.loadBalancer.ingress[0].ip
else
clientService.spec.clusterIP;
service.spec.clusterIP;
local defaultUserUsername = defaultUser[0].data['username'];
local defaultUserPassword = defaultUser[0].data['password'];
local mgmtURI = "http://" + ingress + ":15672";
Expand Down
6 changes: 3 additions & 3 deletions config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ spec:
type: array
override:
properties:
clientService:
service:
properties:
metadata:
properties:
Expand Down Expand Up @@ -3700,12 +3700,12 @@ spec:
service:
default:
type: ClusterIP
description: Settable attributes for the Client Service resource.
description: Settable attributes for the Service resource.
properties:
annotations:
additionalProperties:
type: string
description: Annotations to add to the Client Service.
description: Annotations to add to the Service.
type: object
type:
default: ClusterIP
Expand Down
2 changes: 1 addition & 1 deletion controllers/rabbitmqcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (r *RabbitmqClusterReconciler) getChildResources(ctx context.Context, rmq r
}

if err := r.Client.Get(ctx,
types.NamespacedName{Name: rmq.ChildResourceName("client"), Namespace: rmq.Namespace},
types.NamespacedName{Name: rmq.ChildResourceName(resource.ServiceSuffix), Namespace: rmq.Namespace},
endPoints); err != nil && !errors.IsNotFound(err) {
return nil, err
} else if errors.IsNotFound(err) {
Expand Down

0 comments on commit dda2be1

Please sign in to comment.