Skip to content

Commit

Permalink
pkg/git: fix ssh credentials detection 🦀
Browse files Browse the repository at this point in the history
To detect ssh cerdentials (and validate the git clone url with
cerdentials), we do check if there is a `$HOME/.ssh` folder. With
`disable-home-env-overwrite` we do not overwrite `$HOME` env anymore,
and thus we have *no* control where `$HOME` is and wether the image
ships it with a `.ssh` or not.

This fixes it by looking at a path we control no matter how the
controller is configured : `pipeline.CredsDir` (`/tekton/creds`).

Signed-off-by: Vincent Demeester <[email protected]>
(cherry picked from commit b35bec8)
Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester authored and tekton-robot committed Nov 2, 2020
1 parent 3e31262 commit 240bf12
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"strings"

homedir "github.com/mitchellh/go-homedir"
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -253,9 +254,8 @@ func userHasKnownHostsFile(logger *zap.SugaredLogger) (bool, error) {
}

func validateGitAuth(logger *zap.SugaredLogger, url string) {
homeenv := os.Getenv("HOME")
sshCred := true
if _, err := os.Stat(homeenv + "/.ssh"); os.IsNotExist(err) {
if _, err := os.Stat(pipeline.CredsDir + "/.ssh"); os.IsNotExist(err) {
sshCred = false
}
urlSSHFormat := ValidateGitSSHURLFormat(url)
Expand Down

0 comments on commit 240bf12

Please sign in to comment.