From c4c68e26203cc492f0b0db3560accbe79831342e Mon Sep 17 00:00:00 2001 From: Thomas Jackson Date: Thu, 17 Jan 2019 14:32:26 -0800 Subject: [PATCH 1/4] Move SSH key path to a flag --- cmd/git-sync/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index 0df6d04..6645e9d 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -69,6 +69,8 @@ var flPassword = flag.String("password", envString("GIT_SYNC_PASSWORD", ""), var flSSH = flag.Bool("ssh", envBool("GIT_SYNC_SSH", false), "use SSH for git operations") +var flSSHSecret = flag.String("ssh-key", envString("GIT_SSH_KEY", "/etc/git-secret/ssh"), + "the ssh key to use") var flSSHKnownHosts = flag.Bool("ssh-known-hosts", envBool("GIT_KNOWN_HOSTS", true), "enable SSH known_hosts verification") @@ -513,7 +515,7 @@ func setupGitAuth(username, password, gitURL string) error { func setupGitSSH(setupKnownHosts bool) error { log.V(1).Infof("setting up git SSH credentials") - var pathToSSHSecret = "/etc/git-secret/ssh" + var pathToSSHSecret = *flSSHSecret var pathToSSHKnownHosts = "/etc/git-secret/known_hosts" fileInfo, err := os.Stat(pathToSSHSecret) From 933bbdfc1f1ad53eaf625d41aee09358006e95ef Mon Sep 17 00:00:00 2001 From: Thomas Jackson Date: Thu, 17 Jan 2019 14:35:23 -0800 Subject: [PATCH 2/4] Add flag for ssh known hosts file --- cmd/git-sync/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index 6645e9d..c775bcf 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -73,6 +73,8 @@ var flSSHSecret = flag.String("ssh-key", envString("GIT_SSH_KEY", "/etc/git-secr "the ssh key to use") var flSSHKnownHosts = flag.Bool("ssh-known-hosts", envBool("GIT_KNOWN_HOSTS", true), "enable SSH known_hosts verification") +var flSSHKnownHostsFile = flag.String("ssh-known-hosts-file", envString("GIT_KNOWN_HOSTS_FILE", "/etc/git-secret/known_hosts"), + "the known hosts file to use") var flCookieFile = flag.Bool("cookie-file", envBool("GIT_COOKIE_FILE", false), "use git cookiefile") @@ -516,7 +518,7 @@ func setupGitSSH(setupKnownHosts bool) error { log.V(1).Infof("setting up git SSH credentials") var pathToSSHSecret = *flSSHSecret - var pathToSSHKnownHosts = "/etc/git-secret/known_hosts" + var pathToSSHKnownHosts = *flSSHKnownHostsFile fileInfo, err := os.Stat(pathToSSHSecret) if err != nil { From 088065e4949e2837468240010379c6e678afe0d3 Mon Sep 17 00:00:00 2001 From: Thomas Jackson Date: Tue, 22 Jan 2019 10:36:42 -0800 Subject: [PATCH 3/4] Normalize flag names to include `-file` --- cmd/git-sync/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index c775bcf..69c7fe8 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -69,7 +69,7 @@ var flPassword = flag.String("password", envString("GIT_SYNC_PASSWORD", ""), var flSSH = flag.Bool("ssh", envBool("GIT_SYNC_SSH", false), "use SSH for git operations") -var flSSHSecret = flag.String("ssh-key", envString("GIT_SSH_KEY", "/etc/git-secret/ssh"), +var flSSHKeyFile = flag.String("ssh-key-file", envString("GIT_SSH_KEY", "/etc/git-secret/ssh"), "the ssh key to use") var flSSHKnownHosts = flag.Bool("ssh-known-hosts", envBool("GIT_KNOWN_HOSTS", true), "enable SSH known_hosts verification") @@ -517,7 +517,7 @@ func setupGitAuth(username, password, gitURL string) error { func setupGitSSH(setupKnownHosts bool) error { log.V(1).Infof("setting up git SSH credentials") - var pathToSSHSecret = *flSSHSecret + var pathToSSHSecret = *flSSHKeyFile var pathToSSHKnownHosts = *flSSHKnownHostsFile fileInfo, err := os.Stat(pathToSSHSecret) From b9c0ed3f5d796a8afc7aca9315e2487e0cd85750 Mon Sep 17 00:00:00 2001 From: Thomas Jackson Date: Tue, 22 Jan 2019 11:03:30 -0800 Subject: [PATCH 4/4] Update env vars based on comments --- cmd/git-sync/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index 69c7fe8..789befa 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -69,11 +69,11 @@ var flPassword = flag.String("password", envString("GIT_SYNC_PASSWORD", ""), var flSSH = flag.Bool("ssh", envBool("GIT_SYNC_SSH", false), "use SSH for git operations") -var flSSHKeyFile = flag.String("ssh-key-file", envString("GIT_SSH_KEY", "/etc/git-secret/ssh"), +var flSSHKeyFile = flag.String("ssh-key-file", envString("GIT_SSH_KEY_FILE", "/etc/git-secret/ssh"), "the ssh key to use") var flSSHKnownHosts = flag.Bool("ssh-known-hosts", envBool("GIT_KNOWN_HOSTS", true), "enable SSH known_hosts verification") -var flSSHKnownHostsFile = flag.String("ssh-known-hosts-file", envString("GIT_KNOWN_HOSTS_FILE", "/etc/git-secret/known_hosts"), +var flSSHKnownHostsFile = flag.String("ssh-known-hosts-file", envString("GIT_SSH_KNOWN_HOSTS_FILE", "/etc/git-secret/known_hosts"), "the known hosts file to use") var flCookieFile = flag.Bool("cookie-file", envBool("GIT_COOKIE_FILE", false),