-
Notifications
You must be signed in to change notification settings - Fork 293
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
Trusted builders fix #2205
Trusted builders fix #2205
Conversation
…ed builders and trusted builders, there were several places that still had logic referencing suggested builders in the trusted context. This PR updates those code paths to only consider trusted builders and extracts out a shared function `IsKnownTrustedBuilder` that can be used for "is this a trusted builder" checks. Fixes buildpacks#2198 Signed-off-by: Colin Casey <casey.colin@gmail.com>
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.
Thank you for fixing this! The changes look good to me to fix the issue, though it would be good to have a test for this. I presume something similar to the tests here?
pack/internal/commands/build_test.go
Lines 93 to 128 in ce8db3c
when("the builder is trusted", func() { | |
it.Before(func() { | |
mockClient.EXPECT(). | |
Build(gomock.Any(), EqBuildOptionsWithTrustedBuilder(true)). | |
Return(nil) | |
cfg := config.Config{TrustedBuilders: []config.TrustedBuilder{{Name: "my-builder"}}} | |
command = commands.Build(logger, cfg, mockClient) | |
}) | |
it("sets the trust builder option", func() { | |
logger.WantVerbose(true) | |
command.SetArgs([]string{"image", "--builder", "my-builder"}) | |
h.AssertNil(t, command.Execute()) | |
h.AssertContains(t, outBuf.String(), "Builder 'my-builder' is trusted") | |
}) | |
when("a lifecycle-image is provided", func() { | |
it("ignoring the mentioned lifecycle image, going with default version", func() { | |
command.SetArgs([]string{"--builder", "my-builder", "image", "--lifecycle-image", "some-lifecycle-image"}) | |
h.AssertNil(t, command.Execute()) | |
h.AssertContains(t, outBuf.String(), "Warning: Ignoring the provided lifecycle image as the builder is trusted, running the creator in a single container using the provided builder") | |
}) | |
}) | |
}) | |
when("the builder is suggested", func() { | |
it("sets the trust builder option", func() { | |
mockClient.EXPECT(). | |
Build(gomock.Any(), EqBuildOptionsWithTrustedBuilder(true)). | |
Return(nil) | |
logger.WantVerbose(true) | |
command.SetArgs([]string{"image", "--builder", "heroku/builder:24"}) | |
h.AssertNil(t, command.Execute()) | |
h.AssertContains(t, outBuf.String(), "Builder 'heroku/builder:24' is trusted") | |
}) | |
}) |
Signed-off-by: Colin Casey <casey.colin@gmail.com>
Signed-off-by: Colin Casey <casey.colin@gmail.com>
I am ok with the change, I agree with Ed, add the missing test case |
Signed-off-by: Colin Casey <casey.colin@gmail.com>
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.
Thank you - looks good to me :-)
Signed-off-by: Colin Casey <casey.colin@gmail.com>
Summary
With the changes introduced in #2043 for separating suggested builders and trusted builders, there were several places that still had logic referencing suggested builders in the trusted context. This PR updates those code paths to only consider trusted builders and extracts out a shared function
IsKnownTrustedBuilder
that can be used for "is this a trusted builder" checks.Output
There is a small output change when calling
pack config trusted-builders remove <x>
with a builder in the known trusted list. The previous output gave the following message:Which now says:
Documentation
Related
Resolves #2198