Skip to content

Commit ba53421

Browse files
authored
Merge pull request #4736 from kersten/chore/idiomatic-var-slices
🌱 (chore): replace empty slice literals with idiomatic var decls
2 parents 544c0b4 + f52c15c commit ba53421

File tree

9 files changed

+10
-10
lines changed

9 files changed

+10
-10
lines changed

docs/book/src/getting-started/testdata/project/internal/controller/memcached_controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ var _ = Describe("Memcached Controller", func() {
9494

9595
By("Checking the latest Status Condition added to the Memcached instance")
9696
Expect(k8sClient.Get(ctx, typeNamespacedName, memcached)).To(Succeed())
97-
conditions := []metav1.Condition{}
97+
var conditions []metav1.Condition
9898
Expect(memcached.Status.Conditions).To(ContainElement(
9999
HaveField("Type", Equal(typeAvailableMemcached)), &conditions))
100100
Expect(conditions).To(HaveLen(1), "Multiple conditions of type %s", typeAvailableMemcached)

hack/docs/internal/getting-started/generate_getting_started.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (sp *Sample) updateControllerTest() {
8585
8686
By("Checking the latest Status Condition added to the Memcached instance")
8787
Expect(k8sClient.Get(ctx, typeNamespacedName, memcached)).To(Succeed())
88-
conditions := []metav1.Condition{}
88+
var conditions []metav1.Condition
8989
Expect(memcached.Status.Conditions).To(ContainElement(
9090
HaveField("Type", Equal(typeAvailableMemcached)), &conditions))
9191
Expect(conditions).To(HaveLen(1), "Multiple conditions of type %s", typeAvailableMemcached)

pkg/plugins/external/helpers.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func bindSpecificFlags(fs *pflag.FlagSet, flags []external.Flag) {
254254
}
255255

256256
func filterFlags(flags []external.Flag, externalFlagFilters []externalFlagFilterFunc) []external.Flag {
257-
filteredFlags := []external.Flag{}
257+
var filteredFlags []external.Flag
258258
for _, flag := range flags {
259259
ok := true
260260
for _, filter := range externalFlagFilters {
@@ -271,7 +271,7 @@ func filterFlags(flags []external.Flag, externalFlagFilters []externalFlagFilter
271271
}
272272

273273
func filterArgs(args []string, argFilters []argFilterFunc) []string {
274-
filteredArgs := []string{}
274+
var filteredArgs []string
275275
for _, arg := range args {
276276
ok := true
277277
for _, filter := range argFilters {

pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers/controller-test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ var _ = Describe("{{ .Resource.Kind }} controller", func() {
191191
192192
By("Checking the latest Status Condition added to the {{ .Resource.Kind }} instance")
193193
Expect(k8sClient.Get(ctx, typeNamespacedName, {{ lower .Resource.Kind }})).To(Succeed())
194-
conditions := []metav1.Condition{}
194+
var conditions []metav1.Condition
195195
Expect({{ lower .Resource.Kind }}.Status.Conditions).To(ContainElement(
196196
HaveField("Type", Equal(typeAvailable{{ .Resource.Kind }})), &conditions))
197197
Expect(conditions).To(HaveLen(1), "Multiple conditions of type %s", typeAvailable{{ .Resource.Kind }})

pkg/plugins/optional/grafana/v1alpha/scaffolds/edit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func configReader(reader io.Reader) ([]templates.CustomMetricItem, error) {
100100

101101
func validateCustomMetricItems(rawItems []templates.CustomMetricItem) []templates.CustomMetricItem {
102102
// 1. Filter items of missing `Metric` or `Type`
103-
filterResult := []templates.CustomMetricItem{}
103+
var filterResult []templates.CustomMetricItem
104104
for _, item := range rawItems {
105105
if hasFields(item) {
106106
filterResult = append(filterResult, item)

testdata/project-v4-multigroup/internal/controller/example.com/busybox_controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ var _ = Describe("Busybox controller", func() {
138138

139139
By("Checking the latest Status Condition added to the Busybox instance")
140140
Expect(k8sClient.Get(ctx, typeNamespacedName, busybox)).To(Succeed())
141-
conditions := []metav1.Condition{}
141+
var conditions []metav1.Condition
142142
Expect(busybox.Status.Conditions).To(ContainElement(
143143
HaveField("Type", Equal(typeAvailableBusybox)), &conditions))
144144
Expect(conditions).To(HaveLen(1), "Multiple conditions of type %s", typeAvailableBusybox)

testdata/project-v4-multigroup/internal/controller/example.com/memcached_controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ var _ = Describe("Memcached controller", func() {
139139

140140
By("Checking the latest Status Condition added to the Memcached instance")
141141
Expect(k8sClient.Get(ctx, typeNamespacedName, memcached)).To(Succeed())
142-
conditions := []metav1.Condition{}
142+
var conditions []metav1.Condition
143143
Expect(memcached.Status.Conditions).To(ContainElement(
144144
HaveField("Type", Equal(typeAvailableMemcached)), &conditions))
145145
Expect(conditions).To(HaveLen(1), "Multiple conditions of type %s", typeAvailableMemcached)

testdata/project-v4-with-plugins/internal/controller/busybox_controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ var _ = Describe("Busybox controller", func() {
138138

139139
By("Checking the latest Status Condition added to the Busybox instance")
140140
Expect(k8sClient.Get(ctx, typeNamespacedName, busybox)).To(Succeed())
141-
conditions := []metav1.Condition{}
141+
var conditions []metav1.Condition
142142
Expect(busybox.Status.Conditions).To(ContainElement(
143143
HaveField("Type", Equal(typeAvailableBusybox)), &conditions))
144144
Expect(conditions).To(HaveLen(1), "Multiple conditions of type %s", typeAvailableBusybox)

testdata/project-v4-with-plugins/internal/controller/memcached_controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ var _ = Describe("Memcached controller", func() {
139139

140140
By("Checking the latest Status Condition added to the Memcached instance")
141141
Expect(k8sClient.Get(ctx, typeNamespacedName, memcached)).To(Succeed())
142-
conditions := []metav1.Condition{}
142+
var conditions []metav1.Condition
143143
Expect(memcached.Status.Conditions).To(ContainElement(
144144
HaveField("Type", Equal(typeAvailableMemcached)), &conditions))
145145
Expect(conditions).To(HaveLen(1), "Multiple conditions of type %s", typeAvailableMemcached)

0 commit comments

Comments
 (0)