Skip to content

Commit e565d7d

Browse files
authored
fix: update envbuilder to include kaniko cache fix (#50)
* chore: add test for copy perms * update kaniko and envbuilder to include fix * add multi-stage version of copy perms test * remove unnecessary chowns, collapse to single test * update envbuilder and kaniko
1 parent 6c66d06 commit e565d7d

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ module github.com/coder/terraform-provider-envbuilder
33
go 1.22.4
44

55
// We use our own Kaniko fork.
6-
replace github.com/GoogleContainerTools/kaniko => github.com/coder/kaniko v0.0.0-20240830141327-f307586e3dca
6+
replace github.com/GoogleContainerTools/kaniko => github.com/coder/kaniko v0.0.0-20240925122543-caa18967f374
77

88
// Required to import codersdk due to gvisor dependency.
99
replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20240702054557-aa558fbe5374
1010

1111
require (
1212
github.com/GoogleContainerTools/kaniko v1.9.2
13-
github.com/coder/envbuilder v1.0.0-rc.0.0.20240910082823-b7781d802f88
13+
github.com/coder/envbuilder v1.0.0-rc.0.0.20240925123650-9c315aabfaef
1414
github.com/coder/serpent v0.8.0
1515
github.com/docker/docker v26.1.5+incompatible
1616
github.com/gliderlabs/ssh v0.3.7

go.sum

+8-4
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,14 @@ github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoC
186186
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
187187
github.com/coder/coder/v2 v2.10.1-0.20240704130443-c2d44d16a352 h1:L/EjCuZxs5tOcqqCaASj/nu65TRYEFcTt8qRQfHZXX0=
188188
github.com/coder/coder/v2 v2.10.1-0.20240704130443-c2d44d16a352/go.mod h1:P1KoQSgnKEAG6Mnd3YlGzAophty+yKA9VV48LpfNRvo=
189-
github.com/coder/envbuilder v1.0.0-rc.0.0.20240910082823-b7781d802f88 h1:eXOILD2tWepnV1r7XZalBX0yC4NJMnpf6OP1nF8O2Ak=
190-
github.com/coder/envbuilder v1.0.0-rc.0.0.20240910082823-b7781d802f88/go.mod h1:krXpDmUsORgNNdvBe6tnwWCGGDLhabom1UUqAZq9+v0=
191-
github.com/coder/kaniko v0.0.0-20240830141327-f307586e3dca h1:PrcSWrllqipTrtet50a3VyAJEQmjziIZyhpy0bsC6o0=
192-
github.com/coder/kaniko v0.0.0-20240830141327-f307586e3dca/go.mod h1:XoTDIhNF0Ll4tLmRYdOn31udU9w5zFrY2PME/crSRCA=
189+
github.com/coder/envbuilder v1.0.0-rc.0.0.20240924170424-29636303d05f h1:1KdB2Jbo+zLuG+R08/By1BIeHBcKXiOqv95wZ5+Ewks=
190+
github.com/coder/envbuilder v1.0.0-rc.0.0.20240924170424-29636303d05f/go.mod h1:ju1iDjfVSUQS3tlaIItlRo8UwYbGN5KvOdnbOzlD/6I=
191+
github.com/coder/envbuilder v1.0.0-rc.0.0.20240925123650-9c315aabfaef h1:l9mQMoHNl7P2tiahwM2zkUCdWsjSoLsUDn30Ndgsx0Y=
192+
github.com/coder/envbuilder v1.0.0-rc.0.0.20240925123650-9c315aabfaef/go.mod h1:1Qn60Fx3oGZlwmRfTNkrGxrQJsEZ7XIUUPgzil2lte8=
193+
github.com/coder/kaniko v0.0.0-20240924160037-1e6bd4e19fc6 h1:vLlV6P0abwoOeaBwkqQxB31ZzMv483UQLhQuPvXbvRM=
194+
github.com/coder/kaniko v0.0.0-20240924160037-1e6bd4e19fc6/go.mod h1:XoTDIhNF0Ll4tLmRYdOn31udU9w5zFrY2PME/crSRCA=
195+
github.com/coder/kaniko v0.0.0-20240925122543-caa18967f374 h1:/cyXf0vTSwFh7evQqeWHXXl14aRfC4CsNIYxOenJytQ=
196+
github.com/coder/kaniko v0.0.0-20240925122543-caa18967f374/go.mod h1:XoTDIhNF0Ll4tLmRYdOn31udU9w5zFrY2PME/crSRCA=
193197
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 h1:3A0ES21Ke+FxEM8CXx9n47SZOKOpgSE1bbJzlE4qPVs=
194198
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0/go.mod h1:5UuS2Ts+nTToAMeOjNlnHFkPahrtDkmpydBen/3wgZc=
195199
github.com/coder/quartz v0.1.0 h1:cLL+0g5l7xTf6ordRnUMMiZtRE8Sq5LxpghS63vEXrQ=

internal/provider/cached_image_resource_test.go

+38
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,44 @@ RUN date > /date.txt`,
161161
)
162162
},
163163
},
164+
{
165+
// This tests correct handling of the difference in permissions between
166+
// the provider and the image when running a COPY instruction.
167+
// Added to verify fix for coder/terraform-provider-envbuilder#43
168+
name: "copy_perms",
169+
files: map[string]string{
170+
"Dockerfile": `
171+
FROM localhost:5000/test-ubuntu:latest AS a
172+
COPY date.txt /date.txt
173+
FROM localhost:5000/test-ubuntu:latest
174+
COPY --from=a /date.txt /date.txt`,
175+
"date.txt": fmt.Sprintf("%d", time.Now().Unix()),
176+
},
177+
extraEnv: map[string]string{
178+
"CODER_AGENT_TOKEN": "some-token",
179+
"CODER_AGENT_URL": "https://coder.example.com",
180+
"FOO": testEnvValue,
181+
"ENVBUILDER_GIT_URL": "https://not.the.real.git/url",
182+
"ENVBUILDER_CACHE_REPO": "not-the-real-cache-repo",
183+
"ENVBUILDER_DOCKERFILE_PATH": "Dockerfile",
184+
},
185+
assertEnv: func(t *testing.T, deps testDependencies) resource.TestCheckFunc {
186+
return resource.ComposeAggregateTestCheckFunc(
187+
assertEnv(t,
188+
"CODER_AGENT_TOKEN", "some-token",
189+
"CODER_AGENT_URL", "https://coder.example.com",
190+
"ENVBUILDER_CACHE_REPO", deps.CacheRepo,
191+
"ENVBUILDER_DOCKERFILE_PATH", "Dockerfile",
192+
"ENVBUILDER_DOCKER_CONFIG_BASE64", deps.DockerConfigBase64,
193+
"ENVBUILDER_GIT_SSH_PRIVATE_KEY_PATH", deps.Repo.Key,
194+
"ENVBUILDER_GIT_URL", deps.Repo.URL,
195+
"ENVBUILDER_REMOTE_REPO_BUILD_MODE", "true",
196+
"ENVBUILDER_VERBOSE", "true",
197+
"FOO", "bar\nbaz",
198+
),
199+
)
200+
},
201+
},
164202
} {
165203
t.Run(tc.name, func(t *testing.T) {
166204
//nolint: paralleltest

0 commit comments

Comments
 (0)