(c *dagger.Client, t *testctx.T, tc vcsTestCase)
| 8077 | } |
| 8078 | |
| 8079 | func privateRepoSetup(c *dagger.Client, t *testctx.T, tc vcsTestCase) (dagger.WithContainerFunc, func()) { |
| 8080 | var socket *dagger.Socket |
| 8081 | cleanup := func() {} |
| 8082 | if tc.sshKey { |
| 8083 | var sockPath string |
| 8084 | sockPath, cleanup = setupPrivateRepoSSHAgent(t) |
| 8085 | socket = c.Host().UnixSocket(sockPath) |
| 8086 | } |
| 8087 | |
| 8088 | return func(ctr *dagger.Container) *dagger.Container { |
| 8089 | if socket != nil { |
| 8090 | ctr = ctr. |
| 8091 | WithUnixSocket("/sock/unix-socket", socket). |
| 8092 | WithEnvVariable("SSH_AUTH_SOCK", "/sock/unix-socket") |
| 8093 | } |
| 8094 | if token := tc.token(); token != "" { |
| 8095 | ctr = ctr. |
| 8096 | WithNewFile("/tmp/git-config", makeGitCredentials("https://"+tc.expectedHost, "git", token)). |
| 8097 | WithEnvVariable("GIT_CONFIG_GLOBAL", "/tmp/git-config") |
| 8098 | } |
| 8099 | |
| 8100 | return ctr |
| 8101 | }, cleanup |
| 8102 | } |
| 8103 | |
| 8104 | func makeGitCredentials(url string, username string, token string) string { |
| 8105 | helper := fmt.Sprintf(`!f() { test "$1" = get && echo -e "password=%s\nusername=%s"; }; f`, token, username) |
no test coverage detected