github.com/henvic/wedeploycli@v1.7.6-0.20200319005353-3630f582f284/command/gitcredentialhelper/gitcredentialhelper.go (about) 1 package gitcredentialhelper 2 3 import ( 4 "errors" 5 "fmt" 6 "os" 7 8 "github.com/henvic/wedeploycli/envs" 9 ) 10 11 // Run the credential helper 12 func Run(args []string) error { 13 if len(args) != 3 { 14 return errors.New("usage: lcp git-credential-helper get") 15 } 16 17 // this is a read-only credential helper: ignore transparently other commands 18 // https://www.kernel.org/pub/software/scm/git/docs/technical/api-credentials.html 19 if args[2] != "get" { 20 return nil 21 } 22 23 var token = os.Getenv(envs.GitCredentialRemoteToken) 24 25 if token == "" { 26 return errors.New("internal command: missing credentials") 27 } 28 29 fmt.Printf("username=%s\npassword=\n", token) 30 return nil 31 }