Commit Graph

428 Commits

Author SHA1 Message Date
Jesse Brown ebf6a57d11
Merge pull request #1574 from alphanota/remove-err-check
fix: remove error check that always returns nil
2025-12-17 16:52:37 -06:00
Angel Montero a65b007a63 fix: regression in pack acceptance tests caused by kaniko upgrade
Signed-off-by: Angel Montero <angelmontero@google.com>
2025-12-17 19:04:13 +00:00
Angel Montero 07f8f753a7 fix: remove error check that always returns nil
Signed-off-by: Angel Montero <angelmontero@google.com>
2025-12-17 17:12:17 +00:00
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 07ffe78a2f
Merge pull request #1560 from buildpacks/jab/imgutil-bump-with-moby-updates
Updating to moby libs to satisfy imgutil moby changes
2025-12-03 15:49:54 -06:00
Jesse Brown e539765383
fixup! Updating to moby libs to satisfy imgutil moby changes
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-11-24 14:10:00 -06:00
Jesse Brown 2bbc5ab206
Updating to moby libs to satisfy imgutil moby changes
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-11-24 14:06:32 -06:00
Jesse Brown 39d30970dc
lint and format 2025-10-03 08:57:28 -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
Jesse Brown c121049b41
bump imgutil 2025-05-28 10:00:00 -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 d1f38655a8
Remove format for constant strings in Logs
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-02-28 12:13:35 -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 a058e93f60
Fix https://github.com/buildpacks/lifecycle/issues/1425 by providing insecure registries when we access the run image (#1426)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-11-18 10:23:55 -05:00
Natalie Arellano 4d5a1b4437
Recover corrupted volume cache (#1410)
* Restore succeeds (skipping over the layer) if layer contents are corrupted

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

* Exporter does not re-use layer from volume cache if layer contents are corrupted

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

* Fixes

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-10-24 10:37:00 -04:00
Natalie Arellano 0d51c49e94
Upgrade go and fix lint (#1405)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-10-24 09:45:39 -04:00
Pavel Busko a43d5993a4
Fix run-image access check in restorer phase (#1386)
Signed-off-by: Pavel Busko <pavel.busko@sap.com>
Co-authored-by: Nicolas Bender <nicolas.bender@sap.com>
2024-07-29 11:44:11 -04:00
Natalie Arellano df6be88240
Recover corrupted cache (#1381)
* add failing test to restorer

Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* restorer and exporter working as expected

Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* lint

Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* Update phase/restorer.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* Update phase/cache.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* Update cache/image_cache.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* Update cache/volume_cache.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* Update cache/volume_cache.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* Update cache/volume_cache.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* Update cache/volume_cache.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* Update cache/volume_cache.go

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* update based on feedback

Signed-off-by: Joey Brown <brown.joseph@salesforce.com>

* fix log

* temp fix

* this does not work as is. I think we need to modify img utils.

Image utils should fail with a Layer Not found in both ReuseLayer & GetLayer.

For GetLayer, when there is a missing blob, it's return an unexpected EOF error.

For ReuseLayer, when there is a missing blob, it's not returning an error but it should.

* add eof check

* add not exist check

* reuse layer test

* fix test regression

---------

Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
Co-authored-by: Joey Brown <brown.joseph@salesforce.com>
2024-07-17 10:39:20 -04:00
Pavel Busko f2a3bd78a8
Restore cached launch layers not found in `appLayers` (#1346)
* Restore cached launch layers not found in appLayers

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

* add platform api guard

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

---------

Signed-off-by: Pavel Busko <pavel.busko@sap.com>
Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
2024-07-03 10:04:57 -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 82fdf23a6d
Bump imgutil and docker (#1335)
* Bump imgutil and docker

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

* Grab latest and avoid using "AddOrReuse" method as it requires updating the caching image

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-04-16 12:58:09 -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
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
Ryan Brainard f885774719
Document deprecatedRunImage as deprecated (#1304)
Signed-off-by: Ryan Brainard <966764+ryanbrainard@users.noreply.github.com>
2024-02-29 10:44:48 -05:00
Prashant Rewar 92bb4fb450
Make extensions not experimental for Platform 0.13 and above (#1295)
* Make extensions not experimental for Platform 0.13 and above

Signed-off-by: Prashant Rewar <108176843+prashantrewar@users.noreply.github.com>

* Fix failing acceptance test

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

---------

Signed-off-by: Prashant Rewar <108176843+prashantrewar@users.noreply.github.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2024-02-15 11:43:10 -05:00
Natalie Arellano 2f507d0121
Bumps imgutil to pick up layout package refactor & local package fix … (#1281)
* Bumps imgutil to pick up layout package refactor & local package fix for containerd storage

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

* Remove selective package, use sparse instead

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>
2024-02-09 13:26:50 -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 b8a92ac78d
Creator errors if detected order contains extensions (#1246)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-11-15 08:51:49 -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
Natalie Arellano 7ce5b70299
Fix regression in Platform API 0.10 (#1204)
* Fix Platform 0.10 by writing the new run image reference to analyzed.toml after generate

Platform 0.10 expects to find the reference in analyzed.toml

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

* Fix restorer

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-10-03 15:24:29 -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
Natalie Arellano 6c7d16a718
Move lifecycle package to sub-directory (#1205)
* Move files

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

* Fix imports

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

* Update mockgen directives

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

* WIP: add TODOs

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

* Rename lifecycle -> phase

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

* Address TODOs by adding comments

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

* Update phase/handlers.go

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-09-26 11:30:50 -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
Juan Bustamante aeb177ca46
Adding missing flags for OCI Layout to restorer (#1195)
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
2023-09-07 12:37:49 -04:00
Natalie Arellano a12fbff57d
Remove deprecated buildpack APIs (#1148)
* Remove buildpack APIs 0.2-0.6 according to https://github.com/buildpacks/rfcs/blob/main/text/0110-deprecate-apis.md

- Fix acceptance by updating fixtures to use newer Buildpack API version

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

* Remove backwards compatible glue for buildpacks missing API version

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-08-23 10:34:00 -04: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
Aidan Delaney 7001b6a594
Report image name when restorer fails to pull (#1174)
Report the image name so end-users can take some action.

Signed-off-by: Aidan Delaney <adelaney21@bloomberg.net>
2023-08-03 15:06:31 -04:00
Joe Kimmel 9099967d7a be more helpful when you dont recognize the phase
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-07-26 12:10:47 -07:00
Domenico Luciani 9c455eb4dd
Stop deleting cache images (#1136)
* Remove deleteOrigImage function from the cache and relative test

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

* Revert "Remove deleteOrigImage function from the cache and relative test"

This reverts commit 17e646fc39602777a37977dd9416e59aa62f6d04.

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

* Implemented a new component called cache deleter which takes care of the deletion of the cache images

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

* Adjusted the name of the struct field

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

* Move the imade deleter instatiation up to the main

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

* Add parameter to enable/diable the deletion functionality, for now always set has enabled

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

* Add feature guard based on the platformAPI version

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

* Fixing some test titles

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

* Introduce ImageComparer component

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

* Add async go-subroutine to the delete call to speed up the process

```go
func Benchmark(b *testing.B) {
	mockController := gomock.NewController(b)
	fakeImageComparer := cacheMock.NewMockImageComparer(mockController)
	testLogger := cmd.DefaultLogger
	imageDeleter := NewImageDeleter(fakeImageComparer, testLogger, true)
	for i := 0; i < b.N; i++ {
		fakeOrigImage := fakes.NewImage("fake-image", "", local.IDIdentifier{ImageID: "fakeImage"})
		fakeNewImage := fakes.NewImage("fake-image", "", local.IDIdentifier{ImageID: "fakeNewImage"})

		fakeImageComparer.EXPECT().ImagesEq(fakeOrigImage, fakeNewImage).AnyTimes().Return(false, nil)

		imageDeleter.DeleteOrigImageIfDifferentFromNewImage(fakeOrigImage, fakeNewImage)
	}
}
```

The code above produced this result:

* without the go-subroutine

```
goos: darwin
goarch: amd64
pkg: github.com/buildpacks/lifecycle/cache
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Benchmark
Benchmark-12    	    3501	   8995839 ns/op
PASS
```

* with the go-subroutine

```
goos: darwin
goarch: amd64
pkg: github.com/buildpacks/lifecycle/cache
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Benchmark
Benchmark-12    	    3560	   9133704 ns/op
PASS
```

Speed increased by 1.53% ns/op

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

---------

Signed-off-by: Domenico Luciani <dluciani@vmware.com>
2023-07-12 17:31:30 -04:00
Joe Kimmel e18a752b06
warn when a positional argument might have been a flag (#1147)
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-07-12 14:08:19 -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
Joe Kimmel 8cdec9dc8e restorer gets layers flag again
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-07-06 13:30:42 -07: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 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
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
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