Commit Graph

54 Commits

Author SHA1 Message Date
Angel Montero ad3d5d50d0 Moby updates (excluding acceptance)
Signed-off-by: Angel Montero <angelmontero@google.com>
2025-12-17 19:04:13 +00:00
Jesse Brown 14dedc9561
Revert "chore: Update lifecycle to use newer moby packages, fix flaky acceptance tests" 2025-12-11 12:41:39 -06:00
Angel Montero 1022cb1adc chore: Update lifecycle to use newer moby packages, fix flaky acceptance tests
Signed-off-by: Angel Montero <angelmontero@google.com>
2025-12-10 14:43:26 +00:00
Jesse Brown ee501aec0a
Replace GoogleContainerTools/kaniko with chainguard-dev/kaniko
kaniko is now maintained by chainguard-dev and is the recommended
kaniko to use. This will allow us to keep our dependencies up to date
and avoid issues with the unmaintained GoogleContainerTools/kaniko project.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-06-26 09:37:01 -05:00
Jesse Brown 60bf07f8de
Remove Windows Support
I took a swing at removing any and all references to windows in this reference implementation.

Lifecycle no longer outputs a windows binary as a release artifact
Lifecycle no longer operates against windows containers

https://github.com/buildpacks/rfcs/pull/311
https://medium.com/buildpacks/deprecation-announcement-windows-container-feature-in-cloud-native-buildpacks-bbb70351343d

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2024-12-10 16:56:29 -06:00
Robert Gogolok 81ef5987de Support FreeBSD build phase
Signed-off-by: Robert Gogolok <robert.gogolok@stackit.cloud>
2024-12-09 23:08:13 +01:00
Jesse Brown 8cfa351ee8
Merge pull request #1434 from gogolok/loop_deprecation
lint: Replace `exportloopref` by `copyloopvar` and `intrange`
2024-12-03 08:58:36 -06:00
Robert Gogolok 32f1113b28 copyloopvar: Fix linter errors
Signed-off-by: Robert Gogolok <robert.gogolok@stackit.cloud>
2024-12-03 09:48:36 +01:00
Robert Gogolok 605a233fcf Use `unix` build constraint
Signed-off-by: Robert Gogolok <robert.gogolok@stackit.cloud>
2024-12-02 23:26:23 +01:00
Robert Gogolok eea0ba6a02 Remove obsolete // +build lines
https://tip.golang.org/doc/go1.18#go-build-lines

Signed-off-by: Robert Gogolok <robert.gogolok@stackit.cloud>
2024-12-02 16:26:34 +01: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 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
Johannes Dillmann 7bdfb331bb
Provide context directory for extensions (#1276)
* Provide context folder for extensions

Co-authored-by: Johannes Dillmann <j.dillmann@sap.com>
Signed-off-by: Pavel Busko <pavel.busko@sap.com>

* Address PR feedback

Co-authored-by: Johannes Dillmann <j.dillmann@sap.com>
Signed-off-by: Pavel Busko <pavel.busko@sap.com>

* Split tests by platform API

Co-authored-by: Pavel Busko <pavel.busko@sap.com>
Signed-off-by: Johannes Dillmann <j.dillmann@sap.com>

* Add unit test for FindContexts

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

* acceptnance tests

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

* Address PR feedback

Signed-off-by: Philipp Stehle <philipp.stehle@sap.com>

---------

Signed-off-by: Pavel Busko <pavel.busko@sap.com>
Signed-off-by: Johannes Dillmann <j.dillmann@sap.com>
Signed-off-by: Philipp Stehle <philipp.stehle@sap.com>
Co-authored-by: Pavel Busko <pavel.busko@sap.com>
Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
Co-authored-by: Philipp Stehle <philipp.stehle@sap.com>
2024-02-15 10:40:12 -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
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
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 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 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 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 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 89a1cfebef
Add history when adding buildpack or extension layers (#1099)
* Add history when adding buildpack or extension layers

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

* REVERTME: point imgutil to feature branch

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

* Parse extension ID from history so that we can output a useful log message

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

* Avoid extra wrapping

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

* Bump imgutil

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

* Fix acceptance by overriding imgutil methods for "caching image"

We need to add to the launch cache when adding layers so that the next build will be faster

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

* Add tests for layer factory

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

* Add acceptance test for extender should update history

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

* Move history methods to imgutil

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

* Fix exporter acceptance by fixing imgutil

The digest for a remote image from imgutil
should match the digest for a remote image from ggcr
unless the user specifically requested modifications like overriding history

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

* Add acceptance test; fix layer name when there is only one slice

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>

* Fix acceptance

imgutil mutates the image (history) for newer platforms, so the SHA is different

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

* Point imgutil back to commit on main, also bump containerd

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-05-30 14:35:39 -04: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
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
Joe Kimmel e5f7e4bb55
Launcher sboms copy only sbom extensions (#984)
* fsutils FilesWithExtensions filters directory listings

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

* exporter: launcher sbom copy

only copies sbom files

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

* exporter launcher sbom copy: more thorough test

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

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-01-23 16:56:03 -05:00
Natalie Arellano 02569f89db
Add launcher SBOM input (#963)
* Introduce -launcher-sbom as new flag to the exporter and creator

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

* Add unit test and update acceptance test

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-12-05 17:03:58 -05:00
Olivier MOCQUAIS dcf0f8ff69
Implement RFC for SBOM describing lifecycle / launcher #958 (#944)
Signed-off-by: Olivier Mocquais <omocquais@vmware.com>

Signed-off-by: Olivier Mocquais <omocquais@vmware.com>
2022-11-21 16:00:53 -05:00
Eng Zer Jun 5a4df34080
refactor: move from io/ioutil to io and os packages (#941)
* acceptance: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* archive: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* auth: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* buildpack: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* cache: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* cmd/lifecycle: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* env: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* internal: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* launch: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* layers: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* priv: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* testhelpers: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* tools: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* lifecycle: move from io/ioutil to io and os packages

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2022-10-31 10:56:33 -04:00
Michael de Senna 6a2b4bfd54
ci(lint): address most staticcheck alarms (#940)
* ci(lint): auto lint fixes

Signed-off-by: Michael de Senna <desenna@gmail.com>

* fix: replace deprecated funcs

Signed-off-by: Michael de Senna <desenna@gmail.com>

* ci(lint): fix many io/ioutil staticcheck

Signed-off-by: Michael de Senna <desenna@gmail.com>

* fix: import os

Signed-off-by: Michael de Senna <desenna@gmail.com>

Signed-off-by: Michael de Senna <desenna@gmail.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2022-10-25 17:48:29 -04:00
Natalie Arellano 8cf3678b28
Remove <image> as an argument to the extender (#926)
* Remove <image> as an argument to the extender

Favors passing the reference via analyzed.toml

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

* Fix confusing error messaging when failing to pull oci layout image

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

* Fix error expectation

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

* Fix selective write test

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

* Guard nil build image in extender factory

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-10-24 11:57:29 -04:00
Natalie Arellano 4b33990e43
Fix creator restore bug (#929)
* When platform API is at least 0.10, run the restore phase always but pass
-skip-restore as skip layers to skip layer metadata and SBOM restoration

This ensures:
- In the 5 phase invocation, the restorer can always run (for extension purposes)
- The 5 phase invocation will match the creator invocation

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

* Fix selective write test

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-10-19 16:51:36 -04:00
Natalie Arellano 2f8a818959
Dockerfiles phase 2 (#896)
* Consolidate logic in the platform package

- Remove the platform/launch package as it is not needed to avoid having the launcher depend on the lifecycle

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

* Reinstate platform/launch package to keep the launcher binary smaller

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

* Fix constant

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

* Remove comment

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

* WIP

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

* WIP

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

* Don't mount layers fixture in container

This way changes from the first build (/layers/config/metadata.toml, /layers/sbom, etc.)
are not propagated to the second build.

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

* Set environment variables from the extended build image in the build context

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

* Fix format string

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

* Restorer pulls builder manifest and config

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

* Copy extend-config.toml from extension output to /layers/generated

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

* Only import kaniko on linux

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

* WIP: units pass

Refactor buildpack build, detect, and generate to separate data model from service

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

* WIP: fixed some TODOs

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

* WIP: addressed some more TODOs, units pass

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

* WIP: units pass

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

* WIP: acceptance tests pass

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

* Address some minor TODOs

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

* When running extender acceptance, don't mount in /workspace directory

This leads to incorrect permissions issues when running on linux

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

* Don't try to check for specific curl version

This appears flaky

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

* fixes from testing. (#902)

Signed-off-by: Ozzy Osborne <bardweller@gmail.com>

Signed-off-by: Ozzy Osborne <bardweller@gmail.com>

* Lint

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

* Add tests and TODO

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

* Change CNB_BUILDPACK_DIR -> CNB_EXTENSION_DIR

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

* Fill in default generated dir

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

* Ensure kaniko doesn't try to pull 'oci:/kaniko/cache/base/sha256:XXX' from a remote registry

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

* Add test

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

* Fix panic

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

* Fix assertion

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

* Pass build_id as UUID to Dockerfile

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

* Add tests for selective package

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

* Remove kaniko fork

- Fix acceptance by adding CacheRunLayers option and moving 'ARG build_id=0' statements

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

* Fix windows

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

* Dockerfile validation (#918)

* Add Dockerfile Validation

Signed-off-by: Ozzy Osborne <bardweller@gmail.com>

* use mobi buildkit dockerfile parsing

Signed-off-by: Ozzy Osborne <bardweller@gmail.com>

Signed-off-by: Ozzy Osborne <bardweller@gmail.com>

* Add units for Dockerfile validation

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

* Fix launcher

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

* Minor improvements

- Test ReadGroup for extensions
- Ensure stderr is captured for acceptance test that might expect it
- Read group.toml into an accurate struct (that has extension and optional set for extensions)
  and set these fields to false before writing out to TOML or JSON

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

* Skip image extensions tests on Windows

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Ozzy Osborne <bardweller@gmail.com>
Co-authored-by: Javier Romero <rjavier@vmware.com>
Co-authored-by: Ozzy Osborne <bardweller@gmail.com>
2022-10-07 11:09:58 -04:00
Jesse Brown 68a937bb0a
Allow storing multiple commands instead of a single string (#920)
* Allow storing multiple commands instead of a single string (#900)

* Allow storing multiple commands instead of a single string

This is a first step to implementing #322. This PR is updating our internal structs to allow for a slice of commands while keeping the external API and behavior the same. A future PR will implement handling multiple commands depending on the API version and changing the behavior of the launcher and metadat file output changes.

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

* Comment on usage of cmp.Option

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

* Add comment on Matches interface usage for testing

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

* Added test for launch.toml decoding branching logic

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

* Apply suggestions from code review

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

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

* fixup! Apply suggestions from code review

* fixup! Apply suggestions from code review

* Fix editing daemon settings

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

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

* WIP

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

* Fixing up existing tests

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

* Remove now unused process specific decode paths

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

* fixup! Remove now unused process specific decode paths

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

* fixup! Remove now unused process specific decode paths

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

* fixup! Remove now unused process specific decode paths

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

* fixup! Remove now unused process specific decode paths

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

* fixup! Remove now unused process specific decode paths

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

* Clean up more serialization paths

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

* Remove toml wrapping code

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

* Added comment on UnmarshalTOML

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

* Put back code I didn't mean to remove

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

* Update launch/launch.go

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

* removed line

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

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2022-09-30 13:54:33 -04:00
Natalie Arellano cdc31cf671
Merge release/0.14.2 into main (#913)
* Upgrade go to 1.18 (#907)

* Use go 1.18 in CI
* Bump deps (except toml)

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

* Fix process type parsing (#912)

* Use the last part of the path when trying to find matching process. (#903)

* Use the last part of the path when trying to find matching process.

The process was comparing the base path minus the extension, which was blocking types with a `.` in them from ever matching.

Fixes #895

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

* fixup! Use the last part of the path when trying to find matching process.

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

* fixup! Use the last part of the path when trying to find matching process.

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

* fixup! Use the last part of the path when trying to find matching process.

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

* fixup! Use the last part of the path when trying to find matching process.

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

* fixup! Use the last part of the path when trying to find matching process.

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

* fixup! Use the last part of the path when trying to find matching process.

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

* Upgrade go to 1.18 (#907)

* Use go 1.18 in CI
* Bump deps (except toml)

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

* Test path lookup (#909)

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

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

* Revert "Merge branch 'release/0.14.2' into jab/fix-process-type-parsing"

This reverts commit 6f56a31733, reversing
changes made to e544937760.

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

* Bump imgutil

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

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
Co-authored-by: Jesse Brown <jabrown85@gmail.com>
2022-09-19 10:54:04 -04:00
Natalie Arellano a23f9b1e4f
Move logger interface to own package (#867)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-06-24 13:24:40 -04:00
Natalie Arellano 2e739d6de5
Dockerfiles phase 1 (detect changes) (#860)
Detect changes to support Dockerfiles feature

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-06-08 10:09:31 -04:00
Natalie Arellano 141d74b0a7
If rename fails, fall back to copy and delete on Windows (#856)
* If rename fails, fall back to copy and delete on Windows

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

* Rename internal/io to internal/fsutil

This avoids import collisions with go's io package

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

* fsutil.Copy explicitly ignores weird edge cases

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-05-05 16:17:03 -04:00
Natalie Arellano 86d84b37ee
Move logic out of cmd/lifecycle/analyzer.go (#805)
* Acceptance tests pass with creator commented out

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

* Fix creator

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

* Add unit tests for analyze inputs

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

* Add scaffold for analyzer builder unit tests

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

* Add many unit tests, still have some TODOs

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

* Address most TODOs

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

* Acceptance tests pass

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

* A few more TODOs

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

* Bring back go 1.16

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

* Add unit test

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

* Fix acceptance tests

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

* Fix units

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

* Remove nolint

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

* Remove unneeded things

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

* Use operations pattern

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

* Refactor tests to take advantage of operations pattern

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

* Add missing tests

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

* Fix lint

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

* Analyzer factory assigns "nop" services by default

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

* Try to fix registry handler test

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

* Move new package from cmd/lifecycle/platform to platform/inputs

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

* Updates per PR review

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

* Test the platform instead of the exiter

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

* Combine cmd/lifecycle/platform and platform

With some small changes to avoid an import cycle, we can make a meaningful platform package

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

* Clean up constructors

Eventually only the platform package should switch on platform api

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

* Remove ForAnalyzer struct

Having the analyzer factory take a list of args will ensure we don't forget
to update the creator when things change.

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

* Combine cmd/launcher/platform and platform

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

* Remove comment

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

* Remove spec alias

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

* Move cache metadata back to platform

The lifecycle shouldn't have to depend on the cache package, just the interface

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

* Add comment and remove unused vars

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

* Add test for buildpack incompatibility error

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

* Fix typo

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-05-04 11:45:26 -04:00
Natalie Arellano a820b84f52
Merge release/0.13.5 into main (#833)
* Specify windows-2019 since windows-2022 is the default runner now (#816)

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

* Bump containerd to v1.5.10 (#822)

- Removes CVEs (CVE-2022-23648 & CVE-2021-43816) reported in containerd 1.5.8 & 1.5.9

Signed-off-by: matthewmcnew <mmcnew@pivotal.io>

* When restoring sbom files, silently ignore if the bp layers directory does not exist (#832)

This can happen when there are sbom files for launch but the cache is empty

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

Co-authored-by: Matthew McNew <mmcnew@pivotal.io>
2022-03-21 17:44:28 -04:00
Natalie Arellano 828906b144
Write sbom.legacy.json files for newer platform api (#825)
* Write sbom.legacy.json files for newer platform api

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

* Don't print empty bom for platform 0.9

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

* Fix function name

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

* Return empty bom for newer platform

Due to limitations of our TOML library, we can't add MarshalTOML to the top-level struct.

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

* Use standard capitalization for sbom

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-03-21 17:30:48 -04:00
Natalie Arellano a176d44f72
Improve performance when restoring launch sboms from daemon (#800)
* Add new flags to analyzer

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

* Use nop restorer when not supported by the platform.

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

* Pass through skip layers from the creator

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

* Move empty check inside service

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

* Fix failing tests

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-02-10 12:05:39 -05:00
Natalie Arellano dd0c0d5e16
Fix bug where sbom is not restored for launch=true cache=false layers (#773)
* Fix bug where sbom is not restored for launch=true cache=false layers

Because the layer directory does not exist in the build container, the lifecycle
did not bother to look for any sbom files.

This changes `eachDir` to `eachLayer`. Usages of the return value of `eachLayer`
will not fail if the layer directory does not exist.

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

* WIP

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

* Unit tests passing

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

* Acceptance tests passing

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

* Remove focus

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

* Fix format

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

* Make test setup simpler

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

* Fix format

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

* Fix volume permissions issue

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

* Updates from code review && fix

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

* Don't fail if failed to remove directory

This is the approach taken by analyzer acceptance and pack.

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

* Fix bug when layers/sbom is not cleared if -skip-restore is used

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2021-12-03 14:26:02 -05:00
Yael Harel 2186200870
Move the layer metadata restorer and the layer sha store to a new package (#724)
* Move the layer metadata restorer and the layer sha store to a new package

Signed-off-by: Yael Harel <yharel@vmware.com>

* Remove code duplication of WriteTOML

Signed-off-by: Yael Harel <yharel@vmware.com>

* Create a utils package

Move most of utils.go and the function WriteTOML there

Signed-off-by: Yael Harel <yharel@vmware.com>

* Refactor the new utils package

Signed-off-by: Yael Harel <yharel@vmware.com>

* Make layermetadata an internal package

Signed-off-by: Yael Harel <yharel@vmware.com>

* Move the imageutils files to the image package

Signed-off-by: Yael Harel <yharel@vmware.com>

* Make encoding an internal package

Signed-off-by: Yael Harel <yharel@vmware.com>

* Add the ReadGroup test

Signed-off-by: Yael Harel <yharel@vmware.com>

* Delete image/utils_test.go

WriteTOML that was tested there  moved to the internal/encoding package

Signed-off-by: Yael Harel <yharel@vmware.com>

* Updates to #724 (layer metadata restorer) (#753)

* Merge main

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

* Rename layermetadata to layer

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

* Rename layer metadata restorer

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

* WIP - layers.go has all dependencies on buildpack

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

* WIP

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

* Fix imports

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

* Move some things back to lifecycle package and make str package internal

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

* Rename variable

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

* Make helper function private

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

* Small fix

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

* Fix

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

* Make structs and interface private

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

* Consolidate logic for layer metadata file

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

* Remove unneeded file

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

Co-authored-by: Natalie Arellano <narellano@vmware.com>
2021-12-01 15:04:19 -05:00
Micah Young c06b1d2d86 Clean up logging
- Use heroku/color for colors
- Use apex/logger for base logger
- Fix compiling for Windows

Signed-off-by: Micah Young <myoung@pivotal.io>
Signed-off-by: Javier Romero <jromero@pivotal.io>
2019-10-16 11:43:25 -05:00
David Gageot 3ec1d1647c Add more linters
Also restore the check on imports being organised
in 3 groups.

Signed-off-by: David Gageot <david@gageot.net>
2019-10-15 11:41:59 +02:00
David Gageot ac809101a3 Fix lint errors
Signed-off-by: David Gageot <david@gageot.net>
2019-10-14 17:37:18 +02:00
Joe Kutner ab67a09971
Added logging tests and better windows support
Signed-off-by: Joe Kutner <jpkutner@gmail.com>
2019-09-19 08:21:59 -05:00
Joe Kutner 5edf8d1ae5
Add WantLevel to Logger interface
Signed-off-by: Joe Kutner <jpkutner@gmail.com>
2019-09-18 15:07:38 -05:00