Repository: corneliusweig/ketall (go)

Issue:
No resources returned in v1.3.4
**Describe the bug**
No resources are being returned in the latest version of the krew plugin.

**To Reproduce**
Steps to reproduce the behavior:
1. kubectl get-all -n bar
2. See error:
`DEBU[0000] Set log-level to debug
DEBU[0001] Resources to fetch: []
DEBU[0001] Initial fetchResourcesBulk done (0s)
DEBU[0001] Fetch resources incrementally
DEBU[0001] Requests done (elapsed 0s)
WARN[0001] No resources found, are you authorized? Try to narrow the scope with --namespace.
FATA[0001] no resources found`

**Expected behavior**
I expected too see the same resources I could in v1.3.2

**Screenshots**
<img width="866" alt="image" src="https://user-images.githubusercontent.com/65293263/93106772-a1571980-f6a8-11ea-9d38-10e205b5c550.png">

**Desktop (please complete the following information):**
 - output of `ketall version --full`:
> ketall:     v1.3.4
> platform:   darwin/amd64
> git commit: 071f5c7ec0f520ab9be82529c08e83fc726b4910
> build date: 2020-09-04T23:14:49Z
> go version: go1.15
> compiler:   gc
 - OS: MacOS
 - Browser: Firefox
 - Version 1.3.4

**Additional context**
Exact same command and kubectl version worked fine for version 1.3.2, seems to be a bug.

Pull request:
fix: boolean logic
Fix #93

Patch:
diff --git a/internal/client/client.go b/internal/client/client.go
index 9fa7cd5..5941ccb 100644
--- a/internal/client/client.go
+++ b/internal/client/client.go
@@ -221,7 +221,7 @@ func getResourceScope(scope string) (cluster, namespace bool, err error) {
 	switch scope {
 	case "":
 		cluster = viper.GetString(constants.FlagNamespace) == ""
-		namespace = false
+		namespace = true
 	case "namespace":
 		cluster = false
 		namespace = true


Test patch:
diff --git a/internal/client/client_test.go b/internal/client/client_test.go
new file mode 100644
index 0000000..e398b1e
--- /dev/null
+++ b/internal/client/client_test.go
@@ -0,0 +1,56 @@
+package client
+
+import "testing"
+
+func TestGetResourceScope(t *testing.T) {
+	tests := map[string]struct {
+		scope         string
+		wantCluster   bool
+		wantNamespace bool
+		wantErr       bool
+	}{
+		"no scope": {
+			scope:         "",
+			wantCluster:   true,
+			wantNamespace: true,
+			wantErr:       false,
+		},
+		"namespace scope": {
+			scope:         "namespace",
+			wantCluster:   false,
+			wantNamespace: true,
+			wantErr:       false,
+		},
+		"cluster scope": {
+			scope:         "cluster",
+			wantCluster:   true,
+			wantNamespace: false,
+			wantErr:       false,
+		},
+		"unknown scope": {
+			scope:         "unknown",
+			wantCluster:   false,
+			wantNamespace: false,
+			wantErr:       true,
+		},
+	}
+
+	for name, test := range tests {
+		t.Run(name, func(t *testing.T) {
+			gotCluster, gotNamespace, gotErr := getResourceScope(test.scope)
+
+			if gotCluster != test.wantCluster {
+				t.Fatalf("wrong cluster: got %t, want %t", gotCluster, test.wantNamespace)
+			}
+			if gotNamespace != test.wantNamespace {
+				t.Fatalf("wrong namespace: got %t, want %t", gotNamespace, test.wantNamespace)
+			}
+			if gotErr != nil && !test.wantErr {
+				t.Fatalf("unexpected error: %s", gotErr.Error())
+			}
+			if gotErr == nil && test.wantErr {
+				t.Fatal("expected error, got none")
+			}
+		})
+	}
+}