Skip to content

update(uri): support for .cnb files in dependencies#420

Open
till wants to merge 2 commits intopaketo-buildpacks:mainfrom
hostwithquantum:improve-cnb-handling
Open

update(uri): support for .cnb files in dependencies#420
till wants to merge 2 commits intopaketo-buildpacks:mainfrom
hostwithquantum:improve-cnb-handling

Conversation

@till
Copy link

@till till commented Aug 21, 2025

Summary

Adds support for .cnb files for dependencies, leaving them untouched
during an update process. Supports both local paths, but an archive
from a http/https server alike.

I extracted the code from commands into its own file, to be able to
add a bit of test coverage.

Also extracted some of the check code (for suffix/prefix) into the uri
file to be able to reuse it and make it a bit more readable (hopefully).

LBNL, update the parser to keep http/https scheme around so the uri in
the dependencies doesn't get the scheme stripped.

Resolves: #358

Use Cases

A cnb file in the local file system or on a remote http/https server.

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.
  • I'm happy with the commit history on this PR (I have rebased/squashed as needed).

@till till requested a review from a team as a code owner August 21, 2025 20:02
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 21, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: jericop / name: Jerico Pena (affca14)

@till till force-pushed the improve-cnb-handling branch 2 times, most recently from 54c180e to 1590fdc Compare August 22, 2025 19:49
@pacostas
Copy link
Member

pacostas commented Sep 4, 2025

Hello @till ! Is on my todo list for reviewing it. I just need to find some time :S

Copy link
Member

@pacostas pacostas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice contribution! Could please rebase your branch and adjust your code to match the latest changes as the --no-cnb-registry flag has been deprecated.

I have also added two comments. Feel free to change your code accordingly or not as is mostly aesthetics :)

@pacostas
Copy link
Member

@till Ping

@till till force-pushed the improve-cnb-handling branch 2 times, most recently from d022aef to 991d4dc Compare November 19, 2025 14:27
@till till requested a review from pacostas November 19, 2025 14:28
@till till force-pushed the improve-cnb-handling branch from 991d4dc to cd4de74 Compare November 20, 2025 14:25
@@ -37,16 +37,25 @@ func (d *PackageConfigDependency) UnmarshalTOML(v interface{}) error {
}

if d.URI != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also please add some tests for covering the changes on the package_config file?

@till till force-pushed the improve-cnb-handling branch from 73db74b to 3f1e867 Compare December 3, 2025 16:04

d.URI = strings.TrimPrefix(uri.String(), "//")
// Static URIs with http/https scheme are left unchanged
if uri.Scheme == "http" || uri.Scheme == "https" {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only change. And it should be covered by the integration test?

}

if d.URI != "" {
if !strings.HasPrefix(d.URI, "urn:cnb:registry") {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just removes the if wrapping and exists earlier.

@till
Copy link
Author

till commented Dec 3, 2025

@pacostas Can you add the label? I think minor is fine.

@till till requested a review from pacostas December 10, 2025 09:04
Adds support for .cnb files and directories for dependencies, leaving
them untouched during the update process. Supports cnb files from a
local paths and from a http/https server alike.

Extracted some of the check code (for suffix/prefix) into the uri
file to be able to reuse it and make it a bit more readable (hopefully).

LBNL, update the parser to keep http/https scheme around so the uri in
the dependencies doesn't get the scheme stripped.

Resolves: paketo-buildpacks#358
@till till force-pushed the improve-cnb-handling branch from 3f1e867 to 3eefac2 Compare December 12, 2025 14:02

uri.Scheme = ""
// Parse the URI to check its scheme
uri, err := url.Parse(d.URI)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work, in case you have a ./hello/world.tgz

for i, dependency := range config.Dependencies {
if !strings.HasPrefix(dependency.URI, "docker://") && !strings.HasPrefix(dependency.URI, "urn:cnb:registry") {
// Skip static URIs (local paths, HTTP URLs, etc.) - leave them unchanged
if IsStaticURI(dependency) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not get inside the if statement, in case you have a ./hello/world.tgz uri


d.URI = strings.TrimPrefix(uri.String(), "//")
// Static URIs with http/https scheme are left unchanged
if uri.Scheme == "http" || uri.Scheme == "https" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here you can use the buildpack.GetLocatorType function

if uri.Scheme == "http" || uri.Scheme == "https" {
return nil
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On this function, somewhere we should validate that local files that are referenced on the package.toml, actually exists locally

})
})

context("when dependencies include .cnb archives", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we dont need a new section just for the .cnb archives. Can you add the .cnb testing scenarios in an existing integration test? It would be nice not to increase the amount of integration tests if is not necessary.

expected: true,
},
{
name: "non-existent relative path",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is failing, not due to the file path does not exist, but because the getlocator function can not recognize it as a buildpack.URILocator. Extra code is necessary to ensure that is a file path.

expected: true,
},
{
name: "non-existent relative path",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a scenario when the file exists?

expected: false,
},
{
name: "non-existent absolute path",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is failing, not due to the file path does not exist, but because the getlocator function can not recognize it as a buildpack.URILocator. Extra code is necessary to ensure that is a file path.

expected: false,
},
{
name: "non-existent absolute path",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a scenario when the file exists?

@jericop jericop self-requested a review December 15, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update-builder and update-buildpack treat every URI as a docker image

4 participants