diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 8d182713c..01b0b9bae 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -106,3 +106,4 @@ and we will add you. **All** contributors belong here. 💯 - [Robin Brämer](https://github.com/robinbraemer) - [Geeta Chavan](https://github.com/geetachavan1) - [Stephen Augustus](https://github.com/justaugustus) +- [Erik Cederberg](https://github.com/erikced) diff --git a/pkg/porter/list.go b/pkg/porter/list.go index 0111da446..fb68dc40c 100644 --- a/pkg/porter/list.go +++ b/pkg/porter/list.go @@ -248,7 +248,7 @@ func (p *Porter) ListInstallations(ctx context.Context, opts ListOptions) (Displ return nil, log.Error(fmt.Errorf("could not list installations: %w", err)) } - var displayInstallations DisplayInstallations + var displayInstallations DisplayInstallations = DisplayInstallations{} var fieldSelectorMap map[string]string if opts.FieldSelector != "" { fieldSelectorMap, err = parseFieldSelector(opts.FieldSelector) diff --git a/pkg/porter/list_test.go b/pkg/porter/list_test.go index e20cb8c56..a4a4c2a8e 100644 --- a/pkg/porter/list_test.go +++ b/pkg/porter/list_test.go @@ -104,6 +104,14 @@ func TestPorter_ListInstallations(t *testing.T) { require.NoError(t, err) assert.Len(t, results, 1) }) + + t.Run("empty namespace", func(t *testing.T) { + opts := ListOptions{Namespace: "nonexistent"} + results, err := p.ListInstallations(ctx, opts) + require.NoError(t, err) + assert.Len(t, results, 0) + assert.NotNil(t, results) + }) } func TestPorter_ListInstallationsWithFieldSelector(t *testing.T) {