Skip to content

Commit

Permalink
bugfix --kubeconfig parameter for kubectl-minio proxy command (#1369)
Browse files Browse the repository at this point in the history
* add kubeconfig flag to proxy command
* little refactor to simpify command parameters
  • Loading branch information
pjuarezd committed Dec 13, 2022
1 parent dd39a12 commit 0689133
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 2 additions & 4 deletions kubectl-minio/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,9 @@ func (o *deleteCmd) run(writer io.Writer) error {

path, _ := rootCmd.Flags().GetString(kubeconfig)

var parameters []string
parameters := []string{"delete", "-f", "-"}
if path != "" {
parameters = append(parameters, "--kubeconfig", path, "delete", "-f", "-")
} else {
parameters = append(parameters, "delete", "-f", "-")
parameters = append([]string{"--kubeconfig", path}, parameters...)
}

// do kubectl apply
Expand Down
6 changes: 2 additions & 4 deletions kubectl-minio/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,9 @@ func (o *operatorInitCmd) run(writer io.Writer) error {

path, _ := rootCmd.Flags().GetString(kubeconfig)

var parameters []string
parameters := []string{"apply", "-f", "-"}
if path != "" {
parameters = append(parameters, "--kubeconfig", path, "apply", "-f", "-")
} else {
parameters = append(parameters, "apply", "-f", "-")
parameters = append([]string{"--kubeconfig", path}, parameters...)
}
// do kubectl apply
cmd := exec.Command("kubectl", parameters...)
Expand Down
7 changes: 6 additions & 1 deletion kubectl-minio/cmd/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,13 @@ func servicePortForwardPort(ctx context.Context, namespace, service, port string
defer close(ch)
// service we are going to forward
serviceName := fmt.Sprintf("service/%s", service)
path, _ := rootCmd.Flags().GetString(kubeconfig)
parameters := []string{"port-forward", "--address", "0.0.0.0", "-n", namespace, serviceName, port}
if path != "" {
parameters = append([]string{"--kubeconfig", path}, parameters...)
}
// command to run
cmd := exec.CommandContext(ctx, "kubectl", "port-forward", "--address", "0.0.0.0", "-n", namespace, serviceName, port)
cmd := exec.CommandContext(ctx, "kubectl", parameters...)
// prepare to capture the output
var errStdout, errStderr error
stdoutIn, _ := cmd.StdoutPipe()
Expand Down

0 comments on commit 0689133

Please sign in to comment.