Skip to content

Commit

Permalink
fix SSH known_hosts file create problem (#578)
Browse files Browse the repository at this point in the history
Signed-off-by: Roke Jung <roke@redhat.com>
  • Loading branch information
rokej committed Sep 17, 2021
1 parent fe69cee commit e9b78bb
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions pkg/utils/gitrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,19 @@ func getConnectionOptions(cloneOptions *GitCloneOption, primary bool) (connectio
ReferenceName: cloneOptions.Branch,
}

// The destination directory needs to be created here
err = os.RemoveAll(cloneOptions.DestDir)

if err != nil {
klog.Warning(err, "Failed to remove directory ", cloneOptions.DestDir)
}

err = os.MkdirAll(cloneOptions.DestDir, os.ModePerm)

if err != nil {
return nil, err
}

if strings.HasPrefix(options.URL, "http") {
klog.Info("Connecting to Git server via HTTP")

Expand Down Expand Up @@ -218,18 +231,6 @@ func getConnectionOptions(cloneOptions *GitCloneOption, primary bool) (connectio
}
}

err = os.RemoveAll(cloneOptions.DestDir)

if err != nil {
klog.Warning(err, "Failed to remove directory ", cloneOptions.DestDir)
}

err = os.MkdirAll(cloneOptions.DestDir, os.ModePerm)

if err != nil {
return nil, err
}

return options, nil
}

Expand Down

0 comments on commit e9b78bb

Please sign in to comment.