From 9ca548bd3bd0b1e1856fe55048928c24dde60c17 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Mon, 2 Nov 2020 11:24:43 +0100 Subject: [PATCH] =?UTF-8?q?pkg/git:=20fix=20ssh=20credentials=20detection?= =?UTF-8?q?=20=F0=9F=A6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit b35bec85551597c18544a2cf1e8999fbf55b8af3) Signed-off-by: Vincent Demeester --- pkg/git/git.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/git/git.go b/pkg/git/git.go index 9d7dca7419d..25fa7e17bd4 100644 --- a/pkg/git/git.go +++ b/pkg/git/git.go @@ -26,6 +26,7 @@ import ( "strings" homedir "github.com/mitchellh/go-homedir" + "github.com/tektoncd/pipeline/pkg/apis/pipeline" "go.uber.org/zap" ) @@ -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)