From fc7674e5ae19ea7df12c6756bfb131d9c24f3aa4 Mon Sep 17 00:00:00 2001 From: Renato Correa Date: Fri, 16 Apr 2021 17:24:15 +0200 Subject: [PATCH] Remove --generator flag, as its been deprecated --- CHANGELOG.md | 3 +++ operations/k8s/executor.go | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32b4b13..25ca716 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 1.17.0 - 2021-04-06 +### Fixed +- Compatibility with new versions of `kubectl` by removing deprecated parameter from the command + ### Fixed - SASL mechanism support now also implemented for cluster admin - process no longer gets stuck when deserialization error occurs diff --git a/operations/k8s/executor.go b/operations/k8s/executor.go index dff675e..e92d1c3 100644 --- a/operations/k8s/executor.go +++ b/operations/k8s/executor.go @@ -2,12 +2,13 @@ package k8s import ( "fmt" - "github.com/deviceinsight/kafkactl/operations" - "github.com/deviceinsight/kafkactl/output" "math/rand" "regexp" "strconv" "strings" + + "github.com/deviceinsight/kafkactl/operations" + "github.com/deviceinsight/kafkactl/output" ) type Version struct { @@ -37,7 +38,6 @@ func randomString(n int) string { } func getKubectlVersion(kubectlBinary string, runner Runner) Version { - bytes, err := runner.ExecuteAndReturn(kubectlBinary, []string{"version", "--client", "--short"}) if err != nil { output.Fail(err) @@ -97,7 +97,6 @@ func (kubectl *executor) SetKubectlBinary(bin string) { } func (kubectl *executor) Run(dockerImageType string, kafkactlArgs []string, podEnvironment []string) error { - if KafkaCtlVersion == "" { KafkaCtlVersion = "latest" } @@ -105,8 +104,10 @@ func (kubectl *executor) Run(dockerImageType string, kafkactlArgs []string, podE podName := "kafkactl-" + randomString(10) - kubectlArgs := []string{"run", "--generator=run-pod/v1", "--rm", "-i", "--tty", "--restart=Never", podName, - "--image", dockerImage} + kubectlArgs := []string{ + "run", "--rm", "-i", "--tty", "--restart=Never", podName, + "--image", dockerImage, + } if kubectl.kubeConfig != "" { kubectlArgs = append(kubectlArgs, "--kubeconfig", kubectl.kubeConfig) @@ -130,7 +131,6 @@ func (kubectl *executor) Run(dockerImageType string, kafkactlArgs []string, podE } func (kubectl *executor) exec(args []string) error { - cmd := fmt.Sprintf("exec: %s %s", kubectl.kubectlBinary, join(args)) output.Debugf("kubectl version: %d.%d.%d", kubectl.version.Major, kubectl.version.Minor, kubectl.version.Patch) output.Debugf(cmd)