-
Notifications
You must be signed in to change notification settings - Fork 43
chore: make sure directives are correct #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1354,6 +1354,49 @@ COPY --from=a /root/date.txt /date.txt`, testImageAlpine, testImageAlpine), | |
}) | ||
} | ||
|
||
func TestDefaultDirectivesOnPushedImage(t *testing.T) { | ||
t.Parallel() | ||
|
||
srv := createGitServer(t, gitServerOptions{ | ||
files: map[string]string{ | ||
".devcontainer/entrypoint.sh": "#!/bin/sh\necho 'Hello, world!'", | ||
".devcontainer/Dockerfile": "FROM " + testImageAlpine + "\n" + | ||
"RUN addgroup -S coder && adduser -S coder -G coder \n" + | ||
// These should be overridden by the default directives | ||
"USER coder\n" + | ||
"WORKDIR /app\n" + | ||
"ENTRYPOINT [\"./entrypoint.sh\"]", | ||
BrunoQuaresma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
".devcontainer/devcontainer.json": `{ | ||
"name": "Test", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
}`, | ||
}, | ||
}) | ||
|
||
testReg := setupInMemoryRegistry(t, setupInMemoryRegistryOpts{}) | ||
testRepo := testReg + "/test" | ||
ref, err := name.ParseReference(testRepo + ":latest") | ||
require.NoError(t, err) | ||
|
||
_, err = runEnvbuilder(t, options{env: []string{ | ||
envbuilderEnv("GIT_URL", srv.URL), | ||
envbuilderEnv("CACHE_REPO", testRepo), | ||
envbuilderEnv("PUSH_IMAGE", "1"), | ||
}}) | ||
require.NoError(t, err) | ||
|
||
image, err := remote.Image(ref) | ||
require.NoError(t, err, "expected image to be present after build + push") | ||
configFile, err := image.ConfigFile() | ||
require.NoError(t, err, "expected image to return a config file") | ||
|
||
require.Equal(t, configFile.Config.User, "root", "value does not match any of the possible root user values.") | ||
require.Equal(t, configFile.Config.WorkingDir, "/", "expected image to have root working directory") | ||
require.Equal(t, configFile.Config.Entrypoint, []string{"/.envbuilder/bin/envbuilder"}, "expected image to have envbuilder entrypoint") | ||
Comment on lines
+1395
to
+1397
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably a good idea to assert the opposite in some other test when we don't push There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If they are not pushed, what reference can we use to get the local image and inspect it? |
||
} | ||
|
||
type setupInMemoryRegistryOpts struct { | ||
Username string | ||
Password string | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that you'll have a merge conflict with the other PR: #216