Commit Graph

109 Commits

Author SHA1 Message Date
Jesse Brown b01c4e5645
Merge pull request #1539 from buildpacks/jab/exec-env
Platform 0.15: exec-env support
2025-12-12 09:37:24 -06:00
Jesse Brown 39d30970dc
lint and format 2025-10-03 08:57:28 -05:00
Jesse Brown 19eb349d4f
first pass at unit tests 2025-10-02 17:01:24 -05:00
Jesse Brown 2691aee313
Thread through system.toml parsing gated on 0.15 2025-10-02 16:49:58 -05:00
Jesse Brown dba6e93edb
Initial spike of exec-env support
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-09-10 12:28:34 -05:00
Pavel Busko 5f776886ec code lint
Signed-off-by: Pavel Busko <pavel.busko@sap.com>
2025-04-16 14:47:09 +02:00
Jesse Brown b05882d689
fixup! Ensure lifecycle arg validation executed as expected.
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-02-24 09:38:10 -06:00
Jesse Brown 5d193d0374
Ensure lifecycle arg validation executed as expected.
Make sure the warning message is safely guarded with a length check before attempting to access the first element of the slice.

Make sure the `ValidateOutputImageProvided` function is called first in the input resolve process to ensure the output image is provided before attempting to resolve the input image in other validation functions.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-02-24 09:21:07 -06:00
Natalie Arellano 21811fa4dc
Only log once (per phase) when we have to get target distro information from /etc/os-release (#1424)
* Only log once (per phase) when we have to get target distro information from /etc/os-release

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Save the distro information the first time we read /etc/os-release, so that we end up only reading that file once

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-11-15 11:08:29 -05:00
Natalie Arellano 04f1ad1d03
Fix CNB_TARGET_* env vars on older Platform API (#1374)
* Target data: populate os/arch as well as distro information

Fixes https://github.com/buildpacks/lifecycle/issues/1371

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Only os and arch are truly required

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix one more unit

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix even more units

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-07-09 13:12:47 -04:00
Pavel Busko a02be035c8
Ensure read access to the run image selected by extensions (#1364)
* Ensure read access to the run image selected by extensions

Co-authored-by: Nicolas Bender <nicolas.bender@sap.com>
Signed-off-by: Pavel Busko <pavel.busko@sap.com>
Co-authored-by: Pavel Busko <pavel.busko@sap.com>

* move read access check to the restorer cmd

Signed-off-by: Pavel Busko <pavel.busko@sap.com>

* guard behind platform version check

Signed-off-by: Pavel Busko <pavel.busko@sap.com>

---------

Signed-off-by: Pavel Busko <pavel.busko@sap.com>
Co-authored-by: Nicolas Bender <nicolas.bender@sap.com>
2024-07-03 10:01:21 -04:00
Natalie Arellano 73f6927abc
More fixes for target compat checking during detect (#1354)
* More fixes for target compat checking during detect

- If a buildpack fails to specify os/arch (but specifies distro) still check targets
- If the run image fails to specify os/arch (this should not happen actually as we will fail during analyze) still check targets
- Fix typo in buildpack descriptor struct so that we actually get stack information
- If we get distro information from /etc/os-release, persist this information to later invocations to that the log message
  printed when errors are encountered will be accurate
- Don't override inner `i` in loop (this should not actually affect the outer loop but is confusing)

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When stack is "any", don't infer empty target as it is not needed

Missing targets is sufficient for wildcard match

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Remove backwards compatible glue that actually causes fewer builds to succeed

Fixes https://github.com/buildpacks/lifecycle/issues/1355

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Remove exit (this was added for debugging purposes)

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-05-14 14:10:16 -04:00
Natalie Arellano 83efa75a14
Also read distro information from /etc/os-release when checking target compat (#1352)
* Reorder functions in file

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Also read distro information from /etc/os-release when checking target compat

https://github.com/buildpacks/lifecycle/pull/1347 reads the file when providing target env vars
to buildpacks during detect, but we also need to consider this info when deciding whether or not to run
detect for the buildpack

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Error if we don't find run image OS during analyze

And remove checks for missing OS later in the build, as it should always be there

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-05-10 11:56:44 -04:00
Pavel Busko effdf24b2c
Read `/etc/os-release` file when distro information is not present in labels (#1347)
* Read `/etc/os-release` file when distro information is not present in labels

Signed-off-by: Pavel Busko <pavel.busko@sap.com>

* fix unit tests

Signed-off-by: Pavel Busko <pavel.busko@sap.com>

* Update phase/generator_test.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Pavel Busko <busko.pavel@gmail.com>

* Update phase/generator_test.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Pavel Busko <busko.pavel@gmail.com>

---------

Signed-off-by: Pavel Busko <pavel.busko@sap.com>
Signed-off-by: Pavel Busko <busko.pavel@gmail.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2024-05-06 16:33:51 -04:00
Natalie Arellano 44b70410fe
When a buildpack declares distro information, but a base image does not, (#1348)
consider it not a match

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-05-01 12:43:58 -04:00
Ed Morley 9f9ac3cbc6
Use correct run image label name for distro name/version (#1325)
The spec and docs say that the run image distro and version should be
specified via the Docker image labels `io.buildpacks.base.distro.name`
and `io.buildpacks.base.distro.version`.

See:
https://github.com/buildpacks/spec/blob/buildpack/v0.10/platform.md#target-data

However, until now the lifecycle implementation was checking for
label names that were missing the `.base` substring from the name.

This causes distro name/version `buildpack.toml` target detection
to fail, as well as the env vars `CNB_TARGET_DISTRO_NAME` and
`CNB_TARGET_DISTRO_VERSION` not to be set correctly in the
buildpack environment.

Fixes #1324.

Signed-off-by: Ed Morley <501702+edmorley@users.noreply.github.com>
2024-03-28 09:45:45 -04:00
Natalie Arellano 435d226f1e
Fix: log level and color level should be configurable via the env (#1314)
* Fix: log level and color level should be configurable via the env

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix version

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update order and comment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-03-12 11:39:10 -04:00
Natalie Arellano 1148b713e0
Always set CNB_TARGET_* variables during detect, build, and generate (#1309)
* Always set CNB_TARGET_* variables during detect, build, and generate
when the Buildpack API version is at least 0.10.

Previously, we only set these variables when the Platform API version was at least 0.12.
But, newer Buildpack APIs expect these variables regardless of the Platform API version.
If we are on an older platform, derive the target variables from the base image OS.

Fixes https://github.com/buildpacks/lifecycle/issues/1308

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix unit

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix unit again

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-03-04 12:33:20 -05:00
Ryan Brainard 73af3c126d
Fix rebase run-image resolution (#1305)
* Fix rebase run-image resolution

Currently, if `-run-image` is not set, `io.buildpacks.lifecycle.metdata[runImage.reference]` is used. This does not follow the [Run Image Resolution spec](https://github.com/buildpacks/spec/blob/main/platform.md#run-image-resolution), which specifies using `io.buildpacks.lifecycle.metdata[runImage.image]` and optionally `io.buildpacks.lifecycle.metdata[runImage.mirrors]`. Because of this, it ends up making `lifecycle rebase` without the `-run-image` flag a no-op because the run image is pinned to the same version instead of getting the latest.

This change simplfies and unifies the behavior for before and after Platform Version 0.12 so that they both read the same run-image data type (just from different locations), and then validate and resolve mirrors the same.

Signed-off-by: Ryan Brainard <966764+ryanbrainard@users.noreply.github.com>

* Rewrite if-else-if-else as switch for go-critic

This is to make go-critic happy. See https://github.com/go-critic/go-critic/issues/453.

Signed-off-by: Ryan Brainard <966764+ryanbrainard@users.noreply.github.com>

* Extract and test platform.GetRunImageFromMetadata

Signed-off-by: Ryan Brainard <966764+ryanbrainard@users.noreply.github.com>

---------

Signed-off-by: Ryan Brainard <966764+ryanbrainard@users.noreply.github.com>
2024-03-01 09:31:48 -05:00
Kritka Sahni f8b8669119
Export app image and cache image in parallel (#1247)
* Export app image and cache image in parallel

Signed-off-by: kritka sahni <kritkasahni@google.com>

* Update platform/resolve_inputs.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Kritka Sahni <122665407+kritkasahni-google@users.noreply.github.com>

* Fix warning message for parallel export without cache image.

Signed-off-by: kritka sahni <kritkasahni@google.com>

* Add test for parallel export enabled.

Signed-off-by: kritka sahni <kritkasahni@google.com>

* Fix test for parallel export without cache image.

Signed-off-by: kritka sahni <kritkasahni@google.com>

* Fix test message for parallel export without cache image.

Signed-off-by: kritka sahni <kritkasahni@google.com>

---------

Signed-off-by: kritka sahni <kritkasahni@google.com>
Signed-off-by: Kritka Sahni <122665407+kritkasahni-google@users.noreply.github.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2023-12-14 16:59:52 -05:00
Natalie Arellano 33c5b89004
Consolidate methods that read and write platform spec'd TOML (#1236)
* Consolidate methods that read and write platform spec'd TOML
in platform/files package.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Calculate lifecycle digest and output version as part of acceptance testing

This can help us diagnose weird failures in CI

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-11-03 14:17:52 -04:00
Ralf Pannemans 2bf3ae75a0
Do not obscure error message (#1227)
Signed-off-by: Ralf Pannemans <ralf.pannemans@sap.com>
2023-10-27 13:05:32 -04:00
Natalie Arellano be881f29d5
Refactor lifecycle phase factories (#1207)
* Refactor lifecycle phase factories

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add getter for lifecycle inputs

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-09-27 14:57:46 -04:00
Domenico Luciani 7ffcd58e74
Support insecure registries (#1140)
* Add the support to the new --insecure-registry parameter

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Add the support to the new --insecure-registry parameter in the creator command

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Add keychain mock and handler test

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Add support for a single insecure registry

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Add support to multiple insecure registries

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Adjusted flag name

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Fix problem with the mock

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* InsecureRegistry to InsecureRegistries

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Address comment on FlagTags parity

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Parse the InsecureRegistry env variable with comma separated values

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Changed InsecureRegistry to InsecureRegistries

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Changing name at the env variable

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Exporter now accept insecure registries

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Bump up toward the latest version of imgutil

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Remove legacy guard

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Add WithRegistrySetting with insecure registries into restorer

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Add support for insecure registries to the rebaser

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Add rebaser testdata directory to .gitignore

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Cleaned testdata directory

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Remove testdata rebaser entries from .gitignore

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Add support to insecure registies for the read-write registry check

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Move registryHandler into its own file into the image package

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Add dockerfile.windows

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Introducing GetInsecureRegistryOptions

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Fix linter problems

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Remove legacy guards and add test support to arm64

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Remove duplication and utilize new GetInsecureRegistryOptions function

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Extract common code for getting insecure registry options from imageRef

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Added cli flags behind proper guards

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Bumped up to the imgutil latest version with the insecure adjustment and renamed the getInsecureRegistryOptions function

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Make the getInsecureOptions a static method as a temporary solution to remove duplications

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Added insecure registry to the runImage in the rebaser

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Bump up to the latest version of imgutil with the multiple registries fix

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Go mod tidy

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Remove insecure-registry filter based on the imageRef

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Remove reduntant for loop and added a test for multiple GetInsecureOptions

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Don't remove whitespaces between buildpacks names

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Add FlagInsecureRegistries behind 0.13 guards

Signed-off-by: Domenico Luciani <dluciani@vmware.com>

---------

Signed-off-by: Domenico Luciani <dluciani@vmware.com>
2023-09-22 12:29:58 -04:00
Natalie Arellano 874e2c17e8
Remove deprecated platform APIs (#1191)
* Remove deprecated platform APIs

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Adding back some things and removing more things

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix assertion

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix again

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix windows

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-09-13 12:44:10 -07:00
Natalie Arellano c3998654d3
Merge release/0.17.0 into main (#1177)
* restorer gets layers flag again

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* add explanatory debug logs so a reader knows why the buildpacks are read twice.

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* warn when a positional argument might have been a flag (#1147)

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* Add test for empty digest not returned

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance by providing a base image when we instantiate the remote run image

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* timestamp logs and phase error message cherry-picks (#1164)

* timestamp logs for entry/exit for all the top-level Lifecycle package functions

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

fixing names

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

using defer to make one-liners for fun and profit

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

and today we thank our brave linters for preventing critical defects such as unnecessary trailing newlines from being merged. Its about time somebody thought of the children.

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* be more helpful when you dont recognize the phase

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

---------

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* Simplifies target matching logic per spec PR review (#1166)

* Update units without updating code

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update code

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Unpend test

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add units for rebase without updating code

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update rebase code

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix lint

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When we read the descriptor file, don't fill in "*" as a magic value as missing values are wildcard matches

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Stricter validation for rebase

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add -daemon to restorer (#1168)

This is needed when extensions were used to switch (but not extend) the run image
and we need to re-read the target data from the image config.

In such cases, we don't need the run image to exist in a registry,
because we don't need a manifest for kaniko.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Remove CNB_TARGET_ID according to https://github.com/buildpacks/spec/pull/374 and https://github.com/buildpacks/spec/pull/375 (#1175)

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Field renames per spec review (#1170)

* Rename distributions -> distros in the buildpack spec

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Rename distributions -> distros in the platform spec

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* force pack acceptance tests to build with a version of go that can still make HTTP requests to docker daemon (#1158)

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

---------

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Joe Kimmel <jkimmel@vmware.com>
Co-authored-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>
2023-08-09 12:27:46 -04:00
Natalie Arellano d14bae1e26
Require the CNB_PLATFORM_API env var to be set (#1145)
* Require the CNB_PLATFORM_API env var to be set, instead of defaulting to (deprecated) version 0.3

Instead of defaulting to a newer Platform API version, which would silently change behavior
for platforms that do not currently set this env var.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-07-11 13:13:00 -04:00
Natalie Arellano 84a94d59df
Fixes for run image extension (#1134)
* When pulling remote image data, fail if the remote image is not found

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When validating dockerfiles, set extend to true if there are any instructions (vs more than one instruction)

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update matching logic when considering if two image names are equivalent to ignore the digest portion of the reference if present (for the purpose of selecting data from run.toml to add to the lifecycle metadata label i.e., “run image for rebase”)

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Comments and cleanup

Don't print `%!s(<nil>)` if nil is provided to the "parse maybe" function

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When exporting, continue to use run image identifier (which could be a digest reference or daemon image ID)
instead of falling back to image name when exporting to a daemon.

Previously, the digest reference was incorrect which caused the daemon not to find the image.
But when provided a correct digest reference the daemon can still find it.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add Contains method to structs that hold run image information for export

When determining if a provided reference is found in existing metadata, remove its digest -
except when setting the new run image "image" in analyzed.toml,
because we should always respect what the extension author wrote.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When finding the run image info for export, use the run image "image" (name)
in analyzed.toml as the search key, because the run image "reference" could be a daemon image ID
or include the digest, which isn't helpful when retrieving image names that are supposed to float.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix detector acceptance and add more logging

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix: use "image" instead of "reference" and also guard against image not found
when we are only updating the reference and target data in analyzed.toml

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add comment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-07-05 16:23:20 -04:00
Natalie Arellano f7708d95e6
When checking read/write access, if there is no access, surface the e… (#1133)
* When checking read/write access, if there is no access, surface the error that occurred

This can be helpful in debugging failed builds where access is expected

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance by continuing when iterating through run image mirrors

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Point imgutil back to main

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-26 15:21:13 -04:00
Natalie Arellano 94da70f6b6
Fixes for rebase (#1132)
* Warn whenever --force is used

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Trying to make the diff better

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update name.ParseMaybe to return the tag & add tests

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Make the code simpler by re-using RunImageForExport within RunImageForRebase

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Remove unneeded check

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add comment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add hint about -force in the case that failure can be overridden

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-23 10:45:19 -04:00
Natalie Arellano 7f4666ed2b
Fixes for rebase and log message improvements (#1122)
- Fix daemon invocation by trying to read app image after we have a docker client
- Don't do stack validation for images built on newer platforms

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-14 15:19:20 -04:00
Natalie Arellano 8bd0003a19
Clarify log messages and omitempty (#1125)
* Clarify log messages and omitempty

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix accpetance by updating fixtures & update user check

- We shouldn't fail if extensions leave the user ID as root when extending the build image,
  as the lifecycle will drop privileges to the provided -uid and -gid when running the build phase.
- If the user ID is still root, the `builder` will fail.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-14 14:38:37 -04:00
Joe Kimmel 29e694f8c3
rename env var to CNB_TARGET_ARCH_VARIANT (#1119)
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-06-09 14:36:21 -04:00
Natalie Arellano 5ae441444e
Fixes from user testing (#1117)
* Small fixes from user testing

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fixes from user acceptance

- Removes -stack flag from analyzer
- Fixes debug log message
- Removes deprecated rand.Seed

Signed-off-by: Joe Kimmel <joe-kimmel-vmw@vmware.com>

* Bump linter to a version that will work with go 1.20

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Restorer should ensure ownership of kaniko directory

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* pull the less-than case for flags out of the switch

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* appease the windows linter

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* Fix weird log output

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joe Kimmel <joe-kimmel-vmw@vmware.com>
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
Co-authored-by: Joe Kimmel <joe-kimmel-vmw@vmware.com>
Co-authored-by: Joe Kimmel <jkimmel@vmware.com>
2023-06-08 14:34:47 -04:00
Natalie Arellano 1fc9483341
Improved matching when selecting run image metadata (#1111)
We need to parse the reference in case the registry is not specified (defaults to Docker Hub)

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-07 13:38:25 -04:00
Joe Kimmel df5fca4fc0
metadata label is more clearly named and always has stacks (#1109)
* metadata label is more clearly named and always has stacks

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* Update exporter.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>

* Update exporter.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>

* (with @natalieparellano) simplify exporter interface by removing legacy stack arg and only constructing it when needed for metadata label

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

---------

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
Signed-off-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2023-06-06 15:58:17 -04:00
Natalie Arellano 28084b7412
Refactor: create new package for files in the platform spec (#1076)
* Refactor: create new package for files in the platform spec

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Move test

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Move CNB business logic from file -> platform package

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update comment and var names for clarity

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Remove AccessChecker interface in favor of function signature type

- Remove unused testhelpers
- Make AccessChecker an emergent property of LifecycleInputs (vs something that needs to be set)

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update comments with more info

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-02 13:32:32 -04:00
Natalie Arellano aa86fc68f7
When rebasing, update stack/runImage key in lifecycle metadata label (#1104)
* When rebasing, update stack/runImage key in lifecycle metadata label
if the provided run image does not match existing metadata.

See https://github.com/buildpacks/spec/pull/360

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update rebaser_test.go

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-01 12:11:29 -04:00
Joe Kimmel 1057837bae
Target envvars (#1078)
* CNB_TARGET_ env vars

- allowed to be passed through in the env vars allow-list
- threaded through builder
- threaded through detector
- threaded through generator

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* Update buildpack/generate.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>

* Update buildpack/generate.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>

* Update cmd/lifecycle/builder.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>

---------

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
Signed-off-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2023-05-11 14:42:38 -04:00
Pavel Busko a2dfc786a6
Verify read access while selecting best `run-image` mirror (#1024)
* fallback to run image mirrors if unavailable

Signed-off-by: Pavel Busko <pavel.busko@sap.com>

Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
Co-authored-by: Johannes Dillmann <j.dillmann@sap.com>

Add unit tests for run image resolution

Co-authored-by: Johannes Dillmann <j.dillmann@sap.com>
Co-authored-by: Philipp Stehle <philipp.stehle@sap.com>
Signed-off-by: Ralf Pannemans <ralf.pannemans@sap.com>

Use ImageStrategy instead of AccessChecker to ease testing

Signed-off-by: Johannes Dillmann <j.dillmann@sap.com>
Signed-off-by: Ralf Pannemans <ralf.pannemans@sap.com>

* Move determining ImageStrategy to ResolveInputs

Co-authored-by: Johannes Dillmann <j.dillmann@sap.com>
Signed-off-by: Johannes Dillmann <j.dillmann@sap.com>
Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
Signed-off-by: Ralf Pannemans <ralf.pannemans@sap.com>

* Adapt acceptance tests for checking read access on run images

Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
Signed-off-by: Ralf Pannemans <ralf.pannemans@sap.com>

* Update acceptance/analyzer_test.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Ralf Pannemans <ralf.pannemans@googlemail.com>

---------

Signed-off-by: Johannes Dillmann <j.dillmann@sap.com>
Signed-off-by: Ralf Pannemans <ralf.pannemans@sap.com>
Signed-off-by: Ralf Pannemans <ralf.pannemans@googlemail.com>
Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
Co-authored-by: Johannes Dillmann <j.dillmann@sap.com>
Co-authored-by: Sumit Kulhadia <sumit.kulhadia@sap.com>
Co-authored-by: Ralf Pannemans <ralf.pannemans@googlemail.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2023-05-11 14:05:50 -04:00
Natalie Arellano 68b4ce9a55
Fixes for pack acceptance in the current-current-current configuration (#1075)
* Fixes for pack acceptance in the current-current-current configuration

Signed-off-by: Joe Kimmel <joe-kimmel-vmw@vmware.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add unit tests for fixes

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Joe Kimmel <joe-kimmel-vmw@vmware.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-04-28 15:43:52 -04:00
Natalie Arellano 5eb4eac531
Fix updating run image reference (#1067)
* Fix updating run image reference

We should use the reference that the extension wrote, as that is expected to be in the daemon (when building locally)
`ref.Context().RepositoryStr()` strips the reference of the registry which may not be desired;
we should trust the extension to write the correct reference instead.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance test by updating fixture

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update README

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Use run image function instead of accessing the field directly

Safer in the case the run image is nil

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Change fixture to point to pullable image

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When running pack acceptance, don't consider release candidates or pre-releases

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Pin pack version for acceptance to v0.28.0

pack v0.29.0 accidentally declares support for platform API 0.12
and the acceptance tests aren't passing because `pack build` hasn't actually been updated
with support for platform API 0.12

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-04-17 22:44:43 +02:00
Natalie Arellano e0e30117b3
Exporter changes for run image extension (#1055)
* Make a single constructor for lifecycle inputs

- The logic to update the default path for TOML files was repeated across phases
- In general it is safe to provide default values for inputs that might not be relevant to the current phase,
  as these will be ignored when constructing a new service for the phase;
  e.g., platform.LifecycleInputs.OrderPath will be ignored when constructing a lifecycle.Exporter
- As more inputs are shared across phases (e.g., analyzed.toml is now an input to the detect phase),
  duplicating the logic for providing default values is becoming more cumbersome

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Read values from environment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Buildpack API: run.Dockerfiles are allowed instructions on versions >= 0.10

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the detector accepts a new -run flag

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Move responsibility for validating Dockerfiles into the buildpack package

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When verifying Dockerfiles, return the new base image name if necessary

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When determining the new runtime base image, use criteria outlined in the platform spec

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the schema of analyzed.toml is updated to include run-image.extend = <true or false, default false>

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* TESTME: Update analyzed.toml with new run image if needed

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* If extensions are used to switch the runtime base image, the detector should fail if the selected base image is not found in run.toml.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add fixture to test re-writing of analyzed.toml

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Move updating analyzed.toml into lifecycle package for easier testing

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the restorer will update analyzed.toml with:
- digest ref for run image
- target data for run image

Additionally the restorer will download the run image manifest & config when extend is true

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update acceptance/extender_test.go

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* The extender accepts new -extended and -kind flags

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Bring back selective package

Because we change the media types to be oci types (vs docker types) this changes the digest of the image

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add acceptance test for run image extension

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* WIP

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Refactor

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* WIP: break me up into separate commits

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Validate extend config during buildpack/generate

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Address some TODOs and refactor

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Set io.buildpacks.rebasable

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix merge and restore selective package

imgutil/layout/sparse modifies the image media types which we don't want

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update analyzed.toml with digest reference or target data if needed

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Don't redefine -layers

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* WIP: add acceptance test

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* WIP: first assertion passes

FIXME: extended layers should be small

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* WIP

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* WIP: Second assertion passes

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add new assertions and rename variables for clarity; fix exporter units

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Save extended run image under <extended>/run

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Check for nil config and make the loop simpler

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix ineffectual assignment to err

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Cleanup extender tests

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix typo

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add positive assertion

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Make constants for asserted log lines

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update comment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Acceptance test passes

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix some TODOs

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update imgutil to point to branch commit

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add support to extending daemon images

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* WIP

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix image ref when exporting to daemon

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* More fixes

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Improve script to test on fork

Clarify names of cosign secrets and remove Codecov

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Cleanup extender

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update comments

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Small fixes, units pass

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add generator units

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fixes

- We shouldn't try to use extension layers if they exist in <layers>/extended unless experimental features are enabled
- We only know the size of the compressed layer, so we can't use io.CopyN (but we don't need to guard against decompression bomb anyway since we control the layers)

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix test

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Rename fixture dirs so that we can check out source code on Windows

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Bring back Cleanup()

We need access to the final image after all Dockerfiles have been applied,
so we need to create the working directory outside the applier loop.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update imgutil branch

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix restorer acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance test by making it less brittle

Instead of hard-coding the run image and run image top layer SHAs,
we can derive their values

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fixups from PR review

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix units

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Point imgutil back to main

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update generator.go

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update comment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update exporter.go

Co-authored-by: Jesse Brown <jabrown85@gmail.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Check err type when we fail to get a layer from a sparse image

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Jesse Brown <jabrown85@gmail.com>
2023-04-17 11:24:22 +02:00
Jesse Brown 627deb6dfb
0.12 Rebase Validation and Label Sync (#1056)
* Validate OS, Arch, Variant and optional labels on rebase

For 0.12 and beyond, rebase is now validating the OS, Arch, Variant and io.buildpack labels specific to OS. This can be skipped with the --force flag.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>

* Copy io.buildpacks.base.* labels on rebase

For platforms running 0.12 and beyond, copy the io.buildpacks.base.* labels to the new image on rebase.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>

* fixup! Copy io.buildpacks.base.* labels on rebase

Signed-off-by: Jesse Brown <jabrown85@gmail.com>

* Skip validation if the image was built < 0.12

If the target image was built prior to 0.12, do not run the additional validation. This is because the validation is not backwards compatible with older images. Older images may not have the required fields and we don't want to force platforms to use the `--force` flag.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>

---------

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2023-04-14 14:05:03 -04:00
Joe Kimmel 0a96158154 os and arch: buildpack targets should have stars
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-04-07 14:15:30 -07:00
Joe Kimmel 1431839fad
what are wildcards if not a connection to the starry dynamo in the machinery of night? (#1053)
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-04-05 16:01:27 -04:00
Joe Kimmel 39c4a7b571
detect linux flavors by reading etc/os-release (#1050)
* detect linux flavors by reading etc/os-release

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* little more cleanup and better tests

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* fix bad assertion in linux test

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* sure is a good thing those newlines will never make it into production

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* make format

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* Update internal/fsutil/os_detection.go

Co-authored-by: Jesse Brown <jabrown85@gmail.com>
Signed-off-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>

* cleanups

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

* Update internal/fsutil/os_detection.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>

* finish systemic rename

avoid conflating linux with partial sysd implementatations

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>

---------

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
Signed-off-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>
Co-authored-by: Jesse Brown <jabrown85@gmail.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2023-04-05 16:00:54 -04:00
Natalie Arellano 21fb915dce
Extender changes for run image extension (#1022)
* Make a single constructor for lifecycle inputs

- The logic to update the default path for TOML files was repeated across phases
- In general it is safe to provide default values for inputs that might not be relevant to the current phase,
  as these will be ignored when constructing a new service for the phase;
  e.g., platform.LifecycleInputs.OrderPath will be ignored when constructing a lifecycle.Exporter
- As more inputs are shared across phases (e.g., analyzed.toml is now an input to the detect phase),
  duplicating the logic for providing default values is becoming more cumbersome

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Read values from environment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Buildpack API: run.Dockerfiles are allowed instructions on versions >= 0.10

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the detector accepts a new -run flag

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Move responsibility for validating Dockerfiles into the buildpack package

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When verifying Dockerfiles, return the new base image name if necessary

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When determining the new runtime base image, use criteria outlined in the platform spec

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the schema of analyzed.toml is updated to include run-image.extend = <true or false, default false>

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* TESTME: Update analyzed.toml with new run image if needed

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* If extensions are used to switch the runtime base image, the detector should fail if the selected base image is not found in run.toml.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add fixture to test re-writing of analyzed.toml

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Move updating analyzed.toml into lifecycle package for easier testing

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the restorer will update analyzed.toml with:
- digest ref for run image
- target data for run image

Additionally the restorer will download the run image manifest & config when extend is true

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update acceptance/extender_test.go

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* The extender accepts new -extended and -kind flags

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Bring back selective package

Because we change the media types to be oci types (vs docker types) this changes the digest of the image

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add acceptance test for run image extension

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* WIP

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Refactor

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* WIP: break me up into separate commits

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Validate extend config during buildpack/generate

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Address some TODOs and refactor

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Set io.buildpacks.rebasable

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix merge and restore selective package

imgutil/layout/sparse modifies the image media types which we don't want

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update analyzed.toml with digest reference or target data if needed

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Don't redefine -layers

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Save extended run image under <extended>/run

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Check for nil config and make the loop simpler

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix ineffectual assignment to err

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Cleanup extender tests

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix typo

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add positive assertion

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Make constants for asserted log lines

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update comment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-03-31 17:04:22 -04:00
Jesse Brown 2b6ddbb7af
Rebaser changes for run image extension (#1032)
* Add --force flag to rebase command

Signed-off-by: Jesse Brown <jabrown85@gmail.com>

* Validate io.buildpacks.rebasable label on rebase

For platforms >= 0.12 - the rebaser will now fail if the io.buildpacks.rebasable label is set to false when the force flag is not set.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>

* Read rebase from io.buildpacks.lifecycle.metdata runImage

For Platforms >= 0.12, the default rebase target has moved to the `runImage` key in the `io.buildpacks.lifecycle.metadata` label. This change allows the lifecycle to read the `runImage` key and use it as the default rebase target.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>

* fixup! Validate io.buildpacks.rebasable label on rebase

Signed-off-by: Jesse Brown <jabrown85@gmail.com>

* fixup! Add --force flag to rebase command

Signed-off-by: Jesse Brown <jabrown85@gmail.com>

* fixup! Read rebase from io.buildpacks.lifecycle.metdata runImage

Signed-off-by: Jesse Brown <jabrown85@gmail.com>

---------

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2023-03-28 11:39:39 -04:00
Natalie Arellano 47594c2c29
Restorer changes for run image extension (#1014)
* Make a single constructor for lifecycle inputs

- The logic to update the default path for TOML files was repeated across phases
- In general it is safe to provide default values for inputs that might not be relevant to the current phase,
  as these will be ignored when constructing a new service for the phase;
  e.g., platform.LifecycleInputs.OrderPath will be ignored when constructing a lifecycle.Exporter
- As more inputs are shared across phases (e.g., analyzed.toml is now an input to the detect phase),
  duplicating the logic for providing default values is becoming more cumbersome

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Read values from environment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Buildpack API: run.Dockerfiles are allowed instructions on versions >= 0.10

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the detector accepts a new -run flag

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Move responsibility for validating Dockerfiles into the buildpack package

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When verifying Dockerfiles, return the new base image name if necessary

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When determining the new runtime base image, use criteria outlined in the platform spec

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the schema of analyzed.toml is updated to include run-image.extend = <true or false, default false>

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* TESTME: Update analyzed.toml with new run image if needed

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* If extensions are used to switch the runtime base image, the detector should fail if the selected base image is not found in run.toml.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add fixture to test re-writing of analyzed.toml

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Move updating analyzed.toml into lifecycle package for easier testing

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the restorer will update analyzed.toml with:
- digest ref for run image
- target data for run image

Additionally the restorer will download the run image manifest & config when extend is true

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update acceptance/extender_test.go

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix merge and restore selective package

imgutil/layout/sparse modifies the image media types which we don't want

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update analyzed.toml with digest reference or target data if needed

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Don't redefine -layers

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Test organization and remove the requirement that we're exporting to a registry to use run image extensions

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Test that we don't update target data for older platforms

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Remove target partial and use helper function

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Bump imgutil

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Use imgutil/sparse package instead of internal/selective package

We'll be able to fully remove internal/selective
when we update tests for the extender as part of https://github.com/buildpacks/lifecycle/issues/998

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Don't try to pull a builder image if it wasn't specified

Ensure we write a digest reference to analyzed.toml

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix lint

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add and update comment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-03-28 11:23:24 -04:00