Skip to content

Commit

Permalink
fix: removes unneeded code
Browse files Browse the repository at this point in the history
  • Loading branch information
faiq committed Oct 9, 2024
1 parent 8dc7fd4 commit 86f324d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cmd/konvoy-image-wrapper/cmd/create-package-bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func getKubernetesVerisonFromAnsible() (string, error) {
return kubeVersion, nil
}

//nolint:funlen // most of this is long for readability
func (r *Runner) CreatePackageBundle(args []string) error {
var (
osFlag string
Expand Down Expand Up @@ -141,7 +142,6 @@ func (r *Runner) CreatePackageBundle(args []string) error {
return err
}
}

fetchKubernetesRPMs := true
kubernetesVersion := kubernetesVersionFlag
if kubernetesVersion == "" {
Expand All @@ -153,6 +153,7 @@ func (r *Runner) CreatePackageBundle(args []string) error {
fetchKubernetesRPMs = false
}
if eusReposFlag {
//nolint:goconst //we don't need to make true a constant
r.env["EUS_REPOS"] = "true"
}
if fetchKubernetesRPMs {
Expand Down
14 changes: 8 additions & 6 deletions cmd/konvoy-image-wrapper/cmd/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ func (r *Runner) mountFileEnv(envName string, containerPath string) error {
if containerPath == "" {
containerPath = absFilePath
}

r.env[envName] = containerPath
r.addBindVolume(absFilePath, containerPath, "readonly")
return nil
Expand All @@ -305,8 +304,9 @@ func (r *Runner) setHTTPProxyEnv() {
}
}

func (r *Runner) setAnsibleHostKeyChecking() {
func (r *Runner) setAnsibleEnvs() {
r.env["ANSIBLE_HOST_KEY_CHECKING"] = "false"
r.env["ANSIBLE_LOCAL_TEMP"] = containerWorkingDir
}

func (r *Runner) setupSSHAgent() {
Expand Down Expand Up @@ -337,7 +337,6 @@ func (r *Runner) dockerRun(args []string) error {

if runtime.GOOS != windows && r.containerEngine == containerEngineDocker {
cmd.Args = append(cmd.Args, "-u", r.usr.Uid+":"+r.usr.Gid)
r.addBindVolume(r.tempDir, r.homeDir)
}

for _, gid := range r.supplementaryGroupIDs {
Expand Down Expand Up @@ -481,6 +480,7 @@ func (r *Runner) maskSSHKnownHosts() error {
return nil
}

//nolint:gocyclo // its a complicated function.
func (r *Runner) Run(args []string) error {
// Get the Konvoy image version for marker file
var err error
Expand Down Expand Up @@ -516,8 +516,10 @@ func (r *Runner) Run(args []string) error {
return fmt.Errorf("failed to make temp %w", err)
}
defer func() {
fmt.Println("Removing temporary directory", r.tempDir)
os.RemoveAll(r.tempDir)
removeErr := os.RemoveAll(r.tempDir)
if removeErr != nil {
fmt.Fprintf(os.Stderr, "error removing kib temporary directory: %s\n", removeErr)
}
}()

// Setup the user and group mappings in the container so that uid and
Expand Down Expand Up @@ -560,7 +562,7 @@ func (r *Runner) Run(args []string) error {
return fmt.Errorf("failed to load image %w", err)
}

r.setAnsibleHostKeyChecking()
r.setAnsibleEnvs()
r.setupSSHAgent()
// Run the command in the konvoy docker container.
return r.dockerRun(args)
Expand Down

0 comments on commit 86f324d

Please sign in to comment.