Skip to content

Commit 98f2db3

Browse files
authored
Merge pull request #4 from icy/helm_command_without_separator
helm command doesnot need separator (--)
2 parents ce8476d + 459d540 commit 98f2db3

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ This new way
3333

3434
```
3535
$ gk8s :my-cluster get nodes
36+
$ gk8s :my-cluster helm list
3637
$ gk8s :my-cluster -- helm list
3738
$ gk8s :my-cluster -- custom-command # KUBECONFIG will be set accordingly with default context!
3839
```
@@ -94,8 +95,8 @@ You get no idea of the cluster on which you executed the command(s).
9495

9596
## Getting started
9697

97-
Starting from v1.1.1, you can download binary files generated automatically
98-
by Github-Action (via goreleaser tool). You find the files from
98+
Starting from v1.1.1, you can download binary files generated automatically
99+
by Github-Action (via goreleaser tool). You find the files from
99100
the release listing page: https://github.com/icy/gk8s/releases
100101

101102
To install on your laptop by local compiling process, please try the popular way
@@ -139,6 +140,14 @@ $ gk8s :cluster kubectl get nodes
139140
$ gk8s :cluster -- kubectl get nodes
140141
```
141142

143+
Both `kubectl` and `helm` don't need any separator (`--`). The following
144+
commands are the same:
145+
146+
```
147+
$ gk8s :cluster helm list
148+
$ gk8s :cluster -- helm list
149+
```
150+
142151
Some notes
143152

144153
* The command `kubectl` is used by default.

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/icy/gk8s
2+
3+
go 1.20

main.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ func args2cmd(args []string) (string, []string) {
4848
return command, []string{""}
4949
}
5050
} else {
51-
if strings.Index(args[0], "kubectl") == -1 {
51+
if strings.Index(args[0], "helm") == 0 {
52+
command = "helm"
53+
args = args[0:]
54+
} else if strings.Index(args[0], "kubectl") == -1 {
5255
command = "kubectl"
5356
args = append([]string{command}, args...)
5457
} else {

tests.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Author : Ky-Anh Huynh
55
# License : Public domain
66

7+
78
_gk8s() {
89
"$(pwd -P)"/gk8s "${@}"
910
}
@@ -24,6 +25,15 @@ _fail_when_command_not_found() {
2425
_gk8s :any_name -- foo/bar xyz
2526
}
2627

28+
# NOTE: helm command is required.
29+
_fail_with_helm_repo_list() {
30+
(
31+
export HELM_REPOSITORY_CONFIG=/dev/null
32+
touch ~/.config/gk8s/helm_test
33+
_gk8s :helm_test helm repo list
34+
)
35+
}
36+
2737
# NOTE: kubectl command is required.
2838
_fail_with_cluster_config_not_found() {
2939
(
@@ -118,6 +128,9 @@ _ok_to_delete_with_env_flag() {
118128
)
119129
}
120130

131+
# $1: function to test
132+
# $2: regular expression
133+
# $*: Test description
121134
_test() {
122135
fun="$1"; shift
123136
reg="$1"; shift
@@ -148,7 +161,7 @@ _test() {
148161

149162
default() {
150163
ln -sfv /bin/true kubectl
151-
mkdir -p ~/.config/gk8s
164+
mkdir -pv ~/.config/gk8s
152165

153166
_test _fail_when_command_not_found \
154167
"Command not found" \
@@ -205,6 +218,10 @@ default() {
205218
_test _ok_to_delete_with_env_flag \
206219
"Executing.*kubectl delete pods" \
207220
"Now executing actual delete command."
221+
222+
_test _fail_with_helm_repo_list \
223+
"Error: no repositories to show" \
224+
"helm would not need any separator (--)."
208225
}
209226

210227
### main routines ######################################################

0 commit comments

Comments
 (0)