mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-01 00:23:56 +08:00 
			
		
		
		
	bake: git auth support for remote definitions
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
		| @@ -29,6 +29,7 @@ var bakeTests = []func(t *testing.T, sb integration.Sandbox){ | ||||
| 	testBakeLocal, | ||||
| 	testBakeLocalMulti, | ||||
| 	testBakeRemote, | ||||
| 	testBakeRemoteAuth, | ||||
| 	testBakeRemoteCmdContext, | ||||
| 	testBakeRemoteLocalOverride, | ||||
| 	testBakeLocalCwdOverride, | ||||
| @@ -144,6 +145,41 @@ EOT | ||||
| 	require.FileExists(t, filepath.Join(dirDest, "foo")) | ||||
| } | ||||
|  | ||||
| func testBakeRemoteAuth(t *testing.T, sb integration.Sandbox) { | ||||
| 	bakefile := []byte(` | ||||
| target "default" { | ||||
| 	dockerfile-inline = <<EOT | ||||
| FROM scratch | ||||
| COPY foo /foo | ||||
| EOT | ||||
| } | ||||
| `) | ||||
| 	dir := tmpdir( | ||||
| 		t, | ||||
| 		fstest.CreateFile("docker-bake.hcl", bakefile, 0600), | ||||
| 		fstest.CreateFile("foo", []byte("foo"), 0600), | ||||
| 	) | ||||
| 	dirDest := t.TempDir() | ||||
|  | ||||
| 	git, err := gitutil.New(gitutil.WithWorkingDir(dir)) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	gitutil.GitInit(git, t) | ||||
| 	gitutil.GitAdd(git, t, "docker-bake.hcl", "foo") | ||||
| 	gitutil.GitCommit(git, t, "initial commit") | ||||
|  | ||||
| 	token := identity.NewID() | ||||
| 	addr := gitutil.GitServeHTTP(git, t, gitutil.WithAccessToken(token)) | ||||
|  | ||||
| 	out, err := bakeCmd(sb, withDir(dir), | ||||
| 		withEnv("BUILDX_BAKE_GIT_AUTH_TOKEN="+token), | ||||
| 		withArgs(addr, "--set", "*.output=type=local,dest="+dirDest), | ||||
| 	) | ||||
| 	require.NoError(t, err, out) | ||||
|  | ||||
| 	require.FileExists(t, filepath.Join(dirDest, "foo")) | ||||
| } | ||||
|  | ||||
| func testBakeRemoteLocalOverride(t *testing.T, sb integration.Sandbox) { | ||||
| 	remoteBakefile := []byte(` | ||||
| target "default" { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 CrazyMax
					CrazyMax