-
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
Fix pack buildpack new --targets #2123
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2123 +/- ##
==========================================
+ Coverage 70.19% 70.21% +0.02%
==========================================
Files 233 233
Lines 17086 17097 +11
==========================================
+ Hits 11992 12003 +11
Misses 4325 4325
Partials 769 769
Flags with carried forward coverage won't be shown. Click here to find out more. |
@@ -56,10 +56,10 @@ type Target struct { | |||
OS string `json:"os" toml:"os"` | |||
Arch string `json:"arch" toml:"arch"` | |||
ArchVariant string `json:"variant,omitempty" toml:"variant,omitempty"` | |||
Distributions []Distribution `json:"distributions,omitempty" toml:"distributions,omitempty"` | |||
Distributions []Distribution `json:"distros,omitempty" toml:"distros,omitempty"` |
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 am not sure how many people started using these new fields, but I will need to leave some Note in the release note for pack 0.34.0
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.
The paketo
team (and Broadcom commercial teams) ran into an issue around this. Specifically, newer versions of the lifecycle require [[targets.distributions]]
in buildpack.toml
but pack build
does not pick up those fields correctly.
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 ran the scenario from @edmorley
Note: pack
is the binary compiled from the branch
> pack buildpack new testcase-targets-distros --api 0.10 --targets "linux/amd64:ubuntu@123"
create buildpack.toml
create bin/build
create bin/detect
Successfully created testcase-targets-distros
> cat testcase-targets-distros/buildpack.toml
api = "0.10"
WithWindowsBuild = false
WithLinuxBuild = false
[buildpack]
id = "testcase-targets-distros"
version = "1.0.0"
[[targets]]
os = "linux"
arch = "amd64"
[[targets.distros]]
name = "ubuntu"
version = "123"
Everything looks fine
I did the following test, I tried to package the Buildpack generated. Using the branch binary everything is fine, as expected > $PACK_BINARY_FROM_BRANCH buildpack package testcase-targets-distros --format file
Successfully created package testcase-targets-distros.cnb and saved to file And then, I tried to use the current > pack buildpack package testcase-targets-distros-2 --format file
ERROR: no compatible stacks among provided buildpacks As expected an error must be thrown because we changed the toml schema, my only concern is, should we add a helpful message for end-users to point them out to update:
This could happen if we try to execute the new pack version, containing this fix, with old toml schema |
Sorry about all the messages. The new pack version containing this feature is not going to fail with a buildpack using the previous schema, so things could change for end-users and they wouldn't notice These examples uses the binary for this branch and package the same buildpack with the previous and the new schema # Metadata is fine, it has the expected values
> docker inspect targets-distros-new-schema-new-version | jq '.[] | .Config.Labels | ."io.buildpacks.buildpack.layers" | fromjson' | jq
{
"testcase-targets-distros": {
"1.0.0": {
"api": "0.10",
"targets": [
{
"os": "linux",
"arch": "amd64",
"distros": [
{
"name": "ubuntu"
}
]
}
],
"layerDiffID": "sha256:5274312d546cfc8a8803d2ba932df72a27c8e65fb5015f4a6870dfef030764bf"
}
}
}
# Metadata is missing distros/name but the package is created.
> docker inspect targets-distros-old-schema-new-version | jq '.[] | .Config.Labels | ."io.buildpacks.buildpack.layers" | fromjson' | jq
{
"testcase-targets-distros": {
"1.0.0": {
"api": "0.10",
"targets": [
{
"os": "linux",
"arch": "amd64"
}
],
"layerDiffID": "sha256:60a056247c8b9513c22737dbca36a092836a9cd4bbedb4cf64f7f2172938df21"
}
}
} I think we should:
|
I'd love to see a warning (or error) added if possible, since it would have allowed me to realise sooner that However, I wonder if this would be best implemented as more strict |
I can update this PR to add a warning if we encounter wrong stuff in buildpack.toml |
…n.toml Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
@jjbustamante @edmorley I updated the PR to add the warnings. We should be good to go! |
Amazing - looks great, thank you! |
Awesome work @natalieparellano !!! ❤️ |
Summary
Output
Before
After
Documentation
Related
Resolves #2120
Resolves #2121