Skip to content

Commit

Permalink
Merge pull request #83 from renatojf/feat/kubectl
Browse files Browse the repository at this point in the history
Remove --generator flag, as its been deprecated
  • Loading branch information
d-rk authored May 17, 2021
2 parents b02e160 + 8282b3f commit 3fc7c38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Compatibility with new versions of `kubectl` by removing deprecated parameter from the command

## 1.17.0 - 2021-04-06

### Fixed
Expand Down
14 changes: 7 additions & 7 deletions operations/k8s/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -97,16 +97,17 @@ func (kubectl *executor) SetKubectlBinary(bin string) {
}

func (kubectl *executor) Run(dockerImageType string, kafkactlArgs []string, podEnvironment []string) error {

if KafkaCtlVersion == "" {
KafkaCtlVersion = "latest"
}
dockerImage := "deviceinsight/kafkactl:" + KafkaCtlVersion + "-" + dockerImageType

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)
Expand All @@ -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)
Expand Down

0 comments on commit 3fc7c38

Please sign in to comment.