Skip to content

Commit ed868de

Browse files
committed
Remove duplicate type definitions
1 parent 27b6d50 commit ed868de

File tree

3 files changed

+107
-105
lines changed

3 files changed

+107
-105
lines changed

controllers/rabbitmqcluster_controller_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,8 @@ var _ = Describe("RabbitmqClusterController", func() {
829829
}))
830830

831831
Expect(sts.Spec.Template.Spec.HostNetwork).To(BeFalse())
832-
Expect(sts.Spec.Template.Spec.Volumes).To(ConsistOf(
833-
corev1.Volume{
832+
Expect(sts.Spec.Template.Spec.Volumes).To(ConsistOf([]corev1.Volume{
833+
{
834834
Name: "additional-config",
835835
VolumeSource: corev1.VolumeSource{
836836
ConfigMap: &corev1.ConfigMapVolumeSource{
@@ -841,7 +841,7 @@ var _ = Describe("RabbitmqClusterController", func() {
841841
},
842842
},
843843
},
844-
corev1.Volume{
844+
{
845845
Name: "rabbitmq-confd",
846846
VolumeSource: corev1.VolumeSource{
847847
Projected: &corev1.ProjectedVolumeSource{
@@ -881,7 +881,7 @@ var _ = Describe("RabbitmqClusterController", func() {
881881
},
882882
},
883883
},
884-
corev1.Volume{
884+
{
885885
Name: "plugins-conf",
886886
VolumeSource: corev1.VolumeSource{
887887
ConfigMap: &corev1.ConfigMapVolumeSource{
@@ -893,19 +893,19 @@ var _ = Describe("RabbitmqClusterController", func() {
893893
},
894894
},
895895

896-
corev1.Volume{
896+
{
897897
Name: "rabbitmq-plugins",
898898
VolumeSource: corev1.VolumeSource{
899899
EmptyDir: &corev1.EmptyDirVolumeSource{},
900900
},
901901
},
902-
corev1.Volume{
902+
{
903903
Name: "rabbitmq-erlang-cookie",
904904
VolumeSource: corev1.VolumeSource{
905905
EmptyDir: &corev1.EmptyDirVolumeSource{},
906906
},
907907
},
908-
corev1.Volume{
908+
{
909909
Name: "erlang-cookie-secret",
910910
VolumeSource: corev1.VolumeSource{
911911
Secret: &corev1.SecretVolumeSource{
@@ -914,7 +914,7 @@ var _ = Describe("RabbitmqClusterController", func() {
914914
},
915915
},
916916
},
917-
corev1.Volume{
917+
{
918918
Name: "pod-info",
919919
VolumeSource: corev1.VolumeSource{
920920
DownwardAPI: &corev1.DownwardAPIVolumeSource{
@@ -930,7 +930,7 @@ var _ = Describe("RabbitmqClusterController", func() {
930930
},
931931
},
932932
},
933-
}))
933+
}}))
934934

935935
Expect(extractContainer(sts.Spec.Template.Spec.Containers, "additional-container").Image).To(Equal("my-great-image"))
936936
})

internal/resource/statefulset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func sortEnvVar(envVar []corev1.EnvVar) {
280280
}
281281

282282
// sortVolumeMounts always returns '/var/lib/rabbitmq/' and '/var/lib/rabbitmq/mnesia/' first in the list.
283-
// this is to ensure '/var/lib/rabbitmq/' always mounts before '/var/lib/rabbitmq/mnesia/' to aviod shadowing
283+
// this is to ensure '/var/lib/rabbitmq/' always mounts before '/var/lib/rabbitmq/mnesia/' to avoid shadowing
284284
// popular open-sourced container runtimes like docker and containerD will sort mounts in alphabetical order to
285285
// avoid this issue, but there's no guarantee that all container runtime would do so
286286
func sortVolumeMounts(mounts []corev1.VolumeMount) {

internal/resource/statefulset_test.go

Lines changed: 97 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,33 +1250,33 @@ var _ = Describe("StatefulSet", func() {
12501250
"&& chown 999:999 /var/lib/rabbitmq/.rabbitmqadmin.conf "+
12511251
"&& chmod 600 /var/lib/rabbitmq/.rabbitmqadmin.conf",
12521252
),
1253-
"VolumeMounts": ConsistOf(
1254-
corev1.VolumeMount{
1253+
"VolumeMounts": ConsistOf([]corev1.VolumeMount{
1254+
{
12551255
Name: "plugins-conf",
12561256
MountPath: "/tmp/rabbitmq-plugins/",
12571257
},
1258-
corev1.VolumeMount{
1258+
{
12591259
Name: "rabbitmq-erlang-cookie",
12601260
MountPath: "/var/lib/rabbitmq/",
12611261
},
1262-
corev1.VolumeMount{
1262+
{
12631263
Name: "erlang-cookie-secret",
12641264
MountPath: "/tmp/erlang-cookie-secret/",
12651265
},
1266-
corev1.VolumeMount{
1266+
{
12671267
Name: "rabbitmq-plugins",
12681268
MountPath: "/operator",
12691269
},
1270-
corev1.VolumeMount{
1270+
{
12711271
Name: "persistence",
12721272
MountPath: "/var/lib/rabbitmq/mnesia/",
12731273
},
1274-
corev1.VolumeMount{
1274+
{
12751275
Name: "rabbitmq-confd",
12761276
MountPath: "/tmp/default_user.conf",
12771277
SubPath: "default_user.conf",
12781278
},
1279-
),
1279+
}),
12801280
}))
12811281
})
12821282

@@ -1625,90 +1625,92 @@ var _ = Describe("StatefulSet", func() {
16251625
},
16261626
))
16271627

1628-
Expect(extractContainer(statefulSet.Spec.Template.Spec.Containers, "rabbitmq").Env).To(ConsistOf(
1629-
corev1.EnvVar{
1630-
Name: "test1",
1631-
Value: "test1",
1632-
},
1633-
corev1.EnvVar{
1634-
Name: "MY_POD_NAME",
1635-
ValueFrom: &corev1.EnvVarSource{
1636-
FieldRef: &corev1.ObjectFieldSelector{
1637-
FieldPath: "metadata.name",
1638-
APIVersion: "v1",
1628+
Expect(extractContainer(statefulSet.Spec.Template.Spec.Containers, "rabbitmq").Env).To(
1629+
ConsistOf([]corev1.EnvVar{
1630+
{
1631+
Name: "test1",
1632+
Value: "test1",
1633+
},
1634+
{
1635+
Name: "MY_POD_NAME",
1636+
ValueFrom: &corev1.EnvVarSource{
1637+
FieldRef: &corev1.ObjectFieldSelector{
1638+
FieldPath: "metadata.name",
1639+
APIVersion: "v1",
1640+
},
16391641
},
16401642
},
1641-
},
1642-
corev1.EnvVar{
1643-
Name: "MY_POD_NAMESPACE",
1644-
ValueFrom: &corev1.EnvVarSource{
1645-
FieldRef: &corev1.ObjectFieldSelector{
1646-
FieldPath: "metadata.namespace",
1647-
APIVersion: "v1",
1643+
{
1644+
Name: "MY_POD_NAMESPACE",
1645+
ValueFrom: &corev1.EnvVarSource{
1646+
FieldRef: &corev1.ObjectFieldSelector{
1647+
FieldPath: "metadata.namespace",
1648+
APIVersion: "v1",
1649+
},
16481650
},
16491651
},
1650-
},
1651-
corev1.EnvVar{
1652-
Name: "K8S_SERVICE_NAME",
1653-
Value: instance.ChildResourceName("nodes"),
1654-
},
1655-
corev1.EnvVar{
1656-
Name: "RABBITMQ_USE_LONGNAME",
1657-
Value: "true",
1658-
},
1659-
corev1.EnvVar{
1660-
Name: "RABBITMQ_ENABLED_PLUGINS_FILE",
1661-
Value: "/operator/enabled_plugins",
1662-
},
1663-
corev1.EnvVar{
1664-
Name: "RABBITMQ_NODENAME",
1665-
Value: "rabbit@$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE)",
1666-
},
1667-
corev1.EnvVar{
1668-
Name: "K8S_HOSTNAME_SUFFIX",
1669-
Value: ".$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE)",
1670-
}))
1652+
{
1653+
Name: "K8S_SERVICE_NAME",
1654+
Value: instance.ChildResourceName("nodes"),
1655+
},
1656+
{
1657+
Name: "RABBITMQ_USE_LONGNAME",
1658+
Value: "true",
1659+
},
1660+
{
1661+
Name: "RABBITMQ_ENABLED_PLUGINS_FILE",
1662+
Value: "/operator/enabled_plugins",
1663+
},
1664+
{
1665+
Name: "RABBITMQ_NODENAME",
1666+
Value: "rabbit@$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE)",
1667+
},
1668+
{
1669+
Name: "K8S_HOSTNAME_SUFFIX",
1670+
Value: ".$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE)",
1671+
}}))
16711672
Expect(extractContainer(statefulSet.Spec.Template.Spec.Containers, "new-container-0")).To(Equal(
16721673
corev1.Container{Name: "new-container-0", Image: "my-image-0"}))
16731674
Expect(extractContainer(statefulSet.Spec.Template.Spec.Containers, "new-container-1")).To(Equal(
16741675
corev1.Container{Name: "new-container-1", Image: "my-image-1"}))
1675-
Expect(extractContainer(statefulSet.Spec.Template.Spec.Containers, "rabbitmq").VolumeMounts).To(ConsistOf(
1676-
corev1.VolumeMount{
1677-
Name: "test",
1678-
MountPath: "test-path",
1679-
},
1680-
corev1.VolumeMount{
1681-
Name: "persistence",
1682-
MountPath: "/var/lib/rabbitmq/mnesia/",
1683-
},
1684-
corev1.VolumeMount{
1685-
Name: "rabbitmq-confd",
1686-
MountPath: "/etc/rabbitmq/conf.d/10-operatorDefaults.conf",
1687-
SubPath: "operatorDefaults.conf",
1688-
},
1689-
corev1.VolumeMount{
1690-
Name: "rabbitmq-confd",
1691-
MountPath: "/etc/rabbitmq/conf.d/11-default_user.conf",
1692-
SubPath: "default_user.conf",
1693-
},
1694-
corev1.VolumeMount{
1695-
Name: "rabbitmq-confd",
1696-
MountPath: "/etc/rabbitmq/conf.d/90-userDefinedConfiguration.conf",
1697-
SubPath: "userDefinedConfiguration.conf",
1698-
},
1699-
corev1.VolumeMount{
1700-
Name: "rabbitmq-erlang-cookie",
1701-
MountPath: "/var/lib/rabbitmq/",
1702-
},
1703-
corev1.VolumeMount{
1704-
Name: "pod-info",
1705-
MountPath: "/etc/pod-info/",
1706-
},
1707-
corev1.VolumeMount{
1708-
Name: "rabbitmq-plugins",
1709-
MountPath: "/operator",
1710-
},
1711-
))
1676+
Expect(extractContainer(statefulSet.Spec.Template.Spec.Containers, "rabbitmq").VolumeMounts).To(
1677+
ConsistOf([]corev1.VolumeMount{
1678+
{
1679+
Name: "test",
1680+
MountPath: "test-path",
1681+
},
1682+
{
1683+
Name: "persistence",
1684+
MountPath: "/var/lib/rabbitmq/mnesia/",
1685+
},
1686+
{
1687+
Name: "rabbitmq-confd",
1688+
MountPath: "/etc/rabbitmq/conf.d/10-operatorDefaults.conf",
1689+
SubPath: "operatorDefaults.conf",
1690+
},
1691+
{
1692+
Name: "rabbitmq-confd",
1693+
MountPath: "/etc/rabbitmq/conf.d/11-default_user.conf",
1694+
SubPath: "default_user.conf",
1695+
},
1696+
{
1697+
Name: "rabbitmq-confd",
1698+
MountPath: "/etc/rabbitmq/conf.d/90-userDefinedConfiguration.conf",
1699+
SubPath: "userDefinedConfiguration.conf",
1700+
},
1701+
{
1702+
Name: "rabbitmq-erlang-cookie",
1703+
MountPath: "/var/lib/rabbitmq/",
1704+
},
1705+
{
1706+
Name: "pod-info",
1707+
MountPath: "/etc/pod-info/",
1708+
},
1709+
{
1710+
Name: "rabbitmq-plugins",
1711+
MountPath: "/operator",
1712+
},
1713+
}))
17121714
})
17131715

17141716
Context("Rabbitmq Container volume mounts", func() {
@@ -1824,8 +1826,8 @@ var _ = Describe("StatefulSet", func() {
18241826
Name: "K8S_SERVICE_NAME",
18251827
Value: "foo-nodes",
18261828
}))
1827-
Expect(extractContainer(statefulSet.Spec.Template.Spec.Containers, "rabbitmq").Env).To(ConsistOf(
1828-
corev1.EnvVar{
1829+
Expect(extractContainer(statefulSet.Spec.Template.Spec.Containers, "rabbitmq").Env).To(ConsistOf([]corev1.EnvVar{
1830+
{
18291831
Name: "MY_POD_NAME",
18301832
ValueFrom: &corev1.EnvVarSource{
18311833
FieldRef: &corev1.ObjectFieldSelector{
@@ -1834,7 +1836,7 @@ var _ = Describe("StatefulSet", func() {
18341836
},
18351837
},
18361838
},
1837-
corev1.EnvVar{
1839+
{
18381840
Name: "MY_POD_NAMESPACE",
18391841
ValueFrom: &corev1.EnvVarSource{
18401842
FieldRef: &corev1.ObjectFieldSelector{
@@ -1843,34 +1845,34 @@ var _ = Describe("StatefulSet", func() {
18431845
},
18441846
},
18451847
},
1846-
corev1.EnvVar{
1848+
{
18471849
Name: "test1",
18481850
Value: "test1",
18491851
},
1850-
corev1.EnvVar{
1852+
{
18511853
Name: "K8S_SERVICE_NAME",
18521854
Value: instance.ChildResourceName("nodes"),
18531855
},
1854-
corev1.EnvVar{
1856+
{
18551857
Name: "RABBITMQ_USE_LONGNAME",
18561858
Value: "false",
18571859
},
1858-
corev1.EnvVar{
1860+
{
18591861
Name: "RABBITMQ_ENABLED_PLUGINS_FILE",
18601862
Value: "/operator/enabled_plugins",
18611863
},
1862-
corev1.EnvVar{
1864+
{
18631865
Name: "RABBITMQ_NODENAME",
18641866
Value: "rabbit@$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE)",
18651867
},
1866-
corev1.EnvVar{
1868+
{
18671869
Name: "K8S_HOSTNAME_SUFFIX",
18681870
Value: ".$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE)",
18691871
},
1870-
corev1.EnvVar{
1872+
{
18711873
Name: "RABBITMQ_STREAM_ADVERTISED_HOST",
18721874
Value: "$(MY_POD_NAME).$(K8S_SERVICE_NAME).$(MY_POD_NAMESPACE)",
1873-
}))
1875+
}}))
18741876
})
18751877
})
18761878
})

0 commit comments

Comments
 (0)