-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added krew manifest; added tests; bumped version to v0.1.2
- Loading branch information
1 parent
cc9f194
commit 38a28a2
Showing
9 changed files
with
210 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
**/kubectl-match_name.exe | ||
**/.DS_Store | ||
**/ignore/ | ||
**/release.txt | ||
**/*.zip | ||
go.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/client-go/kubernetes/fake" | ||
) | ||
|
||
func TestGetServices(t *testing.T) { | ||
client := fake.NewSimpleClientset() | ||
names, err := getServices(client.CoreV1(), "default") | ||
expected := 0 | ||
|
||
if err != nil { | ||
t.Errorf("Unexpected error: %s", err) | ||
} | ||
|
||
if len(names) != expected { | ||
t.Errorf("Expected exactly %d Services", expected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestGetObjects(t *testing.T) { | ||
sampleConfig := []byte(` | ||
apiVersion: v1 | ||
clusters: | ||
- cluster: | ||
certificate-authority: /Users/gerald/.minikube/ca.crt | ||
server: https://192.168.99.100:8443 | ||
name: 192-168-99-100:8443 | ||
- cluster: | ||
certificate-authority: /Users/gerald/.minikube/ca.crt | ||
server: https://192.168.99.100:8443 | ||
name: minikube | ||
contexts: | ||
- context: | ||
cluster: 192-168-99-100:8443 | ||
namespace: default | ||
user: /192-168-99-100:8443 | ||
name: default/192-168-99-100:8443/ | ||
- context: | ||
cluster: minikube | ||
namespace: kube-system | ||
user: minikube | ||
name: minikube | ||
current-context: minikube | ||
kind: Config | ||
preferences: {} | ||
users: | ||
- name: /192-168-99-100:8443 | ||
user: | ||
client-certificate: /Users/gerald/.minikube/client.crt | ||
client-key: /Users/gerald/.minikube/client.key | ||
- name: minikube | ||
user: | ||
client-certificate: /Users/gerald/.minikube/client.crt | ||
client-key: /Users/gerald/.minikube/client.key | ||
`) | ||
|
||
var tests = []struct { | ||
description string | ||
config string | ||
namespace string | ||
kind string | ||
allNamespaces bool | ||
}{ | ||
{"no_config", "{}", "default", "pod", false}, | ||
{"unsupported_kind", string(sampleConfig), "default", "invalid", false}, | ||
} | ||
|
||
//getObjects(kubeconfig string, namespace string, kind string, allNamespaces bool) | ||
for _, test := range tests { | ||
t.Run(test.description, func(t *testing.T) { | ||
_, err := getObjects(test.config, test.namespace, test.kind, test.allNamespaces) | ||
if err == nil { | ||
t.Errorf("Function call with invalid parameters must fail") | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestHomeDir(t *testing.T) { | ||
homeDir := homeDir() | ||
if len(homeDir) == 0 { | ||
t.Errorf("home directory must not be empty") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: krew.googlecontainertools.github.com/v1alpha2 | ||
kind: Plugin | ||
metadata: | ||
name: kubectl-match-name | ||
spec: | ||
version: "v0.1.2" | ||
platforms: | ||
- selector: | ||
matchExpressions: | ||
- {key: os, operator: In, values: [darwin]} | ||
url: https://github.com/gerald1248/kubectl-match-name/releases/download/v0.1.0/kubectl-match_name-darwin-amd64.zip | ||
sha256: "789e8be9da2813d92261456e57aa7f7bf283781b7358becd64d57b584d4e69d2" | ||
files: | ||
- from: "/darwin/kubectl-match_name" | ||
to: "." | ||
bin: "./kubectl-match_name" | ||
- selector: | ||
matchExpressions: | ||
- {key: os, operator: In, values: [linux]} | ||
url: https://github.com/gerald1248/kubectl-match-name/releases/download/v0.1.0/kubectl-match_name-linux-amd64.zip | ||
sha256: "8027c16544ad7749d31174e762d09dc49324948e15fff71ada8e1e0620a506d2" | ||
files: | ||
- from: "/linux/kubectl-match_name" | ||
to: "." | ||
bin: "./kubectl-match_name" | ||
- selector: | ||
matchExpressions: | ||
- {key: os, operator: In, values: [windows]} | ||
url: https://github.com/gerald1248/kubectl-match-name/releases/download/v0.1.2/kubectl-match_name-windows-amd64.zip | ||
sha256: "49382ef4e5e104a73a1c2aa6beac377deac5ce23fd890f1b46282f21c778fe42" | ||
files: | ||
- from: "/windows/kubectl-match_name.exe" | ||
to: "." | ||
bin: "./kubectl-match_name.exe" | ||
|
||
shortDescription: Match names of pods and other API objects | ||
caveats: | | ||
API object coverage is incomplete. | ||
description: | | ||
This plugin allows fast regex matching for the names of pods and other API objects. It reduces typing and simplifies automation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
) | ||
|
||
func TestKubeConfigObject(t *testing.T) { | ||
bytes := []byte(`apiVersion: v1 | ||
clusters: | ||
- cluster: | ||
certificate-authority: /Users/gerald/.minikube/ca.crt | ||
server: https://192.168.99.100:8443 | ||
name: 192-168-99-100:8443 | ||
- cluster: | ||
certificate-authority: /Users/gerald/.minikube/ca.crt | ||
server: https://192.168.99.100:8443 | ||
name: minikube | ||
contexts: | ||
- context: | ||
cluster: 192-168-99-100:8443 | ||
namespace: default | ||
user: /192-168-99-100:8443 | ||
name: default/192-168-99-100:8443/ | ||
- context: | ||
cluster: minikube | ||
namespace: kube-system | ||
user: minikube | ||
name: minikube | ||
current-context: minikube | ||
kind: Config | ||
preferences: {} | ||
users: | ||
- name: /192-168-99-100:8443 | ||
user: | ||
client-certificate: /Users/gerald/.minikube/client.crt | ||
client-key: /Users/gerald/.minikube/client.key | ||
- name: minikube | ||
user: | ||
client-certificate: /Users/gerald/.minikube/client.crt | ||
client-key: /Users/gerald/.minikube/client.key | ||
`) | ||
var kubeconfig KubeconfigObject | ||
if err := json.Unmarshal(bytes, &kubeconfig); err == nil { | ||
t.Errorf("KubeConfig object must be compatible with sample YAML input: %s", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters