Skip to content
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

Removing validation of deprecated io.buildpacks.stack.id #2119

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions acceptance/assertions/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ func (o OutputAssertionManager) ReportsSkippingRestore() {
func (o OutputAssertionManager) ReportsRunImageStackNotMatchingBuilder(runImageStack, builderStack string) {
o.testObject.Helper()

o.assert.Contains(
o.output,
fmt.Sprintf("run-image stack id '%s' does not match builder stack '%s'", runImageStack, builderStack),
)
o.assert.Contains(o.output, "Warning: deprecated usage of stack")
}

func (o OutputAssertionManager) WithoutColors() {
Expand Down
17 changes: 10 additions & 7 deletions pkg/client/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,13 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error {
pathsConfig.targetRunImagePath = targetRunImagePath
pathsConfig.hostRunImagePath = hostRunImagePath
}
runImage, err := c.validateRunImage(ctx, runImageName, fetchOptions, bldr.StackID)
runImage, warnings, err := c.validateRunImage(ctx, runImageName, fetchOptions, bldr.StackID)
if err != nil {
return errors.Wrapf(err, "invalid run-image '%s'", runImageName)
}
for _, warning := range warnings {
c.logger.Warn(warning)
}

var runMixins []string
if _, err := dist.GetLabel(runImage, stack.MixinsLabel, &runMixins); err != nil {
Expand Down Expand Up @@ -799,22 +802,22 @@ func (c *Client) getBuilder(img imgutil.Image) (*builder.Builder, error) {
return bldr, nil
}

func (c *Client) validateRunImage(context context.Context, name string, opts image.FetchOptions, expectedStack string) (imgutil.Image, error) {
func (c *Client) validateRunImage(context context.Context, name string, opts image.FetchOptions, expectedStack string) (builderImage imgutil.Image, warnings []string, err error) {
natalieparellano marked this conversation as resolved.
Show resolved Hide resolved
if name == "" {
return nil, errors.New("run image must be specified")
return nil, nil, errors.New("run image must be specified")
}
img, err := c.imageFetcher.Fetch(context, name, opts)
if err != nil {
return nil, err
return nil, nil, err
}
stackID, err := img.Label("io.buildpacks.stack.id")
if err != nil {
return nil, err
return nil, nil, err
}
if stackID != expectedStack {
return nil, fmt.Errorf("run-image stack id '%s' does not match builder stack '%s'", stackID, expectedStack)
warnings = append(warnings, "deprecated usage of stack")
}
return img, nil
return builderImage, warnings, nil
natalieparellano marked this conversation as resolved.
Show resolved Hide resolved
}

func (c *Client) validateMixins(additionalBuildpacks []buildpack.BuildModule, bldr *builder.Builder, runImageName string, runMixins []string) error {
Expand Down
10 changes: 5 additions & 5 deletions pkg/client/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,14 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
h.AssertNil(t, fakeRunImage.SetLabel("io.buildpacks.stack.id", "other.stack"))
})

it("errors", func() {
h.AssertError(t, subject.Build(context.TODO(), BuildOptions{
it("warning", func() {
err := subject.Build(context.TODO(), BuildOptions{
Image: "some/app",
Builder: defaultBuilderName,
RunImage: "custom/run",
}),
"invalid run-image 'custom/run': run-image stack id 'other.stack' does not match builder stack 'some.stack.id'",
)
})
h.AssertNil(t, err)
h.AssertContains(t, outBuf.String(), "Warning: deprecated usage of stack")
})
})

Expand Down
Loading