Compare commits

...

471 Commits

Author SHA1 Message Date
Jesse Brown 0f224448e5
Merge pull request #1534 from buildpacks/dependabot/go_modules/github.com/go-viper/mapstructure/v2-2.4.0
Bump github.com/go-viper/mapstructure/v2 from 2.3.0 to 2.4.0
2025-08-21 12:37:38 -05:00
dependabot[bot] d2f4fccf02
Bump github.com/go-viper/mapstructure/v2 from 2.3.0 to 2.4.0
Bumps [github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure) from 2.3.0 to 2.4.0.
- [Release notes](https://github.com/go-viper/mapstructure/releases)
- [Changelog](https://github.com/go-viper/mapstructure/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-viper/mapstructure/compare/v2.3.0...v2.4.0)

---
updated-dependencies:
- dependency-name: github.com/go-viper/mapstructure/v2
  dependency-version: 2.4.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-21 15:21:02 +00:00
Jesse Brown 4fd9dc8da9
Merge pull request #1512 from buildpacks/dependabot/go_modules/github.com/go-viper/mapstructure/v2-2.3.0
Bump github.com/go-viper/mapstructure/v2 from 2.2.1 to 2.3.0
2025-08-19 13:15:59 -05:00
Jesse Brown 84bbd62a05
Merge pull request #1532 from buildpacks/jab/bump-imgutil-4b1c8875ba7e
Bump imgutil for race fix
2025-08-14 14:46:42 -05:00
Jesse Brown 3eec76970d
Bump imgutil for race fix
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-08-14 12:40:41 -05:00
Jesse Brown 828680fd2d
Merge pull request #1530 from buildpacks/jab/bump-imgutil-081325
Pull up imgutil to latest on main
2025-08-13 11:21:21 -05:00
Jesse Brown c2d348fe76
Pull up imgutil to latest on main
This should bring in the latest imgutil changes that includes significant performance improvements in containerd storage docker daemon use.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-08-13 08:24:05 -05:00
Jesse Brown 998df22b75
Merge pull request #1528 from buildpacks/dependabot/github_actions/actions/download-artifact-5
Bump actions/download-artifact from 4 to 5
2025-08-12 14:38:56 -05:00
Jesse Brown 22f90fc35f
Merge pull request #1529 from buildpacks/jab/go-1-24-6
Update to Go 1.24.6
2025-08-12 13:27:30 -05:00
Jesse Brown d61099a58b
Merge pull request #1526 from buildpacks/dependabot/go_modules/go-dependencies-3727568c2b
Bump the go-dependencies group across 1 directory with 3 updates
2025-08-12 10:19:54 -05:00
Jesse Brown c4730aeb7f
Update to Go 1.24.6
- Update Go version in test-s390x.yml
- Update Go version in Dockerfile
- Update Go version in go.mod
- Add aarch64 support to tools/image

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-08-12 08:55:13 -05:00
Jesse Brown 61101937d3
Merge pull request #1525 from buildpacks/jab/merge-output-streams
Send stdout and stderr to the same stream (build and generate)
2025-08-12 08:29:39 -05:00
dependabot[bot] b26e08c712
Bump actions/download-artifact from 4 to 5
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-12 09:49:15 +00:00
dependabot[bot] c924316f12
Bump the go-dependencies group across 1 directory with 3 updates
Bumps the go-dependencies group with 2 updates in the / directory: [github.com/chainguard-dev/kaniko](https://github.com/chainguard-dev/kaniko) and [golang.org/x/sys](https://github.com/golang/sys).


Updates `github.com/chainguard-dev/kaniko` from 1.25.0 to 1.25.1
- [Release notes](https://github.com/chainguard-dev/kaniko/releases)
- [Changelog](https://github.com/chainguard-dev/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chainguard-dev/kaniko/compare/v1.25.0...v1.25.1)

Updates `github.com/moby/buildkit` from 0.22.0 to 0.23.2
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.22.0...v0.23.2)

Updates `golang.org/x/sys` from 0.34.0 to 0.35.0
- [Commits](https://github.com/golang/sys/compare/v0.34.0...v0.35.0)

---
updated-dependencies:
- dependency-name: github.com/chainguard-dev/kaniko
  dependency-version: 1.25.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/moby/buildkit
  dependency-version: 0.23.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-version: 0.35.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-12 07:35:44 +00:00
Jesse Brown d99c20ea89
fixup! Send stdout and stderr to the same stream (build and generate)
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-08-11 09:53:26 -05:00
Jesse Brown ced3359adc
fixup! Send stdout and stderr to the same stream (build and generate)
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-08-11 09:48:59 -05:00
Jesse Brown 24b93c486f
fixup! Send stdout and stderr to the same stream (build and generate)
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-08-11 09:33:43 -05:00
Jesse Brown 5ac11c505d
Send stdout and stderr to the same stream (build and generate)
To ensure ordering of stdout and stderr in build and generate phases, send the stdout and stderr of the executing command to the same stream (stdout).

This will have an outside effect of anyone consuming `lifecycle` as what was previously in stderr is now in stdout.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-08-11 09:22:44 -05:00
Jesse Brown 8f1b15834c
Merge pull request #1521 from buildpacks/dependabot/go_modules/go-dependencies-8e2b8007e7
Bump the go-dependencies group across 1 directory with 4 updates
2025-07-29 15:42:47 -05:00
dependabot[bot] e25dc2d2f2
Bump the go-dependencies group across 1 directory with 4 updates
Bumps the go-dependencies group with 2 updates in the / directory: [github.com/awslabs/amazon-ecr-credential-helper/ecr-login](https://github.com/awslabs/amazon-ecr-credential-helper) and [github.com/containerd/containerd](https://github.com/containerd/containerd).


Updates `github.com/awslabs/amazon-ecr-credential-helper/ecr-login` from 0.9.1 to 0.10.1
- [Release notes](https://github.com/awslabs/amazon-ecr-credential-helper/releases)
- [Changelog](https://github.com/awslabs/amazon-ecr-credential-helper/blob/main/CHANGELOG.md)
- [Commits](https://github.com/awslabs/amazon-ecr-credential-helper/compare/v0.9.1...v0.10.1)

Updates `github.com/containerd/containerd` from 1.7.27 to 1.7.28
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.27...v1.7.28)

Updates `golang.org/x/sync` from 0.15.0 to 0.16.0
- [Commits](https://github.com/golang/sync/compare/v0.15.0...v0.16.0)

Updates `golang.org/x/sys` from 0.33.0 to 0.34.0
- [Commits](https://github.com/golang/sys/compare/v0.33.0...v0.34.0)

---
updated-dependencies:
- dependency-name: github.com/awslabs/amazon-ecr-credential-helper/ecr-login
  dependency-version: 0.10.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/containerd/containerd
  dependency-version: 1.7.28
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sync
  dependency-version: 0.16.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-version: 0.34.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-29 20:28:10 +00:00
Jesse Brown f27995af70
Merge pull request #1520 from buildpacks/dependabot/go_modules/github.com/docker/docker-28.3.3incompatible
Bump github.com/docker/docker from 28.3.1+incompatible to 28.3.3+incompatible
2025-07-29 15:26:04 -05:00
dependabot[bot] f3e3719918
Bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 28.3.1+incompatible to 28.3.3+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v28.3.1...v28.3.3)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-version: 28.3.3+incompatible
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-29 20:04:05 +00:00
Jesse Brown 3a692e4a34
Merge pull request #1517 from buildpacks/jab/debug-draft-release
debug draft step to see why it does not like recent release branch
2025-07-18 11:27:38 -05:00
Jesse Brown f8bf3ed25e
debug draft step to see why it does not like recent release branch 2025-07-18 09:06:11 -05:00
Jesse Brown f992fd6a6d
Merge pull request #1516 from buildpacks/jab/go-1-24-5
Bump go to 1.24.5
2025-07-17 12:56:01 -05:00
Jesse Brown 669686636a
Bump go to 1.24.5
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-07-16 21:28:33 -05:00
Jesse Brown 21a01a93f5
Merge pull request #1513 from buildpacks/dependabot/go_modules/go-dependencies-b286305dda
Bump github.com/docker/docker from 28.3.0+incompatible to 28.3.1+incompatible in the go-dependencies group
2025-07-08 08:35:09 -05:00
dependabot[bot] 187d6555ad
Bump github.com/docker/docker in the go-dependencies group
Bumps the go-dependencies group with 1 update: [github.com/docker/docker](https://github.com/docker/docker).


Updates `github.com/docker/docker` from 28.3.0+incompatible to 28.3.1+incompatible
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v28.3.0...v28.3.1)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-version: 28.3.1+incompatible
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-08 02:41:13 +00:00
dependabot[bot] d5a70ecfd6
Bump github.com/go-viper/mapstructure/v2 from 2.2.1 to 2.3.0
Bumps [github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure) from 2.2.1 to 2.3.0.
- [Release notes](https://github.com/go-viper/mapstructure/releases)
- [Changelog](https://github.com/go-viper/mapstructure/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-viper/mapstructure/compare/v2.2.1...v2.3.0)

---
updated-dependencies:
- dependency-name: github.com/go-viper/mapstructure/v2
  dependency-version: 2.3.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-03 17:46:15 +00:00
Jesse Brown 096e921bc0
Merge pull request #1511 from AidanDelaney/feature/use-go-tools
Specify tool versions in go.mod
2025-07-03 12:44:59 -05:00
Aidan Delaney 9f602ab430 Specify tool versions in go.mod
Use go 1.24 style "tool" directive to specify tool
dependencies.

Signed-off-by: Aidan Delaney <aidan.delaney@gmail.com>
2025-07-03 09:31:27 +00:00
Jesse Brown eff4eb9d82
Merge pull request #1510 from buildpacks/jab/bump-imgutil-626
Bump imgutil and docker
2025-06-26 15:01:10 -05:00
Jesse Brown ed61c00263
Bump imgutil and docker
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-06-26 12:36:04 -05:00
Jesse Brown 07705bb60a
Merge pull request #1508 from buildpacks/jab/chainguard-kaniko
Replace GoogleContainerTools/kaniko with chainguard-dev/kaniko
2025-06-26 11:23:19 -05: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 4e5936a962
Merge pull request #1507 from maxkrumpe/hotfix/bump-up-go-version
Bump go to version 1.24.4 to fix CVE-2025-22874
2025-06-24 09:18:42 -05:00
Max Krumpe f4c7a93419 bump go to version 1.24.4
Signed-off-by: Max Krumpe <max.krumpe@gmx.de>
2025-06-16 12:14:11 +02:00
Jesse Brown 64b78965f6
Merge pull request #1501 from buildpacks/jab/bump-go-1-24-3
bump go
2025-05-28 17:02:53 -05:00
Jesse Brown 906b0e0779
bump go 2025-05-28 11:40:14 -05:00
Jesse Brown fb74763226
Merge pull request #1500 from buildpacks/dependabot/go_modules/go-dependencies-d0ab6aa9b2
Bump the go-dependencies group with 4 updates
2025-05-28 11:14:59 -05:00
Jesse Brown c121049b41
bump imgutil 2025-05-28 10:00:00 -05:00
dependabot[bot] b98b668838
Bump the go-dependencies group with 4 updates
Bumps the go-dependencies group with 4 updates: [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko), [github.com/docker/docker](https://github.com/docker/docker), [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) and [github.com/moby/buildkit](https://github.com/moby/buildkit).


Updates `github.com/GoogleContainerTools/kaniko` from 1.23.2 to 1.24.0
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.23.2...v1.24.0)

Updates `github.com/docker/docker` from 27.0.3+incompatible to 28.1.1+incompatible
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v27.0.3...v28.1.1)

Updates `github.com/google/go-containerregistry` from 0.20.2 to 0.20.4
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.20.2...v0.20.4)

Updates `github.com/moby/buildkit` from 0.14.1 to 0.22.0
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.14.1...v0.22.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-version: 1.24.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/docker/docker
  dependency-version: 28.1.1+incompatible
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: go-dependencies
- dependency-name: github.com/google/go-containerregistry
  dependency-version: 0.20.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/moby/buildkit
  dependency-version: 0.22.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-26 23:02:02 +00:00
Jesse Brown 761d2bdbb8
Merge pull request #1499 from buildpacks/dependabot/go_modules/go-dependencies-c9f32dbcca
Bump the go-dependencies group with 2 updates
2025-05-14 09:19:35 -05:00
dependabot[bot] 14a6c36c78
Bump the go-dependencies group with 2 updates
Bumps the go-dependencies group with 2 updates: [golang.org/x/sync](https://github.com/golang/sync) and [golang.org/x/sys](https://github.com/golang/sys).


Updates `golang.org/x/sync` from 0.13.0 to 0.14.0
- [Commits](https://github.com/golang/sync/compare/v0.13.0...v0.14.0)

Updates `golang.org/x/sys` from 0.32.0 to 0.33.0
- [Commits](https://github.com/golang/sys/compare/v0.32.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-version: 0.14.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-12 23:33:31 +00:00
Jesse Brown 40c408d453
Merge pull request #1496 from buildpacks/jab/bump-imgutil
Bump imgutil
2025-05-07 12:39:36 -05:00
Jesse Brown 99e4c87d75
Bump imgutil
This brings in the latest version of imgutil which includes a fix for insecure registry support.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-04-24 09:27:40 -05:00
Jesse Brown 8bdb640857
Merge pull request #1493 from buildpacks/jjbustamante/restore-exec-d-windows
Remove build unix constraint to exec_d.go and restore archive tar windows file
2025-04-21 11:41:40 -05:00
Juan Bustamante 997840b2f2 restoring archive/tar_windows.go
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
2025-04-20 18:39:44 -05:00
Juan Bustamante 4f7f331816 removing go:build unix because we already removed windows support
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
2025-04-17 19:06:45 -05:00
Juan Bustamante 55c8b988a5 removing the os build constraint and moving the linux implementation into exec_d
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
2025-04-16 15:08:45 -05:00
Jesse Brown 92d9833a46
Merge pull request #1494 from sap-contributions/update-vulnerable-deps
Update vulnerable dependencies
2025-04-16 11:36:27 -05:00
Pavel Busko 5f776886ec code lint
Signed-off-by: Pavel Busko <pavel.busko@sap.com>
2025-04-16 14:47:09 +02:00
Pavel Busko d34588e569 update vulnerable dependencies
Signed-off-by: Pavel Busko <pavel.busko@sap.com>
2025-04-16 14:26:25 +02:00
Juan Bustamante f923ae5e07 adding also archive windows file
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
2025-04-09 21:08:11 -05:00
Juan Bustamante 3d23976f2d restoring launch/exec_d_windows.go to being able to compile pack LCOW
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
2025-04-07 19:59:30 -05:00
Jesse Brown c895ed4002
Merge pull request #1486 from buildpacks/dependabot/go_modules/go-dependencies-6f573b709f
Bump the go-dependencies group across 1 directory with 3 updates
2025-03-19 09:03:11 -05:00
dependabot[bot] 0adc6dd8ad
Bump the go-dependencies group across 1 directory with 3 updates
Bumps the go-dependencies group with 3 updates in the / directory: [github.com/BurntSushi/toml](https://github.com/BurntSushi/toml), [golang.org/x/sync](https://github.com/golang/sync) and [golang.org/x/sys](https://github.com/golang/sys).


Updates `github.com/BurntSushi/toml` from 1.4.0 to 1.5.0
- [Release notes](https://github.com/BurntSushi/toml/releases)
- [Commits](https://github.com/BurntSushi/toml/compare/v1.4.0...v1.5.0)

Updates `golang.org/x/sync` from 0.11.0 to 0.12.0
- [Commits](https://github.com/golang/sync/compare/v0.11.0...v0.12.0)

Updates `golang.org/x/sys` from 0.30.0 to 0.31.0
- [Commits](https://github.com/golang/sys/compare/v0.30.0...v0.31.0)

---
updated-dependencies:
- dependency-name: github.com/BurntSushi/toml
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-18 14:17:26 +00:00
Jesse Brown d4fe8f0554
Merge pull request #1481 from buildpacks/dependabot/github_actions/appleboy/ssh-action-1.2.2
Bump appleboy/ssh-action from 1.2.1 to 1.2.2
2025-03-18 09:11:59 -05:00
Jesse Brown 0727354ebf
Merge pull request #1482 from buildpacks/dependabot/go_modules/golang.org/x/net-0.36.0
Bump golang.org/x/net from 0.34.0 to 0.36.0
2025-03-18 09:11:33 -05:00
Jesse Brown e9bb570999
Merge pull request #1485 from buildpacks/dependabot/go_modules/github.com/containerd/containerd-1.7.27
Bump github.com/containerd/containerd from 1.7.26 to 1.7.27
2025-03-18 09:11:04 -05:00
dependabot[bot] 3760f4bb9c
Bump github.com/containerd/containerd from 1.7.26 to 1.7.27
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.26 to 1.7.27.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.26...v1.7.27)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-18 00:20:02 +00:00
dependabot[bot] 1b84db28e2
Bump golang.org/x/net from 0.34.0 to 0.36.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.34.0 to 0.36.0.
- [Commits](https://github.com/golang/net/compare/v0.34.0...v0.36.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-13 01:51:23 +00:00
dependabot[bot] ed2e33c6e6
Bump appleboy/ssh-action from 1.2.1 to 1.2.2
Bumps [appleboy/ssh-action](https://github.com/appleboy/ssh-action) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/appleboy/ssh-action/releases)
- [Changelog](https://github.com/appleboy/ssh-action/blob/master/.goreleaser.yaml)
- [Commits](https://github.com/appleboy/ssh-action/compare/v1.2.1...v1.2.2)

---
updated-dependencies:
- dependency-name: appleboy/ssh-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-11 00:11:40 +00:00
Jesse Brown 248343e3b7
Merge pull request #1476 from buildpacks/dependabot/go_modules/go-dependencies-cfb8bb1f27
Bump the go-dependencies group across 1 directory with 5 updates
2025-02-28 14:53:22 -06:00
dependabot[bot] 83faba2a2f
Bump the go-dependencies group across 1 directory with 5 updates
Bumps the go-dependencies group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [github.com/awslabs/amazon-ecr-credential-helper/ecr-login](https://github.com/awslabs/amazon-ecr-credential-helper) | `0.0.0-20240419161514-af205d85bb44` | `0.9.1` |
| [github.com/containerd/containerd](https://github.com/containerd/containerd) | `1.7.24` | `1.7.26` |
| [github.com/google/go-cmp](https://github.com/google/go-cmp) | `0.6.0` | `0.7.0` |
| [golang.org/x/sync](https://github.com/golang/sync) | `0.10.0` | `0.11.0` |
| [golang.org/x/sys](https://github.com/golang/sys) | `0.29.0` | `0.30.0` |



Updates `github.com/awslabs/amazon-ecr-credential-helper/ecr-login` from 0.0.0-20240419161514-af205d85bb44 to 0.9.1
- [Release notes](https://github.com/awslabs/amazon-ecr-credential-helper/releases)
- [Changelog](https://github.com/awslabs/amazon-ecr-credential-helper/blob/main/CHANGELOG.md)
- [Commits](https://github.com/awslabs/amazon-ecr-credential-helper/commits/v0.9.1)

Updates `github.com/containerd/containerd` from 1.7.24 to 1.7.26
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.24...v1.7.26)

Updates `github.com/google/go-cmp` from 0.6.0 to 0.7.0
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.6.0...v0.7.0)

Updates `golang.org/x/sync` from 0.10.0 to 0.11.0
- [Commits](https://github.com/golang/sync/compare/v0.10.0...v0.11.0)

Updates `golang.org/x/sys` from 0.29.0 to 0.30.0
- [Commits](https://github.com/golang/sys/compare/v0.29.0...v0.30.0)

---
updated-dependencies:
- dependency-name: github.com/awslabs/amazon-ecr-credential-helper/ecr-login
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/google/go-cmp
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-28 20:17:42 +00:00
Jesse Brown d71de96b56
Merge pull request #1418 from buildpacks/dependabot/go_modules/github.com/golang-jwt/jwt/v4-4.5.1
Bump github.com/golang-jwt/jwt/v4 from 4.5.0 to 4.5.1
2025-02-28 13:27:16 -06:00
Jesse Brown 05b0768a0b
Merge pull request #1473 from buildpacks/jab/go-1.24
go 1.24
2025-02-28 13:18:43 -06: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 60a94c4b03
Update linter
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-02-28 12:03:32 -06:00
Jesse Brown 3a30c0b597
go 1.24
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-02-28 10:37:53 -06:00
Jesse Brown c0cbaf1e02
Merge pull request #1470 from buildpacks/dependabot/github_actions/appleboy/ssh-action-1.2.1
Bump appleboy/ssh-action from 1.1.0 to 1.2.1
2025-02-28 09:40:21 -06:00
dependabot[bot] ba82c0d126
Bump appleboy/ssh-action from 1.1.0 to 1.2.1
Bumps [appleboy/ssh-action](https://github.com/appleboy/ssh-action) from 1.1.0 to 1.2.1.
- [Release notes](https://github.com/appleboy/ssh-action/releases)
- [Changelog](https://github.com/appleboy/ssh-action/blob/master/.goreleaser.yaml)
- [Commits](https://github.com/appleboy/ssh-action/compare/v1.1.0...v1.2.1)

---
updated-dependencies:
- dependency-name: appleboy/ssh-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-28 15:12:11 +00:00
Jesse Brown fd1604734b
Merge pull request #1428 from buildpacks/dependabot/github_actions/codecov/codecov-action-5
Bump codecov/codecov-action from 4 to 5
2025-02-28 09:11:46 -06:00
Jesse Brown 7bd8e735ea
Merge pull request #1446 from buildpacks/dependabot/github_actions/anchore/scan-action-6
Bump anchore/scan-action from 3 to 6
2025-02-28 09:11:08 -06:00
Jesse Brown e2ec390385
Merge pull request #1466 from buildpacks/jab/use-github-ref-name
Use GITHUB_REF_NAME for draft action
2025-02-25 09:12:18 -06:00
Jesse Brown 3109b04667
Use GITHUB_REF_NAME for draft action
The `GITHUB_REF` includes the full `ref/heads...`and the `gh release create` is expecting the short branch/tag name.

This somehow works fine - but also breaks the UI for generating release notes. This should fix that.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-02-25 08:04:11 -06:00
Jesse Brown fe4a50b65f
Merge pull request #1469 from buildpacks/jab/remove-delete-race
Remove potential for exporter_test race
2025-02-24 15:45:35 -06:00
Jesse Brown 036e579e28
Remove potential for exporter_test race
I think we are seeing flappy tests due to the potential for the registry and daemon case sharing the same variable. Lets duplicate the variable to remove the potential and do the cleanup in each test when block.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-02-24 14:48:12 -06:00
Jesse Brown 93c8b8b133
Merge pull request #1468 from buildpacks/jab/safer-arg-validation
Ensure lifecycle arg validation executed as expected.
2025-02-24 14:12:20 -06: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
Jesse Brown c8585e10fd
Merge pull request #1464 from joeybrown/release/logging-to-tests 2025-02-18 18:03:34 -06:00
Joey Brown 3a09c6dc98 add logging and thread sleep
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
2025-02-13 10:17:25 -06:00
Jesse Brown 2c0f9bd6cd
Merge pull request #1461 from buildpacks/jabrown85-patch-1
Update draft-release.yml
2025-02-10 10:39:03 -06:00
Jesse Brown 35e4fb90bc
Update draft-release.yml
Windows artifacts are no longer built - the draft release validation needs to be updated to reflect that.

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

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-02-10 10:07:09 -06:00
Jesse Brown 9a7a3b586f
Merge pull request #1452 from gogolok/makefile_darwin_integration
Makefile: Use new build approach for darwin amd64+arm64
2025-01-16 09:47:54 -06:00
Robert Gogolok 93d5de7423 Makefile: Use new build approach for darwin amd64+arm64
Signed-off-by: Robert Gogolok <robert.gogolok@stackit.cloud>
2025-01-16 10:53:05 +01:00
Jesse Brown 45b52d389a
Merge pull request #1438 from gogolok/create_dynamic_build_targets
Makefile: Create dynamic build targets
2025-01-10 08:43:33 -06:00
Robert Gogolok 89aeb9ca7a Makefile: Create dynamic build targets
Signed-off-by: Robert Gogolok <robert.gogolok@stackit.cloud>
2025-01-09 23:49:54 +01:00
Jesse Brown b58433202e
Merge pull request #1449 from buildpacks/jab/bump-go-deps 2025-01-07 14:47:07 -06:00
Jesse Brown 92c59d39d9
fixup! Updating go deps for grype 2025-01-06 13:12:51 -06:00
Jesse Brown 952997fe48
Updating go deps for grype
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2025-01-06 13:03:12 -06:00
Jesse Brown 6fd74a9d56
Merge pull request #1444 from buildpacks/dependabot/go_modules/golang.org/x/crypto-0.31.0
Bump golang.org/x/crypto from 0.24.0 to 0.31.0
2025-01-06 12:24:53 -06:00
dependabot[bot] d5e9ad18c5
Bump golang.org/x/crypto from 0.24.0 to 0.31.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.24.0 to 0.31.0.
- [Commits](https://github.com/golang/crypto/compare/v0.24.0...v0.31.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-06 17:56:38 +00:00
Jesse Brown 890ce690cf
Merge pull request #1441 from buildpacks/jab/remove-windows-support
Remove Windows Support
2025-01-06 11:02:08 -06:00
Jesse Brown e38a4b5eb6
fixup! Remove Windows Support
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2024-12-18 09:17:10 -06:00
dependabot[bot] 2191fc1b5f
Bump anchore/scan-action from 3 to 6
Bumps [anchore/scan-action](https://github.com/anchore/scan-action) from 3 to 6.
- [Release notes](https://github.com/anchore/scan-action/releases)
- [Changelog](https://github.com/anchore/scan-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/anchore/scan-action/compare/v3...v6)

---
updated-dependencies:
- dependency-name: anchore/scan-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-16 23:14:03 +00:00
Jesse Brown 2062d5fefc
Merge pull request #1442 from gogolok/dep_updates
Bump go-dependencies containerd, golang.org/x/sync and golang.org/x/sys
2024-12-11 09:36:53 -06:00
Robert Gogolok 1534af909b Bump golang.org/x/sys 0.28.0
Signed-off-by: Robert Gogolok <robert.gogolok@stackit.cloud>
2024-12-11 00:12:00 +01:00
Robert Gogolok 84c043350b Bump golang.org/x/sync v0.10.0
Signed-off-by: Robert Gogolok <robert.gogolok@stackit.cloud>
2024-12-11 00:11:43 +01: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 7fd497eac2 Bump github.com/containerd/containerd v1.7.24
Signed-off-by: Robert Gogolok <robert.gogolok@stackit.cloud>
2024-12-10 23:48:27 +01:00
Jesse Brown ddcded12be
Merge pull request #1439 from gogolok/support_freebsd_build_phase
Support FreeBSD build phase
2024-12-10 08:24:07 -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 acd4499d35
Merge pull request #1437 from gogolok/correct_lifecycle_mk
lifecycle.mk: Add creater and extender symlinks
2024-12-09 09:41:57 -06:00
Robert Gogolok 68703b6cb7 lifecycle.mk: Add creater and extender symlinks
Signed-off-by: Robert Gogolok <robert.gogolok@stackit.cloud>
2024-12-09 00:28:36 +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
Jesse Brown 564dcd3ef3
Merge pull request #1432 from gogolok/go_build_unix
Use `unix` build constraint
2024-12-03 08:57:33 -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 23922f4d08 exportloopref: deprecation
Signed-off-by: Robert Gogolok <robert.gogolok@stackit.cloud>
2024-12-03 09:48:28 +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
Jesse Brown 85540b4c90
Merge pull request #1431 from gogolok/remove_obsolete_build_constraint
Remove obsolete // +build lines
2024-12-02 10:18:19 -06: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
dependabot[bot] 3985f2e33a
Bump codecov/codecov-action from 4 to 5
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-19 00:03:45 +00: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 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
Jesse Brown 0690d133ca
Remove pack acceptance test on windows. (#1421)
Ref: https://github.com/buildpacks/rfcs/pull/311

We don't want to block lifecycle releases on pack windows failure anymore. They are unstable and not something we are staffed to invest time into.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2024-11-11 10:44:21 -05:00
Jesse Brown 58f58e58a6
Silence non-impactful CVE - GHSA-v23v-6jw2-98fq (#1420)
Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2024-11-07 14:44:52 -05:00
Jesse Brown 5517e86a56
bump upload-artifacts-action (#1419)
* bump upload-artifacts-action

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

* bumping download-artifact to v4 as well

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

---------

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2024-11-06 14:45:20 -05:00
dependabot[bot] e6091c97d3
Bump github.com/golang-jwt/jwt/v4 from 4.5.0 to 4.5.1
Bumps [github.com/golang-jwt/jwt/v4](https://github.com/golang-jwt/jwt) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v4.5.0...v4.5.1)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-04 23:44:34 +00:00
dependabot[bot] 095affa914
Bump appleboy/ssh-action from 1.0.3 to 1.1.0 (#1404)
Bumps [appleboy/ssh-action](https://github.com/appleboy/ssh-action) from 1.0.3 to 1.1.0.
- [Release notes](https://github.com/appleboy/ssh-action/releases)
- [Changelog](https://github.com/appleboy/ssh-action/blob/master/.goreleaser.yaml)
- [Commits](https://github.com/appleboy/ssh-action/compare/v1.0.3...v1.1.0)

---
updated-dependencies:
- dependency-name: appleboy/ssh-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-01 15:32:19 -04:00
Natalie Arellano 0872e08127
Silence non-impactful CVE (#1415)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-10-29 09:57:21 -04:00
dependabot[bot] 4a52e3c9e7
Bump the go-dependencies group across 1 directory with 7 updates (#1409)
* Bump the go-dependencies group across 1 directory with 7 updates

Bumps the go-dependencies group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko) | `1.23.1` | `1.23.2` |
| [github.com/containerd/containerd](https://github.com/containerd/containerd) | `1.7.19` | `1.7.23` |
| [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) | `0.20.0` | `0.20.2` |
| [golang.org/x/sync](https://github.com/golang/sync) | `0.7.0` | `0.8.0` |
| [golang.org/x/sys](https://github.com/golang/sys) | `0.22.0` | `0.26.0` |



Updates `github.com/GoogleContainerTools/kaniko` from 1.23.1 to 1.23.2
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.23.1...v1.23.2)

Updates `github.com/containerd/containerd` from 1.7.19 to 1.7.23
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.19...v1.7.23)

Updates `github.com/docker/docker` from 26.1.5+incompatible to 27.0.3+incompatible
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v26.1.5...v27.0.3)

Updates `github.com/google/go-containerregistry` from 0.20.0 to 0.20.2
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.20.0...v0.20.2)

Updates `github.com/moby/buildkit` from 0.13.2 to 0.14.1
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.13.2...v0.14.1)

Updates `golang.org/x/sync` from 0.7.0 to 0.8.0
- [Commits](https://github.com/golang/sync/compare/v0.7.0...v0.8.0)

Updates `golang.org/x/sys` from 0.22.0 to 0.26.0
- [Commits](https://github.com/golang/sys/compare/v0.22.0...v0.26.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: go-dependencies
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix errors

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

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2024-10-28 12:53:04 -04: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
Natalie Arellano 2a5bb2f847
Add more detail to release instructions (#1406)
* Add more detail to release instructions

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

* moved things around (#1411)

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
Co-authored-by: Joey Brown <brown.joseph@salesforce.com>
2024-10-24 09:45:23 -04:00
Natalie Arellano dd23dd7de8
Update README for 0.20.x (#1401)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-09-16 11:00:35 -04:00
Jesse Brown ed3df30e1b
Adjust exporter App Layer log output (#1399)
The 1/N app layer logs are emitted _after_ the layers have been added. This can sometimes be an expensive operation depending on the layer size and export target.

When trying to understand performance during builds, this wording implies the previous log line before the app layers was responsible for the time between the log lines. Adjusting the wording will make it a bit clearer that the time between the two log lines includes both steps.

Before:
```bash
03:50:00 Adding layer 'buildpacksio/lifecycle:launch.sbom'
03:51:00 Adding 5/5 app layer(s)
````

After:
```bash
03:50:00 Adding layer 'buildpacksio/lifecycle:launch.sbom'
03:51:00 Added 5/5 app layer(s)
````

If we are more interested in going the other direction, where we keep "Adding 1/N app layers" and emitting multiple times or something I'm happy to iterate.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2024-09-11 16:12:44 -04:00
Jesse Brown 13adc3a8a8
Merge pull request #1390 from buildpacks/dependabot/go_modules/github.com/docker/docker-26.1.5incompatible
Bump github.com/docker/docker from 26.1.4+incompatible to 26.1.5+incompatible
2024-08-22 10:43:44 -05:00
Natalie Arellano 2e76236d20
When setting up buildpack env, process layers for a given buildpack in alphabetical order (#1394)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-08-20 15:45:26 -04:00
dependabot[bot] 191e6c4790
Bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 26.1.4+incompatible to 26.1.5+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v26.1.4...v26.1.5)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-09 19:09:31 +00: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
Hiroshi Hayakawa 9f262b3e5d
Adapt tools/test-fork.sh to the current GitHub Action workflows. (#1384)
* Make the test-fork.sh script correctly remove the Codecov step from build.yml.

Signed-off-by: hhiroshell <hhiroshell@gmail.com>

* Make the test-fork.sh script add the necessary permissions for pushing images to ghcr.io in the build and post-release workflows.

Signed-off-by: hhiroshell <hhiroshell@gmail.com>

---------

Signed-off-by: hhiroshell <hhiroshell@gmail.com>
2024-07-18 11:07:37 -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
Natalie Arellano a87e12e6cd
Surface registry error (#1376)
* Surface registry error instead of logging it as debug

When permissions issues are encountered, it can be hard to determine the root cause
without the error returned from the registry

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

* Fix test expectation

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-07-11 09:34:05 -04:00
dependabot[bot] 12e2de8449
Bump google.golang.org/grpc from 1.64.0 to 1.64.1 (#1375)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.64.0 to 1.64.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.64.0...v1.64.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-10 09:50:09 -04:00
dependabot[bot] 4c40dcadaf
Bump the go-dependencies group across 1 directory with 6 updates (#1373)
* Bump the go-dependencies group across 1 directory with 6 updates

Bumps the go-dependencies group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko) | `1.23.0` | `1.23.1` |
| [github.com/containerd/containerd](https://github.com/containerd/containerd) | `1.7.17` | `1.7.19` |
| [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) | `0.19.1` | `0.20.0` |
| [github.com/moby/buildkit](https://github.com/moby/buildkit) | `0.13.2` | `0.14.1` |
| [golang.org/x/sys](https://github.com/golang/sys) | `0.20.0` | `0.22.0` |



Updates `github.com/GoogleContainerTools/kaniko` from 1.23.0 to 1.23.1
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.23.0...v1.23.1)

Updates `github.com/containerd/containerd` from 1.7.17 to 1.7.19
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.17...v1.7.19)

Updates `github.com/docker/docker` from 26.1.2+incompatible to 26.1.3+incompatible
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v26.1.2...v26.1.3)

Updates `github.com/google/go-containerregistry` from 0.19.1 to 0.20.0
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.19.1...v0.20.0)

Updates `github.com/moby/buildkit` from 0.13.2 to 0.14.1
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.13.2...v0.14.1)

Updates `golang.org/x/sys` from 0.20.0 to 0.22.0
- [Commits](https://github.com/golang/sys/compare/v0.20.0...v0.22.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>

* Stay on the same version of buildkit as kaniko

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

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2024-07-09 14:54:19 -04: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 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
dependabot[bot] 7b5a8ec1cf
Bump the go-dependencies group across 1 directory with 5 updates (#1360)
* Bump the go-dependencies group across 1 directory with 5 updates

Bumps the go-dependencies group with 3 updates in the / directory: [github.com/BurntSushi/toml](https://github.com/BurntSushi/toml), [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko) and [github.com/containerd/containerd](https://github.com/containerd/containerd).


Updates `github.com/BurntSushi/toml` from 1.3.2 to 1.4.0
- [Release notes](https://github.com/BurntSushi/toml/releases)
- [Commits](https://github.com/BurntSushi/toml/compare/v1.3.2...v1.4.0)

Updates `github.com/GoogleContainerTools/kaniko` from 1.22.0 to 1.23.0
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.22.0...v1.23.0)

Updates `github.com/awslabs/amazon-ecr-credential-helper/ecr-login` from 0.0.0-20231213181459-b0fcec718dc6 to 0.0.0-20240419161514-af205d85bb44
- [Release notes](https://github.com/awslabs/amazon-ecr-credential-helper/releases)
- [Changelog](https://github.com/awslabs/amazon-ecr-credential-helper/blob/main/CHANGELOG.md)
- [Commits](https://github.com/awslabs/amazon-ecr-credential-helper/commits)

Updates `github.com/containerd/containerd` from 1.7.16 to 1.7.17
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.16...v1.7.17)

Updates `github.com/docker/docker` from 26.1.1+incompatible to 26.1.2+incompatible
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v26.1.1...v26.1.2)

---
updated-dependencies:
- dependency-name: github.com/BurntSushi/toml
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/awslabs/amazon-ecr-credential-helper/ecr-login
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix unit

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

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2024-06-05 16:15:50 -04:00
Natalie Arellano 36c0af0d81
Bump imgutil to pick up fixes for containerd and podman (#1361)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-06-05 13:47:22 -04:00
dependabot[bot] 85b745ca87
Bump azure/docker-login from 1 to 2 (#1359)
Bumps [azure/docker-login](https://github.com/azure/docker-login) from 1 to 2.
- [Release notes](https://github.com/azure/docker-login/releases)
- [Commits](https://github.com/azure/docker-login/compare/v1...v2)

---
updated-dependencies:
- dependency-name: azure/docker-login
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-05 12:37:24 -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
Dilip Gowda Bhagavan 1a1de0850a
fix: ibmcloud CLI nic attachment issue for s390x testing (#1353)
* fix: instance create issue for GH actions

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* fix: ibm cloud instance creation issue

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

---------

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>
2024-05-13 11:56:48 -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
dependabot[bot] c0590cda08
Bump the go-dependencies group with 2 updates (#1351)
Bumps the go-dependencies group with 2 updates: [github.com/docker/docker](https://github.com/docker/docker) and [golang.org/x/sys](https://github.com/golang/sys).


Updates `github.com/docker/docker` from 26.1.0+incompatible to 26.1.1+incompatible
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v26.1.0...v26.1.1)

Updates `golang.org/x/sys` from 0.19.0 to 0.20.0
- [Commits](https://github.com/golang/sys/compare/v0.19.0...v0.20.0)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-08 11:12:18 -04:00
dependabot[bot] 8a148423a3
Bump the go-dependencies group across 1 directory with 5 updates (#1349)
Bumps the go-dependencies group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko) | `1.21.1` | `1.22.0` |
| [github.com/containerd/containerd](https://github.com/containerd/containerd) | `1.7.14` | `1.7.16` |
| [github.com/docker/docker](https://github.com/docker/docker) | `26.0.1+incompatible` | `26.1.0+incompatible` |
| [github.com/moby/buildkit](https://github.com/moby/buildkit) | `0.13.1` | `0.13.2` |
| [golang.org/x/sys](https://github.com/golang/sys) | `0.18.0` | `0.19.0` |



Updates `github.com/GoogleContainerTools/kaniko` from 1.21.1 to 1.22.0
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.21.1...v1.22.0)

Updates `github.com/containerd/containerd` from 1.7.14 to 1.7.16
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.14...v1.7.16)

Updates `github.com/docker/docker` from 26.0.1+incompatible to 26.1.0+incompatible
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v26.0.1...v26.1.0)

Updates `github.com/moby/buildkit` from 0.13.1 to 0.13.2
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.13.1...v0.13.2)

Updates `golang.org/x/sys` from 0.18.0 to 0.19.0
- [Commits](https://github.com/golang/sys/compare/v0.18.0...v0.19.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2024-05-06 18:12:00 -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
Natalie Arellano 13d3691dd0
Try to fix test-s390x workflow (#1339)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-04-29 15:09:27 -04:00
Natalie Arellano 37d69857b6
Bump imgutil to pick up fix from https://github.com/buildpacks/imgutil/pull/269 (#1343)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-04-22 15:06:09 -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
Pavel Busko 27ee43580b
Initialize default LayerMetadataRestorer and SBOMRestorer if none provided (#1333)
Signed-off-by: Pavel Busko <pavel.busko@sap.com>
Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
2024-04-11 11:43:22 -04:00
Jesse Brown 85f22a0fa5
Merge pull request #1334 from buildpacks/fix/keychain
Fix auth by wrapping keychain in a ResolvedKeychain
2024-04-10 10:10:01 -05:00
Natalie Arellano 267025743f Fix auth by wrapping keychain in a ResolvedKeychain
Prior to https://github.com/buildpacks/lifecycle/pull/1315, all keychains
passed to NewMultiKeychain were resolved keychains,
which prevented the credentials from becoming inaccessible after the lifecycle dropped privileges.

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-04-10 10:48:33 -04:00
Jesse Brown 137225b961
Merge pull request #1282 from buildpacks/dependabot/github_actions/codecov/codecov-action-4
Bump codecov/codecov-action from 3 to 4
2024-04-10 09:39:46 -05:00
Natalie Arellano fea544183a Provide CODECOV_TOKEN to Codecov
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-04-10 10:07:10 -04:00
Natalie Arellano f309b50003 Merge branch 'main' into dependabot/github_actions/codecov/codecov-action-4 2024-04-09 16:34:01 -04:00
Jesse Brown cd50eb8848
Add go-version-file to draft-release workflow (#1331)
We are getting warnings about go-version not being specified. This should fix that.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2024-04-05 15:08:23 -04:00
Jesse Brown bb9eb96766
go 1.22 (#1328)
* go 1.22

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

* Updated golangci-lint to v1.57.2

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

---------

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2024-04-05 13:11:18 -04:00
Jesse Brown 9c8340112a
Merge pull request #1315 from buildpacks/jab/keychain-allow-vendor-skip
Allow env vars to skip vendor specific keychain
2024-04-01 08:55:25 -05:00
dependabot[bot] feb0d757c9
Bump github.com/docker/docker (#1321)
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 25.0.3+incompatible to 25.0.5+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v25.0.3...v25.0.5)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-28 12:38:08 -04:00
Natalie Arellano 955ab5e7c9
Buildpack API 0.11 is supported as of lifecycle 0.19 (#1326)
Fixes https://github.com/buildpacks/lifecycle/issues/1322

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-03-28 12:36:36 -04:00
dependabot[bot] a4e33e218a
Bump google.golang.org/protobuf from 1.32.0 to 1.33.0 (#1318)
Bumps google.golang.org/protobuf from 1.32.0 to 1.33.0.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-28 10:53:07 -04:00
dependabot[bot] 9eaafdcfa8
Bump the go-dependencies group with 4 updates (#1323)
Bumps the go-dependencies group with 4 updates: [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko), [github.com/containerd/containerd](https://github.com/containerd/containerd), [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) and [github.com/moby/buildkit](https://github.com/moby/buildkit).


Updates `github.com/GoogleContainerTools/kaniko` from 1.21.0 to 1.21.1
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.21.0...v1.21.1)

Updates `github.com/containerd/containerd` from 1.7.13 to 1.7.14
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.13...v1.7.14)

Updates `github.com/google/go-containerregistry` from 0.19.0 to 0.19.1
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.19.0...v0.19.1)

Updates `github.com/moby/buildkit` from 0.12.5 to 0.13.1
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/compare/v0.12.5...v0.13.1)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-28 09:54:22 -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
Jesse Brown dff6494f28
Create README.md for auth package configuration
Signed-off-by: Jesse Brown <jabrown85@gmail.com>

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2024-03-27 14:51:25 -05: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
Jesse Brown 5128c1360c
Allow env vars to skip vendor specific keychain
Vendor keychains can be slow or fail. This allows platform operators to skip them entirely.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2024-03-08 12:10:40 -06:00
Natalie Arellano 3a05fdea09
Update README for 0.19.x (#1313)
Also Platform API 0.13 is not supported in 0.18.x

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-03-07 16:41:24 -05:00
Natalie Arellano 548854fdf8
Fix post release workflow by calculating sha for linux-ppc64le (#1311)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-03-06 15:28:23 -05:00
dependabot[bot] f25f22c1de
Bump the go-dependencies group with 2 updates (#1310)
Bumps the go-dependencies group with 2 updates: [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko) and [golang.org/x/sys](https://github.com/golang/sys).


Updates `github.com/GoogleContainerTools/kaniko` from 1.20.1 to 1.21.0
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.20.1...v1.21.0)

Updates `golang.org/x/sys` from 0.17.0 to 0.18.0
- [Commits](https://github.com/golang/sys/compare/v0.17.0...v0.18.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-06 12:25:31 -05:00
Natalie Arellano de7bcf582c
Update fixtures for exporter acceptance test (#1307)
* Update fixtures for exporter acceptance test

These were previously based on "real" images, but the actual content is unimportant.

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

* Fix config and manifest shas

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

* Fix index sha

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

* Update to correct sha, uggh

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

* Fix fixtures again and make test expectation more robust

We know the extension layer index so we should just use it

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-03-04 12:33:37 -05: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
Natalie Arellano f3f292c6b5
When copying extended run image layers, use the original number of layers (#1306)
in addition to the original top layer digest
to determine what is an extension layer and what is an original layer.
Relying on the original top layer digest (only) introduced errors
if the original run image had a duplicated top layer.

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-03-01 13:41:46 -05:00
Philipp Stehle 41d885b2b4
refactor `phase/generator_test.go` (#1301)
Signed-off-by: Philipp Stehle <philipp.stehle@sap.com>
Signed-off-by: Johannes Dillmann <j.dillmann@sap.com>
Co-authored-by: Johannes Dillmann <j.dillmann@sap.com>
2024-03-01 12:09:36 -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
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
Philipp Stehle 553c041228
refactor `phase/extender_test.go` (#1297)
* refactor `phase/extender_test.go`

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

* Review comments

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Philipp Stehle <philipp.stehle@sap.com>

---------

Signed-off-by: Philipp Stehle <philipp.stehle@sap.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2024-02-28 16:22:05 -05:00
Natalie Arellano 2d2da0b9f0
Fix typo (#1299)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-02-28 15:52:52 -05:00
Matthias Wessendorf 200b00a4a4
💄 Adding build and packaging support for ppc64le arch (#1303)
Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>
2024-02-28 15:20:20 -05:00
Natalie Arellano 4ec55dce9b
Add debug statements to the extender (#1298)
* Add debug statements

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

* Add more debug info

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

* Add even more debug info

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-02-16 14:09:50 -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
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
dependabot[bot] e2b30d8fe5
Bump the go-dependencies group with 1 update (#1296)
Bumps the go-dependencies group with 1 update: [golang.org/x/sys](https://github.com/golang/sys).


Updates `golang.org/x/sys` from 0.16.0 to 0.17.0
- [Commits](https://github.com/golang/sys/compare/v0.16.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-13 17:36:22 -05:00
Natalie Arellano d4e8609f49
Bump kaniko and remove buildkit pin (#1292)
Also remove ignore in .grype.yaml for patched CVE

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-02-12 11:22:41 -05:00
Natalie Arellano be5e24be99
Exporter zeroes timestamps when adding extension layers to the app image (#1289)
* Exporter zeroes timestamps when adding extension layers to the app image

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

* Update fixture to fix Windows

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

* Use normalizing tar reader to fix Windows

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

* Revert "Use normalizing tar reader to fix Windows"

This reverts commit 8c6c12c82c.

* Update fixture to fix Windows

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

* Update phase/exporter.go

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

* Fix format

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

* Try to fix Windows

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

* Skip test on Windows

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-02-09 16:11:19 -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
dependabot[bot] 121d349e68
Bump the go-dependencies group with 1 update (#1283)
Bumps the go-dependencies group with 1 update: [github.com/containerd/containerd](https://github.com/containerd/containerd).


Updates `github.com/containerd/containerd` from 1.7.12 to 1.7.13
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.12...v1.7.13)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-09 13:04:21 -05:00
dependabot[bot] ecbcbd94d4
Bump codecov/codecov-action from 3 to 4
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-05 23:09:57 +00:00
Natalie Arellano 751c7a2737
Update pinned deps (#1280)
We can remove docker & containerd pins:
- Docker was pinned to 23.x because of kaniko,
  but now that kaniko has upgraded we can upgrade.
- Containerd used to be pinned as a purely transitive dependency,
  but now that it has a require directive it should be okay to unpin it.

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-02-05 12:52:54 -05:00
dependabot[bot] 72671535c2
Bump github.com/opencontainers/runc from 1.1.9 to 1.1.12 (#1279)
Bumps [github.com/opencontainers/runc](https://github.com/opencontainers/runc) from 1.1.9 to 1.1.12.
- [Release notes](https://github.com/opencontainers/runc/releases)
- [Changelog](https://github.com/opencontainers/runc/blob/v1.1.12/CHANGELOG.md)
- [Commits](https://github.com/opencontainers/runc/compare/v1.1.9...v1.1.12)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/runc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-05 12:22:39 -05:00
dependabot[bot] 7ab0850c64
Bump the go-dependencies group with 3 updates (#1277)
Bumps the go-dependencies group with 3 updates: [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko), [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) and [github.com/google/uuid](https://github.com/google/uuid).


Updates `github.com/GoogleContainerTools/kaniko` from 1.19.2 to 1.20.0
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.19.2...v1.20.0)

Updates `github.com/google/go-containerregistry` from 0.17.0 to 0.19.0
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.17.0...v0.19.0)

Updates `github.com/google/uuid` from 1.5.0 to 1.6.0
- [Release notes](https://github.com/google/uuid/releases)
- [Changelog](https://github.com/google/uuid/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/uuid/compare/v1.5.0...v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/google/uuid
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-05 11:50:04 -05:00
Natalie Arellano 3c8876ce04
Fix s390x workflow now that go is upgraded (#1268)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-01-10 15:53:03 -05:00
dependabot[bot] 2548af4b8b
Bump the go-dependencies group with 6 updates (#1265)
Bumps the go-dependencies group with 6 updates:

| Package | From | To |
| --- | --- | --- |
| [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko) | `1.17.0` | `1.19.2` |
| [github.com/docker/go-connections](https://github.com/docker/go-connections) | `0.4.0` | `0.5.0` |
| [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) | `0.16.1` | `0.17.0` |
| [github.com/google/uuid](https://github.com/google/uuid) | `1.4.0` | `1.5.0` |
| [golang.org/x/sync](https://github.com/golang/sync) | `0.5.0` | `0.6.0` |
| [golang.org/x/sys](https://github.com/golang/sys) | `0.15.0` | `0.16.0` |


Updates `github.com/GoogleContainerTools/kaniko` from 1.17.0 to 1.19.2
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.17.0...v1.19.2)

Updates `github.com/docker/go-connections` from 0.4.0 to 0.5.0
- [Commits](https://github.com/docker/go-connections/compare/v0.4.0...v0.5.0)

Updates `github.com/google/go-containerregistry` from 0.16.1 to 0.17.0
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.16.1...v0.17.0)

Updates `github.com/google/uuid` from 1.4.0 to 1.5.0
- [Release notes](https://github.com/google/uuid/releases)
- [Changelog](https://github.com/google/uuid/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/uuid/compare/v1.4.0...v1.5.0)

Updates `golang.org/x/sync` from 0.5.0 to 0.6.0
- [Commits](https://github.com/golang/sync/compare/v0.5.0...v0.6.0)

Updates `golang.org/x/sys` from 0.15.0 to 0.16.0
- [Commits](https://github.com/golang/sys/compare/v0.15.0...v0.16.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/docker/go-connections
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/google/uuid
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2024-01-10 15:03:02 -05:00
Natalie Arellano b6a76bff09
Upgrade go (#1267)
* Upgrade to go 1.21

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

* Upgrade compilation images

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-01-10 14:29:05 -05:00
dependabot[bot] c8c4fc4f56
Bump actions/setup-go from 4 to 5 (#1253)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4 to 5.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-10 12:00:37 -05:00
dependabot[bot] 6e199e6a64
Bump appleboy/ssh-action from 1.0.0 to 1.0.3 (#1266)
Bumps [appleboy/ssh-action](https://github.com/appleboy/ssh-action) from 1.0.0 to 1.0.3.
- [Release notes](https://github.com/appleboy/ssh-action/releases)
- [Commits](https://github.com/appleboy/ssh-action/compare/v1.0.0...v1.0.3)

---
updated-dependencies:
- dependency-name: appleboy/ssh-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-10 12:00:10 -05:00
dependabot[bot] e9a83ae69a
Bump golang.org/x/crypto from 0.14.0 to 0.17.0 (#1259)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.14.0 to 0.17.0.
- [Commits](https://github.com/golang/crypto/compare/v0.14.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-10 11:59: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 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
dependabot[bot] dbd27bdef0
Bump the go-dependencies group with 2 updates (#1238)
* Bump the go-dependencies group with 2 updates

Bumps the go-dependencies group with 2 updates: [golang.org/x/sync](https://github.com/golang/sync) and [golang.org/x/sys](https://github.com/golang/sys).


Updates `golang.org/x/sync` from 0.4.0 to 0.5.0
- [Commits](https://github.com/golang/sync/compare/v0.4.0...v0.5.0)

Updates `golang.org/x/sys` from 0.13.0 to 0.14.0
- [Commits](https://github.com/golang/sys/compare/v0.13.0...v0.14.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump github.com/cilium/ebpf

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

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2023-11-13 11:20:48 -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 73648d2423
Fix post-release workflow (#1235)
* Fix post-release workflow

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

* Update grype config with non-impactful CVE

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-10-31 13:47:52 -04:00
dependabot[bot] 7c591d11d6
Bump the go-dependencies group with 1 update (#1234)
Bumps the go-dependencies group with 1 update: [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko).

- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.16.0...v1.17.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-31 09:58:25 -04:00
Natalie Arellano 2b75adb9e5
Fix check release workflow (again) (#1233)
* Fix check release workflow by giving write permissions to the token

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

* Add permission to different scope

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-10-31 09:57:46 -04:00
dependabot[bot] cdd883cdaf
Bump github.com/google/uuid from 1.3.1 to 1.4.0 (#1226)
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.3.1 to 1.4.0.
- [Release notes](https://github.com/google/uuid/releases)
- [Changelog](https://github.com/google/uuid/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/uuid/compare/v1.3.1...v1.4.0)

---
updated-dependencies:
- dependency-name: github.com/google/uuid
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-30 17:55:55 -04:00
Ed Morley 736b776093
Group minor/patch version Go Dependabot updates into one PR (#1228)
Go minor/patch dependencies will now be grouped, using the new
Dependabot grouping feature:
https://github.blog/changelog/2023-08-17-grouped-version-updates-by-semantic-version-level-for-dependabot/

Major updates, as well as security updates will still be opened as
separate PRs. I've not grouped GitHub Actions update PRs, since the
volume is typically much lower for those.

The custom open pull requests limit has been removed, since it is
no longer necessary, as there won't be as many open PRs.

In addition, the schedule has been changed from daily to weekly.

This reduces project maintenance toil (no more having to manually create
combined update PRs), plus makes it less painful for contributors to
subscribe to repository notifications (currently there is a lot of noise
from Dependabot PRs being opened/auto-rebased etc).

Signed-off-by: Ed Morley <501702+edmorley@users.noreply.github.com>
2023-10-30 17:55:34 -04:00
Jesse Brown 653a46fa26
Print `Timer` logs in debug mode only (#1230)
The default of emitting timings to info is too noisy.  This change lets platforms that want to see timings do so by setting the log level to debug.

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2023-10-30 17:51:30 -04:00
Natalie Arellano 9eec0f4f5c
Fix check release workflow by giving write permissions to the token (#1229)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-10-30 17:50:47 -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
dependabot[bot] 367b451eb7
Bump appleboy/ssh-action from 0.1.10 to 1.0.0 (#1214)
Bumps [appleboy/ssh-action](https://github.com/appleboy/ssh-action) from 0.1.10 to 1.0.0.
- [Release notes](https://github.com/appleboy/ssh-action/releases)
- [Commits](https://github.com/appleboy/ssh-action/compare/v0.1.10...v1.0.0)

---
updated-dependencies:
- dependency-name: appleboy/ssh-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-18 11:27:31 -04:00
dependabot[bot] 66472bc154
Bump actions/checkout from 3 to 4 (#1212)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-18 09:33:01 -04:00
dependabot[bot] a00c3832e3
Bump actions/upload-artifact from 2 to 3 (#1213)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-18 09:31:57 -04:00
Natalie Arellano 885847a4d5
Bump deps (#1221)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-10-18 09:31:31 -04:00
Ralf Pannemans ab2fe4f2f3
Fix usage of URL based registries (#1222)
Signed-off-by: Johannes Dillmann <j.dillmann@sap.com>
Co-authored-by: Johannes Dillmann <j.dillmann@sap.com>
2023-10-18 09:30:08 -04:00
Natalie Arellano 6885b2e6ff
Update README and golang.org/x/sys (#1218)
* Update README

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

* Upgrade golang.org/x/sys to bump golang.org/x/net and patch vulnerabilities

- Patches CVE-2023-44487 and CVE-2023-39325
- Removes already patched CVEs from ignore list in .grype.yaml

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

* Fix pack acceptance by letting the tag version float again

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-10-17 17:05:03 -04:00
Dilip Gowda Bhagavan 292aa492a7
Add support for s390x (#1142)
* installing docker and jq

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* added support for s390x

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* adding back newline at end of file

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* adding back newline at end of file

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* updated release workflows

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* Running build and publish flow on fork

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* corrected typo

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* installing docker and jq

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* adding back newline at end of file

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* adding back newline at end of file

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* updated release workflows

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* corrected typo

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* reverting docker repo to buildpacksio

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* seperated s390x job to different file

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* removing hard coded values to secret

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* removed s390x conditon

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* adding s390x conditon

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

* correcting alignment in build.yml

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>

---------

Signed-off-by: Dilip Gowda Bhagavan <dilip.bhagavan@ibm.com>
Signed-off-by: Dilip Gowda Bhagavan <110233170+dilipgb@users.noreply.github.com>
2023-10-05 10:23:33 -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
dependabot[bot] d0ed30b36f
Bump github.com/GoogleContainerTools/kaniko from 1.15.0 to 1.16.0 (#1206)
Bumps [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko) from 1.15.0 to 1.16.0.
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.15.0...v1.16.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-27 14:58:16 -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 5b02ac1c8f
Bump deps (#1203)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-09-19 11:09:48 -04:00
Natalie Arellano 2b81abb8c4
Update cosign (#1201)
* Update some actions and configure dependabot to update actions

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

* Update cosign workflows to use keyless signing

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-09-19 10:02:28 -04:00
Natalie Arellano 06ffeedd58
Update some actions and configure dependabot to update actions (#1200)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-09-19 08:54:41 -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 b384d8c3e6
Fix setup-go by looking for go.mod within pack directory (#1197)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-09-12 12:32:51 -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 105808ccf0
Removes backwards compatible glue for unsupported buildpack APIs (#1188)
Fixes https://github.com/buildpacks/lifecycle/issues/1187

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-08-25 11:32:57 -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 325676eb6e
Update version of pack used in acceptance tests (#1182)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-08-23 10:33:11 -04:00
Natalie Arellano 7fda8e271f
Don't print 'Ignoring cache image "cache-image-name" because it was corrupt' (#1185)
when the cache image is not found

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-08-23 09:54:12 -04:00
Jesse Brown f1e60ccc34
Merge pull request #1183 from buildpacks/dependabot/go_modules/github.com/google/uuid-1.3.1
Bump github.com/google/uuid from 1.3.0 to 1.3.1
2023-08-22 08:51:20 -05:00
dependabot[bot] f82c23bd4f
Bump github.com/google/uuid from 1.3.0 to 1.3.1
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.3.0 to 1.3.1.
- [Release notes](https://github.com/google/uuid/releases)
- [Changelog](https://github.com/google/uuid/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/uuid/compare/v1.3.0...v1.3.1)

---
updated-dependencies:
- dependency-name: github.com/google/uuid
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-21 23:47:48 +00:00
Domenico Luciani c72dc20a93
Add support for darwin-arm64 chipset (#1169)
* Add support for darwin-arm64 chipset

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

* Split darwin builder into a separate module extracting the code for a more generic use

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

* Split darwin.mk to lifecycle.mk and launcher.mk

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

* Update launcher.mk with a better naming

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Update lifecycle.mk with a better naming

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Domenico Luciani <dluciani@vmware.com>

* Adjusted called function

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

---------

Signed-off-by: Domenico Luciani <dluciani@vmware.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2023-08-18 16:15:35 -04:00
Natalie Arellano df9ae90e17
Update github templates (#1179)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-08-10 12:19:42 -04:00
Natalie Arellano 56083d0680
Small improvements to the release notes template & check release workflow (#1178)
* Update release notes template

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

* Update test on fork script

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

* Fix

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

* Update check-latest-release to ignore pre-releases

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-08-10 12:19:32 -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
dependabot[bot] 85fd513b83
Bump github.com/GoogleContainerTools/kaniko from 1.12.1 to 1.13.0 (#1162)
Bumps [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko) from 1.12.1 to 1.13.0.
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.12.1...v1.13.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-09 11:02:23 -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 f8b3419877
Merge pull request #1160 from joe-kimmel-vmw/so-many-loggers-we-ran-out-of-flannel-shirts
timestamp logs for entry/exit for all the top-level Lifecycle package…
2023-07-27 13:48:30 -07:00
Joe Kimmel cc194b8666 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>
2023-07-27 11:24:20 -07:00
Joe Kimmel 28c0253427 using defer to make one-liners for fun and profit
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-07-27 09:18:22 -07:00
Joe Kimmel 8cb8336642
Merge pull request #1161 from joe-kimmel-vmw/its_just_a_phase
be more helpful when you dont recognize the phase
2023-07-26 16:12:58 -07: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
Joe Kimmel 217a234476 fixing names
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-07-26 10:18:16 -07:00
Joe Kimmel 1a36a3b642 timestamp logs for entry/exit for all the top-level Lifecycle package functions
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-07-25 18:08:02 -07:00
Joe Kimmel 1ca5500ad9
Merge pull request #1157 from joe-kimmel-vmw/upgrade-setup-go-action
upgrades setup-go to v4 which mostly sounds like it enables some cach…
2023-07-24 10:55:29 -07:00
Joe Kimmel 8f0cb5886a also upgrade check-latest-release and post-release
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-07-24 10:02:11 -07:00
Joe Kimmel ae64f8848f
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>
2023-07-24 12:08:50 -04:00
Joe Kimmel 1ff8931f47 upgrades setup-go to v4 which mostly sounds like it enables some caching by default
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-07-20 14:18:08 -07:00
Domenico Luciani 9f7f501b95
Remove async go-subroutine delete keeping it sync (#1152)
Signed-off-by: Domenico Luciani <dluciani@vmware.com>
2023-07-13 16:08:06 -04: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 e06b69b5ac
Merge pull request #1143 from joe-kimmel-vmw/restore-restorers-former-color
restorer gets layers flag again
2023-07-07 09:44:48 -07:00
Joe Kimmel 94c3d31ec0
Merge pull request #1144 from joe-kimmel-vmw/jd-add-restore-debug-logs
add explanatory debug logs so a reader knows why the buildpacks are r…
2023-07-07 09:44:19 -07:00
Joe Kimmel 44f4a7d8ab add explanatory debug logs so a reader knows why the buildpacks are read twice.
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-07-06 14:46:45 -07: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
Joe Kimmel 1744539c83
adds grype json output to the created github issue (#1131)
* probably adds grype json output to the created github issue

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

* specify json output and use jq query to select summary

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

small refactor of gh action shell script and better issue name

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

sev threshold explicitly set to high

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

* grype release sev cutoff back to medium

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-07-06 11:23:56 -04:00
dependabot[bot] 477aa7197d
Bump github.com/GoogleContainerTools/kaniko from 1.11.0 to 1.12.1 (#1137)
Bumps [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko) from 1.11.0 to 1.12.1.
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.11.0...v1.12.1)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-05 16:24:23 -04:00
dependabot[bot] c8e89ce07b
Bump golang.org/x/sys from 0.9.0 to 0.10.0 (#1141)
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.9.0 to 0.10.0.
- [Commits](https://github.com/golang/sys/compare/v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-05 16:23:52 -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
Joe Kimmel 12cb541fd1
turn on additional linter checks including godoc comments (#1110)
* turn on additional linter checks including godoc comments

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

* ... but only apply new stricter linting to commits going forward

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

* fetch repo history to enable linting only since a previous commit

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

* update new-from-rev since this PR has been open a while

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

---------

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-06-22 15:07:57 -04:00
Natalie Arellano 91593cf917
Bump go to 1.20 (#1130)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-15 12:54:08 -04:00
dependabot[bot] 7b886e0b80
Bump golang.org/x/sync from 0.2.0 to 0.3.0 (#1128)
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.2.0 to 0.3.0.
- [Commits](https://github.com/golang/sync/compare/v0.2.0...v0.3.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-15 11:08:28 -04:00
Natalie Arellano b1dd93cd14
Sets `check-latest` to always pull the latest version instead of the cached version (#1127)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-15 11:08:07 -04:00
dependabot[bot] 081106052c
Bump github.com/GoogleContainerTools/kaniko from 1.10.0 to 1.11.0 (#1120)
Bumps [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko) from 1.10.0 to 1.11.0.
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.10.0...v1.11.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-14 15:28:22 -04:00
dependabot[bot] 9d07aa934c
Bump golang.org/x/sys from 0.8.0 to 0.9.0 (#1124)
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.8.0 to 0.9.0.
- [Commits](https://github.com/golang/sys/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-14 15:19:45 -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
dependabot[bot] 82da83291a
Bump github.com/BurntSushi/toml from 1.3.1 to 1.3.2 (#1121)
Bumps [github.com/BurntSushi/toml](https://github.com/BurntSushi/toml) from 1.3.1 to 1.3.2.
- [Release notes](https://github.com/BurntSushi/toml/releases)
- [Commits](https://github.com/BurntSushi/toml/compare/v1.3.1...v1.3.2)

---
updated-dependencies:
- dependency-name: github.com/BurntSushi/toml
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-09 14:40:07 -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
dependabot[bot] eac881f32a
Bump github.com/BurntSushi/toml from 1.3.0 to 1.3.1 (#1114)
Bumps [github.com/BurntSushi/toml](https://github.com/BurntSushi/toml) from 1.3.0 to 1.3.1.
- [Release notes](https://github.com/BurntSushi/toml/releases)
- [Commits](https://github.com/BurntSushi/toml/compare/v1.3.0...v1.3.1)

---
updated-dependencies:
- dependency-name: github.com/BurntSushi/toml
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-07 13:39:30 -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
Joe Kimmel f9b8e9325a
extensions get the same targets validation as buildpacks (#1108)
* extensions get the same targets validation as buildpacks

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

* extensions default to */* for os/arch detection

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

---------

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-06-06 13:51:24 -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 f506545986
Bump deps (#1103)
* Bump deps

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

* Bump imgutil, unpin BurntSushi/toml

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-01 12:11:57 -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
Natalie Arellano 0e55ae5ea9
Surface a more useful error message when we fail to add files to archive (#1105)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-01 12:10:32 -04:00
Joe Kimmel c2609a0a52
extender: better uid checks and error if uid ends as root (#1093)
updates to unit test

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-06-01 12:08:04 -04:00
Joe Kimmel e1a8e5451d
probably fixes error message that calls images corrupt when they were just missing but honestly i'm not adding a unit test (#1107)
Previously: Treat images like politicians (if you suddenly can't find
them, they're probably corrupt).

Now: Treat images like accounting errors (if you can't find any, there's
no evidence of corruption)

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-06-01 11:59:26 -04:00
Natalie Arellano 3f1a3461ca
Add more logging so we know when the lifecycle actually starts (#1106)
* Add more logging so we know when the lifecycle actually starts

In working through https://github.com/buildpacks/lifecycle/issues/1007
it was hard to know if the lifecycle had even started
when we were stuck in a loop trying to get the auth,
because the first log lines emitted by the lifecycle
were emitted after the Analyzer had started.

If we had this logging in place beforehand,
we would have known the problem was somewhere in Privileges()

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

* Rename variable to make it clearer

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

* Update cmd/lifecycle/cli/command.go

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-06-01 11:59:14 -04:00
dependabot[bot] ae5c3e572c
Bump github.com/GoogleContainerTools/kaniko from 1.9.2 to 1.10.0 (#1100)
Bumps [github.com/GoogleContainerTools/kaniko](https://github.com/GoogleContainerTools/kaniko) from 1.9.2 to 1.10.0.
- [Release notes](https://github.com/GoogleContainerTools/kaniko/releases)
- [Changelog](https://github.com/GoogleContainerTools/kaniko/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleContainerTools/kaniko/compare/v1.9.2...v1.10.0)

---
updated-dependencies:
- dependency-name: github.com/GoogleContainerTools/kaniko
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-30 17:59:10 -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
Anushka Mittal 5dbedd3ca0
FIXME: pass the logger and print the warning inside (#1038)
* initial changes in layermetadata.go for FIXME

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* minor changes, var name and added TODO

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* Added check for empty string in layermetadata.go

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* checks in layermetadata_test.go for logger

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* api version check - logic moved

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* ran make format for modified files

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* removed comments

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* changes to DecodeLayerMetadataFile

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* check for version shifted from layers.go to layermetadata.go

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* resolved ineffectual assignment to err

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* added new it block, TODO resolve failing test

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* Fix failing test

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

* removed unnecessary fmt

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>

---------

Signed-off-by: anushkamittal20 <anumittal4641@gmail.com>
2023-05-30 11:07:39 -04:00
Joe Kimmel 5c29f544ea
Signed-off-by: Joe Kimmel <jkimmel@vmware.com> (#1092) (#1094)
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-05-17 10:47:46 -04:00
dependabot[bot] da6d62cec1
Bump github.com/docker/distribution (#1089)
Bumps [github.com/docker/distribution](https://github.com/docker/distribution) from 2.8.1+incompatible to 2.8.2+incompatible.
- [Release notes](https://github.com/docker/distribution/releases)
- [Commits](https://github.com/docker/distribution/compare/v2.8.1...v2.8.2)

---
updated-dependencies:
- dependency-name: github.com/docker/distribution
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-11 18:13:07 -04:00
Natalie Arellano a11cb6a5f0
Bump deps (#1088)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-05-11 17:37:02 -04:00
dependabot[bot] cf19426cf0
Bump github.com/google/go-containerregistry from 0.14.0 to 0.15.1 (#1085)
Bumps [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) from 0.14.0 to 0.15.1.
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.14.0...v0.15.1)

---
updated-dependencies:
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-11 16:15:59 -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
Matthew Robertson e9072582a6
Validate the cache image and previous image in the analyze phase (#1060)
* Validate the cache image and previous image in the analyze phase

Signed-off-by: Matthew Robertson <mattrobertson@google.com>

* Fix unit tests

Signed-off-by: Matthew Robertson <mattrobertson@google.com>

* Upgrade imgutil

Signed-off-by: Matthew Robertson <mattrobertson@google.com>

* allow-nondistributable-artifacts for windows images

Signed-off-by: Matthew Robertson <mattrobertson@google.com>

* Update docs

Signed-off-by: Matthew Robertson <mattrobertson@google.com>

---------

Signed-off-by: Matthew Robertson <mattrobertson@google.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2023-05-09 11:58:53 -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
Joe Kimmel 710d938cf9
updating deps after go work sync (#1072)
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-04-25 16:13:06 -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
Joe Kimmel f48162ee68
put the breaks on single os detection by removing break (#1068)
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-04-17 21:06:02 +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 c5a3549b07
Merge pull request #1064 from joe-kimmel-vmw/whyicoulbeastarnow
os and arch: buildpack targets should have stars
2023-04-10 16:05:24 -07: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
dependabot[bot] 1698cfaf58
Bump github.com/docker/docker (#1063)
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 23.0.1+incompatible to 23.0.3+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v23.0.1...v23.0.3)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-06 14:42:05 -04:00
Natalie Arellano af79390a0b
Enable pre-releases in addition to release candidates (#1061)
While "release candidate" is still a pre-release, it conveys more readiness
than a "pre-release" or "preview release".
We'd like to ship pre-release lifecycle artifacts
so that users can test out new features without them being fully implemented
as they would in a release candidate.

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-04-05 18:28:37 -04: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
dependabot[bot] 4aa121f4dc
Bump github.com/opencontainers/runc from 1.1.4 to 1.1.5 (#1052)
Bumps [github.com/opencontainers/runc](https://github.com/opencontainers/runc) from 1.1.4 to 1.1.5.
- [Release notes](https://github.com/opencontainers/runc/releases)
- [Changelog](https://github.com/opencontainers/runc/blob/v1.1.5/CHANGELOG.md)
- [Commits](https://github.com/opencontainers/runc/compare/v1.1.4...v1.1.5)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/runc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-31 16:29:31 -04:00
Natalie Arellano b7f652a764
Merge lifecycle image fix & deps upgrade from release/0.16.1 into main (#1049)
* Ready release/0.16.1 (#1041)

* Fix log message when run image not found (#1004)

Before: "Previous image with name <run image name> not found"
After: "Image with name <run image name> not found"

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

* Bump containerd (#1015)

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

* Replace print with logger in image_cache.go, fixes formatting (#1012)

* Replace print with logger in image_cache.go, fixes formatting

Signed-off-by: Harshal Mittal <harshalmittal4@gmail.com>

* Add tests for image_cache logger

Signed-off-by: Harshal Mittal <harshalmittal4@gmail.com>

---------

Signed-off-by: Harshal Mittal <harshalmittal4@gmail.com>

* Bump golang.org/x/net from 0.5.0 to 0.7.0 (#1017)

Bumps [golang.org/x/net](https://github.com/golang/net) from 0.5.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.5.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Merge pull request #1036 from benri/bl/archive-pax-global-header

Ignore pax global header in tar extract

* Bump golang.org/x/sys from 0.5.0 to 0.6.0 (#1029)

Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/golang/sys/releases)
- [Commits](https://github.com/golang/sys/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/containerd/containerd from 1.6.18 to 1.6.19 (#1040)

* Bump github.com/containerd/containerd from 1.6.18 to 1.7.0

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

* Only bump to 1.6.19 instead of 1.7.x until we can upgrade docker/docker

docker/docker 20.10.23 is incompatible with containerd 1.7.x+ due to the removal of sys/userns_deprecated.go
(upgrading containerd results in lifecycle compile errors like go/pkg/mod/github.com/docker/docker@v20.10.23+incompatible/pkg/archive/archive_unix.go:96:42: undefined: sys.RunningInUserNS)

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

---------

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Harshal Mittal <harshalmittal4@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Harshal Mittal <harshalmittal4@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jesse Brown <jabrown85@gmail.com>

* Add sleep to "publish images" workflow (#1042)

It takes a few seconds for the image to be available

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

* Fix buildpacksio/lifecycle manifest create (#1043)

* Force lifecycle images to have docker media types

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

* Update go.mod to use latest imgutil

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

---------

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

* Bump kaniko & docker and unpin deps (#1045)

* Update kaniko & docker, unpin deps

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

* Update containerd

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

* Remove CVE ignores now that runc is unpinned

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

* Update to released kaniko

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

---------

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

* Ignore non-impactful runc CVE (#1047)

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

* Fix unit

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Harshal Mittal <harshalmittal4@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Harshal Mittal <harshalmittal4@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jesse Brown <jabrown85@gmail.com>
2023-03-29 10:50:40 -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
Joe Kimmel 1299eb80d1
Pull Os and Arch from RunImage; handle * Stacks (#1030)
* all the bits i can do prior to imgutil getting the Variant merged

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

* upgrade imgutil and incorporate arch Variant

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

* move GetTargetFromImage to platform and move ID into just platform

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

* add wildcard stack translation to target md

move common test fns to common places

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

* only pull target metadata from runimage if we're in a newer API

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

* use the * arch when autodetecting OS only

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

* detector.go - debug logger

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

* one wild and crazy test for wildcards

also fixes weird new linter requirement

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

* preferentially detect windows

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-03-22 17:32:33 -04:00
Natalie Arellano 00b292eb4a
Bump github.com/containerd/containerd from 1.6.18 to 1.6.19 (#1040)
* Bump github.com/containerd/containerd from 1.6.18 to 1.7.0

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

* Only bump to 1.6.19 instead of 1.7.x until we can upgrade docker/docker

docker/docker 20.10.23 is incompatible with containerd 1.7.x+ due to the removal of sys/userns_deprecated.go
(upgrading containerd results in lifecycle compile errors like go/pkg/mod/github.com/docker/docker@v20.10.23+incompatible/pkg/archive/archive_unix.go:96:42: undefined: sys.RunningInUserNS)

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-03-20 15:53:28 -04:00
Philipp Stehle 584c6cbd35
Replace deprecated GHA ::set-output syntax (#1037)
Signed-off-by: Philipp Stehle <philipp.stehle@sap.com>
2023-03-20 14:48:31 -04:00
dependabot[bot] 611dee801f
Bump golang.org/x/sys from 0.5.0 to 0.6.0 (#1029)
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/golang/sys/releases)
- [Commits](https://github.com/golang/sys/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-20 13:29:45 -04:00
Jesse Brown a6d834bbf4
Merge pull request #1036 from benri/bl/archive-pax-global-header
Ignore pax global header in tar extract
2023-03-20 12:04:57 -05:00
Benjamin Leong d409e5a939
add test
Signed-off-by: Benjamin Leong <benri@users.noreply.github.com>
2023-03-16 16:18:04 -07:00
Benjamin Leong 310acf90e1
Ignore pax global header in tar extract
Signed-off-by: Benjamin Leong <benri@users.noreply.github.com>
2023-03-16 16:18:04 -07:00
Natalie Arellano fa9a11abd2
Detector changes for run image extension (#1011)
* 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>

* Fix acceptance

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

* Don't redefine -layers

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

* Revert "Replace print with logger in image_cache.go, fixes formatting (#1012)"

This reverts commit 6a10b63c67.

* Revert "Revert "Replace print with logger in image_cache.go, fixes formatting (#1012)""

This reverts commit 5780910ecf.

* Rename image -> images in run.toml

We pluralize all other list elements

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

* Don't enforce constraints for older extensions

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

* Rename function for clarity

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-03-08 15:02:50 -05:00
Joe Kimmel 6d6b469717
Stack removal: detect phase and analyze.toml support Targets (#994)
* initial setup for toml file schemas and structs

BpDescriptor reads and populates Targets data

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

* correct-er detector for target selector

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

* TargetMetadata.Equals: tests and impl nailed down
minor cleanup
nix mixins mixup

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

* refactoring RunImage with some spillover

- RunImage has:
  - Reference
  - Target
While i was in there, some of the other *ImageReference types were
inconvient so I changed them to just be strings instead of structs
containing strings. This does have the effect of collapsing a table,
But as a newer contributor to this project I have the blessing and curse
of not feeling all that constrained by (nor aware of) past decisions.

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

* NewDetector respects the alphabet

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

* only replace stack with target for newer api versions
small cleanups / removal of unneeded check

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

* Equals->Satisfied and other cleanups

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

* detector logic is probably all the way working

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

* turns out the unit tests pass without the bin folders for these buildpack fixtures

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

* analyzed.toml backwards compat shims

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

* change detector to take analyzedMD struct rather than file

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

* small cleanups

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

* runImage only has one distribution and that small adjustment has someconsequences

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

* move isWildcard to private method of detector

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

* analyzed acceptance tests use ReadAnalyzed fn

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

* Updates

Update env/build.go
Update buildpack/bp_descriptor.go
Update default arch to amd64
use OS instead of Os
fixing mocks and fn calls after small change

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

* couple more easy fixes
fix descriptor test bc we decided that we _do_ want that behavior for old versions

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

* Targets are auto-detected based on contents of buildpack/bin

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

* Change AnalyzedMetadata struct to use pointers again

This allows us to remove our custom writer, while keeping the file schema unchanged in Platform API 0.12

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

* Fix lint

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

* Fix nil pointer

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

---------

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
Signed-off-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Joe Kimmel <joe-kimmel-vmw@vmware.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Joe Kimmel <joe-kimmel-vmw@vmware.com>
2023-03-07 15:19:09 -05:00
Joe Kimmel 2f308e4f08
updating development mock generator instructions to enshrine oral tradition from @naralleno (#1028)
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-03-06 18:13:58 -05:00
Natalie Arellano b6af8b5515
Fix CI (#1027)
* Removes tee so that we can see if CI is really failing

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

* Fixes regression introduced in refactor that assumed we could read the -layers flag before other flags

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

* Don't override user-provided order.toml

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

* Read order.toml from environment if provided

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-03-03 10:08:13 -05:00
Natalie Arellano 1400e8edce
Removes tee so that we can see if CI is really failing (#1025)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-03-01 18:01:40 -05:00
dependabot[bot] d99d58f834
Bump golang.org/x/net from 0.5.0 to 0.7.0 (#1017)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.5.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.5.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-28 18:35:57 -05:00
Natalie Arellano cad291f00a
Make a single constructor for lifecycle inputs (#1009)
* 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>

* Pass in layers directory instead of defaulting to a "placeholder" input that will be updated later

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

* Assert layers directory

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

* Fall back to default layers when directory not provided

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

* Consolidate -layers parsing

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

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-02-28 12:01:34 -05:00
Aidan Delaney 4cb2bdcbc5
Add Layer Metadata test as living doc (#1019)
Layer Metadata is straightforward, adding a test to act as a living
document.

Signed-off-by: Aidan Delaney <adelaney21@bloomberg.net>
2023-02-23 10:06:36 -05:00
Juan Bustamante 03ee829704
Implement the capability to the phases to handle input/output images in OCI layout format (#969)
* Implementation of the new flag to export to OCI layout format

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* Adding reference to imgUtil for OCI layout

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* Adding test coverage

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* updating to imgutil librery with the name.ref annotation

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* base on review feedback, I am removing the layout-repo configuration, now platforms must take care of mounting the inputs according to the image ref to path rules described in the RFC

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* reverting the change to remove the layout-dir

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* fixing dockerfile error for the acceptance tests

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* removing chmod validation on /layout-repo

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* pointing to the latest imgutil commit

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* Update cmd/lifecycle/analyzer.go

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

* Fix lint

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

* Apply suggestions from code review

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* Fixing formatting issue

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* fixing errors after later refactor

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* Apply suggestions from code review

Co-authored-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* Using method layout.ParseIdentifier from imgUtil, and removing test case

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* simplifying the image_layout test cases

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* bumping imgutil version to 4cf98dd677d28557679e4f08941e891f640410cd

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

---------

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2023-02-21 14:24:43 -05:00
Harshal Mittal 6a10b63c67
Replace print with logger in image_cache.go, fixes formatting (#1012)
* Replace print with logger in image_cache.go, fixes formatting

Signed-off-by: Harshal Mittal <harshalmittal4@gmail.com>

* Add tests for image_cache logger

Signed-off-by: Harshal Mittal <harshalmittal4@gmail.com>

---------

Signed-off-by: Harshal Mittal <harshalmittal4@gmail.com>
2023-02-21 10:25:04 -05:00
Natalie Arellano 4e537685ce
Update README for 0.16.0 (#1016)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-02-21 10:24:39 -05:00
Natalie Arellano e3e3590866
Bump containerd (#1015)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-02-21 10:24:31 -05:00
Joe Kimmel 3be3585644
tees test output to untracked file (#1013)
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-02-17 11:40:57 -05:00
Natalie Arellano 014ccebcee
Adds -run as an input to the analyzer & creator (#1005)
- Also adds unit tests for create inputs

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-02-13 11:08:57 -05:00
Natalie Arellano 5382f323cf
Fix log message when run image not found (#1004)
Before: "Previous image with name <run image name> not found"
After: "Image with name <run image name> not found"

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-02-08 16:21:05 -05:00
dependabot[bot] 1398dfa30c
Bump github.com/google/go-containerregistry from 0.12.1 to 0.13.0 (#991)
Bumps [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) from 0.12.1 to 0.13.0.
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.12.1...v0.13.0)

---
updated-dependencies:
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-27 14:47:48 -05:00
Natalie Arellano 8040b9cccb
Fix creator acceptance test flake (#990)
* Use launch cache when calling SaveAs on caching image

- Failure to use the launch cache will result in slower second builds,
  due to the time it takes to pull layers from the daemon
- Improve creator acceptance test

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

* Try to make test less flakey by forcing first build to be slower

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-01-26 10:08:25 -05:00
Natalie Arellano 55ce12cecc
Bump deps (#989)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-01-24 13:52:55 -05:00
Natalie Arellano cabbe91325
Fix check release workflow (#987)
There is no go.mod before checkout

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2023-01-23 16:57:01 -05:00
dependabot[bot] 9b4c11c835
Bump github.com/docker/docker (#988)
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.22+incompatible to 20.10.23+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v20.10.22...v20.10.23)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-23 16:56:48 -05:00
dependabot[bot] 73f5f1d291
Bump golang.org/x/sys from 0.3.0 to 0.4.0 (#982)
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/golang/sys/releases)
- [Commits](https://github.com/golang/sys/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-23 16:56:24 -05: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
Jesse Brown ec4e8d3e7e
Merge pull request #980 from buildpacks/dependabot/go_modules/github.com/docker/docker-20.10.22incompatible
Bump github.com/docker/docker from 20.10.21+incompatible to 20.10.22+incompatible
2023-01-13 10:32:26 -06:00
dependabot[bot] e5047bb3dd
Bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.21+incompatible to 20.10.22+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v20.10.21...v20.10.22)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-13 00:11:47 +00:00
Jesse Brown e567b3c88f
Merge pull request #985 from joeybrown-sf/feature/rebase-digest
allow passing previous image in rebase cmd
2023-01-12 15:49:58 -06:00
Joey Brown 9614cad734
Update rebaser_test.go
Co-authored-by: Jesse Brown <jabrown85@gmail.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
2023-01-10 16:34:56 -06:00
Joey Brown 62e5236814
Update rebaser_test.go
Co-authored-by: Jesse Brown <jabrown85@gmail.com>
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
2023-01-10 13:59:35 -06:00
Joey Brown b303de57f8
upgrade imgutils
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
2023-01-10 13:53:26 -06:00
Joey Brown 9e8d9f576f
add a guard clause to ensure min API version
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
2023-01-10 13:49:16 -06:00
Joey Brown 4be1c1c5ed
updated tests
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
2023-01-09 11:08:20 -06:00
Joey Brown b41d4132c5
utilizing saveAs rather than rename
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
2023-01-09 10:33:28 -06:00
Joe Kimmel 72bb70603f
rename CNB_ANALYZE_SKIP_LAYERS to CNB_SKIP_LAYERS (#981)
to match spec and resolve FIXME

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

Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-01-06 16:37:47 -05:00
Joey Brown 50646839c8
add a test
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
2023-01-06 14:44:32 -06:00
Joey Brown 90cdc81a26
rename working as expected
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
2023-01-06 14:18:37 -06:00
Joey Brown d0caf2a428
rename image at the last moment
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
2023-01-06 14:03:30 -06:00
Joey Brown e8b5735ee1
allow passing previous image
Signed-off-by: Joey Brown <brown.joseph@salesforce.com>
2023-01-06 10:59:14 -06:00
Natalie Arellano 4b1f2c3fa1
Fix pack acceptance (#979)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-12-16 15:47:06 -05:00
Natalie Arellano a31d64d13a
Bump deps (#978)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-12-15 15:48:40 -05:00
Natalie Arellano 6454eb0760
Updates go to version 1.19 (#973)
* Updates go to version 1.19

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

* Use go-version-file to detect go version

This is one less thing to change when we upgrade

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-12-15 09:57:43 -05:00
Natalie Arellano 213e143f5e
Remove unused functions (#976)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-12-14 14:31:11 -05:00
Natalie Arellano 960c36cd81
Improve detector log output (#975)
* Improve detector log output: when detect fails, print output as info level

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

* Refactor: detector has a log handler

This eliminates the need for a "multi logger"

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

* Make memory handler private

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>
2022-12-14 14:30:45 -05:00
Natalie Arellano 3648072784
Consider platform API <= 0.6 and buildpack API <= 0.6 deprecated (#974)
* Consider platform API <= 0.6 and buildpack API <= 0.6 deprecated
according to https://github.com/buildpacks/rfcs/blob/main/text/0110-deprecate-apis.md

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

* Fix launcher acceptance

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

* Fix Windows

- Create usable symlink
- When process type has a '.' we need to provide .exe

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

* Keep default platform API as 0.3

Add warning when the env var is unset so that end users know they are defaulting to the default

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

* Unnest tests that pass on any platform API

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

* Improve output when only version is requested

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

* Quote platform API version

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-12-12 10:28:37 -05:00
Natalie Arellano e1f7860500
Fix: rebase does not require stack.toml (#972)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-12-09 13:41:45 -05:00
dependabot[bot] da5da9bb53
Bump golang.org/x/sys from 0.2.0 to 0.3.0 (#971)
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.2.0 to 0.3.0.
- [Release notes](https://github.com/golang/sys/releases)
- [Commits](https://github.com/golang/sys/compare/v0.2.0...v0.3.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-07 13:09:29 -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
Natalie Arellano 3627c94baf
Fix pack acceptance with 0.28.0-rc1 (#968)
We need to configure git to use line feeds on Windows, otherwise
  the test fixtures and hence the layer diff IDs will be different from the test expectations.

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-12-01 10:51:32 -05:00
Natalie Arellano 4e6e4f7ef2
Fix: set HOME for provided user after build image extension (#960) (#964)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-11-28 12:38:55 -05:00
Natalie Arellano 4c62475a8c
(updated with latest main) Allow setting environment variables using the build image (#962)
* Allow setting environment variables using the build image

Signed-off-by: Sambhav Kothari <skothari44@bloomberg.net>

* Add a few more unit tests

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

* Resolve absolute path of build config directory

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

Signed-off-by: Sambhav Kothari <skothari44@bloomberg.net>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Sambhav Kothari <skothari44@bloomberg.net>
2022-11-22 17:21:54 -05:00
Natalie Arellano 532fc6c413
Refactor platform inputs and consolidate logic in platform package (#961)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-11-22 10:26:59 -05:00
dependabot[bot] 6667e59fc6
Bump github.com/google/go-containerregistry from 0.12.0 to 0.12.1 (#955)
Bumps [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) from 0.12.0 to 0.12.1.
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.12.0...v0.12.1)

---
updated-dependencies:
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-21 16:01:33 -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
Natalie Arellano ef9a1449e4
Bump dependencies (go get -u ./...) (#952)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-11-09 13:50:15 -05:00
dependabot[bot] 64c41f844e
Bump github.com/docker/docker (#942)
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.20+incompatible to 20.10.21+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Changelog](https://github.com/moby/moby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/docker/docker/compare/v20.10.20...v20.10.21)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-09 11:13:39 -05:00
Natalie Arellano a1801c09fe
Bump golang.org/x/sys from 0.1.0 to 0.2.0 (#951)
Replaces https://github.com/buildpacks/lifecycle/pull/948 without bumping kaniko

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-11-08 17:04:38 -05:00
Natalie Arellano 51c7e68007
Fix special character escaping when marshaling launch process (#950)
* Add unit tests for marshal & unmarshal

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

* Fix: MarshalJSON() for older platforms should properly escape single string

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

* Fix: MarshalTOML() should properly escape single strings

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

* Fix: UnmarshalJSON()

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-11-08 16:45:52 -05:00
Natalie Arellano caf3d06c00
Use json to marshal command entry for older platform (#947)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-11-04 12:46:43 -04:00
Jesse Brown f78b5cec70
Fix regression in metadata.toml rendering (#946)
* Fix regression in metadata.toml rendering

Moved the dynamic process serialization to a new field type and off of process. The TOML that was previously generated was not expected and the TOML library we use doesn't seem to have a way to render the table the way we expect. Making a new type for the single field `command` allows us to render the TOML the way we want.

Fixes: buildpacks/lifecycle#945
Signed-off-by: Jesse Brown <jabrown85@gmail.com>

* Changes requested from pull request

- Minor reorganization of the code
- Fixed typos
- Removed some redundant checks in one test to not muddy the waters on what is being tested
- Updated some comments
- Removed debug code

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

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2022-11-03 16:23:39 -04: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 8dfa73f4df
Update README with latest apis (#930)
* Update README with latest apis

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-24 11:57:50 -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 d69768d861
Bump dependencies (go get -u ./...) (#938)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-10-24 11:57:15 -04:00
Michael de Senna ca6c1c9118
build: fix coverage (#936)
Signed-off-by: Michael de Senna <desenna@gmail.com>

Signed-off-by: Michael de Senna <desenna@gmail.com>
2022-10-21 12:41:38 -04:00
Natalie Arellano 7b5aa02886
Bump imgutil and docker (#933)
* Bump imgutil and docker

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:55 -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 6643f35886
Merge release/0.15.0-rc.1 into main (#924)
* Bump containerd (fixes CVE-2022-31030) and runc (fixes CVE-2021-30465)

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

* Add .grype.yaml to ignore known non-impactful CVEs (#923)

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

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-10-11 12:02:07 -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
Natalie Arellano 0205531176
Implement overridable process args (#921)
* Implement overridable process args

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

* Apply suggestions from code review

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

* When there are no user-provided args, overridable args should be provided

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

* Fix user provided args for newer buildpack with no always-args

When there are no always-args, we need to check the buildpack API, because
it's not clear from the process definition if the buildpack is newer or older.

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

* Fix: user-provided args should replace overridable args only if non-empty

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

* Fix: older platforms should always append

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Jesse Brown <jabrown85@gmail.com>
2022-10-06 09:19:08 -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 52e7885192
Revert "Allow storing multiple commands instead of a single string (#900)" (#919)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-09-29 14:01:46 -04:00
Natalie Arellano 3fec123f29
Try to fix "check release" workflow (#916)
* Try to fix "check release" workflow

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

* Fix indent

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-09-28 09:53:11 -04:00
Jesse Brown 5fa84a4c38
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>
2022-09-22 15:40:41 -04:00
Natalie Arellano 2885c01804
Add GitHub Actions workflow to update go when a new version is available (#910)
* Add GitHub Actions workflow to check if latest lifecycle release is on the latest patch of Go

Also scan the latest lifecycle image to see if any vulnerabilities are alerted

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

* Pass GH token to step

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

* Update release version for lifecycle image

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

* Don't create issue if it exists already

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

* Create issue if CVEs are found

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-09-19 16:08:11 -04:00
Natalie Arellano f1398cef14
Dockerfiles phase 1: update experimental mode env var (#881)
* Update experimental mode env var

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

* When CNB_EXPERIMENTAL_MODE is unset, default to `error`

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-09-19 10:54:36 -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 18f0abc6fe
Scan dev lifecycle images after they are published (but before they are re-tagged (#911)
with a non-dev version)

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-09-16 17:15:06 -04:00
Natalie Arellano a3304c34db Update setup-go
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-09-16 13:31:14 -04:00
Jesse Brown f3af3e0080
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>
2022-09-13 16:52:52 -04:00
Natalie Arellano 4f52db0a90
Remove -output-dir in favor of -generated (#898)
To be more consistent with the arguments needed by the extender in phase 2

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

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-08-24 12:19:57 -04:00
Natalie Arellano 0c057cd21d
Upgrade GHA runner (#897)
Signed-off-by: Natalie Arellano <narellano@vmware.com>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-08-24 12:19:00 -04:00
dependabot[bot] 6b0943ba43
Bump github.com/google/go-containerregistry from 0.10.0 to 0.11.0 (#885)
Bumps [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-24 10:28:10 -04:00
Jesse Brown 328f07bbb3
Allow new buildpack API to use new launch.toml format (#889)
* Ignore .tool-versions for asdf and other tooling

* Allow new buildpack API to use new launch.toml format

- Buildpacks using the newer buildpack API must use the new launch.toml format
- The older format is still allowed on older buildpack API versions

Issue: https://github.com/buildpacks/lifecycle/issues/870

* Update buildpack/build_test.go

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

* Update buildpack/build_test.go

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

* Update buildpack/build_test.go

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

* Added Buildpack 0.10 as valid buildpack API

Fixed tests that were now invalid due to the default buildpack being 0.10

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

* Apply suggestions from code review

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

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2022-08-23 15:57:23 -04:00
Natalie Arellano 512528c687
Refactor: consolidate some logic in platform package (#875)
* 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>

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-08-23 14:30:47 -04:00
Natalie Arellano 81da25326c
Update dependencies (#883)
* Bump imgutil

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

* Bump deps to fix compile errors

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-07-19 15:19:46 -04:00
Natalie Arellano a9d5c7c2de
Small fixes for Dockerfiles phase 1 (#882)
* Small fixes for Dockerfiles phase 1

* Looks for pre-populated output files in nested directories (e.g., ./generate) instead of the extension root
* Extensions must satisfy all requires they enlisted to provide
* Escape extension ID when locating Dockerfiles
* Resolve analyzed path if not provided

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

* Fix assertion

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

* Fix more assertions and unwrap errors

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-07-19 10:53:44 -04:00
Natalie Arellano 60295970b6
Fix: a buildpack and extension with the same ID can both detect (#879)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-07-18 15:43:49 -04:00
Natalie Arellano cbdfa63223
Remove redundant acceptance tests (#874)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-07-18 15:42:46 -04:00
Javier Romero 746b0978f7
Fix: Output ANAYLYZING phase heading (#878)
On newer platform API versions, the lifecyle is not printing an expected ANALYZING step header

Signed-off-by: Javier Romero <rjavier@vmware.com>
2022-06-30 11:01:03 -04:00
Natalie Arellano ce23c6593a
Dockerfiles phase 1 (generate changes) (#869)
Generate changes to support Dockerfiles feature

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-06-28 10:38:08 -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 b5f8bad1f1
Bump deps (#863)
* Bump imgutil

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

* Bump other deps to fix linter

Update Makefile

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-05-27 13:58:40 -04:00
Natalie Arellano f1d94587d8
Apply the fix from https://github.com/buildpacks/lifecycle/pull/853 to ResolvedKeychain (#862)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-05-27 13:33:10 -04:00
dependabot[bot] 1a76076709
Bump github.com/google/go-containerregistry from 0.8.0 to 0.9.0 (#859)
Bumps [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) from 0.8.0 to 0.9.0.
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-27 11:09:39 -04:00
Natalie Arellano ce9e093c55
When the provided keychain is missing authorization information for a registry, the (#853)
environment variable and/or in-memory keychain should omit it, instead of including it
with an empty header.

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-05-26 14:50:09 -04:00
Sambhav Kothari 7afe29415a
Make runLaunch public (#848)
Signed-off-by: Sambhav Kothari <skothari44@bloomberg.net>
2022-05-26 11:13:51 -04:00
Natalie Arellano 51046e7a98
Add credential helpers for Amazon and Azure (#855)
* Add credential helpers for Amazon and Azure

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

* When using cloud credential helpers, resolve creds early

If the lifecycle is run as root, after dropping privileges it may not be able
to read cred helper files. By resolving creds in memory when the keychain is
instantiated, we avoid this edge case.

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-05-25 17:57:27 -04:00
Natalie Arellano b81fe9c17e
Use identity token when provided, instead of ignoring it (#854)
* Use identity token when provided, instead of ignoring it.

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

* Preserve IdentityToken in AuthConfig

The registry -> header map allows us to reconstruct the AuthConfig when resolving the keychain.
By giving identity tokens a unique header, we are able to distinguish them from registry tokens.

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

* Remove authConfig -> header -> authConfig round tripping for in-memory keychain
(now resolved keychain).

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

* Rename env_keychain.go to keychain.go

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

* Add comment

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-05-25 17:34:13 -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
Juan Bustamante bb40e22710
Add empty layer before saving on remote images (#852)
Initialized the cache image to add an empty layer in case is needed

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

# This is the commit message #2:

Fixing compilation error caused by imgutil PR #141

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* WIP - Initialized the cache image to add an empty layer in case is needed

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* Pointing to the latest imgutil empty layer branch

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>

* Updating imgutil version after PR#142 was merged

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
2022-05-04 13:37:42 -04:00
dependabot[bot] e498b7b189
Bump github.com/google/go-cmp from 0.5.7 to 0.5.8 (#851)
Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.7 to 0.5.8.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.5.7...v0.5.8)

---
updated-dependencies:
- dependency-name: github.com/google/go-cmp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-04 13:36:32 -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 277f3b2834
The lifecycle should ensure ownership of the launch cache dir (#847)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-04-21 10:39:21 -04:00
dependabot[bot] b6803be364
Bump github.com/BurntSushi/toml from 1.0.0 to 1.1.0 (#846)
Bumps [github.com/BurntSushi/toml](https://github.com/BurntSushi/toml) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/BurntSushi/toml/releases)
- [Commits](https://github.com/BurntSushi/toml/compare/v1.0.0...v1.1.0)

---
updated-dependencies:
- dependency-name: github.com/BurntSushi/toml
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-12 15:04:36 -04:00
Natalie Arellano 917c1acd25
Update README for latest apis (#836)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-04-01 10:20:24 -04:00
Natalie Arellano 4b0fe078d6
Turn go modules off with ENV (#843)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-03-30 11:05:00 -04:00
Natalie Arellano 774500dc77
Upgrade to go 1.17 (#839)
* Upgrade to go 1.17

Now that go 1.18 is out, go 1.16 is no longer supported.

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

* Fix Windows

In go 1.17, child processes do not automatically inherit handles from the parent process.

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-03-29 12:41:25 -04:00
dependabot[bot] 410339eb56
Bump github.com/docker/docker (#837)
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.13+incompatible to 20.10.14+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Changelog](https://github.com/moby/moby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/docker/docker/compare/v20.10.13...v20.10.14)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-28 13:06:23 -04:00
Natalie Arellano 0f5a9cdd7f
Strip optional parameter before checking media type (#834)
* Builder when validating bomfile media type against buildpack declared type
should strip optional parameter before checking equality

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

* Use mime package to parse type

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-03-23 13:42:56 -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
dependabot[bot] 1f3a0c092b
Bump github.com/docker/docker (#826)
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.12+incompatible to 20.10.13+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Changelog](https://github.com/moby/moby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/docker/docker/compare/v20.10.12...v20.10.13)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-15 15:39:20 -04:00
Jesse Brown 82298b73ee
Support SOURCE_DATE_EPOCH (#823)
* Support SOURCE_DATE_EPOCH

Platforms can set `SOURCE_DATE_EPOCH` to control the timestamp on the exported app images.

See https://github.com/buildpacks/lifecycle/issues/809 for more details.

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

* Fixing 0.9 skip-layers test

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

* Added 0.9 exiter test

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
2022-03-10 13:26:39 -05:00
Matthew McNew 3ff2467525
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>
2022-03-09 10:13:34 -05:00
Mikey Boldt 76dc230e3f
Set env vars for positional args in build and detect (#818)
As described in RFC 100, set the following environment variables when
running buildpack executables, which correspond to their positional
arguments.

In `detect`:

- CNB_PLATFORM_DIR
- CNB_BUILD_PLAN_PATH

In `build`:

- CNB_LAYERS_DIR
- CNB_PLATFORM_DIR
- CNB_BP_PLAN_PATH

Fixes #806.
Fixes #807.

Signed-off-by: Mikey Boldt <mboldt@vmware.com>
2022-03-04 15:30:16 -05:00
Natalie Arellano b0138eff17
Change working-directory to working-dir (#814)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-03-04 15:29:50 -05:00
Jesse Brown d9a734ec90
Merge pull request #817 from mboldt/dev-add-jq-yj
Add jq and yj as development prerequisites
2022-03-03 12:27:24 -06:00
Mikey Boldt b3975bf1b6 Add jq and yj as development prerequisites
They are required by the buildpack in buildpack/testdata/buildpack.

Signed-off-by: Mikey Boldt <mboldt@vmware.com>
2022-03-03 11:23:50 -06:00
Natalie Arellano 745886f649
Specify windows-2019 since windows-2022 is the default runner now (#816)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-03-03 11:02:57 -05: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
Mikey Boldt 4ebc445600
Process-specific working directory (#792)
* Set working directory for processes running in bash shell

Signed-off-by: Mikey Boldt <mboldt@vmware.com>

* Set working directory for processes running in cmd.exe

Signed-off-by: Mikey Boldt <mboldt@vmware.com>

* Set working directory for direct processes

Signed-off-by: Mikey Boldt <mboldt@vmware.com>

* Handle process working directory in build phase

Signed-off-by: Mikey Boldt <mboldt@vmware.com>

* Simplify command to check working directory in test

Signed-off-by: Mikey Boldt <mboldt@vmware.com>

* Support process working directory on different drive on Windows

Requires the `/d` flag on `cd` to change drive.

Signed-off-by: Mikey Boldt <mboldt@vmware.com>

* Add tests for working directory with direct=false

Signed-off-by: Mikey Boldt <mboldt@vmware.com>

* Use platform-specific path in CNB_APP_DIR

The `cd` for process-specific working directory fails on Windows
when it is given a Unix-style path.

Signed-off-by: Mikey Boldt <mboldt@vmware.com>

* Add default working directory test

Signed-off-by: Mikey Boldt <mboldt@vmware.com>
2022-01-26 12:10:59 -05:00
Natalie Arellano 9f48e5a10a
If there are is no sbom layer in the cache, still copy sbom files for launch that were restored (#798)
from the previous image.

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2022-01-24 15:01:12 -05:00
Anthony Emengo 8df2237a8f
Warn when legacy bom is specified on buildpack API 0.7 (#794)
* Warn when legacy bom is specified on buildpack API 0.7

as opposed to throwing an error. This allows for non-breaking platform migration from legacy bom table to sbom format

This commit partially reverts 880a801db2

Signed-off-by: Anthony Emengo <aemengo@vmware.com>

* Address PR comments

* Add test for top-level bom.version entry
* Don't show warning message if legacy BOM and new SBOM is provided

Signed-off-by: Anthony Emengo <aemengo@vmware.com>
2022-01-24 13:47:17 -05:00
dependabot[bot] db1d753f63
Bump github.com/google/go-cmp from 0.5.6 to 0.5.7 (#796)
Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.6 to 0.5.7.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.5.6...v0.5.7)

---
updated-dependencies:
- dependency-name: github.com/google/go-cmp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-24 12:35:42 -05:00
dependabot[bot] 4a6089b483
Bump github.com/BurntSushi/toml from 0.4.1 to 1.0.0 (#790)
* Bump github.com/BurntSushi/toml from 0.4.1 to 1.0.0

Bumps [github.com/BurntSushi/toml](https://github.com/BurntSushi/toml) from 0.4.1 to 1.0.0.
- [Release notes](https://github.com/BurntSushi/toml/releases)
- [Commits](https://github.com/BurntSushi/toml/compare/v0.4.1...v1.0.0)

---
updated-dependencies:
- dependency-name: github.com/BurntSushi/toml
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix deprecation from updated toml library.

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

* Update test to match new error format

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jesse Brown <jabrown85@gmail.com>
2022-01-14 16:39:38 -05:00
dependabot[bot] 11ea281c1d
Bump github.com/google/go-containerregistry from 0.7.0 to 0.8.0 (#788)
Bumps [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) from 0.7.0 to 0.8.0.
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.7.0...v0.8.0)

---
updated-dependencies:
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-13 16:50:59 -05:00
dependabot[bot] 1a934bdcb5
Bump github.com/docker/docker (#785)
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.11+incompatible to 20.10.12+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Changelog](https://github.com/moby/moby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/docker/docker/compare/v20.10.11...v20.10.12)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-13 16:50:34 -05:00
Mikey Boldt 6f56a15303
Fix lint issues (#787)
Signed-off-by: Mikey Boldt <mboldt@vmware.com>
2022-01-03 11:45:29 -05:00
Natalie Arellano b6408639c0
Fix slow performance for creator when restoring sbom layer from previ… (#784)
* Fix slow performance for creator when restoring sbom layer from previous image in daemon

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

* Add info statements and try to fix exporter flake on arm runner

We should at least log something when restoring the sbom layer. This aligns the logging
for sbom with the logging for layer content metadata.

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2021-12-13 14:34:50 -05:00
Natalie Arellano 157e030cff
Don't run restorer tests for every buildpack api (#781)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2021-12-10 15:55:13 -05:00
Natalie Arellano 77904d2814
Organize analyze inputs (#782)
* Organize analyze inputs

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

* Rename struct back and update comments

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2021-12-10 10:29:58 -05:00
Natalie Arellano 42be2d161b
Remove separate packages for platform interface implementation (#771)
* Remove separate packages for platform interface implementation

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

* Update builder_test.go

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

* Update builder_test.go

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

* Add tests

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2021-12-07 10:17:20 -05:00
Natalie Arellano 071939dab9
Bumps imgutil and also updates indirect dependencies (#777)
* Bumps imgutil and also updates indirect dependencies

The lifecycle and imgutil will be on the same version of ggcr.

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

* Tidy

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2021-12-06 10:02:40 -05:00
Matej Vasek ab007b17fe
guard singleton connection (#779)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-12-06 09:51:46 -05:00
Matej Vasek 1f904803d9
Keep connection opened (#684)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-12-03 16:37:15 -05:00
Natalie Arellano bf99b6fdc7
Remove the pre-release note for 0.13.x (#778)
We forgot to do this when we cut 0.13.0.

Signed-off-by: Natalie Arellano <narellano@vmware.com>
2021-12-03 15:36:10 -05:00
dependabot[bot] d45c5fd9b4
Bump github.com/google/go-containerregistry from 0.6.0 to 0.7.0 (#774)
Bumps [github.com/google/go-containerregistry](https://github.com/google/go-containerregistry) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/google/go-containerregistry/releases)
- [Changelog](https://github.com/google/go-containerregistry/blob/main/.goreleaser.yml)
- [Commits](https://github.com/google/go-containerregistry/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: github.com/google/go-containerregistry
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-03 14:40:31 -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
Natalie Arellano 51280df55b
Bump ggcr & imgutil (#770)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2021-12-01 18:03:37 -05:00
Natalie Arellano e6cad2ecf1
Fix pack acceptance (#772)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2021-12-01 17:22:17 -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
dependabot[bot] 5744dae9b0
Bump github.com/docker/docker (#769)
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.10+incompatible to 20.10.11+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Changelog](https://github.com/moby/moby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/docker/docker/compare/v20.10.10...v20.10.11)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-29 12:43:19 -05:00
Natalie Arellano 496670f2ab
Update buildpack.toml to use sbom-formats (#768)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2021-11-18 14:06:00 -05:00
Natalie Arellano 9ba9bb88a9
Fix comment (#767)
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2021-11-18 12:29:49 -05:00
Anthony Emengo 880a801db2
Error when previous bom is specified on buildpack API 0.7 (#764)
* Error when previous bom is specified on buildpack API 0.7

instead of warning

Signed-off-by: Anthony Emengo <aemengo@vmware.com>

* Warn when new sbom is specified on buildpack API <0.7

Signed-off-by: Anthony Emengo <aemengo@vmware.com>
2021-11-17 12:14:11 -05:00
Jesse Brown 196f637ace
Switch bom to sbom (#761) (#763)
Signed-off-by: Anthony Emengo <aemengo@vmware.com>

Co-authored-by: Anthony Emengo <aemengo@vmware.com>
Co-authored-by: Natalie Arellano <narellano@vmware.com>
2021-11-15 13:11:39 -05:00
Jesse Brown b1a2a7c624
Merge pull request #762 from aemengo/switch-bom-to-sbom-2
bom -> sbom 2
2021-11-11 12:29:58 -06:00
Anthony Emengo 91727236ce bom -> sbom
Signed-off-by: Anthony Emengo <anthonyemengojr@gmail.com>
2021-11-11 12:27:09 -05:00
641 changed files with 31254 additions and 16094 deletions

View File

@ -2,12 +2,14 @@
name: Bug
about: Bug report
title: ''
labels: status/triage, type/bug
labels: type/bug, status/triage
assignees: ''
---
### Summary
<!--- Please provide a general summary of the issue. -->
<!-- Please provide a general summary of the issue. -->
---
@ -15,17 +17,20 @@ assignees: ''
### Reproduction
##### Steps
<!--- What steps should be taken to reproduce the issue? -->
<!-- What steps should be taken to reproduce the issue? -->
1.
2.
3.
##### Current behavior
<!--- What happened? Logs, etc. could go here. -->
<!-- What happened? Logs, etc. could go here. -->
##### Expected behavior
<!-- What did you expect to happen? -->
##### Expected
<!--- What did you expect to happen? -->
---
@ -33,10 +38,15 @@ assignees: ''
### Context
##### lifecycle version
<!--- If you can find this, it helps us pin down the issue. For example, run `pack inspect-builder BUILDER` which should report the lifecycle version in question. -->
<!-- If you can find this, it helps us pin down the issue. For example, run `pack builder inspect <builder name>` which should report the lifecycle version in question. -->
##### platform version(s)
<!--- For example run `pack report` and `docker info` and copy output here. -->
<!-- For example run `pack report` and `docker info` and copy output here, redacting any sensitive information. -->
##### anything else?
<!--- Tekton task version, kpack version, etc. -->
<!-- Add any other context that may help (e.g., Tekton task version, kpack version, etc.). -->

View File

@ -7,11 +7,20 @@ assignees: ''
---
### Description
<!-- A concise description of why this chore matters, who will enjoy it and how. -->
### Summary
<!-- Please describe why this chore matters, who will enjoy it and how. -->
### Proposed solution
<!-- A clear and concise description of how you think the chore should be implemented. -->
### Additional context
<!-- Add any other context or screenshots about the chore that may help. -->
---
### Proposal
<!-- How do you think the chore should be implemented? -->
---
### Context
<!-- Add any other context that may help. -->

View File

@ -7,14 +7,27 @@ assignees: ''
---
### Description
<!-- A concise description of what problem the feature solves and why solving it matters. -->
### Summary
<!-- Please describe the feature and why it matters. -->
### Proposed solution
<!-- A clear and concise description of what you want to happen. -->
### Describe alternatives you've considered
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
### Additional context
<!-- Add any other context or screenshots about the feature request here. -->
---
### Proposal
<!-- How do you think the feature should be implemented? -->
---
### Related
<!-- If this feature addresses an RFC, please provide the RFC number below. -->
RFC #___
---
### Context
<!-- Add any other context that may help. -->

View File

@ -3,5 +3,14 @@ updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
interval: weekly
groups:
# Group all minor/patch go dependencies into a single PR.
go-dependencies:
update-types:
- "minor"
- "patch"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly

25
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1,25 @@
<!-- 🎉🎉🎉 Thank you for the PR!!! 🎉🎉🎉 -->
### Summary
<!-- Please describe your changes at a high level. -->
#### Release notes
<!-- Please provide 1-2 sentences for release notes. -->
<!-- Example: When using platform API `0.7` or greater, the `creator` logs the expected phase header for the analyze phase -->
---
### Related
<!-- If this PR addresses an issue, please provide the issue number below. -->
Resolves #___
---
### Context
<!-- Add any other context that may help reviewers (e.g., code that requires special attention, etc.). -->

View File

@ -12,13 +12,16 @@ on:
jobs:
test-linux-amd64:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up go
uses: actions/setup-go@v2
- uses: actions/checkout@v4
with:
go-version: '1.16'
fetch-depth: '0'
- name: Setup go
uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: 'go.mod'
- name: Install jq
run: |
mkdir -p deps/bin
@ -29,100 +32,58 @@ jobs:
env:
TEST_COVERAGE: 1
run: make test
- name: Upload Coverage
uses: codecov/codecov-action@v1.0.5
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./out/tests/coverage-unit.txt
flags: unit,os_linux
fail_ci_if_error: true
verbose: true
test-linux-arm64:
runs-on: linux-arm64
steps:
- uses: actions/checkout@v2
- name: Set up go
uses: actions/setup-go@v2
- uses: actions/checkout@v4
with:
go-version: '1.16'
fetch-depth: '0'
- name: Setup go
uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: 'go.mod'
- name: Test
run: |
make format || true
make test
test-windows:
runs-on: windows-latest
steps:
- name: Set git to use LF and symlinks
run: |
git config --global core.autocrlf false
git config --global core.eol lf
git config --global core.symlinks true
- uses: actions/checkout@v2
- name: Set up go
uses: actions/setup-go@v2
with:
go-version: '1.16'
- name: Add runner IP to daemon insecure-registries and firewall
shell: powershell
run: |
# Get IP from default gateway interface
$IPAddress=(Get-NetIPAddress -InterfaceAlias ((Get-NetRoute "0.0.0.0/0").InterfaceAlias) -AddressFamily IPv4)[0].IPAddress
# Allow container-to-host registry traffic (from public interface, to the same interface)
New-NetfirewallRule -DisplayName test-registry -LocalAddress $IPAddress -RemoteAddress $IPAddress
# create or update daemon config to allow host as insecure-registry
$config=@{}
if (Test-Path C:\ProgramData\docker\config\daemon.json) {
$config=(Get-Content C:\ProgramData\docker\config\daemon.json | ConvertFrom-json)
}
$config."insecure-registries" = @("$IPAddress/32")
ConvertTo-json $config | Out-File -Encoding ASCII C:\ProgramData\docker\config\daemon.json
Restart-Service docker
# dump docker info for auditing
docker version
docker info
- name: Test
env:
TEST_COVERAGE: 1
run: |
make test
- name: Prepare Codecov
uses: crazy-max/ghaction-chocolatey@v1
with:
args: install codecov -y
- name: Run Codecov
run: |
codecov.exe -f .\out\tests\coverage-unit.txt -v --flag os_windows
build-and-publish:
needs:
- test-linux-amd64
- test-linux-arm64
- test-windows
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history for all branches and tags
- name: Set up go
uses: actions/setup-go@v2
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.16'
check-latest: true
go-version-file: 'go.mod'
- name: Install Cosign
uses: sigstore/cosign-installer@v1.0.0
with:
cosign-release: 'v1.0.0'
uses: sigstore/cosign-installer@v3
- name: Set version
run: |
echo "LIFECYCLE_VERSION=$(go run tools/version/main.go)" | tee -a $GITHUB_ENV version.txt
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: version
path: version.txt
- name: Set tag
run: |
echo "LIFECYCLE_IMAGE_TAG=$(git describe --always --abbrev=7)" >> tag.txt
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: tag
path: tag.txt
@ -131,71 +92,65 @@ jobs:
make clean
make build
make package
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: lifecycle-linux-x86-64
path: out/lifecycle-v*+linux.x86-64.tgz
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: lifecycle-linux-x86-64-sha256
path: out/lifecycle-v*+linux.x86-64.tgz.sha256
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: lifecycle-linux-arm64
path: out/lifecycle-v*+linux.arm64.tgz
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: lifecycle-linux-arm64-sha256
path: out/lifecycle-v*+linux.arm64.tgz.sha256
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: lifecycle-windows-x86-64
path: out/lifecycle-v*+windows.x86-64.tgz
- uses: actions/upload-artifact@v2
name: lifecycle-linux-ppc64le
path: out/lifecycle-v*+linux.ppc64le.tgz
- uses: actions/upload-artifact@v4
with:
name: lifecycle-windows-x86-64-sha256
path: out/lifecycle-v*+windows.x86-64.tgz.sha256
name: lifecycle-linux-ppc64le-sha256
path: out/lifecycle-v*+linux.ppc64le.tgz.sha256
- uses: actions/upload-artifact@v4
with:
name: lifecycle-linux-s390x
path: out/lifecycle-v*+linux.s390x.tgz
- uses: actions/upload-artifact@v4
with:
name: lifecycle-linux-s390x-sha256
path: out/lifecycle-v*+linux.s390x.tgz.sha256
- name: Generate SBOM JSON
uses: CycloneDX/gh-gomod-generate-sbom@v1
uses: CycloneDX/gh-gomod-generate-sbom@v2
with:
args: mod -licenses -json -output lifecycle-v${{ env.LIFECYCLE_VERSION }}-bom.cdx.json
version: ^v1
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: lifecycle-bom-cdx
path: lifecycle-v*-bom.cdx.json
- name: Calculate SBOM sha
run: |
shasum -a 256 lifecycle-v${{ env.LIFECYCLE_VERSION }}-bom.cdx.json > lifecycle-v${{ env.LIFECYCLE_VERSION }}-bom.cdx.json.sha256
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: lifecycle-bom-cdx-sha256
path: lifecycle-v*-bom.cdx.json.sha256
- uses: azure/docker-login@v1
- uses: azure/docker-login@v2
if: github.event_name == 'push'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v5
with:
name: tag
- name: Set env
run: |
cat tag.txt >> $GITHUB_ENV
- name: Rename cosign public key
run: |
cp cosign.pub lifecycle-v${{ env.LIFECYCLE_VERSION }}-cosign.pub
- uses: actions/upload-artifact@v2
with:
name: lifecycle-cosign-public-key
path: lifecycle-v${{ env.LIFECYCLE_VERSION }}-cosign.pub
- name: Calculate cosign sha
run: |
shasum -a 256 lifecycle-v${{ env.LIFECYCLE_VERSION }}-cosign.pub > lifecycle-v${{ env.LIFECYCLE_VERSION }}-cosign.pub.sha256
- uses: actions/upload-artifact@v2
with:
name: lifecycle-cosign-public-key-sha256
path: lifecycle-v${{ env.LIFECYCLE_VERSION }}-cosign.pub.sha256
- name: Publish images
if: github.event_name == 'push'
run: |
@ -208,44 +163,60 @@ jobs:
LINUX_ARM64_SHA=$(go run ./tools/image/main.go -lifecyclePath ./out/lifecycle-v*+linux.arm64.tgz -tag buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}-linux-arm64 -arch arm64 | awk '{print $NF}')
echo "LINUX_ARM64_SHA: $LINUX_ARM64_SHA"
WINDOWS_AMD64_SHA=$(go run ./tools/image/main.go -lifecyclePath ./out/lifecycle-v*+windows.x86-64.tgz -tag buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}-windows -os windows | awk '{print $NF}')
echo "WINDOWS_AMD64_SHA: $WINDOWS_AMD64_SHA"
LINUX_PPC64LE_SHA=$(go run ./tools/image/main.go -lifecyclePath ./out/lifecycle-v*+linux.ppc64le.tgz -tag buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}-linux-ppc64le -arch ppc64le | awk '{print $NF}')
echo "LINUX_PPC64LE_SHA: LINUX_PPC64LE_SHA"
LINUX_S390X_SHA=$(go run ./tools/image/main.go -lifecyclePath ./out/lifecycle-v*+linux.s390x.tgz -tag buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}-linux-s390x -arch s390x | awk '{print $NF}')
echo "LINUX_S390X_SHA: $LINUX_S390X_SHA"
docker manifest create buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG} \
buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}-linux-x86-64@${LINUX_AMD64_SHA} \
buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}-linux-arm64@${LINUX_ARM64_SHA} \
buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}-windows@${WINDOWS_AMD64_SHA}
buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}-linux-ppc64le@${LINUX_PPC64LE_SHA} \
buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}-linux-s390x@${LINUX_S390X_SHA}
MANIFEST_SHA=$(docker manifest push buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG})
echo "MANIFEST_SHA: $MANIFEST_SHA"
COSIGN_PASSWORD=${{ secrets.COSIGN_PASSWORD }} cosign sign -r \
-key <(echo -n "${{ secrets.COSIGN_PRIVATE_KEY }}" | base64 --decode) \
cosign sign -r -y \
-a tag=${LIFECYCLE_IMAGE_TAG} \
buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}@${MANIFEST_SHA}
cosign verify -key cosign.pub -a tag=${LIFECYCLE_IMAGE_TAG} buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}
cosign verify \
--certificate-identity-regexp "https://github.com/${{ github.repository_owner }}/lifecycle/.github/workflows/build.yml" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
-a tag=${LIFECYCLE_IMAGE_TAG} \
buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}
- name: Scan image
if: github.event_name == 'push'
uses: anchore/scan-action@v6
with:
image: buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}
pack-acceptance-linux:
if: github.event_name == 'push'
needs: build-and-publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
repository: 'buildpacks/pack'
path: 'pack'
ref: 'main'
fetch-depth: 0 # fetch all history for all branches and tags
- uses: actions/download-artifact@v2
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: 'pack/go.mod'
- uses: actions/download-artifact@v5
with:
name: version
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v5
with:
name: tag
- name: Set env
run: |
cat version.txt >> $GITHUB_ENV
cat tag.txt >> $GITHUB_ENV
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v5
with:
name: lifecycle-linux-x86-64
path: pack
@ -256,66 +227,3 @@ jobs:
LIFECYCLE_PATH="../lifecycle-v${{ env.LIFECYCLE_VERSION }}+linux.x86-64.tgz" \
LIFECYCLE_IMAGE="buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}" \
make acceptance
pack-acceptance-windows:
if: github.event_name == 'push'
needs: build-and-publish
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
repository: 'buildpacks/pack'
path: 'pack'
ref: 'main'
fetch-depth: 0 # fetch all history for all branches and tags
- name: Add runner IP to daemon insecure-registries and firewall
shell: powershell
run: |
# Get IP from default gateway interface
$IPAddress=(Get-NetIPAddress -InterfaceAlias ((Get-NetRoute "0.0.0.0/0").InterfaceAlias) -AddressFamily IPv4)[0].IPAddress
# Allow container-to-host registry traffic (from public interface, to the same interface)
New-NetfirewallRule -DisplayName test-registry -LocalAddress $IPAddress -RemoteAddress $IPAddress
# create or update daemon config to allow host as insecure-registry
$config=@{}
if (Test-Path C:\ProgramData\docker\config\daemon.json) {
$config=(Get-Content C:\ProgramData\docker\config\daemon.json | ConvertFrom-json)
}
$config."insecure-registries" = @("$IPAddress/32")
ConvertTo-json $config | Out-File -Encoding ASCII C:\ProgramData\docker\config\daemon.json
Restart-Service docker
# dump docker info for auditing
docker version
docker info
- name: Modify etc\hosts to include runner IP
shell: powershell
run: |
$IPAddress=(Get-NetIPAddress -InterfaceAlias ((Get-NetRoute "0.0.0.0/0").InterfaceAlias) -AddressFamily IPv4)[0].IPAddress
"# Modified by CNB: https://github.com/buildpacks/ci/tree/main/gh-runners/windows
${IPAddress} host.docker.internal
${IPAddress} gateway.docker.internal
" | Out-File -Filepath C:\Windows\System32\drivers\etc\hosts -Encoding utf8
- uses: actions/download-artifact@v2
with:
name: version
- uses: actions/download-artifact@v2
with:
name: tag
- name: Set env
run: |
cat version.txt >> $env:GITHUB_ENV
cat tag.txt >> $env:GITHUB_ENV
- uses: actions/download-artifact@v2
with:
name: lifecycle-windows-x86-64
path: pack
- name: Run pack acceptance
run: |
cd pack
git checkout $(git describe --abbrev=0 --tags) # check out the latest tag
$env:LIFECYCLE_PATH="..\lifecycle-v${{ env.LIFECYCLE_VERSION }}+windows.x86-64.tgz"
$env:LIFECYCLE_IMAGE="buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}"
make acceptance

View File

@ -0,0 +1,127 @@
name: check-latest-release
on:
schedule:
- cron: 0 2 * * 1,4
workflow_dispatch: {}
jobs:
check-release:
runs-on:
- ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: 'go.mod'
- name: Get previous release tag
id: get-previous-release-tag
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
script: |
return github.rest.repos.getLatestRelease({
owner: "buildpacks",
repo: "lifecycle",
}).then(result => {
return result.data.tag_name
})
- name: Read go and release versions
id: read-versions
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
#!/usr/bin/env bash
set -euo pipefail
LATEST_GO_VERSION=$(go version | cut -d ' ' -f 3)
LATEST_RELEASE_VERSION=${{ steps.get-previous-release-tag.outputs.result }}
wget https://github.com/buildpacks/lifecycle/releases/download/$LATEST_RELEASE_VERSION/lifecycle-$LATEST_RELEASE_VERSION+linux.x86-64.tgz -O lifecycle.tgz
tar xzf lifecycle.tgz
LATEST_RELEASE_GO_VERSION=$(go version ./lifecycle/lifecycle | cut -d ' ' -f 2)
echo "latest-go-version=${LATEST_GO_VERSION}" >> "$GITHUB_OUTPUT"
echo "latest-release-go-version=${LATEST_RELEASE_GO_VERSION}" >> "$GITHUB_OUTPUT"
LATEST_RELEASE_VERSION=$(echo $LATEST_RELEASE_VERSION | cut -d \v -f 2)
echo "latest-release-version=${LATEST_RELEASE_VERSION}" >> "$GITHUB_OUTPUT"
- name: Create issue if needed
if: ${{ steps.read-versions.outputs.latest-go-version != steps.read-versions.outputs.latest-release-go-version }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
#!/usr/bin/env bash
set -euo pipefail
title="Upgrade lifecycle to ${{ steps.read-versions.outputs.latest-go-version }}"
label=${{ steps.read-versions.outputs.latest-go-version }}
# Create label to use for exact search
gh label create "$label" || true
search_output=$(gh issue list --search "$title" --label "$label")
body="Latest lifecycle release v${{ steps.read-versions.outputs.latest-release-version }} is built with Go version ${{ steps.read-versions.outputs.latest-release-go-version }}; newer version ${{ steps.read-versions.outputs.latest-go-version }} is available."
if [ -z "${search_output// }" ]
then
echo "No issues matched search; creating new issue..."
gh issue create \
--label "type/bug" \
--label "status/triage" \
--label "$label" \
--title "$title" \
--body "$body"
else
echo "Found matching issues:"
echo $search_output
fi
- name: Scan latest release image
id: scan-image
uses: anchore/scan-action@v6
with:
image: buildpacksio/lifecycle:${{ steps.read-versions.outputs.latest-release-version }}
fail-build: true
severity-cutoff: medium
output-format: json
- name: Create issue if needed
if: failure() && steps.scan-image.outcome == 'failure'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
#!/usr/bin/env bash
set -euo pipefail
title="CVE(s) found in v${{ steps.read-versions.outputs.latest-release-version }}"
label=cve
# Create label to use for exact search
gh label create "$label" || true
search_output=$(gh issue list --search "$title" --label "$label")
GITHUB_WORKFLOW_URL=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
body="Latest lifecycle release v${{ steps.read-versions.outputs.latest-release-version }} triggered CVE(s) from Grype. For further details, see: $GITHUB_WORKFLOW_URL json: $(cat ${{ steps.scan-image.outputs.json }} | jq '.matches[] | .vulnerability | {id, severity, description}' )"
if [ -z "${search_output// }" ]
then
echo "No issues matched search; creating new issue..."
gh issue create \
--label "type/bug" \
--label "status/triage" \
--label "$label" \
--title "$title" \
--body "$body"
else
echo "Found matching issues:"
echo $search_output
fi

View File

@ -6,8 +6,10 @@ on:
jobs:
draft-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install jq
run: |
mkdir -p deps/bin
@ -22,9 +24,10 @@ jobs:
exit 1
fi
echo "LIFECYCLE_VERSION=$version" >> $GITHUB_ENV
- name: Determine download urls for linux-x86-64, linux-arm64 and windows
- name: Determine download urls for linux-x86-64, linux-arm64, linux-ppc64le, linux-s390x
id: artifact-urls
uses: actions/github-script@v3.0.0
# FIXME: this script should be updated to work with actions/github-script@v6
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
@ -80,7 +83,10 @@ jobs:
throw "no artifacts found"
}
if (urlList.length != 10) {
throw "there should be exactly ten artifacts"
// found too many artifacts
// list them and throw
console.log(urlList);
throw "there should be exactly 10 artifacts, found " + urlList.length + " artifacts"
}
return urlList.join(",")
})
@ -104,34 +110,80 @@ jobs:
cat *.sha256 | sort > lifecycle-v${{ env.LIFECYCLE_VERSION }}-checksums.txt
rm *.sha256
- name: Set pre-release kind
if: contains(env.LIFECYCLE_VERSION, 'rc') # e.g., 0.99.0-rc.1
if: "contains(env.LIFECYCLE_VERSION, 'rc') || contains(env.LIFECYCLE_VERSION, 'pre')" # e.g., 0.99.0-rc.1
run: |
echo "RELEASE_KIND=pre-release" >> $GITHUB_ENV
- name: Set release kind
if: "!contains(env.LIFECYCLE_VERSION, 'rc')"
if: "!contains(env.LIFECYCLE_VERSION, 'rc') && !contains(env.LIFECYCLE_VERSION, 'pre')"
run: |
echo "RELEASE_KIND=release" >> $GITHUB_ENV
- name: Get previous release tag
id: get-previous-release-tag
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
script: |
return github.rest.repos.getLatestRelease({
owner: "buildpacks",
repo: "lifecycle",
}).then(result => {
return result.data.tag_name
})
- name: Setup go
uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: 'go.mod'
- name: Get go version
id: get-go-version
run: |
mkdir tmp
tar xzvf ${{ env.ARTIFACTS_PATH }}/lifecycle-v${{ env.LIFECYCLE_VERSION }}+linux.x86-64.tgz -C tmp/
echo "GO_VERSION=$(go version tmp/lifecycle/lifecycle | cut -d ' ' -f 2 | sed -e 's/^go//')" >> $GITHUB_ENV
- name: Set release body text
run: |
cat << EOF > body.txt
# lifecycle v${{ env.LIFECYCLE_VERSION }}
Welcome to v${{ env.LIFECYCLE_VERSION }}, a **beta** ${{ env.RELEASE_KIND }} of the Cloud Native Buildpacks Lifecycle.
Welcome to v${{ env.LIFECYCLE_VERSION }}, a ${{ env.RELEASE_KIND }} of the Cloud Native Buildpacks Lifecycle.
## Prerequisites
The lifecycle runs as a normal user in a series of unprivileged containers. To export images and cache image layers, it requires access to a Docker daemon **or** Docker registry.
The lifecycle runs as a normal user in a series of unprivileged containers. To export images and cache image layers, it requires access to a Docker (compatible) daemon **or** an OCI registry.
## Install
Extract the .tgz file and copy the lifecycle binaries into a [build stack base image](https://github.com/buildpack/spec/blob/master/platform.md#stacks). The build image can then be orchestrated by a platform implementation such as the [pack CLI](https://github.com/buildpack/pack) or [tekton](https://github.com/tektoncd/catalog/blob/master/task/buildpacks/0.1/README.md).
Extract the .tgz file and copy the lifecycle binaries into a [build image](https://github.com/buildpacks/spec/blob/main/platform.md#build-image). The build image can then be orchestrated by a platform implementation such as the [pack CLI](https://github.com/buildpack/pack) or [tekton](https://github.com/tektoncd/catalog/tree/main/task/buildpacks).
## Lifecycle Image
An OCI image containing the lifecycle binaries is available at buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}.
## Features
* TODO
* Updates go to version ${{ env.GO_VERSION }}
## Bugfixes
* TODO
## Chores
* TODO
**Full Changelog**: https://github.com/buildpacks/lifecycle/compare/${{ steps.get-previous-release-tag.outputs.result }}...release/${{ env.LIFECYCLE_VERSION }}
## Contributors
We'd like to acknowledge that this release wouldn't be as good without the help of the following amazing contributors:
TODO
EOF
- name: Create Pre Release
if: contains(env.LIFECYCLE_VERSION, 'rc') # e.g., 0.99.0-rc.1
- name: Create pre-release
if: "contains(env.LIFECYCLE_VERSION, 'rc') || contains(env.LIFECYCLE_VERSION, 'pre')" # e.g., 0.99.0-rc.1
run: |
cd ${{ env.ARTIFACTS_PATH }}
gh release create v${{ env.LIFECYCLE_VERSION }} \
@ -139,19 +191,19 @@ jobs:
--draft \
--notes-file ../body.txt \
--prerelease \
--target $GITHUB_REF \
--target $GITHUB_REF_NAME \
--title "lifecycle v${{ env.LIFECYCLE_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
if: "!contains(env.LIFECYCLE_VERSION, 'rc')"
- name: Create release
if: "!contains(env.LIFECYCLE_VERSION, 'rc') && !contains(env.LIFECYCLE_VERSION, 'pre')"
run: |
cd ${{ env.ARTIFACTS_PATH }}
gh release create v${{ env.LIFECYCLE_VERSION }} \
$(ls | sort | paste -sd " " -) \
--draft \
--notes-file ../body.txt \
--target $GITHUB_REF \
--target $GITHUB_REF_NAME \
--title "lifecycle v${{ env.LIFECYCLE_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -8,20 +8,21 @@ on:
jobs:
retag-lifecycle-images:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- name: Set up go
uses: actions/setup-go@v2
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.16'
check-latest: true
go-version-file: 'go.mod'
- name: Install crane
run: |
go install github.com/google/go-containerregistry/cmd/crane@latest
- name: Install cosign
uses: sigstore/cosign-installer@main
with:
cosign-release: 'v1.2.0'
- uses: azure/docker-login@v1
uses: sigstore/cosign-installer@v3
- uses: azure/docker-login@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
@ -31,17 +32,22 @@ jobs:
echo "LIFECYCLE_IMAGE_TAG=$(git describe --always --abbrev=7)" >> $GITHUB_ENV
- name: Verify lifecycle images
run: |
LINUX_AMD64_SHA=$(cosign verify -key cosign.pub buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-x86-64 | jq -r .[0].critical.image.\"docker-manifest-digest\")
LINUX_AMD64_SHA=$(cosign verify --certificate-identity-regexp "https://github.com/${{ github.repository_owner }}/lifecycle/.github/workflows/build.yml" --certificate-oidc-issuer https://token.actions.githubusercontent.com buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-x86-64 | jq -r .[0].critical.image.\"docker-manifest-digest\")
echo "LINUX_AMD64_SHA: $LINUX_AMD64_SHA"
echo "LINUX_AMD64_SHA=$LINUX_AMD64_SHA" >> $GITHUB_ENV
LINUX_ARM64_SHA=$(cosign verify -key cosign.pub buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-arm64 | jq -r .[0].critical.image.\"docker-manifest-digest\")
LINUX_ARM64_SHA=$(cosign verify --certificate-identity-regexp "https://github.com/${{ github.repository_owner }}/lifecycle/.github/workflows/build.yml" --certificate-oidc-issuer https://token.actions.githubusercontent.com buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-arm64 | jq -r .[0].critical.image.\"docker-manifest-digest\")
echo "LINUX_ARM64_SHA: $LINUX_ARM64_SHA"
echo "LINUX_ARM64_SHA=$LINUX_ARM64_SHA" >> $GITHUB_ENV
WINDOWS_AMD64_SHA=$(cosign verify -key cosign.pub buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-windows | jq -r .[0].critical.image.\"docker-manifest-digest\")
echo "WINDOWS_AMD64_SHA: $WINDOWS_AMD64_SHA"
echo "WINDOWS_AMD64_SHA=$WINDOWS_AMD64_SHA" >> $GITHUB_ENV
LINUX_PPC64LE_SHA=$(cosign verify --certificate-identity-regexp "https://github.com/${{ github.repository_owner }}/lifecycle/.github/workflows/build.yml" --certificate-oidc-issuer https://token.actions.githubusercontent.com buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-ppc64le | jq -r .[0].critical.image.\"docker-manifest-digest\")
echo "LINUX_PPC64LE_SHA: $LINUX_PPC64LE_SHA"
echo "LINUX_PPC64LE_SHA=$LINUX_PPC64LE_SHA" >> $GITHUB_ENV
LINUX_S390X_SHA=$(cosign verify --certificate-identity-regexp "https://github.com/${{ github.repository_owner }}/lifecycle/.github/workflows/build.yml" --certificate-oidc-issuer https://token.actions.githubusercontent.com buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-s390x | jq -r .[0].critical.image.\"docker-manifest-digest\")
echo "LINUX_S390X_SHA: $LINUX_S390X_SHA"
echo "LINUX_S390X_SHA=$LINUX_S390X_SHA" >> $GITHUB_ENV
- name: Download SBOM
run: |
gh release download --pattern '*-bom.cdx.json' ${{ github.event.release.tag_name }}
@ -53,54 +59,70 @@ jobs:
crane tag buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-x86-64@${{ env.LINUX_AMD64_SHA }} ${{ env.LIFECYCLE_VERSION }}-linux-x86-64
crane tag buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-arm64@${{ env.LINUX_ARM64_SHA }} ${{ env.LIFECYCLE_VERSION }}-linux-arm64
crane tag buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-windows@${{ env.WINDOWS_AMD64_SHA }} ${{ env.LIFECYCLE_VERSION }}-windows
crane tag buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-ppc64le@${{ env.LINUX_PPC64LE_SHA }} ${{ env.LIFECYCLE_VERSION }}-linux-ppc64le
crane tag buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-s390x@${{ env.LINUX_S390X_SHA }} ${{ env.LIFECYCLE_VERSION }}-linux-s390x
docker manifest create buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }} \
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}-linux-x86-64@${{ env.LINUX_AMD64_SHA }} \
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}-linux-arm64@${{ env.LINUX_ARM64_SHA }} \
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}-windows@${{ env.WINDOWS_AMD64_SHA }}
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}-linux-ppc64le@${{ env.LINUX_PPC64LE_SHA }} \
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}-linux-s390x@${{ env.LINUX_S390X_SHA }}
MANIFEST_SHA=$(docker manifest push buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }})
echo "MANIFEST_SHA: $MANIFEST_SHA"
COSIGN_PASSWORD=${{ secrets.COSIGN_PASSWORD }} cosign sign -r \
-key <(echo -n "${{ secrets.COSIGN_PRIVATE_KEY }}" | base64 --decode) \
cosign sign -r -y \
-a tag=${{ env.LIFECYCLE_VERSION }} \
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}@${MANIFEST_SHA}
cosign verify -key cosign.pub -a tag=${{ env.LIFECYCLE_VERSION }} buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}
cosign verify \
--certificate-identity-regexp "https://github.com/${{ github.repository_owner }}/lifecycle/.github/workflows/post-release.yml" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
-a tag=${{ env.LIFECYCLE_VERSION }} \
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}
cosign attach sbom -sbom ./*-bom.cdx.json -type cyclonedx buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}
COSIGN_PASSWORD=${{ secrets.COSIGN_PASSWORD }} cosign sign -r \
-key <(echo -n "${{ secrets.COSIGN_PRIVATE_KEY }}" | base64 --decode) \
-a tag=${{ env.LIFECYCLE_VERSION }} -attachment sbom \
cosign attach sbom --sbom ./*-bom.cdx.json --type cyclonedx buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}
cosign sign -r -y \
-a tag=${{ env.LIFECYCLE_VERSION }} --attachment sbom \
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}@${MANIFEST_SHA}
cosign verify -key cosign.pub -a tag=${{ env.LIFECYCLE_VERSION }} -attachment sbom buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}@${MANIFEST_SHA}
cosign verify \
--certificate-identity-regexp "https://github.com/${{ github.repository_owner }}/lifecycle/.github/workflows/post-release.yml" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
-a tag=${{ env.LIFECYCLE_VERSION }} --attachment sbom \
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}
- name: Retag lifecycle images & create manifest list - latest
if: "!contains(env.LIFECYCLE_VERSION, 'rc')"
if: "!contains(env.LIFECYCLE_VERSION, 'rc') && !contains(env.LIFECYCLE_VERSION, 'pre')"
run: |
DOCKER_CLI_EXPERIMENTAL=enabled
crane tag buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-x86-64@${{ env.LINUX_AMD64_SHA }} latest-linux-x86-64
crane tag buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-arm64@${{ env.LINUX_ARM64_SHA }} latest-linux-arm64
crane tag buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-windows@${{ env.WINDOWS_AMD64_SHA }} latest-windows
crane tag buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-ppc64le@${{ env.LINUX_PPC64LE_SHA }} latest-linux-ppc64le
crane tag buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}-linux-s390x@${{ env.LINUX_S390X_SHA }} latest-linux-s390x
docker manifest create buildpacksio/lifecycle:latest \
buildpacksio/lifecycle:latest-linux-x86-64@${{ env.LINUX_AMD64_SHA }} \
buildpacksio/lifecycle:latest-linux-arm64@${{ env.LINUX_ARM64_SHA }} \
buildpacksio/lifecycle:latest-windows@${{ env.WINDOWS_AMD64_SHA }}
buildpacksio/lifecycle:latest-linux-ppc64le@${{ env.LINUX_PPC64LE_SHA }} \
buildpacksio/lifecycle:latest-linux-s390x@${{ env.LINUX_S390X_SHA }}
MANIFEST_SHA=$(docker manifest push buildpacksio/lifecycle:latest)
echo "MANIFEST_SHA: $MANIFEST_SHA"
COSIGN_PASSWORD=${{ secrets.COSIGN_PASSWORD }} cosign sign -r \
-key <(echo -n "${{ secrets.COSIGN_PRIVATE_KEY }}" | base64 --decode) \
cosign sign -r -y \
-a tag=latest \
buildpacksio/lifecycle:latest@${MANIFEST_SHA}
cosign verify -key cosign.pub -a tag=latest buildpacksio/lifecycle:latest
cosign verify \
--certificate-identity-regexp "https://github.com/${{ github.repository_owner }}/lifecycle/.github/workflows/post-release.yml" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
-a tag=latest \
buildpacksio/lifecycle:latest
cosign attach sbom -sbom ./*-bom.cdx.json -type cyclonedx buildpacksio/lifecycle:latest
COSIGN_PASSWORD=${{ secrets.COSIGN_PASSWORD }} cosign sign -r \
-key <(echo -n "${{ secrets.COSIGN_PRIVATE_KEY }}" | base64 --decode) \
-a tag=${{ env.LIFECYCLE_VERSION }} -attachment sbom \
cosign attach sbom --sbom ./*-bom.cdx.json --type cyclonedx buildpacksio/lifecycle:latest
cosign sign -r -y \
-a tag=${{ env.LIFECYCLE_VERSION }} --attachment sbom \
buildpacksio/lifecycle:latest@${MANIFEST_SHA}
cosign verify -key cosign.pub -a tag=${{ env.LIFECYCLE_VERSION }} -attachment sbom buildpacksio/lifecycle:latest@${MANIFEST_SHA}
cosign verify \
--certificate-identity-regexp "https://github.com/${{ github.repository_owner }}/lifecycle/.github/workflows/post-release.yml" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
-a tag=${{ env.LIFECYCLE_VERSION }} --attachment sbom \
buildpacksio/lifecycle:latest

87
.github/workflows/test-s390x.yml vendored Normal file
View File

@ -0,0 +1,87 @@
name: test-s390x
on:
push:
branches:
- main
- 'release/**'
pull_request:
branches:
- main
- 'release/**'
jobs:
test-linux-s390x:
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release*')
runs-on: ubuntu-latest
env:
ZVSI_FP_NAME: bp-floating-ci-${{ github.run_id }}
ZVSI_INSTANCE_NAME: bp-zvsi-ci-${{ github.run_id }}
ZVSI_ZONE_NAME: ca-tor-1
ZVSI_PROFILE_NAME: bz2-4x16
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: install ibmcli and setup ibm login
run: |
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud login -q --apikey ${{ secrets.IBMCLOUD_API_KEY }} -r ca-tor
ibmcloud plugin install vpc-infrastructure
- name: Creation of ZVSI
id: ZVSI
run: |
#creation of zvsi
ibmcloud is instance-create $ZVSI_INSTANCE_NAME ${{ secrets.ZVSI_VPC }} $ZVSI_ZONE_NAME $ZVSI_PROFILE_NAME ${{ secrets.ZVSI_SUBNET }} --image ${{ secrets.ZVSI_IMAGE }} --keys ${{ secrets.ZVSI_KEY }} --resource-group-id ${{ secrets.ZVSI_RG_ID }} --primary-network-interface "{\"name\":\"eth0\",\"allow_ip_spoofing\":false,\"subnet\": {\"name\":\"${{ secrets.ZVSI_SUBNET }}\"},\"security_groups\":[{\"id\":\"${{ secrets.ZVSI_SG }}\"}]}"
#Reserving a floating ip to the ZVSI
ibmcloud is floating-ip-reserve $ZVSI_FP_NAME --zone $ZVSI_ZONE_NAME --resource-group-id ${{ secrets.ZVSI_RG_ID }} --in $ZVSI_INSTANCE_NAME
#Bouding the Floating ip to the ZVSI
ibmcloud is floating-ip-update $ZVSI_FP_NAME --nic eth0 --in $ZVSI_INSTANCE_NAME
sleep 60
#Saving the Floating IP to login ZVSI
ZVSI_HOST=$(ibmcloud is floating-ip $ZVSI_FP_NAME | awk '/Address/{print $2}')
echo $ZVSI_HOST
echo "IP=${ZVSI_HOST}" >> $GITHUB_OUTPUT
- name: Status of ZVSI
run: |
check=$(ibmcloud is ins| awk '/'$ZVSI_INSTANCE_NAME'/{print $3}')
while [[ $check != "running" ]]
do
check=$(ibmcloud is ins | awk '/'$ZVSI_INSTANCE_NAME'/{print $3}')
if [[ $check == 'failed' ]]
then
echo "Failed to run the ZVSI"
break
fi
done
- name: Install dependencies and run all tests on s390x ZVSI
uses: appleboy/ssh-action@v1.2.2
env:
GH_REPOSITORY: ${{ github.server_url }}/${{ github.repository }}
GH_REF: ${{ github.ref }}
with:
host: ${{ steps.ZVSI.outputs.IP }}
username: ${{ secrets.ZVSI_SSH_USER }}
key: ${{ secrets.ZVSI_PR_KEY }}
envs: GH_REPOSITORY,GH_REF
command_timeout: 100m
script: |
apt-get update -y
apt-get install -y wget curl git make gcc jq docker.io
wget https://go.dev/dl/go1.24.6.linux-s390x.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.6.linux-s390x.tar.gz
export PATH=$PATH:/usr/local/go/bin
git clone ${GH_REPOSITORY} lifecycle
cd lifecycle && git checkout ${GH_REF}
go env
export PATH=$PATH:~/go/bin
make format || true
make test
- name: Cleanup ZVSI
if: ${{ steps.ZVSI.conclusion == 'success' && always() }}
run: |
#Delete the created ZVSI
ibmcloud is instance-delete $ZVSI_INSTANCE_NAME --force
sleep 20
#Release the created FP
ibmcloud is floating-ip-release $ZVSI_FP_NAME --force

7
.gitignore vendored
View File

@ -3,8 +3,15 @@
*.coverprofile
*.test
*~
.tool-versions
/out
.vscode
acceptance/testdata/*/**/container/cnb/lifecycle/*
acceptance/testdata/*/**/container/docker-config/*
acceptance/testdata/exporter/container/cnb/run.toml
acceptance/testdata/exporter/container/layers/*analyzed.toml
acceptance/testdata/exporter/container/other_layers/*analyzed.toml
acceptance/testdata/restorer/container/layers/*analyzed.toml

5
.grype.yaml Normal file
View File

@ -0,0 +1,5 @@
ignore:
- vulnerability: CVE-2015-5237 # false positive, see https://github.com/anchore/grype/issues/558
- vulnerability: CVE-2021-22570 # false positive, see https://github.com/anchore/grype/issues/558
- vulnerability: CVE-2024-41110 # non-impactful as we only use docker as a client
- vulnerability: GHSA-v23v-6jw2-98fq # non-impactful as we only use docker as a client

View File

@ -11,12 +11,17 @@
* macOS: `brew install go`
* Windows: `choco install golang -y`
* [Docker](https://www.docker.com/products/docker-desktop)
* [jq](https://stedolan.github.io/jq/) and [yj](https://github.com/sclevine/yj) utilities
* macOS: `brew install jq yj`
* Windows:
* `choco insall jq -y`
* `go get github.com/sclevine/yj`
* Make (and build tools)
* macOS: `xcode-select --install`
* Windows:
* `choco install cygwin make -y`
* `[Environment]::SetEnvironmentVariable("PATH", "C:\tools\cygwin\bin;$ENV:PATH", "MACHINE")`
### Caveats
* The acceptance tests require the docker daemon to be able to communicate with a local containerized insecure registry. On Docker Desktop 3.3.x, this may result in failures such as: `Expected nil: push response: : Get http://localhost:<port>/v2/: dial tcp [::1]:<port>: connect: connection refused`. To fix these failures, it may be necessary to add the following to the Docker Desktop Engine config:
@ -31,20 +36,18 @@
The lifecycle release process involves chaining a series of GitHub actions together such that:
* The "build" workflow creates the artifacts
* .tgz files containing the lifecycle binaries, shasums for the .tgz files, a cosign public key, an SBOM, etc.
* .tgz files containing the lifecycle binaries, shasums for the .tgz files, an SBOM, etc.
* OCI images containing the lifecycle binaries, tagged with their commit sha (for more information, see RELEASE.md)
* The "draft-release" workflow finds the artifacts and downloads them, creating the draft release
* The "post-release" workflow re-tags the OCI images that were created during the "build" workflow with the release version
It can be rather cumbersome to test changes to these workflows, as they are heavily intertwined. Thus we recommend forking the buildpacks/lifecycle repository in GitHub and running through the entire release process end-to-end.
For the fork, it is necessary to add the following secrets:
* COSIGN_PASSWORD (see [cosign](https://github.com/sigstore/cosign#generate-a-keypair))
* COSIGN_PRIVATE_KEY
* DOCKER_PASSWORD (if not using ghcr.io)
* DOCKER_USERNAME (if not using ghcr.io)
The tools/test-fork.sh script can be used to update the source code to reflect the state of the fork.
It can be invoked like so: `./tools/test-fork.sh <registry repo name> <path to cosign public key>`
The tools/test-fork.sh script can be used to update the source code to reflect the state of the fork.
It can be invoked like so: `./tools/test-fork.sh <registry repo name>`
## Tasks
@ -72,6 +75,16 @@ Formats, vets, and tests the code.
$ make test
```
#### Mocks
We use mock generators like most golang projects to help with our testing. To make new mocks:
```bash
$ make generate
$ make format lint
```
This is because the mock generator will make a larger diff that the formatter will fix.
### Build
Builds binaries to `out/linux/lifecycle/` and `out/windows/lifecycle/`.

View File

@ -7,23 +7,28 @@ This image is maintained by the [Cloud Native Buildpacks project](https://buildp
Supported tags are semver-versioned manifest lists - e.g., `0.12.0` or `0.12.0-rc.1`, pointing to one of the following os/architectures:
* `linux/amd64`
* `linux/arm64`
* `windows/amd64`
# About this image
Images are built in [GitHub actions](https://github.com/buildpacks/lifecycle/actions) and signed with [`cosign`](https://github.com/sigstore/cosign). To verify:
* Locate the public key `lifecycle-v<tag>-cosign.pub` on the [releases page](https://github.com/buildpacks/lifecycle/releases)
* Run:
```
cosign verify -key lifecycle-v<tag>-cosign.pub buildpacksio/lifecycle:<tag>
cosign version # must be at least 2.0.0
cosign verify \
--certificate-identity-regexp "https://github.com/buildpacks/lifecycle/.github/workflows/post-release.yml" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
buildpacksio/lifecycle:<tag>
```
A CycloneDX SBOM is "attached" to the image and signed with [`cosign`](https://github.com/sigstore/cosign). To verify:
* Locate the public key `lifecycle-v<tag>-cosign.pub` on the [releases page](https://github.com/buildpacks/lifecycle/releases)
* Run:
```
cosign version # must be at least 1.2.0
cosign verify -key cosign.pub -a tag=<tag> -attachment sbom buildpacksio/lifecycle:<tag>
cosign version # must be at least 2.0.0
cosign verify \
--certificate-identity-regexp "https://github.com/buildpacks/lifecycle/.github/workflows/post-release.yml" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
-a tag=<tag> -attachment sbom \
buildpacksio/lifecycle:<tag>
cosign download sbom buildpacksio/lifecycle:<tag>
```
@ -36,4 +41,4 @@ With [tekton](https://github.com/tektoncd/catalog/tree/main/task/buildpacks-phas
* Provide as param `LIFECYCLE_IMAGE` in taskrun
***
[Source](https://github.com/buildpacks/lifecycle/blob/main/IMAGE.md) for this page
[Source](https://github.com/buildpacks/lifecycle/blob/main/IMAGE.md) for this page

273
Makefile
View File

@ -30,8 +30,6 @@ LDFLAGS+=-X 'github.com/buildpacks/lifecycle/cmd.Version=$(LIFECYCLE_VERSION)'
GOBUILD:=go build $(GOFLAGS) -ldflags "$(LDFLAGS)"
GOTEST=$(GOCMD) test $(GOFLAGS)
BUILD_DIR?=$(PWD)$/out
LINUX_COMPILATION_IMAGE?=golang:1.16-alpine
WINDOWS_COMPILATION_IMAGE?=golang:1.16-windowsservercore-1809
SOURCE_COMPILATION_IMAGE?=lifecycle-img
BUILD_CTR?=lifecycle-ctr
DOCKER_CMD?=make test
@ -40,11 +38,9 @@ GOFILES := $(shell $(GOCMD) run tools$/lister$/main.go)
all: test build package
build: build-linux-amd64 build-linux-arm64 build-windows-amd64
GOOS_ARCHS = linux/amd64 linux/arm64 linux/ppc64le linux/s390x darwin/amd64 darwin/arm64
build-linux-amd64: build-linux-amd64-lifecycle build-linux-amd64-symlinks build-linux-amd64-launcher
build-linux-arm64: build-linux-arm64-lifecycle build-linux-arm64-symlinks build-linux-arm64-launcher
build-windows-amd64: build-windows-amd64-lifecycle build-windows-amd64-symlinks build-windows-amd64-launcher
build: build-linux-amd64 build-linux-arm64 build-linux-ppc64le build-linux-s390x
build-image-linux-amd64: build-linux-amd64 package-linux-amd64
build-image-linux-amd64: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+linux.x86-64.tgz
@ -56,177 +52,117 @@ build-image-linux-arm64: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSIO
build-image-linux-arm64:
$(GOCMD) run ./tools/image/main.go -daemon -lifecyclePath $(ARCHIVE_PATH) -os linux -arch arm64 -tag lifecycle:$(LIFECYCLE_IMAGE_TAG)
build-image-windows-amd64: build-windows-amd64 package-windows-amd64
build-image-windows-amd64: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+windows.x86-64.tgz
build-image-windows-amd64:
$(GOCMD) run ./tools/image/main.go -daemon -lifecyclePath $(ARCHIVE_PATH) -os windows -arch amd64 -tag lifecycle:$(LIFECYCLE_IMAGE_TAG)
build-image-linux-ppc64le: build-linux-ppc64le package-linux-ppc64le
build-image-linux-ppc64le: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+linux.ppc64le.tgz
build-image-linux-ppc64le:
$(GOCMD) run ./tools/image/main.go -daemon -lifecyclePath $(ARCHIVE_PATH) -os linux -arch ppc64le -tag lifecycle:$(LIFECYCLE_IMAGE_TAG)
build-linux-amd64-lifecycle: $(BUILD_DIR)/linux-amd64/lifecycle/lifecycle
build-image-linux-s390x: build-linux-s390x package-linux-s390x
build-image-linux-s390x: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+linux.s390x.tgz
build-image-linux-s390x:
$(GOCMD) run ./tools/image/main.go -daemon -lifecyclePath $(ARCHIVE_PATH) -os linux -arch s390x -tag lifecycle:$(LIFECYCLE_IMAGE_TAG)
build-linux-arm64-lifecycle: $(BUILD_DIR)/linux-arm64/lifecycle/lifecycle
define build_targets
build-$(1)-$(2): build-$(1)-$(2)-lifecycle build-$(1)-$(2)-symlinks build-$(1)-$(2)-launcher
$(BUILD_DIR)/linux-amd64/lifecycle/lifecycle: export GOOS:=linux
$(BUILD_DIR)/linux-amd64/lifecycle/lifecycle: export GOARCH:=amd64
$(BUILD_DIR)/linux-amd64/lifecycle/lifecycle: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
$(BUILD_DIR)/linux-amd64/lifecycle/lifecycle: $(GOFILES)
$(BUILD_DIR)/linux-amd64/lifecycle/lifecycle:
@echo "> Building lifecycle/lifecycle for $(GOOS)/$(GOARCH)..."
mkdir -p $(OUT_DIR)
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/lifecycle -a ./cmd/lifecycle
build-$(1)-$(2)-lifecycle: $(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle
$(BUILD_DIR)/linux-arm64/lifecycle/lifecycle: export GOOS:=linux
$(BUILD_DIR)/linux-arm64/lifecycle/lifecycle: export GOARCH:=arm64
$(BUILD_DIR)/linux-arm64/lifecycle/lifecycle: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
$(BUILD_DIR)/linux-arm64/lifecycle/lifecycle: $(GOFILES)
$(BUILD_DIR)/linux-arm64/lifecycle/lifecycle:
@echo "> Building lifecycle/lifecycle for $(GOOS)/$(GOARCH)..."
mkdir -p $(OUT_DIR)
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/lifecycle -a ./cmd/lifecycle
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle: export GOOS:=$(1)
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle: export GOARCH:=$(2)
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle: OUT_DIR?=$$(BUILD_DIR)/$$(GOOS)-$$(GOARCH)/lifecycle
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle: $$(GOFILES)
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle:
@echo "> Building lifecycle/lifecycle for $$(GOOS)/$$(GOARCH)..."
mkdir -p $$(OUT_DIR)
$$(GOENV) $$(GOBUILD) -o $$(OUT_DIR)/lifecycle -a ./cmd/lifecycle
build-linux-amd64-launcher: $(BUILD_DIR)/linux-amd64/lifecycle/launcher
build-$(1)-$(2)-symlinks: export GOOS:=$(1)
build-$(1)-$(2)-symlinks: export GOARCH:=$(2)
build-$(1)-$(2)-symlinks: OUT_DIR?=$$(BUILD_DIR)/$$(GOOS)-$$(GOARCH)/lifecycle
build-$(1)-$(2)-symlinks:
@echo "> Creating phase symlinks for $$(GOOS)/$$(GOARCH)..."
ln -sf lifecycle $$(OUT_DIR)/detector
ln -sf lifecycle $$(OUT_DIR)/analyzer
ln -sf lifecycle $$(OUT_DIR)/restorer
ln -sf lifecycle $$(OUT_DIR)/builder
ln -sf lifecycle $$(OUT_DIR)/exporter
ln -sf lifecycle $$(OUT_DIR)/rebaser
ln -sf lifecycle $$(OUT_DIR)/creator
ln -sf lifecycle $$(OUT_DIR)/extender
$(BUILD_DIR)/linux-amd64/lifecycle/launcher: export GOOS:=linux
$(BUILD_DIR)/linux-amd64/lifecycle/launcher: export GOARCH:=amd64
$(BUILD_DIR)/linux-amd64/lifecycle/launcher: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
$(BUILD_DIR)/linux-amd64/lifecycle/launcher: $(GOFILES)
$(BUILD_DIR)/linux-amd64/lifecycle/launcher:
@echo "> Building lifecycle/launcher for $(GOOS)/$(GOARCH)..."
mkdir -p $(OUT_DIR)
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/launcher -a ./cmd/launcher
test $$(du -m $(OUT_DIR)/launcher|cut -f 1) -le 3
build-$(1)-$(2)-launcher: $$(BUILD_DIR)/$(1)-$(2)/lifecycle/launcher
build-linux-arm64-launcher: $(BUILD_DIR)/linux-arm64/lifecycle/launcher
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/launcher: export GOOS:=$(1)
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/launcher: export GOARCH:=$(2)
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/launcher: OUT_DIR?=$$(BUILD_DIR)/$$(GOOS)-$$(GOARCH)/lifecycle
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/launcher: $$(GOFILES)
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/launcher:
@echo "> Building lifecycle/launcher for $$(GOOS)/$$(GOARCH)..."
mkdir -p $$(OUT_DIR)
$$(GOENV) $$(GOBUILD) -o $$(OUT_DIR)/launcher -a ./cmd/launcher
test $$$$(du -m $$(OUT_DIR)/launcher|cut -f 1) -le 3
endef
$(BUILD_DIR)/linux-arm64/lifecycle/launcher: export GOOS:=linux
$(BUILD_DIR)/linux-arm64/lifecycle/launcher: export GOARCH:=arm64
$(BUILD_DIR)/linux-arm64/lifecycle/launcher: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
$(BUILD_DIR)/linux-arm64/lifecycle/launcher: $(GOFILES)
$(BUILD_DIR)/linux-arm64/lifecycle/launcher:
@echo "> Building lifecycle/launcher for $(GOOS)/$(GOARCH)..."
mkdir -p $(OUT_DIR)
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/launcher -a ./cmd/launcher
test $$(du -m $(OUT_DIR)/launcher|cut -f 1) -le 3
$(foreach ga,$(GOOS_ARCHS),$(eval $(call build_targets,$(word 1, $(subst /, ,$(ga))),$(word 2, $(subst /, ,$(ga))))))
build-linux-amd64-symlinks: export GOOS:=linux
build-linux-amd64-symlinks: export GOARCH:=amd64
build-linux-amd64-symlinks: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
build-linux-amd64-symlinks:
@echo "> Creating phase symlinks for $(GOOS)/$(GOARCH)..."
ln -sf lifecycle $(OUT_DIR)/detector
ln -sf lifecycle $(OUT_DIR)/analyzer
ln -sf lifecycle $(OUT_DIR)/restorer
ln -sf lifecycle $(OUT_DIR)/builder
ln -sf lifecycle $(OUT_DIR)/exporter
ln -sf lifecycle $(OUT_DIR)/rebaser
ln -sf lifecycle $(OUT_DIR)/creator
generate-sbom: run-syft-linux-amd64 run-syft-linux-arm64 run-syft-linux-ppc64le run-syft-linux-s390x
build-linux-arm64-symlinks: export GOOS:=linux
build-linux-arm64-symlinks: export GOARCH:=arm64
build-linux-arm64-symlinks: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
build-linux-arm64-symlinks:
@echo "> Creating phase symlinks for $(GOOS)/$(GOARCH)..."
ln -sf lifecycle $(OUT_DIR)/detector
ln -sf lifecycle $(OUT_DIR)/analyzer
ln -sf lifecycle $(OUT_DIR)/restorer
ln -sf lifecycle $(OUT_DIR)/builder
ln -sf lifecycle $(OUT_DIR)/exporter
ln -sf lifecycle $(OUT_DIR)/rebaser
ln -sf lifecycle $(OUT_DIR)/creator
run-syft-linux-amd64: install-syft
run-syft-linux-amd64: export GOOS:=linux
run-syft-linux-amd64: export GOARCH:=amd64
run-syft-linux-amd64:
@echo "> Running syft..."
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.cdx.json
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.cdx.json
build-windows-amd64-lifecycle: $(BUILD_DIR)/windows-amd64/lifecycle/lifecycle.exe
run-syft-linux-arm64: install-syft
run-syft-linux-arm64: export GOOS:=linux
run-syft-linux-arm64: export GOARCH:=arm64
run-syft-linux-arm64:
@echo "> Running syft..."
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.cdx.json
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.cdx.json
$(BUILD_DIR)/windows-amd64/lifecycle/lifecycle.exe: export GOOS:=windows
$(BUILD_DIR)/windows-amd64/lifecycle/lifecycle.exe: export GOARCH:=amd64
$(BUILD_DIR)/windows-amd64/lifecycle/lifecycle.exe: OUT_DIR?=$(BUILD_DIR)$/$(GOOS)-$(GOARCH)$/lifecycle
$(BUILD_DIR)/windows-amd64/lifecycle/lifecycle.exe: $(GOFILES)
$(BUILD_DIR)/windows-amd64/lifecycle/lifecycle.exe:
@echo "> Building lifecycle/lifecycle for $(GOOS)/$(GOARCH)..."
$(GOBUILD) -o $(OUT_DIR)$/lifecycle.exe -a .$/cmd$/lifecycle
run-syft-linux-ppc64le: install-syft
run-syft-linux-ppc64le: export GOOS:=linux
run-syft-linux-ppc64le: export GOARCH:=ppc64le
run-syft-linux-ppc64le:
@echo "> Running syft..."
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.cdx.json
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.cdx.json
build-windows-amd64-launcher: $(BUILD_DIR)/windows-amd64/lifecycle/launcher.exe
run-syft-linux-s390x: install-syft
run-syft-linux-s390x: export GOOS:=linux
run-syft-linux-s390x: export GOARCH:=s390x
run-syft-linux-s390x:
@echo "> Running syft..."
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.cdx.json
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.cdx.json
$(BUILD_DIR)/windows-amd64/lifecycle/launcher.exe: export GOOS:=windows
$(BUILD_DIR)/windows-amd64/lifecycle/launcher.exe: export GOARCH:=amd64
$(BUILD_DIR)/windows-amd64/lifecycle/launcher.exe: OUT_DIR?=$(BUILD_DIR)$/$(GOOS)-$(GOARCH)$/lifecycle
$(BUILD_DIR)/windows-amd64/lifecycle/launcher.exe: $(GOFILES)
$(BUILD_DIR)/windows-amd64/lifecycle/launcher.exe:
@echo "> Building lifecycle/launcher for $(GOOS)/$(GOARCH)..."
$(GOBUILD) -o $(OUT_DIR)$/launcher.exe -a .$/cmd$/launcher
install-syft:
@echo "> Installing syft..."
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
build-windows-amd64-symlinks: export GOOS:=windows
build-windows-amd64-symlinks: export GOARCH:=amd64
build-windows-amd64-symlinks: OUT_DIR?=$(BUILD_DIR)$/$(GOOS)-$(GOARCH)$/lifecycle
build-windows-amd64-symlinks:
@echo "> Creating phase symlinks for Windows..."
ifeq ($(OS),Windows_NT)
call del $(OUT_DIR)$/detector.exe
call del $(OUT_DIR)$/analyzer.exe
call del $(OUT_DIR)$/restorer.exe
call del $(OUT_DIR)$/builder.exe
call del $(OUT_DIR)$/exporter.exe
call del $(OUT_DIR)$/rebaser.exe
call del $(OUT_DIR)$/creator.exe
call mklink $(OUT_DIR)$/detector.exe lifecycle.exe
call mklink $(OUT_DIR)$/analyzer.exe lifecycle.exe
call mklink $(OUT_DIR)$/restorer.exe lifecycle.exe
call mklink $(OUT_DIR)$/builder.exe lifecycle.exe
call mklink $(OUT_DIR)$/exporter.exe lifecycle.exe
call mklink $(OUT_DIR)$/rebaser.exe lifecycle.exe
call mklink $(OUT_DIR)$/creator.exe lifecycle.exe
else
ln -sf lifecycle.exe $(OUT_DIR)$/detector.exe
ln -sf lifecycle.exe $(OUT_DIR)$/analyzer.exe
ln -sf lifecycle.exe $(OUT_DIR)$/restorer.exe
ln -sf lifecycle.exe $(OUT_DIR)$/builder.exe
ln -sf lifecycle.exe $(OUT_DIR)$/exporter.exe
ln -sf lifecycle.exe $(OUT_DIR)$/rebaser.exe
ln -sf lifecycle.exe $(OUT_DIR)$/creator.exe
endif
build-darwin-amd64: build-darwin-amd64-lifecycle build-darwin-amd64-launcher
build-darwin-amd64-lifecycle: $(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle
$(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle: export GOOS:=darwin
$(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle: export GOARCH:=amd64
$(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle: OUT_DIR:=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
$(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle: $(GOFILES)
$(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle:
@echo "> Building lifecycle for darwin/amd64..."
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/lifecycle -a ./cmd/lifecycle
@echo "> Creating lifecycle symlinks for darwin/amd64..."
ln -sf lifecycle $(OUT_DIR)/detector
ln -sf lifecycle $(OUT_DIR)/analyzer
ln -sf lifecycle $(OUT_DIR)/restorer
ln -sf lifecycle $(OUT_DIR)/builder
ln -sf lifecycle $(OUT_DIR)/exporter
ln -sf lifecycle $(OUT_DIR)/rebaser
build-darwin-amd64-launcher: $(BUILD_DIR)/darwin-amd64/lifecycle/launcher
$(BUILD_DIR)/darwin-amd64/lifecycle/launcher: export GOOS:=darwin
$(BUILD_DIR)/darwin-amd64/lifecycle/launcher: export GOARCH:=amd64
$(BUILD_DIR)/darwin-amd64/lifecycle/launcher: OUT_DIR:=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
$(BUILD_DIR)/darwin-amd64/lifecycle/launcher: $(GOFILES)
$(BUILD_DIR)/darwin-amd64/lifecycle/launcher:
@echo "> Building launcher for darwin/amd64..."
mkdir -p $(OUT_DIR)
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/launcher -a ./cmd/launcher
test $$(du -m $(OUT_DIR)/launcher|cut -f 1) -le 4
define install-go-tool
@echo "> Installing $(1)..."
$(GOCMD) install $(1)@$(shell $(GOCMD) list -m -f '{{.Version}}' $(2))
endef
install-goimports:
@echo "> Installing goimports..."
$(GOCMD) install golang.org/x/tools/cmd/goimports@v0.1.2
$(call install-go-tool,golang.org/x/tools/cmd/goimports,golang.org/x/tools)
install-yj:
@echo "> Installing yj..."
$(GOCMD) install github.com/sclevine/yj@v0.0.0-20210612025309-737bdf40a5d1
$(call install-go-tool,github.com/sclevine/yj,github.com/sclevine/yj)
install-mockgen:
@echo "> Installing mockgen..."
$(GOCMD) install github.com/golang/mock/mockgen@v1.5.0
$(call install-go-tool,github.com/golang/mock/mockgen,github.com/golang/mock)
install-golangci-lint:
@echo "> Installing golangci-lint..."
$(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.42.1
$(call install-go-tool,github.com/golangci/golangci-lint/v2/cmd/golangci-lint,github.com/golangci/golangci-lint/v2)
lint: install-golangci-lint
@echo "> Linting code..."
@ -244,7 +180,6 @@ format: install-goimports
tidy:
@echo "> Tidying modules..."
$(GOCMD) mod tidy
cd tools && $(GOCMD) mod tidy
test: unit acceptance
@ -270,7 +205,7 @@ clean:
@echo "> Cleaning workspace..."
rm -rf $(BUILD_DIR)
package: package-linux-amd64 package-linux-arm64 package-windows-amd64
package: generate-sbom package-linux-amd64 package-linux-arm64 package-linux-ppc64le package-linux-s390x
package-linux-amd64: GOOS:=linux
package-linux-amd64: GOARCH:=amd64
@ -290,26 +225,20 @@ package-linux-arm64:
@echo "> Packaging lifecycle for $(GOOS)/$(GOARCH)..."
$(GOCMD) run $(PACKAGER) --inputDir $(INPUT_DIR) -archivePath $(ARCHIVE_PATH) -descriptorPath $(LIFECYCLE_DESCRIPTOR_PATH) -version $(LIFECYCLE_VERSION)
package-windows-amd64: GOOS:=windows
package-windows-amd64: GOARCH:=amd64
package-windows-amd64: INPUT_DIR:=$(BUILD_DIR)$/$(GOOS)-$(GOARCH)$/lifecycle
package-windows-amd64: ARCHIVE_PATH=$(BUILD_DIR)$/lifecycle-v$(LIFECYCLE_VERSION)+$(GOOS).x86-64.tgz
package-windows-amd64: PACKAGER=.$/tools$/packager$/main.go
package-windows-amd64:
package-linux-ppc64le: GOOS:=linux
package-linux-ppc64le: GOARCH:=ppc64le
package-linux-ppc64le: INPUT_DIR:=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
package-linux-ppc64le: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+$(GOOS).ppc64le.tgz
package-linux-ppc64le: PACKAGER=./tools/packager/main.go
package-linux-ppc64le:
@echo "> Packaging lifecycle for $(GOOS)/$(GOARCH)..."
$(GOCMD) run $(PACKAGER) --inputDir $(INPUT_DIR) -archivePath $(ARCHIVE_PATH) -descriptorPath $(LIFECYCLE_DESCRIPTOR_PATH) -version $(LIFECYCLE_VERSION)
# Ensure workdir is clean and build image from .git
docker-build-source-image-windows: $(GOFILES)
docker-build-source-image-windows:
$(if $(shell git status --short), @echo Uncommitted changes. Refusing to run. && exit 1)
docker build .git -f tools/Dockerfile.windows --tag $(SOURCE_COMPILATION_IMAGE) --build-arg image_tag=$(WINDOWS_COMPILATION_IMAGE) --cache-from=$(SOURCE_COMPILATION_IMAGE) --isolation=process --compress
docker-run-windows: docker-build-source-image-windows
docker-run-windows:
@echo "> Running '$(DOCKER_CMD)' in docker windows..."
@docker volume rm -f lifecycle-out
docker run -v lifecycle-out:c:/lifecycle/out -e LIFECYCLE_VERSION -e PLATFORM_API -e BUILDPACK_API -v gopathcache:c:/gopath -v '\\.\pipe\docker_engine:\\.\pipe\docker_engine' --isolation=process --interactive --tty --rm $(SOURCE_COMPILATION_IMAGE) $(DOCKER_CMD)
docker run -v lifecycle-out:c:/lifecycle/out --rm $(SOURCE_COMPILATION_IMAGE) tar -cf- out | tar -xf-
@docker volume rm -f lifecycle-out
package-linux-s390x: GOOS:=linux
package-linux-s390x: GOARCH:=s390x
package-linux-s390x: INPUT_DIR:=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
package-linux-s390x: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+$(GOOS).s390x.tgz
package-linux-s390x: PACKAGER=./tools/packager/main.go
package-linux-s390x:
@echo "> Packaging lifecycle for $(GOOS)/$(GOARCH)..."
$(GOCMD) run $(PACKAGER) --inputDir $(INPUT_DIR) -archivePath $(ARCHIVE_PATH) -descriptorPath $(LIFECYCLE_DESCRIPTOR_PATH) -version $(LIFECYCLE_VERSION)

View File

@ -2,23 +2,23 @@
[![Build Status](https://github.com/buildpacks/lifecycle/workflows/build/badge.svg)](https://github.com/buildpacks/lifecycle/actions)
[![GoDoc](https://godoc.org/github.com/buildpacks/lifecycle?status.svg)](https://godoc.org/github.com/buildpacks/lifecycle)
[![codecov](https://codecov.io/gh/buildpacks/pack/branch/main/graph/badge.svg)](https://codecov.io/gh/buildpacks/pack)
[![codecov](https://codecov.io/gh/buildpacks/lifecycle/branch/main/graph/badge.svg)](https://codecov.io/gh/buildpacks/lifecycle/tree/main)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4748/badge)](https://bestpractices.coreinfrastructure.org/projects/4748)
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/buildpacks/lifecycle)
A reference implementation of the [Cloud Native Buildpacks specification](https://github.com/buildpacks/spec).
## Supported APIs
Lifecycle Version | Platform APIs | Buildpack APIs |
------------------|------------------------------------------------------------------------------------|----------------|
0.13.x* | [0.3][p/0.3], [0.4][p/0.4], [0.5][p/0.5], [0.6][p/0.6], [0.7][p/0.7], [0.8][p/0.8] | [0.2][b/0.2], [0.3][b/0.3], [0.4][b/0.4], [0.5][b/0.5], [0.6][b/0.6], [0.7][b/0.7]
0.12.x | [0.3][p/0.3], [0.4][p/0.4], [0.5][p/0.5], [0.6][p/0.6], [0.7][p/0.7] | [0.2][b/0.2], [0.3][b/0.3], [0.4][b/0.4], [0.5][b/0.5], [0.6][b/0.6]
0.11.x | [0.3][p/0.3], [0.4][p/0.4], [0.5][p/0.5], [0.6][p/0.6] | [0.2][b/0.2], [0.3][b/0.3], [0.4][b/0.4], [0.5][b/0.5], [0.6][b/0.6]
0.10.x | [0.3][p/0.3], [0.4][p/0.4], [0.5][p/0.5] | [0.2][b/0.2], [0.3][b/0.3], [0.4][b/0.4], [0.5][b/0.5]
0.9.x | [0.3][p/0.3], [0.4][p/0.4] | [0.2][b/0.2], [0.3][b/0.3], [0.4][b/0.4]
0.8.x | [0.3][p/0.3] | [0.2][b/0.2]
0.7.x | [0.2][p/0.2] | [0.2][b/0.2]
0.6.x | [0.2][p/0.2] | [0.2][b/0.2]
| Lifecycle Version | Platform APIs | Buildpack APIs |
|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| 0.20.x | [0.7][p/0.7], [0.8][p/0.8], [0.9][p/0.9], [0.10][p/0.10], [0.11][p/0.11], [0.12][p/0.12], [0.13][p/0.13], [0.14][p/0.14] | [0.7][b/0.7], [0.8][b/0.8], [0.9][b/0.9], [0.10][b/0.10], [0.11][b/0.11] |
| 0.19.x | [0.7][p/0.7], [0.8][p/0.8], [0.9][p/0.9], [0.10][p/0.10], [0.11][p/0.11], [0.12][p/0.12], [0.13][p/0.13] | [0.7][b/0.7], [0.8][b/0.8], [0.9][b/0.9], [0.10][b/0.10], [0.11][b/0.11] |
| 0.18.x | [0.7][p/0.7], [0.8][p/0.8], [0.9][p/0.9], [0.10][p/0.10], [0.11][p/0.11], [0.12][p/0.12] | [0.7][b/0.7], [0.8][b/0.8], [0.9][b/0.9], [0.10][b/0.10] |
| 0.17.x | [0.3][p/0.3], [0.4][p/0.4], [0.5][p/0.5], [0.6][p/0.6], [0.7][p/0.7], [0.8][p/0.8], [0.9][p/0.9], [0.10][p/0.10], [0.11][p/0.11], [0.12][p/0.12] | [0.2][b/0.2], [0.3][b/0.3], [0.4][b/0.4], [0.5][b/0.5], [0.6][b/0.6], [0.7][b/0.7], [0.8][b/0.8], [0.9][b/0.9], [0.10][b/0.10] |
| 0.16.x | [0.3][p/0.3], [0.4][p/0.4], [0.5][p/0.5], [0.6][p/0.6], [0.7][p/0.7], [0.8][p/0.8], [0.9][p/0.9], [0.10][p/0.10], [0.11][p/0.11] | [0.2][b/0.2], [0.3][b/0.3], [0.4][b/0.4], [0.5][b/0.5], [0.6][b/0.6], [0.7][b/0.7], [0.8][b/0.8], [0.9][b/0.9] |
| 0.15.x | [0.3][p/0.3], [0.4][p/0.4], [0.5][p/0.5], [0.6][p/0.6], [0.7][p/0.7], [0.8][p/0.8], [0.9][p/0.9], [0.10][p/0.10] | [0.2][b/0.2], [0.3][b/0.3], [0.4][b/0.4], [0.5][b/0.5], [0.6][b/0.6], [0.7][b/0.7], [0.8][b/0.8], [0.9][b/0.9] |
| 0.14.x | [0.3][p/0.3], [0.4][p/0.4], [0.5][p/0.5], [0.6][p/0.6], [0.7][p/0.7], [0.8][p/0.8], [0.9][p/0.9] | [0.2][b/0.2], [0.3][b/0.3], [0.4][b/0.4], [0.5][b/0.5], [0.6][b/0.6], [0.7][b/0.7], [0.8][b/0.8] |
| 0.13.x | [0.3][p/0.3], [0.4][p/0.4], [0.5][p/0.5], [0.6][p/0.6], [0.7][p/0.7], [0.8][p/0.8] | [0.2][b/0.2], [0.3][b/0.3], [0.4][b/0.4], [0.5][b/0.5], [0.6][b/0.6], [0.7][b/0.7] |
[b/0.2]: https://github.com/buildpacks/spec/blob/buildpack/v0.2/buildpack.md
[b/0.3]: https://github.com/buildpacks/spec/tree/buildpack/v0.3/buildpack.md
@ -26,6 +26,10 @@ Lifecycle Version | Platform APIs
[b/0.5]: https://github.com/buildpacks/spec/tree/buildpack/v0.5/buildpack.md
[b/0.6]: https://github.com/buildpacks/spec/tree/buildpack/v0.6/buildpack.md
[b/0.7]: https://github.com/buildpacks/spec/tree/buildpack/v0.7/buildpack.md
[b/0.8]: https://github.com/buildpacks/spec/tree/buildpack/v0.8/buildpack.md
[b/0.9]: https://github.com/buildpacks/spec/tree/buildpack/v0.9/buildpack.md
[b/0.10]: https://github.com/buildpacks/spec/tree/buildpack/v0.10/buildpack.md
[b/0.11]: https://github.com/buildpacks/spec/tree/buildpack/v0.11/buildpack.md
[p/0.2]: https://github.com/buildpacks/spec/blob/platform/v0.2/platform.md
[p/0.3]: https://github.com/buildpacks/spec/blob/platform/v0.3/platform.md
[p/0.4]: https://github.com/buildpacks/spec/blob/platform/v0.4/platform.md
@ -33,6 +37,12 @@ Lifecycle Version | Platform APIs
[p/0.6]: https://github.com/buildpacks/spec/blob/platform/v0.6/platform.md
[p/0.7]: https://github.com/buildpacks/spec/blob/platform/v0.7/platform.md
[p/0.8]: https://github.com/buildpacks/spec/blob/platform/v0.8/platform.md
[p/0.9]: https://github.com/buildpacks/spec/blob/platform/v0.9/platform.md
[p/0.10]: https://github.com/buildpacks/spec/blob/platform/v0.10/platform.md
[p/0.11]: https://github.com/buildpacks/spec/blob/platform/v0.11/platform.md
[p/0.12]: https://github.com/buildpacks/spec/blob/platform/v0.12/platform.md
[p/0.13]: https://github.com/buildpacks/spec/blob/platform/v0.13/platform.md
[p/0.14]: https://github.com/buildpacks/spec/blob/platform/v0.14/platform.md
\* denotes unreleased version
@ -41,9 +51,9 @@ Lifecycle Version | Platform APIs
### Build
Either:
* `analyzer` - Reads metadata from the previous image and ensures registry access.
* `detector` - Chooses buildpacks (via `/bin/detect`) and produces a build plan.
* `analyzer` - Restores layer metadata from the previous image and from the cache.
* `restorer` - Restores cached layers.
* `restorer` - Restores layer metadata from the previous image and from the cache, and restores cached layers.
* `builder` - Executes buildpacks (via `/bin/build`).
* `exporter` - Creates an image and caches layers.

View File

@ -1,22 +1,73 @@
## Release Finalization
# Release Finalization
To cut a pre-release:
## Types of releases
#### New minor
* For newly supported Platform or Buildpack API versions, or breaking changes (e.g., API deprecations).
#### Pre-release aka release candidate
* Ideally we should ship a pre-release (waiting a few days for folks to try it out) before we ship a new minor.
* We typically don't ship pre-releases for patches or backports.
#### New patch
* For go version updates, CVE fixes / dependency bumps, bug fixes, etc.
* Review the latest commits on `main` to determine if any are unacceptable for a patch - if there are commits that should be excluded, branch off the latest tag for the current minor and cherry-pick commits over.
#### Backport
* New patch for an old minor. Typically, to help folks out who haven't yet upgraded from [unsupported APIs](https://github.com/buildpacks/rfcs/blob/main/text/0110-deprecate-apis.md).
* For go version updates, CVE fixes / dependency bumps, bug fixes, etc.
* Branch off the latest tag for the desired minor.
## Release Finalization Steps
### Step 1 - Prepare
Determine the type of release ([new minor](#new-minor), [pre-release](#pre-release-aka-release-candidate), [new patch](#new-patch), or [backport](#backport)) and prepare the branch accordingly.
**To prepare the release branch:**
1. Check open PRs for any dependabot updates that should be merged.
1. Create a release branch in the format `release/0.99.0-rc.1` (for pre-releases) or `release/0.99.0` (for final releases).
* New commits to this branch will trigger the `build` workflow and produce a lifecycle image: `buildpacksio/lifecycle:<commit sha>`.
1. If applicable, ensure the README is updated with the latest supported apis (example PR: https://github.com/buildpacks/lifecycle/pull/550).
1. Create a release branch in the format `release/0.99.0-rc.1`. New commits to this branch will trigger the `build` workflow and produce a lifecycle image: `buildpacksio/lifecycle:<commit sha>`.
1. When ready to cut the release, manually trigger the `draft-release` workflow: Actions -> draft-release -> Run workflow -> Use workflow from branch: `release/0.99.0-rc.1`. This will create a draft release on GitHub using the artifacts from the `build` workflow run for the latest commit on the release branch.
1. Edit the release notes as necessary.
1. Perform any manual validation of the artifacts (see below).
1. When ready to publish the release, edit the release page and click "Publish release". This will trigger the `post-release` workflow that will re-tag the lifecycle image from `buildpacksio/lifecycle:<commit sha>` to `buildpacksio/lifecycle:0.99.0` but will NOT update the `latest` tag.
* For final releases (not pre-releases), remove the pre-release note (`*`) for the latest apis.
To cut a release:
**For final releases (not pre-releases):**
1. Ensure the relevant spec APIs have been released.
1. Ensure the `lifecycle/0.99.0` milestone on the [docs repo](https://github.com/buildpacks/docs/blob/main/RELEASE.md#lump-changes) is complete, such that every new feature in the lifecycle is fully explained in the `release/lifecycle/0.99` branch on the docs repo, and [migration guides](https://github.com/buildpacks/docs/tree/main/content/docs/reference/spec/migration) (if relevant) are included.
1. If applicable, ensure the README is updated with the latest supported apis (example PR: https://github.com/buildpacks/lifecycle/pull/550).
1. Create a release branch in the format `release/0.99.0`. New commits to this branch will trigger the `build` workflow and produce a lifecycle image: `buildpacksio/lifecycle:<commit sha>`.
1. When ready to cut the release, manually trigger the `draft-release` workflow: Actions -> draft-release -> Run workflow -> Use workflow from branch: `release/0.99.0`. This will create a draft release on GitHub using the artifacts from the `build` workflow run for the latest commit on the release branch.
### Step 2 - Publish the Release
1. Manually trigger the `draft-release` workflow: Actions -> draft-release -> Run workflow -> Use workflow from branch: `release/<release version>`. This will create a draft release on GitHub using the artifacts from the `build` workflow run for the latest commit on the release branch.
1. Edit the release notes as necessary.
1. Perform any manual validation of the artifacts.
1. When ready to publish the release, edit the release page and click "Publish release". This will trigger the `post-release` workflow that will re-tag the lifecycle image from `buildpacksio/lifecycle:<commit sha>` to `buildpacksio/lifecycle:0.99.0` and `buildpacksio/lifecycle:latest`.
1. Once released
- Update the `main` branch to remove the pre-release note in [README.md](https://github.com/buildpacks/lifecycle/blob/main/README.md) and/or merge `release/0.99.0` into `main`.
- Ask the learning team to merge the `release/lifecycle/0.99` branch into `main` on the docs repo.
1. Perform any manual validation of the artifacts as necessary (usually none).
1. Edit the release page and click "Publish release".
* This will trigger the `post-release` workflow that will re-tag the lifecycle image from `buildpacksio/lifecycle:<commit sha>` to `buildpacksio/lifecycle:<release version>`.
* For final releases ONLY, this will also re-tag the lifecycle image from `buildpacksio/lifecycle:<commit sha>` to `buildpacksio/lifecycle:latest`.
### Step 3 - Follow-up
**For pre-releases:**
* Ask the relevant teams to try out the pre-released artifacts.
**For final releases:**
* Update the `main` branch to remove the pre-release note in [README.md](https://github.com/buildpacks/lifecycle/blob/main/README.md) and/or merge `release/0.99.0` into `main`.
* Ask the learning team to merge the `release/lifecycle/0.99` branch into `main` on the docs repo.
## Go version updates
Go version updates should be released as a [new minor](#new-minor) or [new patch](#new-patch) release.
### New Patch
If the go patch is in [actions/go-versions](https://github.com/actions/go-versions/pulls?q=is%3Apr+is%3Aclosed) then CI should pull it in automatically without any action needed.
We simply need to create the release branch and let the pipeline run.
### New Minor
We typically do this when the existing patch version exceeds 6 - e.g., `1.22.6`. This means we have about 6 months to upgrade before the current minor becomes unsupported due to the introduction of the new n+2 minor.
#### Steps
1. Update go.mod
1. Search for the old `major.minor`, there are a few files that need to be updated (example PR: https://github.com/buildpacks/lifecycle/pull/1405/files)
1. Update the linter to a version that supports the current `major.minor`
1. Fix any lint errors as necessary

View File

@ -2,7 +2,6 @@ package acceptance
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
@ -28,7 +27,7 @@ var (
func TestVersion(t *testing.T) {
var err error
buildDir, err = ioutil.TempDir("", "lifecycle-acceptance")
buildDir, err = os.MkdirTemp("", "lifecycle-acceptance")
h.AssertNil(t, err)
defer func() {
h.AssertNil(t, os.RemoveAll(buildDir))
@ -142,6 +141,7 @@ func testVersion(t *testing.T, when spec.G, it spec.S) {
w(tc.description, func() {
it("only prints the version", func() {
cmd := lifecycleCmd(tc.command, tc.args...)
cmd.Env = []string{fmt.Sprintf("CNB_PLATFORM_API=%s", api.Platform.Latest().String())}
output, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("failed to run %v\n OUTPUT: %s\n ERROR: %s\n", cmd.Args, output, err)

File diff suppressed because it is too large Load Diff

View File

@ -3,21 +3,16 @@ package acceptance
import (
"context"
"fmt"
"io/ioutil"
"math/rand"
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"
"time"
"github.com/BurntSushi/toml"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
"github.com/buildpacks/lifecycle/api"
"github.com/buildpacks/lifecycle/platform"
"github.com/buildpacks/lifecycle/platform/files"
h "github.com/buildpacks/lifecycle/testhelpers"
)
@ -29,11 +24,6 @@ var (
)
func TestBuilder(t *testing.T) {
h.SkipIf(t, runtime.GOOS == "windows", "Builder acceptance tests are not yet supported on Windows")
h.SkipIf(t, runtime.GOARCH != "amd64", "Builder acceptance tests are not yet supported on non-amd64")
rand.Seed(time.Now().UTC().UnixNano())
info, err := h.DockerCli(t).Info(context.TODO())
h.AssertNil(t, err)
@ -44,6 +34,8 @@ func TestBuilder(t *testing.T) {
builderDaemonArch = info.Architecture
if builderDaemonArch == "x86_64" {
builderDaemonArch = "amd64"
} else if builderDaemonArch == "aarch64" {
builderDaemonArch = "arm64"
}
h.MakeAndCopyLifecycle(t, builderDaemonOS, builderDaemonArch, builderBinaryDir)
@ -66,7 +58,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = ioutil.TempDir("", "test-docker-copy-")
copyDir, err = os.MkdirTemp("", "test-docker-copy-")
h.AssertNil(t, err)
})
@ -131,14 +123,105 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
),
)
// check builder metadata.toml for success test
md := getBuilderMetadata(t, filepath.Join(copyDir, "layers/config/metadata.toml"))
_, md := getBuilderMetadata(t, filepath.Join(copyDir, "layers", "config", "metadata.toml"))
h.AssertStringContains(t, md.Buildpacks[0].API, "0.2")
h.AssertStringContains(t, md.Buildpacks[0].API, "0.10")
h.AssertStringContains(t, md.Buildpacks[0].ID, "hello_world")
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
})
})
when("writing metadata.toml", func() {
it("writes and reads successfully", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
ctrPath("/layers"),
builderImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
"--env", "CNB_GROUP_PATH=/cnb/group_tomls/always_detect_group.toml",
"--env", "CNB_PLAN_PATH=/cnb/plan_tomls/always_detect_plan.toml",
),
)
// check builder metadata.toml for success test
contents, md := getBuilderMetadata(t, filepath.Join(copyDir, "layers", "config", "metadata.toml"))
// prevent regression of inline table serialization
h.AssertStringDoesNotContain(t, contents, "processes =")
h.AssertStringContains(t, md.Buildpacks[0].API, "0.10")
h.AssertStringContains(t, md.Buildpacks[0].ID, "hello_world")
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
h.AssertEq(t, len(md.Processes), 1)
h.AssertEq(t, md.Processes[0].Type, "hello")
h.AssertEq(t, len(md.Processes[0].Command.Entries), 1)
h.AssertEq(t, md.Processes[0].Command.Entries[0], "echo world")
h.AssertEq(t, len(md.Processes[0].Args), 1)
h.AssertEq(t, md.Processes[0].Args[0], "arg1")
h.AssertEq(t, md.Processes[0].Direct, true)
h.AssertEq(t, md.Processes[0].WorkingDirectory, "")
h.AssertEq(t, md.Processes[0].Default, false)
})
when("the platform < 0.10", func() {
it("writes and reads successfully", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
ctrPath("/layers"),
builderImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API=0.9",
"--env", "CNB_GROUP_PATH=/cnb/group_tomls/always_detect_group.toml",
"--env", "CNB_PLAN_PATH=/cnb/plan_tomls/always_detect_plan.toml",
),
)
// check builder metadata.toml for success test
contents, md := getBuilderMetadata(t, filepath.Join(copyDir, "layers", "config", "metadata.toml"))
// prevent regression of inline table serialization
h.AssertStringDoesNotContain(t, contents, "processes =")
h.AssertStringContains(t, md.Buildpacks[0].API, "0.10")
h.AssertStringContains(t, md.Buildpacks[0].ID, "hello_world")
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
h.AssertEq(t, len(md.Processes), 1)
h.AssertEq(t, md.Processes[0].Type, "hello")
h.AssertEq(t, len(md.Processes[0].Command.Entries), 1)
h.AssertEq(t, md.Processes[0].Command.Entries[0], "echo world")
h.AssertEq(t, len(md.Processes[0].Args), 1)
h.AssertEq(t, md.Processes[0].Args[0], "arg1")
h.AssertEq(t, md.Processes[0].Direct, true)
h.AssertEq(t, md.Processes[0].WorkingDirectory, "")
h.AssertEq(t, md.Processes[0].Default, false)
})
})
})
when("-group contains extensions", func() {
it("includes the provided extensions in <layers>/config/metadata.toml", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
ctrPath("/layers"),
builderImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
"--env", "CNB_GROUP_PATH=/cnb/group_tomls/group_with_ext.toml",
"--env", "CNB_PLAN_PATH=/cnb/plan_tomls/always_detect_plan.toml",
),
)
// check builder metadata.toml for success test
_, md := getBuilderMetadata(t, filepath.Join(copyDir, "layers", "config", "metadata.toml"))
h.AssertStringContains(t, md.Buildpacks[0].API, "0.10")
h.AssertStringContains(t, md.Buildpacks[0].ID, "hello_world")
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
h.AssertStringContains(t, md.Extensions[0].API, "0.10")
h.AssertStringContains(t, md.Extensions[0].ID, "hello_world")
h.AssertStringContains(t, md.Extensions[0].Version, "0.0.1")
})
})
when("invalid input files", func() {
// .../cmd/lifecycle/builder.go#readData
when("group.toml", func() {
@ -154,7 +237,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to read buildpack group: open /layers/group.toml: no such file or directory"
expected := "failed to read group file: open /layers/group.toml: no such file or directory"
h.AssertStringContains(t, string(output), expected)
})
})
@ -173,7 +256,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
),
)
// check builder metadata.toml for success test
md := getBuilderMetadata(t, filepath.Join(copyDir, "layers/config/metadata.toml"))
_, md := getBuilderMetadata(t, filepath.Join(copyDir, "layers", "config", "metadata.toml"))
h.AssertEq(t, len(md.Processes), 0)
})
})
@ -191,7 +274,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to read buildpack group: Near line 1 (last key parsed '')"
expected := "failed to read group file: toml: line 1: expected '.' or '=', but got 'a' instead"
h.AssertStringContains(t, string(output), expected)
})
})
@ -230,7 +313,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to parse detect plan: open /layers/plan.toml: no such file or directory"
expected := "failed to read plan file: open /layers/plan.toml: no such file or directory"
h.AssertStringContains(t, string(output), expected)
})
})
@ -249,9 +332,9 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
),
)
// check builder metadata.toml for success test
md := getBuilderMetadata(t, filepath.Join(copyDir, "layers/config/metadata.toml"))
_, md := getBuilderMetadata(t, filepath.Join(copyDir, "layers", "config", "metadata.toml"))
h.AssertStringContains(t, md.Buildpacks[0].API, "0.2")
h.AssertStringContains(t, md.Buildpacks[0].API, "0.10")
h.AssertStringContains(t, md.Buildpacks[0].ID, "hello_world")
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
})
@ -270,7 +353,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to parse detect plan: Near line 1 (last key parsed '')"
expected := "failed to read plan file: toml: line 1: expected '.' or '=', but got 'a' instead"
h.AssertStringContains(t, string(output), expected)
})
})
@ -292,9 +375,9 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
"--env", "CNB_PLAN_PATH=/cnb/plan_tomls/always_detect_plan_buildpack_2.toml",
),
)
md := getBuilderMetadata(t, filepath.Join(copyDir, "layers/different_layer_dir_from_env/config/metadata.toml"))
_, md := getBuilderMetadata(t, filepath.Join(copyDir, "layers/different_layer_dir_from_env/config/metadata.toml"))
h.AssertStringContains(t, md.Buildpacks[0].API, "0.2")
h.AssertStringContains(t, md.Buildpacks[0].API, "0.10")
h.AssertStringContains(t, md.Buildpacks[0].ID, "hello_world_2")
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.2")
})
@ -314,9 +397,9 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
"--env", "CNB_GROUP_PATH=/cnb/group_tomls/always_detect_group_buildpack2.toml",
),
)
md := getBuilderMetadata(t, filepath.Join(copyDir, "layers/different_layer_dir_from_env/config/metadata.toml"))
_, md := getBuilderMetadata(t, filepath.Join(copyDir, "layers/different_layer_dir_from_env/config/metadata.toml"))
h.AssertStringContains(t, md.Buildpacks[0].API, "0.2")
h.AssertStringContains(t, md.Buildpacks[0].API, "0.10")
h.AssertStringContains(t, md.Buildpacks[0].ID, "hello_world_2")
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.2")
})
@ -416,15 +499,37 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
h.AssertStringContains(t, string(output), expected)
})
})
when("It runs", func() {
it("sets CNB_TARGET_* vars", func() {
command := exec.Command(
"docker",
"run",
"--rm",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
"--env", "CNB_LAYERS_DIR=/layers/03_layer",
"--env", "CNB_PLAN_PATH=/cnb/plan_tomls/always_detect_plan_buildpack_3.toml",
builderImage,
)
output, err := command.CombinedOutput()
fmt.Println(string(output))
h.AssertNil(t, err)
h.AssertStringContains(t, string(output), "CNB_TARGET_ARCH: amd64")
h.AssertStringContains(t, string(output), "CNB_TARGET_ARCH_VARIANT: some-variant")
h.AssertStringContains(t, string(output), "CNB_TARGET_OS: linux")
h.AssertStringContains(t, string(output), "CNB_TARGET_DISTRO_NAME: ubuntu")
h.AssertStringContains(t, string(output), "CNB_TARGET_DISTRO_VERSION: some-cute-version")
})
})
}
func getBuilderMetadata(t *testing.T, path string) *platform.BuildMetadata {
contents, _ := ioutil.ReadFile(path)
func getBuilderMetadata(t *testing.T, path string) (string, *files.BuildMetadata) {
t.Helper()
contents, _ := os.ReadFile(path)
h.AssertEq(t, len(contents) > 0, true)
var analyzedMd platform.BuildMetadata
_, err := toml.Decode(string(contents), &analyzedMd)
buildMD, err := files.Handler.ReadBuildMetadata(path, api.MustParse(latestPlatformAPI))
h.AssertNil(t, err)
return &analyzedMd
return string(contents), buildMD
}

View File

@ -1,16 +1,16 @@
//go:build acceptance
// +build acceptance
package acceptance
import (
"math/rand"
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"
"time"
"github.com/buildpacks/lifecycle/internal/path"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
@ -29,10 +29,6 @@ var (
)
func TestCreator(t *testing.T) {
h.SkipIf(t, runtime.GOOS == "windows", "Creator acceptance tests are not yet supported on Windows")
rand.Seed(time.Now().UTC().UnixNano())
testImageDockerContext := filepath.Join("testdata", "creator")
createTest = NewPhaseTest(t, "creator", testImageDockerContext)
createTest.Start(t)
@ -40,7 +36,6 @@ func TestCreator(t *testing.T) {
createImage = createTest.testImageRef
creatorPath = createTest.containerBinaryPath
cacheFixtureDir = filepath.Join("testdata", "creator", "cache-dir")
createRegAuthConfig = createTest.targetRegistry.authConfig
createRegNetwork = createTest.targetRegistry.network
createDaemonFixtures = createTest.targetDaemon.fixtures
@ -55,82 +50,394 @@ func testCreatorFunc(platformAPI string) func(t *testing.T, when spec.G, it spec
return func(t *testing.T, when spec.G, it spec.S) {
var createdImageName string
it.After(func() {
h.DockerImageRemove(t, createdImageName)
when("called with run", func() {
it("uses the provided run.toml path", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "Platform API < 0.12 does not accept -run")
cmd := exec.Command(
"docker", "run", "--rm",
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+createRegAuthConfig,
"--network", createRegNetwork,
createImage,
ctrPath(creatorPath),
"-run", "/cnb/run.toml",
createRegFixtures.SomeAppImage,
) // #nosec G204
output, err := cmd.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to resolve inputs: failed to find accessible run image"
h.AssertStringContains(t, string(output), expected)
})
})
when("detected order contains extensions", func() {
it("errors", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.10"), "")
cmd := exec.Command(
"docker", "run", "--rm",
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+createRegAuthConfig,
"--network", createRegNetwork,
createImage,
ctrPath(creatorPath),
"-log-level", "debug",
"-order", "/cnb/order-with-extensions.toml",
"-run-image", createRegFixtures.ReadOnlyRunImage,
createRegFixtures.SomeAppImage,
) // #nosec G204
output, err := cmd.CombinedOutput()
h.AssertNotNil(t, err)
expected := "detected order contains extensions which is not supported by the creator"
h.AssertStringContains(t, string(output), expected)
})
})
when("daemon case", func() {
when("first build", func() {
when("app", func() {
it("is created", func() {
createFlags := []string{"-daemon"}
createFlags = append(createFlags, []string{"-run-image", createRegFixtures.ReadOnlyRunImage}...)
it.After(func() {
h.DockerImageRemove(t, createdImageName)
})
createArgs := append([]string{ctrPath(creatorPath)}, createFlags...)
createdImageName = "some-created-image-" + h.RandString(10)
createArgs = append(createArgs, createdImageName)
it("creates app", func() {
createFlags := []string{"-daemon"}
createFlags = append(createFlags, []string{"-run-image", createRegFixtures.ReadOnlyRunImage}...)
output := h.DockerRun(t,
createArgs := append([]string{ctrPath(creatorPath)}, createFlags...)
createdImageName = "some-created-image-" + h.RandString(10)
createArgs = append(createArgs, createdImageName)
output := h.DockerRun(t,
createImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+createRegAuthConfig,
"--network", createRegNetwork,
)...),
h.WithArgs(createArgs...),
)
h.AssertStringContains(t, output, "Saving "+createdImageName)
assertImageOSAndArch(t, createdImageName, createTest)
output = h.DockerRun(t,
createdImageName,
h.WithFlags(
"--entrypoint", "/cnb/lifecycle/launcher",
),
h.WithArgs("env"),
)
h.AssertStringContains(t, output, "SOME_VAR=some-val") // set by buildpack
})
})
when("registry case", func() {
it.After(func() {
h.DockerImageRemove(t, createdImageName)
})
it("creates app", func() {
var createFlags []string
createFlags = append(createFlags, []string{"-run-image", createRegFixtures.ReadOnlyRunImage}...)
createArgs := append([]string{ctrPath(creatorPath)}, createFlags...)
createdImageName = createTest.RegRepoName("some-created-image-" + h.RandString(10))
createArgs = append(createArgs, createdImageName)
output := h.DockerRun(t,
createImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+createRegAuthConfig,
"--network", createRegNetwork,
),
h.WithArgs(createArgs...),
)
h.AssertStringContains(t, output, "Saving "+createdImageName)
h.Run(t, exec.Command("docker", "pull", createdImageName))
assertImageOSAndArch(t, createdImageName, createTest)
output = h.DockerRun(t,
createdImageName,
h.WithFlags(
"--entrypoint", "/cnb/lifecycle/launcher",
),
h.WithArgs("env"),
)
h.AssertStringContains(t, output, "SOME_VAR=some-val") // set by buildpack
})
})
when("multiple builds", func() {
var (
container1 string
container2 string
container3 string
container4 string
dirBuild1 string
dirBuild2 string
dirCache string
dirLaunchCache string
dirRun1 string
dirRun2 string
imageName string
)
it.Before(func() {
// assign container names
for _, cPtr := range []*string{&container1, &container2, &container3, &container4} {
*cPtr = "test-container-" + h.RandString(10)
}
// create temp dirs
for _, dirPtr := range []*string{&dirCache, &dirLaunchCache, &dirBuild1, &dirRun1, &dirBuild2, &dirRun2} {
dir, err := os.MkdirTemp("", "creator-acceptance")
h.AssertNil(t, err)
h.AssertNil(t, os.Chmod(dir, 0777)) // Override umask
// Resolve temp dir so it can be properly mounted by the Docker daemon.
*dirPtr, err = filepath.EvalSymlinks(dir)
h.AssertNil(t, err)
}
// assign image name
imageName = "some-created-image-" + h.RandString(10)
})
it.After(func() {
// remove containers if needed
for _, container := range []string{container1, container2, container3, container4} {
if h.DockerContainerExists(t, container) {
h.Run(t, exec.Command("docker", "rm", container))
}
}
// remove temp dirs
for _, dir := range []string{dirCache, dirLaunchCache, dirBuild1, dirRun1, dirBuild2, dirRun2} {
_ = os.RemoveAll(dir)
}
// remove image
h.DockerImageRemove(t, imageName)
})
when("multiple builds", func() {
var (
createFlags []string
createArgs []string
duration1, duration2 time.Duration
)
it.Before(func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.8"), "Platform API < 0.8 does not support standardized SBOM")
createFlags = []string{"-daemon"}
createFlags = append(createFlags, []string{
"-run-image", createRegFixtures.ReadOnlyRunImage,
"-cache-dir", ctrPath("/cache"),
"-launch-cache", ctrPath("/launch-cache"),
"-log-level", "debug",
}...)
createArgs = append([]string{ctrPath(creatorPath)}, createFlags...)
createArgs = append(createArgs, imageName)
startTime := time.Now()
// first build
output := h.DockerRunAndCopy(t,
container1,
dirBuild1,
ctrPath("/layers"),
createImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+createRegAuthConfig,
"--network", createRegNetwork,
"--volume", dirCache+":"+ctrPath("/cache"),
"--volume", dirLaunchCache+":"+ctrPath("/launch-cache"),
)...),
h.WithArgs(createArgs...),
)
duration1 = time.Now().Sub(startTime)
t.Logf("First build duration: %s", duration1)
h.AssertStringDoesNotContain(t, output, "restored with content")
h.AssertPathExists(t, filepath.Join(dirBuild1, "layers", "sbom", "build", "samples_hello-world", "sbom.cdx.json"))
h.AssertPathExists(t, filepath.Join(dirBuild1, "layers", "sbom", "build", "samples_hello-world", "some-build-layer", "sbom.cdx.json"))
// first run
output = h.DockerRunAndCopy(t,
container2,
dirRun1,
ctrPath("/layers"),
imageName,
h.WithFlags(
"--entrypoint", "/cnb/lifecycle/launcher",
),
h.WithArgs("env"),
)
h.AssertPathExists(t, filepath.Join(dirRun1, "layers", "sbom", "launch", "samples_hello-world", "sbom.cdx.json"))
h.AssertPathExists(t, filepath.Join(dirRun1, "layers", "sbom", "launch", "samples_hello-world", "some-launch-cache-layer", "sbom.cdx.json"))
h.AssertPathExists(t, filepath.Join(dirRun1, "layers", "sbom", "launch", "samples_hello-world", "some-layer", "sbom.cdx.json"))
h.AssertPathDoesNotExist(t, filepath.Join(dirRun1, "layers", "sbom", "build"))
h.AssertPathDoesNotExist(t, filepath.Join(dirRun1, "layers", "sbom", "cache"))
})
when("rebuild with cache", func() {
it("exports SBOM in the app image", func() {
startTime := time.Now()
// second build
output := h.DockerRunAndCopy(t,
container3,
dirBuild2,
ctrPath("/layers"),
createImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+createRegAuthConfig,
"--network", createRegNetwork,
"--volume", dirCache+":/cache",
"--volume", dirLaunchCache+":"+ctrPath("/launch-cache"),
)...),
h.WithArgs(createArgs...),
)
h.AssertStringContains(t, output, "Saving "+createdImageName)
// check that launch cache was used
duration2 = time.Now().Sub(startTime)
t.Logf("Second build duration: %s", duration2)
if duration2+time.Duration(0.1*float64(time.Second)) >= duration1 {
t.Logf("Second build output: %s", output)
t.Fatalf("Expected second build to complete 0.1s faster than first build; first build took %s, second build took %s", duration1, duration2)
}
h.AssertStringContains(t, output, "some-layer.sbom.cdx.json restored with content: {\"key\": \"some-launch-true-bom-content\"}")
h.AssertStringContains(t, output, "some-cache-layer.sbom.cdx.json restored with content: {\"key\": \"some-cache-true-bom-content\"}")
h.AssertStringContains(t, output, "some-launch-cache-layer.sbom.cdx.json restored with content: {\"key\": \"some-launch-true-cache-true-bom-content\"}")
h.AssertStringContains(t, output, "Reusing layer 'buildpacksio/lifecycle:launch.sbom'")
h.AssertPathExists(t, filepath.Join(dirBuild2, "layers", "sbom", "build", "samples_hello-world", "sbom.cdx.json"))
h.AssertPathExists(t, filepath.Join(dirBuild2, "layers", "sbom", "build", "samples_hello-world", "some-build-layer", "sbom.cdx.json"))
t.Log("restores store.toml")
h.AssertStringContains(t, output, "store.toml restored with content: [metadata]")
assertImageOSAndArch(t, createdImageName, createTest)
output = h.DockerRun(t,
createdImageName,
// second run
output = h.DockerRunAndCopy(t,
container4,
dirRun2,
ctrPath("/layers"),
imageName,
h.WithFlags(
"--entrypoint", "/cnb/lifecycle/launcher",
),
h.WithArgs("env"),
)
h.AssertStringContains(t, output, "SOME_VAR=some-val") // set by buildpack
h.AssertPathExists(t, filepath.Join(dirRun1, "layers", "sbom", "launch", "samples_hello-world", "sbom.cdx.json"))
h.AssertPathExists(t, filepath.Join(dirRun1, "layers", "sbom", "launch", "samples_hello-world", "some-launch-cache-layer", "sbom.cdx.json"))
h.AssertPathExists(t, filepath.Join(dirRun1, "layers", "sbom", "launch", "samples_hello-world", "some-layer", "sbom.cdx.json"))
h.AssertPathDoesNotExist(t, filepath.Join(dirRun1, "layers", "sbom", "build"))
h.AssertPathDoesNotExist(t, filepath.Join(dirRun1, "layers", "sbom", "cache"))
})
})
when("rebuild with clear cache", func() {
it("exports SBOM in the app image", func() {
createArgs = append([]string{ctrPath(creatorPath)}, append(createFlags, "-skip-restore")...)
createArgs = append(createArgs, imageName)
// second build
output := h.DockerRunAndCopy(t,
container3,
dirBuild2,
ctrPath("/layers"),
createImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+createRegAuthConfig,
"--network", createRegNetwork,
"--volume", dirCache+":/cache",
"--volume", dirLaunchCache+":"+ctrPath("/launch-cache"),
)...),
h.WithArgs(createArgs...),
)
h.AssertStringDoesNotContain(t, output, "some-layer.sbom.cdx.json restored with content: {\"key\": \"some-launch-true-bom-content\"}")
h.AssertStringDoesNotContain(t, output, "some-cache-layer.sbom.cdx.json restored with content: {\"key\": \"some-cache-true-bom-content\"}")
h.AssertStringDoesNotContain(t, output, "some-launch-cache-layer.sbom.cdx.json restored with content: {\"key\": \"some-launch-true-cache-true-bom-content\"}")
// check that store.toml was restored
if api.MustParse(platformAPI).AtLeast("0.10") {
h.AssertStringContains(t, output, "store.toml restored with content: [metadata]")
} else {
h.AssertStringDoesNotContain(t, output, "store.toml restored with content")
}
})
})
})
})
when("registry case", func() {
when("first build", func() {
when("app", func() {
it("is created", func() {
var createFlags []string
createFlags = append(createFlags, []string{"-run-image", createRegFixtures.ReadOnlyRunImage}...)
when("layout case", func() {
var (
containerName string
err error
layoutDir string
tmpDir string
)
when("experimental mode is enabled", func() {
it.Before(func() {
// creates the directory to save all the OCI images on disk
tmpDir, err = os.MkdirTemp("", "layout")
h.AssertNil(t, err)
createArgs := append([]string{ctrPath(creatorPath)}, createFlags...)
createdImageName = createTest.RegRepoName("some-created-image-" + h.RandString(10))
createArgs = append(createArgs, createdImageName)
containerName = "test-container-" + h.RandString(10)
layoutDir = filepath.Join(path.RootDir, "layout-repo")
})
output := h.DockerRun(t,
createImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+createRegAuthConfig,
"--network", createRegNetwork,
),
h.WithArgs(createArgs...),
)
h.AssertStringContains(t, output, "Saving "+createdImageName)
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
h.DockerImageRemove(t, createdImageName)
h.Run(t, exec.Command("docker", "pull", createdImageName))
assertImageOSAndArch(t, createdImageName, createTest)
// removes all images created
os.RemoveAll(tmpDir)
output = h.DockerRun(t,
createdImageName,
h.WithFlags(
"--entrypoint", "/cnb/lifecycle/launcher",
),
h.WithArgs("env"),
)
h.AssertStringContains(t, output, "SOME_VAR=some-val") // set by buildpack
})
})
it("creates app", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "Platform API < 0.12 does not accept a -layout flag")
var createFlags []string
createFlags = append(createFlags, []string{"-layout", "-layout-dir", layoutDir, "-run-image", "busybox"}...)
createArgs := append([]string{ctrPath(creatorPath)}, createFlags...)
createdImageName = "some-created-image-" + h.RandString(10)
createArgs = append(createArgs, createdImageName)
output := h.DockerRunAndCopy(t, containerName, tmpDir, layoutDir, createImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_EXPERIMENTAL_MODE=warn",
),
h.WithArgs(createArgs...))
h.AssertStringContains(t, output, "Saving /layout-repo/index.docker.io/library/"+createdImageName+"/latest")
index := h.ReadIndexManifest(t, filepath.Join(tmpDir, layoutDir, "index.docker.io", "library", createdImageName+"/latest"))
h.AssertEq(t, len(index.Manifests), 1)
})
})
when("experimental mode is not enabled", func() {
it("errors", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "Platform API < 0.12 does not accept a -layout flag")
cmd := exec.Command(
"docker", "run", "--rm",
"--env", "CNB_PLATFORM_API="+platformAPI,
createImage,
ctrPath(creatorPath),
"-layout",
"-layout-dir", layoutDir,
"-run-image", "busybox",
"some-image",
) // #nosec G204
output, err := cmd.CombinedOutput()
h.AssertNotNil(t, err)
expected := "experimental features are disabled by CNB_EXPERIMENTAL_MODE=error"
h.AssertStringContains(t, string(output), expected)
})
})
})

View File

@ -1,43 +1,46 @@
//go:build acceptance
// +build acceptance
package acceptance
import (
"context"
"fmt"
"io/ioutil"
"math/rand"
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"
"time"
"github.com/BurntSushi/toml"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
"github.com/buildpacks/lifecycle/api"
"github.com/buildpacks/lifecycle/buildpack"
"github.com/buildpacks/lifecycle/platform"
"github.com/buildpacks/lifecycle/cmd"
"github.com/buildpacks/lifecycle/platform/files"
h "github.com/buildpacks/lifecycle/testhelpers"
)
var (
detectDockerContext = filepath.Join("testdata", "detector")
detectorBinaryDir = filepath.Join("testdata", "detector", "container", "cnb", "lifecycle")
detectImage = "lifecycle/acceptance/detector"
userID = "1234"
detectDockerContext = filepath.Join("testdata", "detector")
detectorBinaryDir = filepath.Join("testdata", "detector", "container", "cnb", "lifecycle")
detectImage = "lifecycle/acceptance/detector"
userID = "1234"
detectorDaemonOS, detectorDaemonArch string
)
func TestDetector(t *testing.T) {
h.SkipIf(t, runtime.GOOS == "windows", "Detector acceptance tests are not yet supported on Windows")
h.SkipIf(t, runtime.GOARCH != "amd64", "Detector acceptance tests are not yet supported on non-amd64")
info, err := h.DockerCli(t).Info(context.TODO())
h.AssertNil(t, err)
rand.Seed(time.Now().UTC().UnixNano())
detectorDaemonOS = info.OSType
detectorDaemonArch = info.Architecture
if detectorDaemonArch == "x86_64" {
detectorDaemonArch = "amd64"
}
if detectorDaemonArch == "aarch64" {
detectorDaemonArch = "arm64"
}
h.MakeAndCopyLifecycle(t, "linux", "amd64", detectorBinaryDir)
h.MakeAndCopyLifecycle(t, detectorDaemonOS, detectorDaemonArch, detectorBinaryDir)
h.DockerBuild(t,
detectImage,
detectDockerContext,
@ -45,412 +48,77 @@ func TestDetector(t *testing.T) {
)
defer h.DockerImageRemove(t, detectImage)
spec.Run(t, "acceptance-detector", testDetector, spec.Parallel(), spec.Report(report.Terminal{}))
for _, platformAPI := range api.Platform.Supported {
if platformAPI.LessThan("0.12") {
continue
}
spec.Run(t, "acceptance-detector/"+platformAPI.String(), testDetectorFunc(platformAPI.String()), spec.Parallel(), spec.Report(report.Terminal{}))
}
}
func testDetector(t *testing.T, when spec.G, it spec.S) {
when("called with arguments", func() {
it("errors", func() {
command := exec.Command(
"docker",
"run",
"--rm",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
detectImage,
"some-arg",
)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to parse arguments: received unexpected arguments"
h.AssertStringContains(t, string(output), expected)
})
})
when("running as a root", func() {
it("errors", func() {
command := exec.Command(
"docker",
"run",
"--rm",
"--user",
"root",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
detectImage,
)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to build: refusing to run as root"
h.AssertStringContains(t, string(output), expected)
})
})
when("read buildpack order file failed", func() {
it("errors", func() {
// no order.toml file in the default search locations
command := exec.Command(
"docker",
"run",
"--rm",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
detectImage,
)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to read buildpack order file"
h.AssertStringContains(t, string(output), expected)
})
})
when("no buildpack group passed detection", func() {
it("errors", func() {
command := exec.Command(
"docker",
"run",
"--rm",
"--env", "CNB_ORDER_PATH=/cnb/orders/empty_order.toml",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
detectImage,
)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
failErr, ok := err.(*exec.ExitError)
if !ok {
t.Fatalf("expected an error of type exec.ExitError")
}
h.AssertEq(t, failErr.ExitCode(), 20) // platform code for cmd.FailedDetect
expected := "No buildpack groups passed detection."
h.AssertStringContains(t, string(output), expected)
})
})
when("there is a buildpack group that pass detection", func() {
var copyDir, containerName string
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = ioutil.TempDir("", "test-docker-copy-")
h.AssertNil(t, err)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
os.RemoveAll(copyDir)
})
it("writes group.toml and plan.toml", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
detectImage,
h.WithFlags("--user", userID,
"--env", "CNB_ORDER_PATH=/cnb/orders/simple_order.toml",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
),
h.WithArgs(),
)
// check group.toml
tempGroupToml := filepath.Join(copyDir, "layers", "group.toml")
var buildpackGroup buildpack.Group
_, err := toml.DecodeFile(tempGroupToml, &buildpackGroup)
h.AssertNil(t, err)
h.AssertEq(t, buildpackGroup.Group[0].ID, "simple_buildpack")
h.AssertEq(t, buildpackGroup.Group[0].Version, "simple_buildpack_version")
// check plan.toml
tempPlanToml := filepath.Join(copyDir, "layers", "plan.toml")
var buildPlan platform.BuildPlan
_, err = toml.DecodeFile(tempPlanToml, &buildPlan)
h.AssertNil(t, err)
h.AssertEq(t, buildPlan.Entries[0].Providers[0].ID, "simple_buildpack")
h.AssertEq(t, buildPlan.Entries[0].Providers[0].Version, "simple_buildpack_version")
h.AssertEq(t, buildPlan.Entries[0].Requires[0].Name, "some_requirement")
h.AssertEq(t, buildPlan.Entries[0].Requires[0].Metadata["some_metadata_key"], "some_metadata_val")
h.AssertEq(t, buildPlan.Entries[0].Requires[0].Metadata["version"], "some_version")
})
})
when("environment variables are provided for buildpack and app directories and for the output files", func() {
var copyDir, containerName string
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = ioutil.TempDir("", "test-docker-copy-")
h.AssertNil(t, err)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
os.RemoveAll(copyDir)
})
it("writes group.toml and plan.toml in the right location and with the right names", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
detectImage,
h.WithFlags("--user", userID,
"--env", "CNB_ORDER_PATH=/cnb/orders/always_detect_order.toml",
"--env", "CNB_BUILDPACKS_DIR=/cnb/custom_buildpacks",
"--env", "CNB_APP_DIR=/custom_workspace",
"--env", "CNB_GROUP_PATH=./custom_group.toml",
"--env", "CNB_PLAN_PATH=./custom_plan.toml",
"--env", "CNB_PLATFORM_DIR=/custom_platform",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
),
h.WithArgs("-log-level=debug"),
)
// check group.toml
tempGroupToml := filepath.Join(copyDir, "layers", "custom_group.toml")
var buildpackGroup buildpack.Group
_, err := toml.DecodeFile(tempGroupToml, &buildpackGroup)
h.AssertNil(t, err)
h.AssertEq(t, buildpackGroup.Group[0].ID, "always_detect_buildpack")
h.AssertEq(t, buildpackGroup.Group[0].Version, "always_detect_buildpack_version")
// check plan.toml - should be empty since we're using always_detect_order.toml so there is no "actual plan"
tempPlanToml := filepath.Join(copyDir, "layers", "custom_plan.toml")
planContents, err := ioutil.ReadFile(tempPlanToml)
h.AssertNil(t, err)
h.AssertEq(t, len(planContents) == 0, true)
// check platform directory
logs := h.Run(t, exec.Command("docker", "logs", containerName))
expectedPlatformPath := "platform_path: /custom_platform"
expectedAppDir := "app_dir: /custom_workspace"
h.AssertStringContains(t, logs, expectedPlatformPath)
h.AssertStringContains(t, logs, expectedAppDir)
})
})
when("-order is provided", func() {
var copyDir, containerName, expectedOrderTOMLPath string
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = ioutil.TempDir("", "test-docker-copy-")
h.AssertNil(t, err)
simpleOrderTOML := filepath.Join("testdata", "detector", "container", "cnb", "orders", "simple_order.toml")
expectedOrderTOMLPath, err = filepath.Abs(simpleOrderTOML)
h.AssertNil(t, err)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
os.RemoveAll(copyDir)
})
when("the order.toml exists", func() {
it("processes the provided order.toml", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
detectImage,
h.WithFlags("--user", userID,
"--volume", expectedOrderTOMLPath+":/custom/order.toml",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
),
h.WithArgs(
"-log-level=debug",
"-order=/custom/order.toml",
),
)
// check group.toml
tempGroupToml := filepath.Join(copyDir, "layers", "group.toml")
var buildpackGroup buildpack.Group
_, err := toml.DecodeFile(tempGroupToml, &buildpackGroup)
h.AssertNil(t, err)
h.AssertEq(t, buildpackGroup.Group[0].ID, "simple_buildpack")
h.AssertEq(t, buildpackGroup.Group[0].Version, "simple_buildpack_version")
})
})
when("the order.toml does not exist", func() {
it("errors", func() {
command := exec.Command("docker", "run",
"--user", userID,
"--rm",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
detectImage,
"-order=/custom/order.toml")
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to read buildpack order file: open /custom/order.toml: no such file or directory"
h.AssertStringContains(t, string(output), expected)
})
})
})
when("-order is not provided", func() {
var copyDir, containerName, expectedOrderTOMLPath, otherOrderTOMLPath string
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = ioutil.TempDir("", "test-docker-copy-")
h.AssertNil(t, err)
simpleOrderTOML := filepath.Join("testdata", "detector", "container", "cnb", "orders", "simple_order.toml")
expectedOrderTOMLPath, err = filepath.Abs(simpleOrderTOML)
h.AssertNil(t, err)
alwaysDetectOrderTOML := filepath.Join("testdata", "detector", "container", "cnb", "orders", "always_detect_order.toml")
otherOrderTOMLPath, err = filepath.Abs(alwaysDetectOrderTOML)
h.AssertNil(t, err)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
os.RemoveAll(copyDir)
})
when("/cnb/order.toml and /layers/order.toml are present", func() {
it("prefers /layers/order.toml", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
detectImage,
h.WithFlags("--user", userID,
"--volume", expectedOrderTOMLPath+":/layers/order.toml",
"--volume", otherOrderTOMLPath+":/cnb/order.toml",
"--env", "CNB_ORDER_PATH=",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
),
h.WithArgs("-log-level=debug"),
)
// check group.toml
tempGroupToml := filepath.Join(copyDir, "layers", "group.toml")
var buildpackGroup buildpack.Group
_, err := toml.DecodeFile(tempGroupToml, &buildpackGroup)
h.AssertNil(t, err)
h.AssertEq(t, buildpackGroup.Group[0].ID, "simple_buildpack")
h.AssertEq(t, buildpackGroup.Group[0].Version, "simple_buildpack_version")
})
})
when("only /cnb/order.toml is present", func() {
it("processes /cnb/order.toml", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
detectImage,
h.WithFlags("--user", userID,
"--volume", expectedOrderTOMLPath+":/cnb/order.toml",
"--env", "CNB_ORDER_PATH=",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
),
h.WithArgs("-log-level=debug"),
)
// check group.toml
tempGroupToml := filepath.Join(copyDir, "layers", "group.toml")
var buildpackGroup buildpack.Group
_, err := toml.DecodeFile(tempGroupToml, &buildpackGroup)
h.AssertNil(t, err)
h.AssertEq(t, buildpackGroup.Group[0].ID, "simple_buildpack")
h.AssertEq(t, buildpackGroup.Group[0].Version, "simple_buildpack_version")
})
})
when("only /layers/order.toml is present", func() {
it("processes /layers/order.toml", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
detectImage,
h.WithFlags("--user", userID,
"--volume", expectedOrderTOMLPath+":/layers/order.toml",
"--env", "CNB_ORDER_PATH=",
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
),
h.WithArgs("-log-level=debug"),
)
// check group.toml
tempGroupToml := filepath.Join(copyDir, "layers", "group.toml")
var buildpackGroup buildpack.Group
_, err := toml.DecodeFile(tempGroupToml, &buildpackGroup)
h.AssertNil(t, err)
h.AssertEq(t, buildpackGroup.Group[0].ID, "simple_buildpack")
h.AssertEq(t, buildpackGroup.Group[0].Version, "simple_buildpack_version")
})
})
when("platform api < 0.6", func() {
when("/cnb/order.toml and /layers/order.toml are present", func() {
it("only processes /cnb/order.toml", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
detectImage,
h.WithFlags("--user", userID,
"--volume", expectedOrderTOMLPath+":/cnb/order.toml",
"--volume", otherOrderTOMLPath+":/layers/order.toml",
"--env", "CNB_PLATFORM_API=0.5",
"--env", "CNB_ORDER_PATH=",
),
h.WithArgs("-log-level=debug"),
)
// check group.toml
tempGroupToml := filepath.Join(copyDir, "layers", "group.toml")
var buildpackGroup buildpack.Group
_, err := toml.DecodeFile(tempGroupToml, &buildpackGroup)
h.AssertNil(t, err)
h.AssertEq(t, buildpackGroup.Group[0].ID, "simple_buildpack")
h.AssertEq(t, buildpackGroup.Group[0].Version, "simple_buildpack_version")
})
})
when("only /layers/order.toml is present", func() {
it("errors", func() {
command := exec.Command("docker", "run",
"--user", userID,
"--volume", otherOrderTOMLPath+":/layers/order.toml",
"--env", "CNB_PLATFORM_API=0.5",
"--env", "CNB_ORDER_PATH=",
"--rm", detectImage)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to read buildpack order file: open /cnb/order.toml: no such file or directory"
h.AssertStringContains(t, string(output), expected)
})
})
})
})
when("platform api < 0.6", func() {
when("no buildpack group passed detection", func() {
func testDetectorFunc(platformAPI string) func(t *testing.T, when spec.G, it spec.S) {
return func(t *testing.T, when spec.G, it spec.S) {
when("called with arguments", func() {
it("errors", func() {
command := exec.Command(
"docker",
"run",
"--rm",
"--env", "CNB_ORDER_PATH=/cnb/orders/empty_order.toml",
"--env", "CNB_PLATFORM_API=0.5",
"--env", "CNB_PLATFORM_API="+platformAPI,
detectImage,
"some-arg",
)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to parse arguments: received unexpected arguments"
h.AssertStringContains(t, string(output), expected)
})
})
when("running as a root", func() {
it("errors", func() {
command := exec.Command(
"docker",
"run",
"--rm",
"--user",
"root",
"--env", "CNB_PLATFORM_API="+platformAPI,
detectImage,
)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to detect: refusing to run as root"
h.AssertStringContains(t, string(output), expected)
})
})
when("read buildpack order file failed", func() {
it("errors", func() {
// no order.toml file in the default search locations
command := exec.Command(
"docker",
"run",
"--rm",
"--env", "CNB_PLATFORM_API="+platformAPI,
detectImage,
)
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to initialize detector: reading order"
h.AssertStringContains(t, string(output), expected)
})
})
when("no buildpack group passed detection", func() {
it("errors and exits with the expected code", func() {
command := exec.Command(
"docker",
"run",
"--rm",
"--env", "CNB_ORDER_PATH=/cnb/orders/fail_detect_order.toml",
"--env", "CNB_PLATFORM_API="+platformAPI,
detectImage,
)
output, err := command.CombinedOutput()
@ -459,10 +127,296 @@ func testDetector(t *testing.T, when spec.G, it spec.S) {
if !ok {
t.Fatalf("expected an error of type exec.ExitError")
}
h.AssertEq(t, failErr.ExitCode(), 100) // platform code for cmd.FailedDetect
expected := "No buildpack groups passed detection."
h.AssertStringContains(t, string(output), expected)
h.AssertEq(t, failErr.ExitCode(), 20) // platform code for failed detect
expected1 := `======== Output: fail_detect_buildpack@some_version ========
Opted out of detection
======== Results ========
fail: fail_detect_buildpack@some_version`
h.AssertStringContains(t, string(output), expected1)
expected2 := "No buildpack groups passed detection."
h.AssertStringContains(t, string(output), expected2)
})
})
})
when("there is a buildpack group that passes detection", func() {
var copyDir, containerName string
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = os.MkdirTemp("", "test-docker-copy-")
h.AssertNil(t, err)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
os.RemoveAll(copyDir)
})
it("writes group.toml and plan.toml at the default locations", func() {
output := h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
detectImage,
h.WithFlags("--user", userID,
"--env", "CNB_ORDER_PATH=/cnb/orders/simple_order.toml",
"--env", "CNB_PLATFORM_API="+platformAPI,
),
h.WithArgs(),
)
// check group.toml
foundGroupTOML := filepath.Join(copyDir, "layers", "group.toml")
group, err := files.Handler.ReadGroup(foundGroupTOML)
h.AssertNil(t, err)
h.AssertEq(t, group.Group[0].ID, "simple_buildpack")
h.AssertEq(t, group.Group[0].Version, "simple_buildpack_version")
// check plan.toml
foundPlanTOML := filepath.Join(copyDir, "layers", "plan.toml")
buildPlan, err := files.Handler.ReadPlan(foundPlanTOML)
h.AssertNil(t, err)
h.AssertEq(t, buildPlan.Entries[0].Providers[0].ID, "simple_buildpack")
h.AssertEq(t, buildPlan.Entries[0].Providers[0].Version, "simple_buildpack_version")
h.AssertEq(t, buildPlan.Entries[0].Requires[0].Name, "some_requirement")
h.AssertEq(t, buildPlan.Entries[0].Requires[0].Metadata["some_metadata_key"], "some_metadata_val")
h.AssertEq(t, buildPlan.Entries[0].Requires[0].Metadata["version"], "some_version")
// check output
h.AssertStringContains(t, output, "simple_buildpack simple_buildpack_version")
h.AssertStringDoesNotContain(t, output, "======== Results ========") // log output is info level as detect passed
})
})
when("environment variables are provided for buildpack and app directories and for the output files", func() {
var copyDir, containerName string
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = os.MkdirTemp("", "test-docker-copy-")
h.AssertNil(t, err)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
os.RemoveAll(copyDir)
})
it("writes group.toml and plan.toml in the right locations and with the right names", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
detectImage,
h.WithFlags("--user", userID,
"--env", "CNB_ORDER_PATH=/cnb/orders/always_detect_order.toml",
"--env", "CNB_BUILDPACKS_DIR=/cnb/custom_buildpacks",
"--env", "CNB_APP_DIR=/custom_workspace",
"--env", "CNB_GROUP_PATH=./custom_group.toml",
"--env", "CNB_PLAN_PATH=./custom_plan.toml",
"--env", "CNB_PLATFORM_DIR=/custom_platform",
"--env", "CNB_PLATFORM_API="+platformAPI,
),
h.WithArgs("-log-level=debug"),
)
// check group.toml
foundGroupTOML := filepath.Join(copyDir, "layers", "custom_group.toml")
group, err := files.Handler.ReadGroup(foundGroupTOML)
h.AssertNil(t, err)
h.AssertEq(t, group.Group[0].ID, "always_detect_buildpack")
h.AssertEq(t, group.Group[0].Version, "always_detect_buildpack_version")
// check plan.toml - should be empty since we're using always_detect_order.toml so there is no "actual plan"
tempPlanToml := filepath.Join(copyDir, "layers", "custom_plan.toml")
planContents, err := os.ReadFile(tempPlanToml)
h.AssertNil(t, err)
h.AssertEq(t, len(planContents) == 0, true)
// check platform directory
logs := h.Run(t, exec.Command("docker", "logs", containerName))
expectedPlatformPath := "platform_path: /custom_platform"
expectedAppDir := "app_dir: /custom_workspace"
h.AssertStringContains(t, logs, expectedPlatformPath)
h.AssertStringContains(t, logs, expectedAppDir)
})
})
when("-order is provided", func() {
var copyDir, containerName, expectedOrderTOMLPath string
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = os.MkdirTemp("", "test-docker-copy-")
h.AssertNil(t, err)
simpleOrderTOML := filepath.Join("testdata", "detector", "container", "cnb", "orders", "simple_order.toml")
expectedOrderTOMLPath, err = filepath.Abs(simpleOrderTOML)
h.AssertNil(t, err)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
os.RemoveAll(copyDir)
})
when("the order.toml exists", func() {
it("processes the provided order.toml", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
detectImage,
h.WithFlags("--user", userID,
"--volume", expectedOrderTOMLPath+":/custom/order.toml",
"--env", "CNB_PLATFORM_API="+platformAPI,
),
h.WithArgs(
"-log-level=debug",
"-order=/custom/order.toml",
),
)
// check group.toml
foundGroupTOML := filepath.Join(copyDir, "layers", "group.toml")
group, err := files.Handler.ReadGroup(foundGroupTOML)
h.AssertNil(t, err)
h.AssertEq(t, group.Group[0].ID, "simple_buildpack")
h.AssertEq(t, group.Group[0].Version, "simple_buildpack_version")
})
})
when("the order.toml does not exist", func() {
it("errors", func() {
command := exec.Command("docker", "run",
"--user", userID,
"--rm",
"--env", "CNB_PLATFORM_API="+platformAPI,
detectImage,
"-order=/custom/order.toml")
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to initialize detector: reading order: failed to read order file: open /custom/order.toml: no such file or directory"
h.AssertStringContains(t, string(output), expected)
})
})
when("the order.toml contains a buildpack using an unsupported api", func() {
it("errors", func() {
command := exec.Command("docker", "run",
"--user", userID,
"--rm",
"--env", "CNB_PLATFORM_API="+platformAPI,
detectImage,
"-order=/cnb/orders/bad_api.toml")
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
failErr, ok := err.(*exec.ExitError)
if !ok {
t.Fatalf("expected an error of type exec.ExitError")
}
h.AssertEq(t, failErr.ExitCode(), 12) // platform code for buildpack api error
expected := "buildpack API version '0.1' is incompatible with the lifecycle"
h.AssertStringContains(t, string(output), expected)
})
})
})
when("-order contains extensions", func() {
var containerName, copyDir, orderPath string
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = os.MkdirTemp("", "test-docker-copy-")
h.AssertNil(t, err)
orderPath, err = filepath.Abs(filepath.Join("testdata", "detector", "container", "cnb", "orders", "order_with_ext.toml"))
h.AssertNil(t, err)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
os.RemoveAll(copyDir)
})
it("processes the provided order.toml", func() {
experimentalMode := "warn"
if api.MustParse(platformAPI).AtLeast("0.13") {
experimentalMode = "error"
}
output := h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
detectImage,
h.WithFlags(
"--user", userID,
"--volume", orderPath+":/layers/order.toml",
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_EXPERIMENTAL_MODE="+experimentalMode,
),
h.WithArgs(
"-analyzed=/layers/analyzed.toml",
"-extensions=/cnb/extensions",
"-generated=/layers/generated",
"-log-level=debug",
"-run=/layers/run.toml", // /cnb/run.toml is the default location of run.toml
),
)
t.Log("runs /bin/detect for buildpacks and extensions")
if api.MustParse(platformAPI).LessThan("0.13") {
h.AssertStringContains(t, output, "Platform requested experimental feature 'Dockerfiles'")
}
h.AssertStringContains(t, output, "FOO=val-from-build-config")
h.AssertStringContains(t, output, "simple_extension: output from /bin/detect")
t.Log("writes group.toml")
foundGroupTOML := filepath.Join(copyDir, "layers", "group.toml")
group, err := files.Handler.ReadGroup(foundGroupTOML)
h.AssertNil(t, err)
h.AssertEq(t, group.GroupExtensions[0].ID, "simple_extension")
h.AssertEq(t, group.GroupExtensions[0].Version, "simple_extension_version")
h.AssertEq(t, group.Group[0].ID, "buildpack_for_ext")
h.AssertEq(t, group.Group[0].Version, "buildpack_for_ext_version")
h.AssertEq(t, group.Group[0].Extension, false)
t.Log("writes plan.toml")
foundPlanTOML := filepath.Join(copyDir, "layers", "plan.toml")
buildPlan, err := files.Handler.ReadPlan(foundPlanTOML)
h.AssertNil(t, err)
h.AssertEq(t, len(buildPlan.Entries), 0) // this shows that the plan was filtered to remove `requires` provided by extensions
t.Log("runs /bin/generate for extensions")
h.AssertStringContains(t, output, "simple_extension: output from /bin/generate")
var dockerfilePath string
if api.MustParse(platformAPI).LessThan("0.13") {
t.Log("copies the generated Dockerfiles to the output directory")
dockerfilePath = filepath.Join(copyDir, "layers", "generated", "run", "simple_extension", "Dockerfile")
} else {
dockerfilePath = filepath.Join(copyDir, "layers", "generated", "simple_extension", "run.Dockerfile")
}
h.AssertPathExists(t, dockerfilePath)
contents, err := os.ReadFile(dockerfilePath)
h.AssertEq(t, string(contents), "FROM some-run-image-from-extension\n")
t.Log("records the new run image in analyzed.toml")
foundAnalyzedTOML := filepath.Join(copyDir, "layers", "analyzed.toml")
analyzedMD, err := files.Handler.ReadAnalyzed(foundAnalyzedTOML, cmd.DefaultLogger)
h.AssertNil(t, err)
h.AssertEq(t, analyzedMD.RunImage.Image, "some-run-image-from-extension")
})
})
}
}

View File

@ -1,24 +1,35 @@
//go:build acceptance
// +build acceptance
package acceptance
import (
"context"
"math/rand"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
"time"
"github.com/buildpacks/imgutil"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/pkg/errors"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
"github.com/buildpacks/lifecycle"
"github.com/buildpacks/lifecycle/api"
"github.com/buildpacks/lifecycle/platform"
"github.com/buildpacks/lifecycle/auth"
"github.com/buildpacks/lifecycle/cache"
"github.com/buildpacks/lifecycle/cmd"
"github.com/buildpacks/lifecycle/internal/fsutil"
"github.com/buildpacks/lifecycle/internal/path"
"github.com/buildpacks/lifecycle/platform/files"
h "github.com/buildpacks/lifecycle/testhelpers"
)
@ -33,25 +44,19 @@ var (
)
func TestExporter(t *testing.T) {
h.SkipIf(t, runtime.GOOS == "windows", "Exporter acceptance tests are not yet supported on Windows")
rand.Seed(time.Now().UTC().UnixNano())
testImageDockerContext := filepath.Join("testdata", "exporter")
exportTest = NewPhaseTest(t, "exporter", testImageDockerContext)
exportTest.Start(t, updateAnalyzedTOMLFixturesWithRegRepoName)
exportTest.Start(t, updateTOMLFixturesWithTestRegistry)
defer exportTest.Stop(t)
exportImage = exportTest.testImageRef
exporterPath = exportTest.containerBinaryPath
cacheFixtureDir = filepath.Join("testdata", "exporter", "cache-dir")
exportRegAuthConfig = exportTest.targetRegistry.authConfig
exportRegNetwork = exportTest.targetRegistry.network
exportDaemonFixtures = exportTest.targetDaemon.fixtures
exportRegFixtures = exportTest.targetRegistry.fixtures
rand.Seed(time.Now().UTC().UnixNano())
for _, platformAPI := range api.Platform.Supported {
spec.Run(t, "acceptance-exporter/"+platformAPI.String(), testExporterFunc(platformAPI.String()), spec.Parallel(), spec.Report(report.Terminal{}))
}
@ -59,52 +64,259 @@ func TestExporter(t *testing.T) {
func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spec.S) {
return func(t *testing.T, when spec.G, it spec.S) {
var exportedImageName string
it.After(func() {
h.DockerImageRemove(t, exportedImageName)
})
when("daemon case", func() {
when("first build", func() {
when("app", func() {
it("is created", func() {
exportFlags := []string{"-daemon"}
if api.MustParse(platformAPI).LessThan("0.7") {
exportFlags = append(exportFlags, []string{"-run-image", exportRegFixtures.ReadOnlyRunImage}...)
}
var exportedImageName string
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = "some-exported-image-" + h.RandString(10)
exportArgs = append(exportArgs, exportedImageName)
it.After(func() {
_, _, _ = h.RunE(exec.Command("docker", "rmi", exportedImageName)) // #nosec G204
})
output := h.DockerRun(t,
exportImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+exportRegAuthConfig,
"--network", exportRegNetwork,
)...),
h.WithArgs(exportArgs...),
)
h.AssertStringContains(t, output, "Saving "+exportedImageName)
it("app is created", func() {
exportFlags := []string{"-daemon", "-log-level", "debug"}
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = "some-exported-image-" + h.RandString(10)
exportArgs = append(exportArgs, exportedImageName)
assertImageOSAndArch(t, exportedImageName, exportTest)
})
output := h.DockerRun(t,
exportImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_PLATFORM_API="+platformAPI,
)...),
h.WithArgs(exportArgs...),
)
h.AssertStringContains(t, output, "Saving "+exportedImageName)
if api.MustParse(platformAPI).AtLeast("0.11") {
extensions := []string{"sbom.cdx.json", "sbom.spdx.json", "sbom.syft.json"}
for _, extension := range extensions {
h.AssertStringContains(t, output, fmt.Sprintf("Copying SBOM lifecycle.%s to %s", extension, filepath.Join(path.RootDir, "layers", "sbom", "build", "buildpacksio_lifecycle", extension)))
h.AssertStringContains(t, output, fmt.Sprintf("Copying SBOM launcher.%s to %s", extension, filepath.Join(path.RootDir, "layers", "sbom", "launch", "buildpacksio_lifecycle", "launcher", extension)))
}
} else {
h.AssertStringDoesNotContain(t, output, "Copying SBOM")
}
if api.MustParse(platformAPI).AtLeast("0.12") {
expectedHistory := []string{
"Buildpacks Launcher Config",
"Buildpacks Application Launcher",
"Application Layer",
"Software Bill-of-Materials",
"Layer: 'corrupted-layer', Created by buildpack: corrupted_buildpack@corrupted_v1",
"Layer: 'launch-layer', Created by buildpack: cacher_buildpack@cacher_v1",
"", // run image layer
}
assertDaemonImageHasHistory(t, exportedImageName, expectedHistory)
} else {
assertDaemonImageDoesNotHaveHistory(t, exportedImageName)
}
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, imgutil.NormalizedDateTime)
})
when("using extensions", func() {
it.Before(func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "")
})
it("app is created from the extended run image", func() {
exportFlags := []string{
"-analyzed", "/layers/run-image-extended-analyzed.toml", // though the run image is a registry image, it also exists in the daemon with the same tag
"-daemon",
"-extended", "/layers/some-extended-dir",
"-log-level", "debug",
"-run", "/cnb/run.toml", // though the run image is a registry image, it also exists in the daemon with the same tag
}
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = "some-exported-image-" + h.RandString(10)
exportArgs = append(exportArgs, exportedImageName)
// get run image top layer
inspect, _, err := h.DockerCli(t).ImageInspectWithRaw(context.TODO(), exportTest.targetRegistry.fixtures.ReadOnlyRunImage)
h.AssertNil(t, err)
layers := inspect.RootFS.Layers
runImageFixtureTopLayerSHA := layers[len(layers)-1]
runImageFixtureSHA := inspect.ID
experimentalMode := "warn"
if api.MustParse(platformAPI).AtLeast("0.13") {
experimentalMode = "error"
}
output := h.DockerRun(t,
exportImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_EXPERIMENTAL_MODE="+experimentalMode,
"--env", "CNB_PLATFORM_API="+platformAPI,
)...),
h.WithArgs(exportArgs...),
)
h.AssertStringContains(t, output, "Saving "+exportedImageName)
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, imgutil.NormalizedDateTime)
expectedHistory := []string{
"Buildpacks Launcher Config",
"Buildpacks Application Launcher",
"Application Layer",
"Software Bill-of-Materials",
"Layer: 'corrupted-layer', Created by buildpack: corrupted_buildpack@corrupted_v1",
"Layer: 'launch-layer', Created by buildpack: cacher_buildpack@cacher_v1",
"Layer: 'RUN mkdir /some-other-dir && echo some-data > /some-other-dir/some-file && echo some-data > /some-other-file', Created by extension: second-extension",
"Layer: 'RUN mkdir /some-dir && echo some-data > /some-dir/some-file && echo some-data > /some-file', Created by extension: first-extension",
"", // run image layer
}
assertDaemonImageHasHistory(t, exportedImageName, expectedHistory)
t.Log("bases the exported image on the extended run image")
inspect, _, err = h.DockerCli(t).ImageInspectWithRaw(context.TODO(), exportedImageName)
h.AssertNil(t, err)
h.AssertEq(t, inspect.Config.Labels["io.buildpacks.rebasable"], "false") // from testdata/exporter/container/layers/some-extended-dir/run/sha256_<sha>/blobs/sha256/<config>
t.Log("Adds extension layers")
type testCase struct {
expectedDiffID string
layerIndex int
}
testCases := []testCase{
{
expectedDiffID: "sha256:fb54d2566824d6630d94db0b008d9a544a94d3547a424f52e2fd282b648c0601", // from testdata/exporter/container/layers/some-extended-dir/run/sha256_<c72eda1c>/blobs/sha256/65c2873d397056a5cb4169790654d787579b005f18b903082b177d4d9b4aecf5 after un-compressing and zeroing timestamps
layerIndex: 1,
},
{
expectedDiffID: "sha256:1018c7d3584c4f7fa3ef4486d1a6a11b93956b9d8bfe0898a3e0fbd248c984d8", // from testdata/exporter/container/layers/some-extended-dir/run/sha256_<c72eda1c>/blobs/sha256/0fb9b88c9cbe9f11b4c8da645f390df59f5949632985a0bfc2a842ef17b2ad18 after un-compressing and zeroing timestamps
layerIndex: 2,
},
}
for _, tc := range testCases {
h.AssertEq(t, inspect.RootFS.Layers[tc.layerIndex], tc.expectedDiffID)
}
t.Log("sets the layers metadata label according to the new spec")
var lmd files.LayersMetadata
lmdJSON := inspect.Config.Labels["io.buildpacks.lifecycle.metadata"]
h.AssertNil(t, json.Unmarshal([]byte(lmdJSON), &lmd))
h.AssertEq(t, lmd.RunImage.Image, exportTest.targetRegistry.fixtures.ReadOnlyRunImage) // from analyzed.toml
h.AssertEq(t, lmd.RunImage.Mirrors, []string{"mirror1", "mirror2"}) // from run.toml
h.AssertEq(t, lmd.RunImage.TopLayer, runImageFixtureTopLayerSHA)
h.AssertEq(t, lmd.RunImage.Reference, strings.TrimPrefix(runImageFixtureSHA, "sha256:"))
})
})
when("SOURCE_DATE_EPOCH is set", func() {
it("app is created with config CreatedAt set to SOURCE_DATE_EPOCH", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.9"), "SOURCE_DATE_EPOCH support added in 0.9")
expectedTime := time.Date(2022, 1, 5, 5, 5, 5, 0, time.UTC)
exportFlags := []string{"-daemon"}
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = "some-exported-image-" + h.RandString(10)
exportArgs = append(exportArgs, exportedImageName)
output := h.DockerRun(t,
exportImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+exportRegAuthConfig,
"--env", "SOURCE_DATE_EPOCH="+fmt.Sprintf("%d", expectedTime.Unix()),
"--network", exportRegNetwork,
)...),
h.WithArgs(exportArgs...),
)
h.AssertStringContains(t, output, "Saving "+exportedImageName)
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, expectedTime)
})
})
})
when("registry case", func() {
when("first build", func() {
when("app", func() {
it("is created", func() {
var exportFlags []string
if api.MustParse(platformAPI).LessThan("0.7") {
exportFlags = append(exportFlags, []string{"-run-image", exportRegFixtures.ReadOnlyRunImage}...)
}
var exportedImageName string
it.After(func() {
_, _, _ = h.RunE(exec.Command("docker", "rmi", exportedImageName)) // #nosec G204
})
it("app is created", func() {
var exportFlags []string
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
exportArgs = append(exportArgs, exportedImageName)
output := h.DockerRun(t,
exportImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+exportRegAuthConfig,
"--network", exportRegNetwork,
),
h.WithArgs(exportArgs...),
)
h.AssertStringContains(t, output, "Saving "+exportedImageName)
h.Run(t, exec.Command("docker", "pull", exportedImageName))
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, imgutil.NormalizedDateTime)
})
when("registry is insecure", func() {
it.Before(func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "")
})
it("uses http protocol", func() {
var exportFlags []string
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = exportTest.RegRepoName("some-insecure-exported-image-" + h.RandString(10))
exportArgs = append(exportArgs, exportedImageName)
insecureRegistry := "host.docker.internal/bar"
insecureAnalyzed := "/layers/analyzed_insecure.toml"
_, _, err := h.DockerRunWithError(t,
exportImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_INSECURE_REGISTRIES="+insecureRegistry,
"--env", "CNB_ANALYZED_PATH="+insecureAnalyzed,
"--network", exportRegNetwork,
),
h.WithArgs(exportArgs...),
)
h.AssertStringContains(t, err.Error(), "http://host.docker.internal")
})
})
when("SOURCE_DATE_EPOCH is set", func() {
it("app is created with config CreatedAt set to SOURCE_DATE_EPOCH", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.9"), "SOURCE_DATE_EPOCH support added in 0.9")
expectedTime := time.Date(2022, 1, 5, 5, 5, 5, 0, time.UTC)
var exportFlags []string
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
exportArgs = append(exportArgs, exportedImageName)
output := h.DockerRun(t,
exportImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+exportRegAuthConfig,
"--env", "SOURCE_DATE_EPOCH="+fmt.Sprintf("%d", expectedTime.Unix()),
"--network", exportRegNetwork,
),
h.WithArgs(exportArgs...),
)
h.AssertStringContains(t, output, "Saving "+exportedImageName)
h.Run(t, exec.Command("docker", "pull", exportedImageName))
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, expectedTime)
})
})
// FIXME: move this out of the registry block
when("cache", func() {
when("image case", func() {
it("cache is created", func() {
cacheImageName := exportTest.RegRepoName("some-cache-image-" + h.RandString(10))
exportFlags := []string{"-cache-image", cacheImageName}
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
exportArgs = append(exportArgs, exportedImageName)
@ -119,20 +331,16 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
h.WithArgs(exportArgs...),
)
h.AssertStringContains(t, output, "Saving "+exportedImageName)
// To detect whether the export of cacheImage and exportedImage is successful
h.Run(t, exec.Command("docker", "pull", exportedImageName))
assertImageOSAndArch(t, exportedImageName, exportTest)
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, imgutil.NormalizedDateTime)
h.Run(t, exec.Command("docker", "pull", cacheImageName))
})
})
when("cache", func() {
when("cache image case", func() {
it("is created", func() {
cacheImageName := exportTest.RegRepoName("some-cache-image-" + h.RandString(10))
exportFlags := []string{"-cache-image", cacheImageName}
if api.MustParse(platformAPI).LessThan("0.7") {
exportFlags = append(exportFlags, "-run-image", exportRegFixtures.ReadOnlyRunImage)
}
when("parallel export is enabled", func() {
it("cache is created", func() {
cacheImageName := exportTest.RegRepoName("some-cache-image-" + h.RandString(10))
exportFlags := []string{"-cache-image", cacheImageName, "-parallel"}
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
exportArgs = append(exportArgs, exportedImageName)
@ -149,31 +357,321 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
h.AssertStringContains(t, output, "Saving "+exportedImageName)
h.Run(t, exec.Command("docker", "pull", exportedImageName))
assertImageOSAndArch(t, exportedImageName, exportTest)
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, imgutil.NormalizedDateTime)
h.Run(t, exec.Command("docker", "pull", cacheImageName))
})
})
when("cache is provided but no data was cached", func() {
it("cache is created with an empty layer", func() {
cacheImageName := exportTest.RegRepoName("some-empty-cache-image-" + h.RandString(10))
exportFlags := []string{"-cache-image", cacheImageName, "-layers", "/other_layers"}
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
exportArgs = append(exportArgs, exportedImageName)
output := h.DockerRun(t,
exportImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+exportRegAuthConfig,
"--network", exportRegNetwork,
),
h.WithArgs(exportArgs...),
)
h.AssertStringContains(t, output, "Saving "+exportedImageName)
testEmptyLayerSHA := calculateEmptyLayerSha(t)
// Retrieve the cache image from the ephemeral registry
h.Run(t, exec.Command("docker", "pull", cacheImageName))
logger := cmd.DefaultLogger
subject, err := cache.NewImageCacheFromName(cacheImageName, authn.DefaultKeychain, logger, cache.NewImageDeleter(cache.NewImageComparer(), logger, api.MustParse(platformAPI).LessThan("0.13")))
h.AssertNil(t, err)
//Assert the cache image was created with an empty layer
layer, err := subject.RetrieveLayer(testEmptyLayerSHA)
h.AssertNil(t, err)
defer layer.Close()
})
})
})
when("directory case", func() {
when("original cache was corrupted", func() {
var cacheDir string
it.Before(func() {
var err error
cacheDir, err = os.MkdirTemp("", "cache")
h.AssertNil(t, err)
h.AssertNil(t, os.Chmod(cacheDir, 0777)) // Override umask
cacheFixtureDir := filepath.Join("testdata", "exporter", "cache-dir")
h.AssertNil(t, fsutil.Copy(cacheFixtureDir, cacheDir))
// We have to pre-create the tar files so that their digests do not change due to timestamps
// But, ':' in the filepath on Windows is not allowed
h.AssertNil(t, os.Rename(
filepath.Join(cacheDir, "committed", "sha256_258dfa0cc987efebc17559694866ebc91139e7c0e574f60d1d4092f53d7dff59.tar"),
filepath.Join(cacheDir, "committed", "sha256:258dfa0cc987efebc17559694866ebc91139e7c0e574f60d1d4092f53d7dff59.tar"),
))
})
it.After(func() {
_ = os.RemoveAll(cacheDir)
})
it("overwrites the original layer", func() {
exportFlags := []string{
"-cache-dir", "/cache",
"-log-level", "debug",
}
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
exportArgs = append(exportArgs, exportedImageName)
output := h.DockerRun(t,
exportImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+exportRegAuthConfig,
"--network", exportRegNetwork,
"--volume", fmt.Sprintf("%s:/cache", cacheDir),
),
h.WithArgs(exportArgs...),
)
h.AssertStringContains(t, output, "Skipping reuse for layer corrupted_buildpack:corrupted-layer: expected layer contents to have SHA 'sha256:258dfa0cc987efebc17559694866ebc91139e7c0e574f60d1d4092f53d7dff59'; found 'sha256:9e0b77ed599eafdab8611f7eeefef084077f91f02f1da0a3870c7ff20a08bee8'")
h.AssertStringContains(t, output, "Saving "+exportedImageName)
h.Run(t, exec.Command("docker", "pull", exportedImageName))
defer h.Run(t, exec.Command("docker", "image", "rm", exportedImageName))
// Verify the app has the correct sha for the layer
inspect, _, err := h.DockerCli(t).ImageInspectWithRaw(context.TODO(), exportedImageName)
h.AssertNil(t, err)
var lmd files.LayersMetadata
lmdJSON := inspect.Config.Labels["io.buildpacks.lifecycle.metadata"]
h.AssertNil(t, json.Unmarshal([]byte(lmdJSON), &lmd))
h.AssertEq(t, lmd.Buildpacks[2].Layers["corrupted-layer"].SHA, "sha256:258dfa0cc987efebc17559694866ebc91139e7c0e574f60d1d4092f53d7dff59")
// Verify the cache has correct contents now
foundDiffID, err := func() (string, error) {
layerPath := filepath.Join(cacheDir, "committed", "sha256:258dfa0cc987efebc17559694866ebc91139e7c0e574f60d1d4092f53d7dff59.tar")
layerRC, err := os.Open(layerPath)
if err != nil {
return "", err
}
defer func() {
_ = layerRC.Close()
}()
hasher := sha256.New()
if _, err = io.Copy(hasher, layerRC); err != nil {
return "", errors.Wrap(err, "hashing layer")
}
foundDiffID := "sha256:" + hex.EncodeToString(hasher.Sum(make([]byte, 0, hasher.Size())))
return foundDiffID, nil
}()
h.AssertNil(t, err)
h.AssertEq(t, foundDiffID, "sha256:258dfa0cc987efebc17559694866ebc91139e7c0e574f60d1d4092f53d7dff59")
})
})
})
})
when("using extensions", func() {
it.Before(func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "")
})
it("app is created from the extended run image", func() {
exportFlags := []string{
"-analyzed", "/layers/run-image-extended-analyzed.toml",
"-extended", "/layers/some-extended-dir",
"-log-level", "debug",
"-run", "/cnb/run.toml",
}
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
exportArgs = append(exportArgs, exportedImageName)
// get run image SHA & top layer
ref, imageAuth, err := auth.ReferenceForRepoName(authn.DefaultKeychain, exportTest.targetRegistry.fixtures.ReadOnlyRunImage)
h.AssertNil(t, err)
remoteImage, err := remote.Image(ref, remote.WithAuth(imageAuth))
h.AssertNil(t, err)
layers, err := remoteImage.Layers()
h.AssertNil(t, err)
runImageFixtureTopLayerSHA, err := layers[len(layers)-1].DiffID()
h.AssertNil(t, err)
runImageFixtureSHA, err := remoteImage.Digest()
h.AssertNil(t, err)
experimentalMode := "warn"
if api.MustParse(platformAPI).AtLeast("0.13") {
experimentalMode = "error"
}
output := h.DockerRun(t,
exportImage,
h.WithFlags(
"--env", "CNB_EXPERIMENTAL_MODE="+experimentalMode,
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_REGISTRY_AUTH="+exportRegAuthConfig,
"--network", exportRegNetwork,
),
h.WithArgs(exportArgs...),
)
h.AssertStringContains(t, output, "Saving "+exportedImageName)
h.Run(t, exec.Command("docker", "pull", exportedImageName))
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, imgutil.NormalizedDateTime)
t.Log("bases the exported image on the extended run image")
ref, imageAuth, err = auth.ReferenceForRepoName(authn.DefaultKeychain, exportedImageName)
h.AssertNil(t, err)
remoteImage, err = remote.Image(ref, remote.WithAuth(imageAuth))
h.AssertNil(t, err)
configFile, err := remoteImage.ConfigFile()
h.AssertNil(t, err)
h.AssertEq(t, configFile.Config.Labels["io.buildpacks.rebasable"], "false") // from testdata/exporter/container/layers/some-extended-dir/run/sha256_<sha>/blobs/sha256/<config>
t.Log("Adds extension layers")
layers, err = remoteImage.Layers()
h.AssertNil(t, err)
type testCase struct {
expectedDigest string
layerIndex int
}
testCases := []testCase{
{
expectedDigest: "sha256:08e7ad5ce17cf5e5f70affe68b341a93de86ee2ba074932c3a05b8770f66d772", // from testdata/exporter/container/layers/some-extended-dir/run/sha256_<c72eda1c>/blobs/sha256/65c2873d397056a5cb4169790654d787579b005f18b903082b177d4d9b4aecf5 after un-compressing, zeroing timestamps, and re-compressing
layerIndex: 1,
},
{
expectedDigest: "sha256:0e74ef444ea437147e3fa0ce2aad371df5380c26b96875ae07b9b67f44cdb2ee", // from testdata/exporter/container/layers/some-extended-dir/run/sha256_<c72eda1c>/blobs/sha256/0fb9b88c9cbe9f11b4c8da645f390df59f5949632985a0bfc2a842ef17b2ad18 after un-compressing, zeroing timestamps, and re-compressing
layerIndex: 2,
},
}
for _, tc := range testCases {
layer := layers[tc.layerIndex]
digest, err := layer.Digest()
h.AssertNil(t, err)
h.AssertEq(t, digest.String(), tc.expectedDigest)
}
t.Log("sets the layers metadata label according to the new spec")
var lmd files.LayersMetadata
lmdJSON := configFile.Config.Labels["io.buildpacks.lifecycle.metadata"]
h.AssertNil(t, json.Unmarshal([]byte(lmdJSON), &lmd))
h.AssertEq(t, lmd.RunImage.Image, exportTest.targetRegistry.fixtures.ReadOnlyRunImage) // from analyzed.toml
h.AssertEq(t, lmd.RunImage.Mirrors, []string{"mirror1", "mirror2"}) // from run.toml
h.AssertEq(t, lmd.RunImage.TopLayer, runImageFixtureTopLayerSHA.String())
h.AssertEq(t, lmd.RunImage.Reference, fmt.Sprintf("%s@%s", exportTest.targetRegistry.fixtures.ReadOnlyRunImage, runImageFixtureSHA.String()))
})
})
})
when("layout case", func() {
var (
containerName string
err error
layoutDir string
tmpDir string
exportedImageName string
)
when("experimental mode is enabled", func() {
it.Before(func() {
// create the directory to save all OCI images on disk
tmpDir, err = os.MkdirTemp("", "layout")
h.AssertNil(t, err)
containerName = "test-container-" + h.RandString(10)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
// removes all images created
os.RemoveAll(tmpDir)
})
when("using a custom layout directory", func() {
it.Before(func() {
exportedImageName = "my-custom-layout-app"
layoutDir = filepath.Join(path.RootDir, "my-layout-dir")
})
it("app is created", func() {
var exportFlags []string
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "Platform API < 0.12 does not accept a -layout flag")
exportFlags = append(exportFlags, []string{"-layout", "-layout-dir", layoutDir, "-analyzed", "/layers/layout-analyzed.toml"}...)
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
exportArgs = append(exportArgs, exportedImageName)
output := h.DockerRunAndCopy(t, containerName, tmpDir, layoutDir, exportImage,
h.WithFlags(
"--env", "CNB_EXPERIMENTAL_MODE=warn",
"--env", "CNB_PLATFORM_API="+platformAPI,
),
h.WithArgs(exportArgs...))
h.AssertStringContains(t, output, "Saving /my-layout-dir/index.docker.io/library/my-custom-layout-app/latest")
// assert the image was saved on disk in OCI layout format
index := h.ReadIndexManifest(t, filepath.Join(tmpDir, layoutDir, "index.docker.io", "library", exportedImageName, "latest"))
h.AssertEq(t, len(index.Manifests), 1)
})
})
})
when("experimental mode is not enabled", func() {
it.Before(func() {
layoutDir = filepath.Join(path.RootDir, "layout-dir")
})
it("errors", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "Platform API < 0.12 does not accept a -layout flag")
cmd := exec.Command(
"docker", "run", "--rm",
"--env", "CNB_PLATFORM_API="+platformAPI,
exportImage,
ctrPath(exporterPath),
"-layout",
"-layout-dir", layoutDir,
"some-image",
) // #nosec G204
output, err := cmd.CombinedOutput()
h.AssertNotNil(t, err)
expected := "experimental features are disabled by CNB_EXPERIMENTAL_MODE=error"
h.AssertStringContains(t, string(output), expected)
})
})
})
}
}
func assertImageOSAndArch(t *testing.T, imageName string, phaseTest *PhaseTest) {
inspect, _, err := h.DockerCli(t).ImageInspectWithRaw(context.TODO(), imageName)
func assertDaemonImageDoesNotHaveHistory(t *testing.T, repoName string) {
history, err := h.DockerCli(t).ImageHistory(context.TODO(), repoName)
h.AssertNil(t, err)
h.AssertEq(t, inspect.Os, phaseTest.targetDaemon.os)
h.AssertEq(t, inspect.Architecture, phaseTest.targetDaemon.arch)
for _, hs := range history {
h.AssertEq(t, hs.Created, imgutil.NormalizedDateTime.Unix())
h.AssertEq(t, hs.CreatedBy, "")
}
}
func updateAnalyzedTOMLFixturesWithRegRepoName(t *testing.T, phaseTest *PhaseTest) {
placeHolderPath := filepath.Join("testdata", "exporter", "container", "layers", "analyzed.toml.placeholder")
analyzedMD := assertAnalyzedMetadata(t, placeHolderPath)
analyzedMD.RunImage = &platform.ImageIdentifier{Reference: phaseTest.targetRegistry.fixtures.ReadOnlyRunImage}
lifecycle.WriteTOML(strings.TrimSuffix(placeHolderPath, ".placeholder"), analyzedMD)
placeHolderPath = filepath.Join("testdata", "exporter", "container", "layers", "some-analyzed.toml.placeholder")
analyzedMD = assertAnalyzedMetadata(t, placeHolderPath)
analyzedMD.PreviousImage = &platform.ImageIdentifier{Reference: phaseTest.targetRegistry.fixtures.SomeAppImage}
analyzedMD.RunImage = &platform.ImageIdentifier{Reference: phaseTest.targetRegistry.fixtures.ReadOnlyRunImage}
lifecycle.WriteTOML(strings.TrimSuffix(placeHolderPath, ".placeholder"), analyzedMD)
func assertDaemonImageHasHistory(t *testing.T, repoName string, expectedHistory []string) {
history, err := h.DockerCli(t).ImageHistory(context.TODO(), repoName)
h.AssertNil(t, err)
h.AssertEq(t, len(history), len(expectedHistory))
for idx, hs := range history {
h.AssertEq(t, hs.Created, imgutil.NormalizedDateTime.Unix())
h.AssertEq(t, hs.CreatedBy, expectedHistory[idx])
}
}
func calculateEmptyLayerSha(t *testing.T) string {
tmpDir, err := os.MkdirTemp("", "")
h.AssertNil(t, err)
testLayerEmptyPath := filepath.Join(tmpDir, "empty.tar")
h.AssertNil(t, os.WriteFile(testLayerEmptyPath, []byte{}, 0600))
return "sha256:" + h.ComputeSHA256ForFile(t, testLayerEmptyPath)
}

288
acceptance/extender_test.go Normal file
View File

@ -0,0 +1,288 @@
//go:build acceptance
package acceptance
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"testing"
"github.com/buildpacks/imgutil/layout/sparse"
"github.com/google/go-containerregistry/pkg/authn"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/layout"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
"github.com/buildpacks/lifecycle/api"
"github.com/buildpacks/lifecycle/auth"
"github.com/buildpacks/lifecycle/cmd"
"github.com/buildpacks/lifecycle/platform/files"
h "github.com/buildpacks/lifecycle/testhelpers"
)
var (
extendImage string
extendRegAuthConfig string
extendRegNetwork string
extenderPath string
extendDaemonFixtures *daemonImageFixtures
extendRegFixtures *regImageFixtures
extendTest *PhaseTest
)
const (
// Log message emitted by kaniko;
// if we provide cache directory as an option, kaniko looks there for the base image as a tarball;
// however the base image is in OCI layout format, so we fail to initialize the base image;
// we manage to provide the base image because we override image.RetrieveRemoteImage,
// but the log message could be confusing to end users, hence we check that it is not printed.
msgErrRetrievingImageFromCache = "Error while retrieving image from cache"
)
func TestExtender(t *testing.T) {
testImageDockerContext := filepath.Join("testdata", "extender")
extendTest = NewPhaseTest(t, "extender", testImageDockerContext)
extendTest.Start(t)
defer extendTest.Stop(t)
extendImage = extendTest.testImageRef
extenderPath = extendTest.containerBinaryPath
extendRegAuthConfig = extendTest.targetRegistry.authConfig
extendRegNetwork = extendTest.targetRegistry.network
extendDaemonFixtures = extendTest.targetDaemon.fixtures
extendRegFixtures = extendTest.targetRegistry.fixtures
for _, platformAPI := range api.Platform.Supported {
if platformAPI.LessThan("0.10") {
continue
}
spec.Run(t, "acceptance-extender/"+platformAPI.String(), testExtenderFunc(platformAPI.String()), spec.Parallel(), spec.Report(report.Terminal{}))
}
}
func testExtenderFunc(platformAPI string) func(t *testing.T, when spec.G, it spec.S) {
return func(t *testing.T, when spec.G, it spec.S) {
var generatedDir = "/layers/generated"
it.Before(func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.10"), "")
if api.MustParse(platformAPI).AtLeast("0.13") {
generatedDir = "/layers/generated-with-contexts"
}
})
when("kaniko case", func() {
var extendedDir, kanikoDir, analyzedPath string
it.Before(func() {
var err error
extendedDir, err = os.MkdirTemp("", "lifecycle-acceptance")
h.AssertNil(t, err)
kanikoDir, err = os.MkdirTemp("", "lifecycle-acceptance")
h.AssertNil(t, err)
// push base image to test registry
h.Run(t, exec.Command("docker", "tag", extendImage, extendTest.RegRepoName(extendImage)))
h.AssertNil(t, h.PushImage(h.DockerCli(t), extendTest.RegRepoName(extendImage), extendTest.targetRegistry.registry.EncodedLabeledAuth()))
// mimic what the restorer would have done in the previous phase:
// warm kaniko cache
// get remote image
os.Setenv("DOCKER_CONFIG", extendTest.targetRegistry.dockerConfigDir)
ref, auth, err := auth.ReferenceForRepoName(authn.DefaultKeychain, extendTest.RegRepoName(extendImage))
h.AssertNil(t, err)
remoteImage, err := remote.Image(ref, remote.WithAuth(auth))
h.AssertNil(t, err)
baseImageHash, err := remoteImage.Digest()
h.AssertNil(t, err)
baseImageDigest := baseImageHash.String()
baseCacheDir := filepath.Join(kanikoDir, "cache", "base")
h.AssertNil(t, os.MkdirAll(baseCacheDir, 0755))
// write sparse image
layoutImage, err := sparse.NewImage(filepath.Join(baseCacheDir, baseImageDigest), remoteImage)
h.AssertNil(t, err)
h.AssertNil(t, layoutImage.Save())
// write image reference in analyzed.toml
analyzedMD := files.Analyzed{
BuildImage: &files.ImageIdentifier{
Reference: fmt.Sprintf("%s@%s", extendTest.RegRepoName(extendImage), baseImageDigest),
},
RunImage: &files.RunImage{
Reference: fmt.Sprintf("%s@%s", extendTest.RegRepoName(extendImage), baseImageDigest),
Extend: true,
},
}
analyzedPath = h.TempFile(t, "", "analyzed.toml")
h.AssertNil(t, files.Handler.WriteAnalyzed(analyzedPath, &analyzedMD, cmd.DefaultLogger))
})
it.After(func() {
_ = os.RemoveAll(kanikoDir)
_ = os.RemoveAll(extendedDir)
})
when("extending the build image", func() {
it("succeeds", func() {
extendArgs := []string{
ctrPath(extenderPath),
"-analyzed", "/layers/analyzed.toml",
"-generated", generatedDir,
"-log-level", "debug",
"-gid", "1000",
"-uid", "1234",
}
extendFlags := []string{
"--env", "CNB_PLATFORM_API=" + platformAPI,
"--volume", fmt.Sprintf("%s:/layers/analyzed.toml", analyzedPath),
"--volume", fmt.Sprintf("%s:/kaniko", kanikoDir),
}
t.Log("first build extends the build image by running Dockerfile commands")
firstOutput := h.DockerRunWithCombinedOutput(t,
extendImage,
h.WithFlags(extendFlags...),
h.WithArgs(extendArgs...),
)
h.AssertStringDoesNotContain(t, firstOutput, msgErrRetrievingImageFromCache)
h.AssertStringContains(t, firstOutput, "ca-certificates")
h.AssertStringContains(t, firstOutput, "Hello Extensions buildpack\ncurl") // output by buildpack, shows that curl was installed on the build image
t.Log("sets environment variables from the extended build image in the build context")
h.AssertStringContains(t, firstOutput, "CNB_STACK_ID for buildpack: stack-id-from-ext-tree")
h.AssertStringContains(t, firstOutput, "HOME for buildpack: /home/cnb")
t.Log("cleans the kaniko directory")
fis, err := os.ReadDir(kanikoDir)
h.AssertNil(t, err)
h.AssertEq(t, len(fis), 1) // 1: /kaniko/cache
t.Log("second build extends the build image by pulling from the cache directory")
secondOutput := h.DockerRunWithCombinedOutput(t,
extendImage,
h.WithFlags(extendFlags...),
h.WithArgs(extendArgs...),
)
h.AssertStringDoesNotContain(t, secondOutput, msgErrRetrievingImageFromCache)
h.AssertStringDoesNotContain(t, secondOutput, "ca-certificates") // shows that first cache layer was used
h.AssertStringDoesNotContain(t, secondOutput, "No cached layer found for cmd RUN apt-get update && apt-get install -y tree") // shows that second cache layer was used
h.AssertStringContains(t, secondOutput, "Hello Extensions buildpack\ncurl") // output by buildpack, shows that curl is still installed in the unpacked cached layer
})
})
when("extending the run image", func() {
it.Before(func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "Platform API < 0.12 does not support run image extension")
})
it("succeeds", func() {
extendArgs := []string{
ctrPath(extenderPath),
"-analyzed", "/layers/analyzed.toml",
"-extended", "/layers/extended",
"-generated", generatedDir,
"-kind", "run",
"-log-level", "debug",
"-gid", "1000",
"-uid", "1234",
}
extendFlags := []string{
"--env", "CNB_PLATFORM_API=" + platformAPI,
"--volume", fmt.Sprintf("%s:/layers/analyzed.toml", analyzedPath),
"--volume", fmt.Sprintf("%s:/layers/extended", extendedDir),
"--volume", fmt.Sprintf("%s:/kaniko", kanikoDir),
}
t.Log("first build extends the run image by running Dockerfile commands")
firstOutput := h.DockerRunWithCombinedOutput(t,
extendImage,
h.WithFlags(extendFlags...),
h.WithArgs(extendArgs...),
)
h.AssertStringDoesNotContain(t, firstOutput, msgErrRetrievingImageFromCache)
h.AssertStringContains(t, firstOutput, "ca-certificates")
h.AssertStringContains(t, firstOutput, "No cached layer found for cmd RUN apt-get update && apt-get install -y tree")
t.Log("does not run the build phase")
h.AssertStringDoesNotContain(t, firstOutput, "Hello Extensions buildpack\ncurl")
t.Log("outputs extended image layers to the extended directory")
images, err := os.ReadDir(filepath.Join(extendedDir, "run"))
h.AssertNil(t, err)
h.AssertEq(t, len(images), 1) // sha256:<extended image digest>
assertExpectedImage(t, filepath.Join(extendedDir, "run", images[0].Name()), platformAPI)
t.Log("cleans the kaniko directory")
caches, err := os.ReadDir(kanikoDir)
h.AssertNil(t, err)
h.AssertEq(t, len(caches), 1) // 1: /kaniko/cache
t.Log("second build extends the build image by pulling from the cache directory")
secondOutput := h.DockerRunWithCombinedOutput(t,
extendImage,
h.WithFlags(extendFlags...),
h.WithArgs(extendArgs...),
)
h.AssertStringDoesNotContain(t, secondOutput, msgErrRetrievingImageFromCache)
h.AssertStringDoesNotContain(t, secondOutput, "ca-certificates") // shows that first cache layer was used
h.AssertStringDoesNotContain(t, secondOutput, "No cached layer found for cmd RUN apt-get update && apt-get install -y tree") // shows that second cache layer was used
t.Log("does not run the build phase")
h.AssertStringDoesNotContain(t, secondOutput, "Hello Extensions buildpack\ncurl")
t.Log("outputs extended image layers to the extended directory")
images, err = os.ReadDir(filepath.Join(extendedDir, "run"))
h.AssertNil(t, err)
h.AssertEq(t, len(images), 1) // sha256:<first extended image digest>
assertExpectedImage(t, filepath.Join(extendedDir, "run", images[0].Name()), platformAPI)
t.Log("cleans the kaniko directory")
caches, err = os.ReadDir(kanikoDir)
h.AssertNil(t, err)
h.AssertEq(t, len(caches), 1) // 1: /kaniko/cache
})
})
})
}
}
func assertExpectedImage(t *testing.T, imagePath, platformAPI string) {
image, err := readOCI(imagePath)
h.AssertNil(t, err)
configFile, err := image.ConfigFile()
h.AssertNil(t, err)
h.AssertEq(t, configFile.Config.Labels["io.buildpacks.rebasable"], "false")
layers, err := image.Layers()
h.AssertNil(t, err)
history := configFile.History
h.AssertEq(t, len(history), len(configFile.RootFS.DiffIDs))
if api.MustParse(platformAPI).AtLeast("0.13") {
h.AssertEq(t, len(layers), 7) // base (3), curl (2), tree (2)
h.AssertEq(t, history[3].CreatedBy, "Layer: 'RUN apt-get update && apt-get install -y curl', Created by extension: curl")
h.AssertEq(t, history[4].CreatedBy, "Layer: 'COPY run-file /', Created by extension: curl")
h.AssertEq(t, history[5].CreatedBy, "Layer: 'RUN apt-get update && apt-get install -y tree', Created by extension: tree")
h.AssertEq(t, history[6].CreatedBy, "Layer: 'COPY shared-file /shared-run', Created by extension: tree")
} else {
h.AssertEq(t, len(layers), 5) // base (3), curl (1), tree (1)
h.AssertEq(t, history[3].CreatedBy, "Layer: 'RUN apt-get update && apt-get install -y curl', Created by extension: curl")
h.AssertEq(t, history[4].CreatedBy, "Layer: 'RUN apt-get update && apt-get install -y tree', Created by extension: tree")
}
}
func readOCI(fromPath string) (v1.Image, error) {
layoutPath, err := layout.FromPath(fromPath)
if err != nil {
return nil, fmt.Errorf("getting layout from path: %w", err)
}
hash, err := v1.NewHash(filepath.Base(fromPath))
if err != nil {
return nil, fmt.Errorf("getting hash from reference '%s': %w", fromPath, err)
}
v1Image, err := layoutPath.Image(hash)
if err != nil {
return nil, fmt.Errorf("getting image from hash '%s': %w", hash.String(), err)
}
return v1Image, nil
}

View File

@ -4,7 +4,6 @@ import (
"fmt"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
@ -25,9 +24,6 @@ func TestLauncher(t *testing.T) {
launchTest = NewPhaseTest(t, "launcher", testImageDockerContext, withoutDaemonFixtures, withoutRegistry)
containerBinaryDir := filepath.Join("testdata", "launcher", "linux", "container", "cnb", "lifecycle")
if launchTest.targetDaemon.os == "windows" {
containerBinaryDir = filepath.Join("testdata", "launcher", "windows", "container", "cnb", "lifecycle")
}
withCustomContainerBinaryDir := func(_ *testing.T, phaseTest *PhaseTest) {
phaseTest.containerBinaryDir = containerBinaryDir
}
@ -41,304 +37,201 @@ func TestLauncher(t *testing.T) {
}
func testLauncher(t *testing.T, when spec.G, it spec.S) {
when("Buildpack API >= 0.5", func() {
when("exec.d", func() {
it("executes the binaries and modifies env before running profiles", func() {
cmd := exec.Command("docker", "run", "--rm",
"--env=VAR_FROM_EXEC_D=orig-val",
launchImage, "exec.d-checker")
when("exec.d", func() {
it("executes the binaries and modifies env before running profiles", func() {
cmd := exec.Command("docker", "run", "--rm", //nolint
"--env=CNB_PLATFORM_API=0.7",
"--entrypoint=exec.d-checker"+exe,
"--env=VAR_FROM_EXEC_D=orig-val",
launchImage)
helper := "helper" + exe
execDHelper := ctrPath("/layers", execDBpDir, "some_layer/exec.d", helper)
execDCheckerHelper := ctrPath("/layers", execDBpDir, "some_layer/exec.d/exec.d-checker", helper)
workDir := ctrPath("/workspace")
helper := "helper" + exe
execDHelper := ctrPath("/layers", execDBpDir, "some_layer/exec.d", helper)
execDCheckerHelper := ctrPath("/layers", execDBpDir, "some_layer/exec.d/exec.d-checker", helper)
workDir := ctrPath("/workspace")
expected := fmt.Sprintf("%s was executed\n", execDHelper)
expected += fmt.Sprintf("Exec.d Working Dir: %s\n", workDir)
expected += fmt.Sprintf("%s was executed\n", execDCheckerHelper)
expected += fmt.Sprintf("Exec.d Working Dir: %s\n", workDir)
expected += "sourced bp profile\n"
expected += "sourced app profile\n"
expected += "VAR_FROM_EXEC_D: orig-val:val-from-exec.d:val-from-exec.d-for-process-type-exec.d-checker"
expected := fmt.Sprintf("%s was executed\n", execDHelper)
expected += fmt.Sprintf("Exec.d Working Dir: %s\n", workDir)
expected += fmt.Sprintf("%s was executed\n", execDCheckerHelper)
expected += fmt.Sprintf("Exec.d Working Dir: %s\n", workDir)
expected += "sourced bp profile\n"
expected += "sourced app profile\n"
expected += "VAR_FROM_EXEC_D: orig-val:val-from-exec.d:val-from-exec.d-for-process-type-exec.d-checker"
assertOutput(t, cmd, expected)
})
assertOutput(t, cmd, expected)
})
})
when("Platform API >= 0.4", func() {
when("entrypoint is a process", func() {
when("entrypoint is a process", func() {
it("launches that process", func() {
cmd := exec.Command("docker", "run", "--rm", //nolint
"--entrypoint=web",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage)
assertOutput(t, cmd, "Executing web process-type")
})
when("process contains a period", func() {
it("launches that process", func() {
cmd := exec.Command("docker", "run", "--rm",
"--entrypoint=web",
"--entrypoint=process.with.period"+exe,
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage)
assertOutput(t, cmd, "Executing web process-type")
})
it("appends any args to the process args", func() {
cmd := exec.Command("docker", "run", "--rm",
"--entrypoint=web",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage, "with user provided args")
if runtime.GOOS == "windows" {
assertOutput(t, cmd, `Executing web process-type "with user provided args"`)
} else {
assertOutput(t, cmd, "Executing web process-type with user provided args")
}
assertOutput(t, cmd, "Executing process.with.period process-type")
})
})
when("entrypoint is a not a process", func() {
it("builds a process from the arguments", func() {
cmd := exec.Command("docker", "run", "--rm",
"--entrypoint=launcher",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage, "--", "env")
if runtime.GOOS == "windows" {
cmd = exec.Command("docker", "run", "--rm",
`--entrypoint=launcher`,
"--env=CNB_PLATFORM_API=0.4",
launchImage, "--", "cmd", "/c", "set",
)
}
assertOutput(t, cmd,
"SOME_VAR=some-bp-val",
"OTHER_VAR=other-bp-val",
)
})
})
when("CNB_PROCESS_TYPE is set", func() {
it("should warn", func() {
cmd := exec.Command("docker", "run", "--rm",
"--env=CNB_PROCESS_TYPE=direct-process",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
"--env=CNB_NO_COLOR=true",
launchImage,
)
out, err := cmd.CombinedOutput()
h.AssertNotNil(t, err)
h.AssertStringContains(t, string(out), "Warning: CNB_PROCESS_TYPE is not supported in Platform API "+latestPlatformAPI)
h.AssertStringContains(t, string(out), `Warning: Run with ENTRYPOINT 'direct-process' to invoke the 'direct-process' process type`)
h.AssertStringContains(t, string(out), "ERROR: failed to launch: determine start command: when there is no default process a command is required")
})
it("appends any args to the process args", func() {
cmd := exec.Command( //nolint
"docker", "run", "--rm",
"--entrypoint=web",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage, "with user provided args",
)
assertOutput(t, cmd, "Executing web process-type with user provided args")
})
})
when("Platform API < 0.4", func() {
when("there is no CMD provided", func() {
when("CNB_PROCESS_TYPE is NOT set", func() {
it("web is the default process-type", func() {
cmd := exec.Command("docker", "run", "--rm", launchImage)
assertOutput(t, cmd, "Executing web process-type")
})
})
when("entrypoint is a not a process", func() {
it("builds a process from the arguments", func() {
cmd := exec.Command( //nolint
"docker", "run", "--rm",
"--entrypoint=launcher",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage, "--",
"env",
)
when("CNB_PROCESS_TYPE is set", func() {
it("should run the specified CNB_PROCESS_TYPE", func() {
cmd := exec.Command("docker", "run", "--rm", "--env", "CNB_PROCESS_TYPE=direct-process", launchImage)
if runtime.GOOS == "windows" {
assertOutput(t, cmd, "Usage: ping")
} else {
assertOutput(t, cmd, "Executing direct-process process-type")
}
})
})
assertOutput(t, cmd,
"SOME_VAR=some-bp-val",
"OTHER_VAR=other-bp-val",
)
})
})
when("process-type provided in CMD", func() {
it("launches that process-type", func() {
cmd := exec.Command("docker", "run", "--rm", launchImage, "direct-process")
expected := "Executing direct-process process-type"
if runtime.GOOS == "windows" {
expected = "Usage: ping"
}
assertOutput(t, cmd, expected)
})
it("sets env vars from process specific directories", func() {
cmd := exec.Command("docker", "run", "--rm", launchImage, "worker")
expected := "worker-process-val"
assertOutput(t, cmd, expected)
})
})
when("process is direct=false", func() {
when("the process type has no args", func() {
it("runs command as script", func() {
h.SkipIf(t, runtime.GOOS == "windows", "scripts are unsupported on windows")
cmd := exec.Command("docker", "run", "--rm",
"--env", "VAR1=val1",
"--env", "VAR2=val with space",
launchImage, "indirect-process-with-script",
)
assertOutput(t, cmd, "'val1' 'val with space'")
})
})
when("the process type has args", func() {
when("buildpack API 0.4", func() {
// buildpack API is determined by looking up the API of the process buildpack in metadata.toml
it("command and args become shell-parsed tokens in a script", func() {
var val2 string
if runtime.GOOS == "windows" {
val2 = `"val with space"` // windows values with spaces must contain quotes
} else {
val2 = "val with space"
}
cmd := exec.Command("docker", "run", "--rm",
"--env", "VAR1=val1",
"--env", "VAR2="+val2,
launchImage, "indirect-process-with-args",
) // #nosec G204
assertOutput(t, cmd, "'val1' 'val with space'")
})
})
when("buildpack API < 0.4", func() {
// buildpack API is determined by looking up the API of the process buildpack in metadata.toml
it("args become arguments to bash", func() {
h.SkipIf(t, runtime.GOOS == "windows", "scripts are unsupported on windows")
cmd := exec.Command("docker", "run", "--rm",
launchImage, "legacy-indirect-process-with-args",
)
assertOutput(t, cmd, "'arg' 'arg with spaces'")
})
it("script must be explicitly written to accept bash args", func() {
h.SkipIf(t, runtime.GOOS == "windows", "scripts are unsupported on windows")
cmd := exec.Command("docker", "run", "--rm",
launchImage, "legacy-indirect-process-with-incorrect-args",
)
output, err := cmd.CombinedOutput()
h.AssertNotNil(t, err)
h.AssertStringContains(t, string(output), "printf: usage: printf [-v var] format [arguments]")
})
})
})
it("sources scripts from process specific directories", func() {
cmd := exec.Command("docker", "run", "--rm", launchImage, "profile-checker")
expected := "sourced bp profile\nsourced bp profile-checker profile\nsourced app profile\nval-from-profile"
assertOutput(t, cmd, expected)
})
})
it("respects CNB_APP_DIR and CNB_LAYERS_DIR environment variables", func() {
when("CNB_PROCESS_TYPE is set", func() {
it("should warn", func() {
cmd := exec.Command("docker", "run", "--rm",
"--env", "CNB_APP_DIR=/other-app",
"--env", "CNB_LAYERS_DIR=/other-layers",
launchImage)
assertOutput(t, cmd, "sourced other app profile\nExecuting other-layers web process-type")
"--env=CNB_PROCESS_TYPE=direct-process",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
"--env=CNB_NO_COLOR=true",
launchImage,
)
out, err := cmd.CombinedOutput()
h.AssertNotNil(t, err)
h.AssertStringContains(t, string(out), "Warning: CNB_PROCESS_TYPE is not supported in Platform API "+latestPlatformAPI)
h.AssertStringContains(t, string(out), `Warning: Run with ENTRYPOINT 'direct-process' to invoke the 'direct-process' process type`)
h.AssertStringContains(t, string(out), "ERROR: failed to launch: determine start command: when there is no default process a command is required")
})
})
when("provided CMD is not a process-type", func() {
it("sources profiles and executes the command in a shell", func() {
cmd := exec.Command( //nolint
"docker", "run", "--rm",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage,
"echo", "something",
)
assertOutput(t, cmd, "sourced bp profile\nsourced app profile\nsomething")
})
when("provided CMD is not a process-type", func() {
it("sources profiles and executes the command in a shell", func() {
cmd := exec.Command("docker", "run", "--rm", launchImage, "echo", "something")
assertOutput(t, cmd, "sourced bp profile\nsourced app profile\nsomething")
})
it("sets env vars from layers", func() {
cmd := exec.Command("docker", "run", "--rm", launchImage, "echo", "$SOME_VAR", "$OTHER_VAR", "$WORKER_VAR")
if runtime.GOOS == "windows" {
cmd = exec.Command("docker", "run", "--rm", launchImage, "echo", "%SOME_VAR%", "%OTHER_VAR%", "%WORKER_VAR%")
}
assertOutput(t, cmd, "sourced bp profile\nsourced app profile\nsome-bp-val other-bp-val worker-no-process-val")
})
it("passes through env vars from user, excluding excluded vars", func() {
args := []string{"echo", "$SOME_USER_VAR, $CNB_APP_DIR, $OTHER_VAR"}
if runtime.GOOS == "windows" {
args = []string{"echo", "%SOME_USER_VAR%, %CNB_APP_DIR%, %OTHER_VAR%"}
}
cmd := exec.Command("docker",
append(
[]string{
"run", "--rm",
"--env", "CNB_APP_DIR=/workspace",
"--env", "SOME_USER_VAR=some-user-val",
"--env", "OTHER_VAR=other-user-val",
launchImage,
},
args...)...,
) // #nosec G204
if runtime.GOOS == "windows" {
// windows values with spaces will contain quotes
// empty values on windows preserve variable names instead of interpolating to empty strings
assertOutput(t, cmd, "sourced bp profile\nsourced app profile\n\"some-user-val, %CNB_APP_DIR%, other-user-val**other-bp-val\"")
} else {
assertOutput(t, cmd, "sourced bp profile\nsourced app profile\nsome-user-val, , other-user-val**other-bp-val")
}
})
it("adds buildpack bin dirs to the path", func() {
cmd := exec.Command("docker", "run", "--rm", launchImage, "bp-executable")
assertOutput(t, cmd, "bp executable")
})
it("sets env vars from layers", func() {
cmd := exec.Command( //nolint
"docker", "run", "--rm",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage,
"echo", "$SOME_VAR", "$OTHER_VAR", "$WORKER_VAR",
)
assertOutput(t, cmd, "sourced bp profile\nsourced app profile\nsome-bp-val other-bp-val worker-no-process-val")
})
when("CMD provided starts with --", func() {
it("launches command directly", func() {
if runtime.GOOS == "windows" {
cmd := exec.Command("docker", "run", "--rm", launchImage, "--", "ping", "/?")
assertOutput(t, cmd, "Usage: ping")
} else {
cmd := exec.Command("docker", "run", "--rm", launchImage, "--", "echo", "something")
assertOutput(t, cmd, "something")
}
})
it("sets env vars from layers", func() {
cmd := exec.Command("docker", "run", "--rm", launchImage, "--", "env")
if runtime.GOOS == "windows" {
cmd = exec.Command("docker", "run", "--rm", launchImage, "--", "cmd", "/c", "set")
}
assertOutput(t, cmd,
"SOME_VAR=some-bp-val",
"OTHER_VAR=other-bp-val",
)
})
it("passes through env vars from user, excluding excluded vars", func() {
cmd := exec.Command("docker", "run", "--rm",
"--env", "CNB_APP_DIR=/workspace",
"--env", "SOME_USER_VAR=some-user-val",
launchImage, "--",
"env",
)
if runtime.GOOS == "windows" {
cmd = exec.Command("docker", "run", "--rm",
"--env", "CNB_APP_DIR=/workspace",
it("passes through env vars from user, excluding excluded vars", func() {
args := []string{"echo", "$SOME_USER_VAR, $CNB_APP_DIR, $OTHER_VAR"}
cmd := exec.Command("docker",
append(
[]string{
"run", "--rm",
"--env", "CNB_APP_DIR=" + ctrPath("/workspace"),
"--env=CNB_PLATFORM_API=" + latestPlatformAPI,
"--env", "SOME_USER_VAR=some-user-val",
launchImage, "--",
"cmd", "/c", "set",
)
}
"--env", "OTHER_VAR=other-user-val",
launchImage,
},
args...)...,
) // #nosec G204
output, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("failed to run %v\n OUTPUT: %s\n ERROR: %s\n", cmd.Args, output, err)
}
expected := "SOME_USER_VAR=some-user-val"
if !strings.Contains(string(output), expected) {
t.Fatalf("failed to execute provided CMD:\n\t got: %s\n\t want: %s", output, expected)
}
assertOutput(t, cmd, "sourced bp profile\nsourced app profile\nsome-user-val, , other-user-val**other-bp-val")
})
if strings.Contains(string(output), "CNB_APP_DIR") {
t.Fatalf("env contained white listed env far CNB_APP_DIR:\n\t got: %s\n", output)
}
})
it("adds buildpack bin dirs to the path", func() {
cmd := exec.Command( //nolint
"docker", "run", "--rm",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage,
"bp-executable",
)
assertOutput(t, cmd, "bp executable")
})
})
it("adds buildpack bin dirs to the path before looking up command", func() {
cmd := exec.Command("docker", "run", "--rm", launchImage, "--", "bp-executable")
assertOutput(t, cmd, "bp executable")
})
when("CMD provided starts with --", func() {
it("launches command directly", func() {
cmd := exec.Command( //nolint
"docker", "run", "--rm",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage, "--",
"echo", "something",
)
assertOutput(t, cmd, "something")
})
it("sets env vars from layers", func() {
cmd := exec.Command( //nolint
"docker", "run", "--rm",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage, "--",
"env",
)
assertOutput(t, cmd,
"SOME_VAR=some-bp-val",
"OTHER_VAR=other-bp-val",
)
})
it("passes through env vars from user, excluding excluded vars", func() {
cmd := exec.Command( //nolint
"docker", "run", "--rm",
"--env", "CNB_APP_DIR=/workspace",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
"--env", "SOME_USER_VAR=some-user-val",
launchImage, "--",
"env",
)
output, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("failed to run %v\n OUTPUT: %s\n ERROR: %s\n", cmd.Args, output, err)
}
expected := "SOME_USER_VAR=some-user-val"
if !strings.Contains(string(output), expected) {
t.Fatalf("failed to execute provided CMD:\n\t got: %s\n\t want: %s", output, expected)
}
if strings.Contains(string(output), "CNB_APP_DIR") {
t.Fatalf("env contained white listed env far CNB_APP_DIR:\n\t got: %s\n", output)
}
})
it("adds buildpack bin dirs to the path before looking up command", func() {
cmd := exec.Command( //nolint
"docker", "run", "--rm",
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
launchImage, "--",
"bp-executable",
)
assertOutput(t, cmd, "bp executable")
})
})
}

View File

@ -2,23 +2,32 @@ package acceptance
import (
"context"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"os/exec"
"path/filepath"
"reflect"
"runtime"
"strings"
"testing"
"time"
"github.com/docker/docker/api/types/image"
ih "github.com/buildpacks/imgutil/testhelpers"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/registry"
"github.com/buildpacks/lifecycle/auth"
"github.com/buildpacks/lifecycle/cmd"
"github.com/buildpacks/lifecycle/internal/encoding"
"github.com/buildpacks/lifecycle/platform"
"github.com/buildpacks/lifecycle/platform/files"
h "github.com/buildpacks/lifecycle/testhelpers"
)
@ -121,7 +130,29 @@ func (p *PhaseTest) Start(t *testing.T, phaseOp ...func(*testing.T, *PhaseTest))
}
h.MakeAndCopyLifecycle(t, p.targetDaemon.os, p.targetDaemon.arch, p.containerBinaryDir)
h.DockerBuild(t, p.testImageRef, p.testImageDockerContext, h.WithArgs("-f", filepath.Join(p.testImageDockerContext, dockerfileName)))
// calculate lifecycle digest
hasher := sha256.New()
f, err := os.Open(filepath.Join(p.containerBinaryDir, "lifecycle"+exe)) //#nosec G304
h.AssertNil(t, err)
_, err = io.Copy(hasher, f)
h.AssertNil(t, err)
t.Logf("Built lifecycle binary with digest: %s", hex.EncodeToString(hasher.Sum(nil)))
copyFakeSboms(t)
h.DockerBuild(
t,
p.testImageRef,
p.testImageDockerContext,
h.WithArgs("-f", filepath.Join(p.testImageDockerContext, dockerfileName)),
)
t.Logf("Using image %s with lifecycle version %s",
p.testImageRef,
h.DockerRun(
t,
p.testImageRef,
h.WithFlags("--env", "CNB_PLATFORM_API="+latestPlatformAPI, "--entrypoint", ctrPath("/cnb/lifecycle/lifecycle"+exe)),
h.WithArgs("-version"),
))
}
func (p *PhaseTest) Stop(t *testing.T) {
@ -143,7 +174,7 @@ func (d *targetDaemon) createFixtures(t *testing.T) {
var fixtures daemonImageFixtures
appMeta := minifyMetadata(t, filepath.Join("testdata", "app_image_metadata.json"), platform.LayersMetadata{})
appMeta := minifyMetadata(t, filepath.Join("testdata", "app_image_metadata.json"), files.LayersMetadata{})
cacheMeta := minifyMetadata(t, filepath.Join("testdata", "cache_image_metadata.json"), platform.CacheMetadata{})
fixtures.AppImage = "some-app-image-" + h.RandString(10)
@ -188,10 +219,10 @@ func (d *targetDaemon) removeFixtures(t *testing.T) {
func (r *targetRegistry) start(t *testing.T) {
var err error
r.dockerConfigDir, err = ioutil.TempDir("", "test.docker.config.dir")
r.dockerConfigDir, err = os.MkdirTemp("", "test.docker.config.dir")
h.AssertNil(t, err)
sharedRegHandler := registry.New(registry.Logger(log.New(ioutil.Discard, "", log.Lshortfile)))
sharedRegHandler := registry.New(registry.Logger(log.New(io.Discard, "", log.Lshortfile)))
r.registry = ih.NewDockerRegistry(
ih.WithAuth(r.dockerConfigDir),
ih.WithSharedHandler(sharedRegHandler),
@ -216,7 +247,7 @@ func (r *targetRegistry) start(t *testing.T) {
func (r *targetRegistry) createFixtures(t *testing.T) {
var fixtures regImageFixtures
appMeta := minifyMetadata(t, filepath.Join("testdata", "app_image_metadata.json"), platform.LayersMetadata{})
appMeta := minifyMetadata(t, filepath.Join("testdata", "app_image_metadata.json"), files.LayersMetadata{})
cacheMeta := minifyMetadata(t, filepath.Join("testdata", "cache_image_metadata.json"), platform.CacheMetadata{})
// With Permissions
@ -345,7 +376,7 @@ func cleanupDaemonFixtures(t *testing.T, fixtures interface{}) {
}
func minifyMetadata(t *testing.T, path string, metadataStruct interface{}) string {
metadata, err := ioutil.ReadFile(path)
metadata, err := os.ReadFile(path)
h.AssertNil(t, err)
// Unmarshal and marshal to strip unnecessary whitespace
@ -363,3 +394,129 @@ func withoutDaemonFixtures(phaseTest *PhaseTest) {
func withoutRegistry(phaseTest *PhaseTest) {
phaseTest.targetRegistry = nil
}
func copyFakeSboms(t *testing.T) {
goos := runtime.GOOS
// Check Target Daemon != runtime.GOOS
if goos == "darwin" {
goos = "linux"
}
buildLifecycleDir, err := filepath.Abs(filepath.Join("..", "out", fmt.Sprintf("%s-%s", goos, runtime.GOARCH), "lifecycle"))
if err != nil {
t.Log("Fail to locate lifecycle directory")
}
extensions := SBOMExtensions()
components := SBOMComponents()
for _, component := range components {
for _, extension := range extensions {
if err := encoding.WriteJSON(filepath.Join(buildLifecycleDir, component+extension), "fake data"); err != nil {
t.Log("Fail to write:" + component + extension)
}
}
}
}
func SBOMExtensions() []string {
return []string{".sbom.cdx.json", ".sbom.spdx.json", ".sbom.syft.json"}
}
func SBOMComponents() []string {
return []string{"lifecycle", "launcher"}
}
func assertImageOSAndArch(t *testing.T, imageName string, phaseTest *PhaseTest) { //nolint - these functions are in fact used, i promise
inspect, err := h.DockerCli(t).ImageInspect(context.TODO(), imageName)
h.AssertNil(t, err)
h.AssertEq(t, inspect.Os, phaseTest.targetDaemon.os)
h.AssertEq(t, inspect.Architecture, phaseTest.targetDaemon.arch)
}
func assertImageOSAndArchAndCreatedAt(t *testing.T, imageName string, phaseTest *PhaseTest, expectedCreatedAt time.Time) { //nolint
inspect, err := h.DockerCli(t).ImageInspect(context.TODO(), imageName)
if err != nil {
list, _ := h.DockerCli(t).ImageList(context.TODO(), image.ListOptions{})
fmt.Println("Error encountered running ImageInspectWithRaw. imageName: ", imageName)
fmt.Println(err)
for _, value := range list {
fmt.Println("Image Name: ", value)
}
if strings.Contains(err.Error(), "No such image") {
t.Log("Image not found, retrying...")
time.Sleep(1 * time.Second)
inspect, err = h.DockerCli(t).ImageInspect(context.TODO(), imageName)
}
}
h.AssertNil(t, err)
h.AssertEq(t, inspect.Os, phaseTest.targetDaemon.os)
h.AssertEq(t, inspect.Architecture, phaseTest.targetDaemon.arch)
h.AssertEq(t, inspect.Created, expectedCreatedAt.Format(time.RFC3339))
}
func assertRunMetadata(t *testing.T, path string) *files.Run { //nolint
contents, err := os.ReadFile(path)
h.AssertNil(t, err)
h.AssertEq(t, len(contents) > 0, true)
runMD, err := files.Handler.ReadRun(path, cmd.DefaultLogger)
h.AssertNil(t, err)
return &runMD
}
func updateTOMLFixturesWithTestRegistry(t *testing.T, phaseTest *PhaseTest) { //nolint
analyzedTOMLPlaceholders := []string{
filepath.Join(phaseTest.testImageDockerContext, "container", "layers", "analyzed.toml.placeholder"),
filepath.Join(phaseTest.testImageDockerContext, "container", "layers", "run-image-extended-analyzed.toml.placeholder"),
filepath.Join(phaseTest.testImageDockerContext, "container", "layers", "some-analyzed.toml.placeholder"),
filepath.Join(phaseTest.testImageDockerContext, "container", "layers", "some-extend-false-analyzed.toml.placeholder"),
filepath.Join(phaseTest.testImageDockerContext, "container", "layers", "some-extend-true-analyzed.toml.placeholder"),
filepath.Join(phaseTest.testImageDockerContext, "container", "other_layers", "analyzed.toml.placeholder"),
}
runTOMLPlaceholders := []string{
filepath.Join(phaseTest.testImageDockerContext, "container", "cnb", "run.toml.placeholder"),
}
layoutPlaceholders := []string{
filepath.Join(phaseTest.testImageDockerContext, "container", "layers", "layout-analyzed.toml.placeholder"),
}
for _, pPath := range analyzedTOMLPlaceholders {
if _, err := os.Stat(pPath); os.IsNotExist(err) {
continue
}
analyzedMD := assertAnalyzedMetadata(t, pPath)
if analyzedMD.RunImage != nil {
analyzedMD.RunImage.Reference = phaseTest.targetRegistry.fixtures.ReadOnlyRunImage // don't override extend
if analyzedMD.RunImage.Image == "REPLACE" {
analyzedMD.RunImage.Image = phaseTest.targetRegistry.fixtures.ReadOnlyRunImage
}
}
h.AssertNil(t, encoding.WriteTOML(strings.TrimSuffix(pPath, ".placeholder"), analyzedMD))
}
for _, pPath := range runTOMLPlaceholders {
if _, err := os.Stat(pPath); os.IsNotExist(err) {
continue
}
runMD := assertRunMetadata(t, pPath)
for idx, image := range runMD.Images {
image.Image = phaseTest.targetRegistry.fixtures.ReadOnlyRunImage
runMD.Images[idx] = image
}
h.AssertNil(t, encoding.WriteTOML(strings.TrimSuffix(pPath, ".placeholder"), runMD))
}
for _, pPath := range layoutPlaceholders {
if _, err := os.Stat(pPath); os.IsNotExist(err) {
continue
}
analyzedMD := assertAnalyzedMetadata(t, pPath)
if analyzedMD.RunImage != nil {
// Values from image acceptance/testdata/exporter/container/layout-repo in OCI layout format
analyzedMD.RunImage = &files.RunImage{Reference: "/layout-repo/index.docker.io/library/busybox/latest@sha256:445c45cc89fdeb64b915b77f042e74ab580559b8d0d5ef6950be1c0265834c33"}
}
h.AssertNil(t, encoding.WriteTOML(strings.TrimSuffix(pPath, ".placeholder"), analyzedMD))
}
}

View File

@ -0,0 +1,58 @@
//go:build acceptance
package acceptance
import (
"path/filepath"
"testing"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
"github.com/buildpacks/lifecycle/api"
h "github.com/buildpacks/lifecycle/testhelpers"
)
var (
rebaserTest *PhaseTest
rebaserPath string
rebaserImage string
)
func TestRebaser(t *testing.T) {
testImageDockerContextFolder := filepath.Join("testdata", "rebaser")
rebaserTest = NewPhaseTest(t, "rebaser", testImageDockerContextFolder)
rebaserTest.Start(t, updateTOMLFixturesWithTestRegistry)
defer rebaserTest.Stop(t)
rebaserImage = rebaserTest.testImageRef
rebaserPath = rebaserTest.containerBinaryPath
for _, platformAPI := range api.Platform.Supported {
spec.Run(t, "acceptance-rebaser/"+platformAPI.String(), testRebaser(platformAPI.String()), spec.Sequential(), spec.Report(report.Terminal{}))
}
}
func testRebaser(platformAPI string) func(t *testing.T, when spec.G, it spec.S) {
return func(t *testing.T, when spec.G, it spec.S) {
when("called with insecure registry flag", func() {
it.Before(func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "")
})
it("should do an http request", func() {
insecureRegistry := "host.docker.internal"
rebaserOutputImageName := insecureRegistry + "/bar"
_, _, err := h.DockerRunWithError(t,
rebaserImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_INSECURE_REGISTRIES="+insecureRegistry,
),
h.WithArgs(ctrPath(rebaserPath), rebaserOutputImageName),
)
h.AssertStringContains(t, err.Error(), "http://host.docker.internal")
})
})
}
}

View File

@ -1,40 +1,47 @@
//go:build acceptance
// +build acceptance
package acceptance
import (
"io/ioutil"
"math/rand"
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"
"time"
"github.com/google/go-containerregistry/pkg/name"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
"github.com/buildpacks/lifecycle/api"
"github.com/buildpacks/lifecycle/cmd"
"github.com/buildpacks/lifecycle/platform/files"
h "github.com/buildpacks/lifecycle/testhelpers"
)
const emptyImageSHA = "03cbce912ef1a8a658f73c660ab9c539d67188622f00b15c4f15b89b884f0e10"
var (
restoreDockerContext = filepath.Join("testdata", "restorer")
restorerBinaryDir = filepath.Join("testdata", "restorer", "container", "cnb", "lifecycle")
restorerImage = "lifecycle/acceptance/restorer"
restoreImage string
restoreRegAuthConfig string
restoreRegNetwork string
restorerPath string
restoreDaemonFixtures *daemonImageFixtures
restoreRegFixtures *regImageFixtures
restoreTest *PhaseTest
)
func TestRestorer(t *testing.T) {
h.SkipIf(t, runtime.GOOS == "windows", "Restorer acceptance tests are not yet supported on Windows")
h.SkipIf(t, runtime.GOARCH != "amd64", "Restorer acceptance tests are not yet supported on non-amd64")
testImageDockerContext := filepath.Join("testdata", "restorer")
restoreTest = NewPhaseTest(t, "restorer", testImageDockerContext)
restoreTest.Start(t, updateTOMLFixturesWithTestRegistry)
defer restoreTest.Stop(t)
rand.Seed(time.Now().UTC().UnixNano())
h.MakeAndCopyLifecycle(t, "linux", "amd64", restorerBinaryDir)
h.DockerBuild(t, restorerImage, restoreDockerContext)
defer h.DockerImageRemove(t, restorerImage)
restoreImage = restoreTest.testImageRef
restorerPath = restoreTest.containerBinaryPath
restoreRegAuthConfig = restoreTest.targetRegistry.authConfig
restoreRegNetwork = restoreTest.targetRegistry.network
restoreDaemonFixtures = restoreTest.targetDaemon.fixtures
restoreRegFixtures = restoreTest.targetRegistry.fixtures
for _, platformAPI := range api.Platform.Supported {
spec.Run(t, "acceptance-restorer/"+platformAPI.String(), testRestorerFunc(platformAPI.String()), spec.Parallel(), spec.Report(report.Terminal{}))
@ -43,9 +50,24 @@ func TestRestorer(t *testing.T) {
func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spec.S) {
return func(t *testing.T, when spec.G, it spec.S) {
var copyDir, containerName string
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = os.MkdirTemp("", "test-docker-copy-")
h.AssertNil(t, err)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
_ = os.RemoveAll(copyDir)
})
when("called with arguments", func() {
it("errors", func() {
command := exec.Command("docker", "run", "--rm", restorerImage, "some-arg")
command := exec.Command("docker", "run", "--rm", "--env", "CNB_PLATFORM_API="+platformAPI, restoreImage, "some-arg")
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "failed to parse arguments: received unexpected Args"
@ -53,61 +75,23 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
})
})
when("called with -analyzed", func() {
it("errors", func() {
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 supports -analyzed flag")
command := exec.Command("docker", "run", "--rm", restorerImage, "-analyzed some-file-location")
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "flag provided but not defined: -analyzed"
h.AssertStringContains(t, string(output), expected)
})
})
when("called with -skip-layers", func() {
it("errors", func() {
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 supports -skip-layers flag")
command := exec.Command("docker", "run", "--rm", restorerImage, "-skip-layers true")
output, err := command.CombinedOutput()
h.AssertNotNil(t, err)
expected := "flag provided but not defined: -skip-layers"
h.AssertStringContains(t, string(output), expected)
})
})
when("called without any cache flag", func() {
it("outputs it will not restore cache layer data", func() {
command := exec.Command("docker", "run", "--rm", "--env", "CNB_PLATFORM_API="+platformAPI, restorerImage)
command := exec.Command("docker", "run", "--rm", "--env", "CNB_PLATFORM_API="+platformAPI, restoreImage)
output, err := command.CombinedOutput()
h.AssertNil(t, err)
expected := "Not restoring cached layer data, no cache flag specified"
expected := "No cached data will be used, no cache specified"
h.AssertStringContains(t, string(output), expected)
})
})
when("analyzed.toml exists with app metadata", func() {
var copyDir, containerName string
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = ioutil.TempDir("", "test-docker-copy-")
h.AssertNil(t, err)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
os.RemoveAll(copyDir)
})
it("restores app metadata", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.7"), "Platform API < 0.7 does not restore app metadata")
output := h.DockerRunAndCopy(t,
containerName,
copyDir,
ctrPath("/layers"),
restorerImage,
restoreImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_PLATFORM_API="+platformAPI,
@ -118,32 +102,36 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
h.AssertStringContains(t, output, "Restoring metadata for \"some-buildpack-id:launch-layer\"")
})
when("restores app metadata using an insecure registry", func() {
it.Before(func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "")
})
it("does an http request ", func() {
insecureRegistry := "host.docker.internal"
_, _, err := h.DockerRunWithError(t,
restoreImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "CNB_INSECURE_REGISTRIES="+insecureRegistry,
"--env", "CNB_BUILD_IMAGE="+insecureRegistry+"/bar",
)...),
)
h.AssertStringContains(t, err.Error(), "http://host.docker.internal")
})
})
})
when("using cache-dir", func() {
when("there is cache present from a previous build", func() {
var copyDir, containerName string
it.Before(func() {
containerName = "test-container-" + h.RandString(10)
var err error
copyDir, err = ioutil.TempDir("", "test-docker-copy-")
h.AssertNil(t, err)
})
it.After(func() {
if h.DockerContainerExists(t, containerName) {
h.Run(t, exec.Command("docker", "rm", containerName))
}
os.RemoveAll(copyDir)
})
it("restores cached layer data", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
restorerImage,
restoreImage,
h.WithFlags("--env", "CNB_PLATFORM_API="+platformAPI),
h.WithArgs("-cache-dir", "/cache"),
)
@ -153,17 +141,17 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
h.AssertPathExists(t, cachedFile)
// check restored cache file content is correct
contents, err := ioutil.ReadFile(cachedFile)
contents, err := os.ReadFile(cachedFile)
h.AssertNil(t, err)
h.AssertEq(t, string(contents), "cached-data\n")
})
it("does not restore cache=true layers not in cache", func() {
output := h.DockerRunAndCopy(t,
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
restorerImage,
restoreImage,
h.WithFlags("--env", "CNB_PLATFORM_API="+platformAPI),
h.WithArgs("-cache-dir", "/cache"),
)
@ -171,17 +159,14 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
// check uncached layer is not restored
uncachedFile := filepath.Join(copyDir, "layers", "cacher_buildpack", "uncached-layer")
h.AssertPathDoesNotExist(t, uncachedFile)
// check output to confirm why this layer was not restored from cache
h.AssertStringContains(t, string(output), "Removing \"cacher_buildpack:layer-not-in-cache\", not in cache")
})
it("does not restore unused buildpack layer data", func() {
it("does not restore layer data from unused buildpacks", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
restorerImage,
restoreImage,
h.WithFlags("--env", "CNB_PLATFORM_API="+platformAPI),
h.WithArgs("-cache-dir", "/cache"),
)
@ -190,6 +175,163 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
unusedBpLayer := filepath.Join(copyDir, "layers", "unused_buildpack")
h.AssertPathDoesNotExist(t, unusedBpLayer)
})
it("does not restore corrupted layer data", func() {
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/layers",
restoreImage,
h.WithFlags("--env", "CNB_PLATFORM_API="+platformAPI),
h.WithArgs("-cache-dir", "/cache"),
)
// check corrupted layer is not restored
corruptedFile := filepath.Join(copyDir, "layers", "corrupted_buildpack", "corrupted-layer")
h.AssertPathDoesNotExist(t, corruptedFile)
})
})
})
when("restoring builder image metadata for extensions", func() {
it("accepts -build-image and saves the metadata to /kaniko/cache", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.10"), "Platform API < 0.10 does not restore builder image metadata")
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/",
restoreImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "DOCKER_CONFIG=/docker-config",
"--network", restoreRegNetwork,
),
h.WithArgs("-build-image", restoreRegFixtures.SomeCacheImage), // some-cache-image simulates a builder image in a registry
)
t.Log("records builder image digest in analyzed.toml")
analyzedMD, err := files.Handler.ReadAnalyzed(filepath.Join(copyDir, "layers", "analyzed.toml"), cmd.DefaultLogger)
h.AssertNil(t, err)
h.AssertStringContains(t, analyzedMD.BuildImage.Reference, restoreRegFixtures.SomeCacheImage+"@sha256:")
t.Log("writes builder manifest and config to the kaniko cache")
ref, err := name.ParseReference(analyzedMD.BuildImage.Reference)
h.AssertNil(t, err)
fis, err := os.ReadDir(filepath.Join(copyDir, "kaniko", "cache", "base"))
h.AssertNil(t, err)
h.AssertEq(t, len(fis), 1)
h.AssertPathExists(t, filepath.Join(copyDir, "kaniko", "cache", "base", ref.Identifier(), "oci-layout"))
})
})
when("restoring run image metadata for extensions", func() {
it("saves metadata to /kaniko/cache", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "Platform API < 0.12 does not restore run image metadata")
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/",
restoreImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "DOCKER_CONFIG=/docker-config",
"--network", restoreRegNetwork,
),
h.WithArgs(
"-analyzed", "/layers/some-extend-true-analyzed.toml",
"-log-level", "debug",
),
)
t.Log("updates run image reference in analyzed.toml to include digest and target data")
analyzedMD, err := files.Handler.ReadAnalyzed(filepath.Join(copyDir, "layers", "some-extend-true-analyzed.toml"), cmd.DefaultLogger)
h.AssertNil(t, err)
h.AssertStringContains(t, analyzedMD.RunImage.Reference, restoreRegFixtures.ReadOnlyRunImage+"@sha256:")
h.AssertEq(t, analyzedMD.RunImage.Image, restoreRegFixtures.ReadOnlyRunImage)
h.AssertEq(t, analyzedMD.RunImage.TargetMetadata.OS, "linux")
t.Log("does not return the digest for an empty image")
h.AssertStringDoesNotContain(t, analyzedMD.RunImage.Reference, restoreRegFixtures.ReadOnlyRunImage+"@sha256:"+emptyImageSHA)
t.Log("writes run image manifest and config to the kaniko cache")
ref, err := name.ParseReference(analyzedMD.RunImage.Reference)
h.AssertNil(t, err)
fis, err := os.ReadDir(filepath.Join(copyDir, "kaniko", "cache", "base"))
h.AssertNil(t, err)
h.AssertEq(t, len(fis), 1)
h.AssertPathExists(t, filepath.Join(copyDir, "kaniko", "cache", "base", ref.Identifier(), "oci-layout"))
})
})
when("target data", func() {
it("updates run image reference in analyzed.toml to include digest and target data on newer platforms", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.10"), "")
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/",
restoreImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "DOCKER_CONFIG=/docker-config",
"--network", restoreRegNetwork,
),
h.WithArgs(
"-analyzed", "/layers/some-extend-false-analyzed.toml",
"-log-level", "debug",
),
)
if api.MustParse(platformAPI).AtLeast("0.12") {
t.Log("updates run image reference in analyzed.toml to include digest and target data")
analyzedMD, err := files.Handler.ReadAnalyzed(filepath.Join(copyDir, "layers", "some-extend-false-analyzed.toml"), cmd.DefaultLogger)
h.AssertNil(t, err)
h.AssertStringContains(t, analyzedMD.RunImage.Reference, restoreRegFixtures.ReadOnlyRunImage+"@sha256:")
h.AssertEq(t, analyzedMD.RunImage.Image, restoreRegFixtures.ReadOnlyRunImage)
h.AssertEq(t, analyzedMD.RunImage.TargetMetadata.OS, "linux")
t.Log("does not return the digest for an empty image")
h.AssertStringDoesNotContain(t, analyzedMD.RunImage.Reference, restoreRegFixtures.ReadOnlyRunImage+"@sha256:"+emptyImageSHA)
t.Log("does not write run image manifest and config to the kaniko cache")
fis, err := os.ReadDir(filepath.Join(copyDir, "kaniko"))
h.AssertNil(t, err)
h.AssertEq(t, len(fis), 1) // .gitkeep
} else {
t.Log("updates run image reference in analyzed.toml to include digest only")
analyzedMD, err := files.Handler.ReadAnalyzed(filepath.Join(copyDir, "layers", "some-extend-false-analyzed.toml"), cmd.DefaultLogger)
h.AssertNil(t, err)
h.AssertStringContains(t, analyzedMD.RunImage.Reference, restoreRegFixtures.ReadOnlyRunImage+"@sha256:")
h.AssertEq(t, analyzedMD.RunImage.Image, restoreRegFixtures.ReadOnlyRunImage)
h.AssertNil(t, analyzedMD.RunImage.TargetMetadata)
t.Log("does not return the digest for an empty image")
h.AssertStringDoesNotContain(t, analyzedMD.RunImage.Reference, restoreRegFixtures.ReadOnlyRunImage+"@sha256:"+emptyImageSHA)
}
})
when("-daemon", func() {
it("updates run image reference in analyzed.toml to include digest and target data on newer platforms", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "Platform API < 0.12 does not support -daemon flag")
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/",
restoreImage,
h.WithFlags(append(
dockerSocketMount,
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "DOCKER_CONFIG=/docker-config",
"--network", restoreRegNetwork,
)...),
h.WithArgs(
"-analyzed", "/layers/some-extend-false-analyzed.toml",
"-daemon",
"-log-level", "debug",
),
)
t.Log("updates run image reference in analyzed.toml to include digest and target data")
analyzedMD, err := files.Handler.ReadAnalyzed(filepath.Join(copyDir, "layers", "some-extend-false-analyzed.toml"), cmd.DefaultLogger)
h.AssertNil(t, err)
h.AssertStringDoesNotContain(t, analyzedMD.RunImage.Reference, "@sha256:") // daemon image ID
h.AssertEq(t, analyzedMD.RunImage.Image, restoreRegFixtures.ReadOnlyRunImage)
h.AssertEq(t, analyzedMD.RunImage.TargetMetadata.OS, "linux")
t.Log("does not write run image manifest and config to the kaniko cache")
fis, err := os.ReadDir(filepath.Join(copyDir, "kaniko"))
h.AssertNil(t, err)
h.AssertEq(t, len(fis), 1) // .gitkeep
})
})
})
}

View File

@ -1,5 +1,4 @@
FROM ubuntu:bionic
ARG cnb_platform_api
RUN apt-get update && apt-get install -y ca-certificates
@ -11,6 +10,7 @@ ENV CNB_USER_ID=2222
ENV CNB_GROUP_ID=3333
ARG cnb_platform_api
ENV CNB_PLATFORM_API=${cnb_platform_api}
RUN chown -R $CNB_USER_ID:$CNB_GROUP_ID /some-dir

View File

@ -1,12 +0,0 @@
FROM mcr.microsoft.com/windows/nanoserver:1809
USER ContainerAdministrator
COPY container /
WORKDIR /layers
ENV CNB_USER_ID=1
ENV CNB_GROUP_ID=1
ENV CNB_PLATFORM_API=${cnb_platform_api}

View File

@ -0,0 +1,5 @@
[[images]]
image = "some-run-image-from-run-toml"
[[images]]
image = "some-other-run-image"

View File

@ -1,4 +1,4 @@
[[group]]
id = "some-buildpack-id"
version = "some-buildpack-version"
api = "0.2"
api = "0.10"

View File

@ -1,4 +1,4 @@
[[group]]
id = "some-other-buildpack-id"
version = "some-other-buildpack-version"
api = "0.3"
api = "0.10"

View File

@ -0,0 +1,4 @@
[[group]]
id = "some-other-buildpack-id"
version = "some-other-buildpack-version"
api = "0.1"

View File

@ -0,0 +1 @@
{"architecture":"amd64","config":{"Hostname":"","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sh"],"Image":"sha256:688db7a53b2e8d0358c0e1f309856290bb25ce7acabbf9938f580582e921833f","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":null},"container":"65aaed1d1f89cd3cd5aac9137c4786831e99a845ad823496c6008a22a725c780","container_config":{"Hostname":"65aaed1d1f89","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh","-c","#(nop) ","CMD [\"sh\"]"],"Image":"sha256:688db7a53b2e8d0358c0e1f309856290bb25ce7acabbf9938f580582e921833f","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":{}},"created":"2022-11-18T01:19:29.442257773Z","docker_version":"20.10.12","history":[{"created":"2022-11-18T01:19:29.321465538Z","created_by":"/bin/sh -c #(nop) ADD file:36d9f497f679d56737ac1379d93f7b6a2e4c814e38e868a5a8e719c4b226ef6e in / "},{"created":"2022-11-18T01:19:29.442257773Z","created_by":"/bin/sh -c #(nop) CMD [\"sh\"]","empty_layer":true}],"os":"linux","rootfs":{"type":"layers","diff_ids":["sha256:40cf597a9181e86497f4121c604f9f0ab208950a98ca21db883f26b0a548a2eb"]}}

View File

@ -0,0 +1,16 @@
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"size": 1457,
"digest": "sha256:9d5226e6ce3fb6aee2822206a5ef85f38c303d2b37bfc894b419fca2c0501269"
},
"layers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"size": 772999,
"digest": "sha256:405fecb6a2fa4f29683f977e7e3b852bf6f8975a2aba647d234d2371894943da"
}
]
}

View File

@ -0,0 +1,14 @@
{
"schemaVersion": 2,
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 527,
"digest": "sha256:f75f3d1a317fc82c793d567de94fc8df2bece37acd5f2bd364a0d91a0d1f3dab",
"platform": {
"architecture": "amd64",
"os": "linux"
}
}
]
}

View File

@ -0,0 +1,3 @@
{
"imageLayoutVersion": "1.0.0"
}

View File

@ -1,4 +1,4 @@
[[group]]
id = "another-buildpack-id"
version = "another-buildpack-version"
api = "0.2"
api = "0.10"

View File

@ -1,14 +0,0 @@
FROM mcr.microsoft.com/windows/nanoserver:1809
USER ContainerAdministrator
COPY container /
ENTRYPOINT ["/cnb/lifecycle/builder"]
WORKDIR /layers
ENV CNB_USER_ID=1
ENV CNB_GROUP_ID=1
ENV CNB_PLATFORM_API=${cnb_platform_api}

View File

@ -24,4 +24,12 @@ echo "plan contents:"
cat ${plan_path}
echo
# Set default start command
cat > "${layers_dir}/launch.toml" << EOL
[[processes]]
type = "hello"
command = ["echo world"]
args = ["arg1"]
EOL
echo "---> Done"

View File

@ -1,5 +1,5 @@
# Buildpack API version
api = "0.2"
api = "0.10"
# Buildpack ID and metadata
[buildpack]

View File

@ -1,5 +1,5 @@
# Buildpack API version
api = "0.2"
api = "0.10"
# Buildpack ID and metadata
[buildpack]

View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -eo pipefail
echo "---> Hello World 3 buildpack"
# INPUT ARGUMENTS
platform_dir=$2
env_dir=${platform_dir}/env
layers_dir=$1
plan_path=$3
# CNB_APP_DIR
echo "CNB_APP_DIR: ${PWD}"
# PLATFORM DIR
echo "PLATFORM_DIR: ${platform_dir}"
# LAYERS
echo "LAYERS_DIR: ${layers_dir}"
# PLAN
echo "PLAN_PATH: ${plan_path}"
echo "plan contents:"
cat ${plan_path}
echo
echo "CNB_TARGET_ARCH:" `printenv CNB_TARGET_ARCH`
echo "CNB_TARGET_ARCH_VARIANT:" `printenv CNB_TARGET_ARCH_VARIANT`
echo "CNB_TARGET_OS:" `printenv CNB_TARGET_OS`
echo "CNB_TARGET_DISTRO_NAME:" `printenv CNB_TARGET_DISTRO_NAME`
echo "CNB_TARGET_DISTRO_VERSION:" `printenv CNB_TARGET_DISTRO_VERSION`
echo "---> Done"

View File

@ -0,0 +1,7 @@
# Buildpack API version
api = "0.10"
# Buildpack ID and metadata
[buildpack]
id = "hello_world_3"
version = "0.0.3"

View File

@ -1,4 +1,4 @@
[[group]]
api = "0.2"
api = "0.10"
id = "hello_world"
version = "0.0.1"

View File

@ -1,4 +1,4 @@
[[group]]
api = "0.2"
api = "0.10"
id = "hello_world_2"
version = "0.0.2"

View File

@ -0,0 +1,9 @@
[[group]]
api = "0.10"
id = "hello_world"
version = "0.0.1"
[[group-extensions]]
api = "0.10"
id = "hello_world"
version = "0.0.1"

View File

@ -0,0 +1,10 @@
[[entries]]
[[entries.providers]]
id = "hello_world_3"
version = "0.0.3"
[[entries.requires]]
name = "03_plan.toml_requires_subset_content_idk"
[entries.requires.metadata]
# arbitrary data describing the required dependency

View File

@ -1,5 +1,5 @@
# Buildpack API version
api = "0.2"
api = "0.10"
# Buildpack ID and metadata
[buildpack]

View File

@ -0,0 +1,9 @@
[run-image.target]
id = "my id"
os = "linux"
arch = "amd64"
arch-variant = "some-variant"
[run-image.target.distro]
name = "ubuntu"
version = "some-cute-version"

View File

@ -0,0 +1,4 @@
[[group]]
api = "0.10"
id = "hello_world_3"
version = "0.0.3"

View File

@ -0,0 +1,6 @@
[[entries]]
[[entries.providers]]
id = "hello_world_3"
version = "0.0.3"

View File

@ -0,0 +1,6 @@
[run-image]
[target]
id = "software"
os = "linux"
arch = "amd64"

View File

@ -1,4 +1,4 @@
[[group]]
api = "0.2"
api = "0.10"
id = "hello_world_2"
version = "0.0.2"

View File

@ -13,6 +13,7 @@ RUN groupadd cnb --gid ${cnb_gid} && \
# chown the directories so the tests do not have to run as root
RUN chown -R "${cnb_uid}:${cnb_gid}" "/layers"
RUN chown -R "${cnb_uid}:${cnb_gid}" "/layout-repo"
WORKDIR /layers

View File

@ -9,14 +9,98 @@ env_dir=${platform_dir}/env
layers_dir=$1
plan_path=$3
if test -d /layers/sbom; then
echo "/layers/sbom should not exist during buildpack builds"
exit 1
fi
# LAYERS
echo " layers_dir: ${layers_dir}"
# launch=true layer
mkdir -p ${layers_dir}/some-layer/env
echo -n "some-val" > ${layers_dir}/some-layer/env/SOME_VAR
cat <<EOF > "$layers_dir"/some-layer.toml
if test -f ${layers_dir}/some-layer.sbom.cdx.json; then
echo "${layers_dir}/some-layer.sbom.cdx.json restored with content: $(cat ${layers_dir}/some-layer.sbom.cdx.json)"
fi
echo -n "{\"key\": \"some-launch-true-bom-content\"}" > ${layers_dir}/some-layer.sbom.cdx.json
if test -f ${layers_dir}/some-layer.toml; then
# mimic not downloading new content
echo "nop"
else
# mimic downloading new content
sleep 1
fi
cat <<EOF > ${layers_dir}/some-layer.toml
[types]
launch = true
EOF
# cache=true layer
mkdir -p ${layers_dir}/some-cache-layer
if test -f ${layers_dir}/some-cache-layer.sbom.cdx.json; then
echo "${layers_dir}/some-cache-layer.sbom.cdx.json restored with content: $(cat ${layers_dir}/some-cache-layer.sbom.cdx.json)"
fi
echo -n "{\"key\": \"some-cache-true-bom-content\"}" > ${layers_dir}/some-cache-layer.sbom.cdx.json
cat <<EOF > ${layers_dir}/some-cache-layer.toml
[types]
cache = true
EOF
# launch=true cache=true layer
mkdir -p ${layers_dir}/some-launch-cache-layer
if test -f ${layers_dir}/some-launch-cache-layer.sbom.cdx.json; then
echo "${layers_dir}/some-launch-cache-layer.sbom.cdx.json restored with content: $(cat ${layers_dir}/some-launch-cache-layer.sbom.cdx.json)"
fi
echo -n "{\"key\": \"some-launch-true-cache-true-bom-content\"}" > ${layers_dir}/some-launch-cache-layer.sbom.cdx.json
cat <<EOF > ${layers_dir}/some-launch-cache-layer.toml
[types]
launch = true
cache = true
EOF
# build=true layer
mkdir -p ${layers_dir}/some-build-layer
if test -f ${layers_dir}/some-build-layer.sbom.cdx.json; then
echo "${layers_dir}/some-build-layer.sbom.cdx.json" should never be restored
exit 1
fi
echo -n "{\"key\": \"some-bom-content\"}" > ${layers_dir}/some-build-layer.sbom.cdx.json
cat <<EOF > ${layers_dir}/some-build-layer.toml
[types]
build = true
EOF
# launch bom
if test -f ${layers_dir}/launch.sbom.cdx.json; then
echo "${layers_dir}/launch.sbom.cdx.json should never be restored"
exit 1
fi
echo -n "{\"key\": \"some-bom-content\"}" > ${layers_dir}/launch.sbom.cdx.json
# build bom
if test -f ${layers_dir}/build.sbom.cdx.json; then
echo "${layers_dir}/build.sbom.cdx.json should never be restored"
exit 1
fi
echo -n "{\"key\": \"some-bom-content\"}" > ${layers_dir}/build.sbom.cdx.json
# store.toml
if test -f ${layers_dir}/store.toml; then
echo "${layers_dir}/store.toml restored with content: $(cat ${layers_dir}/store.toml)"
fi
printf "[metadata]\n\"some-key\" = \"some-value\"" > ${layers_dir}/store.toml

View File

@ -1,11 +1,12 @@
# Buildpack API version
api = "0.6"
api = "0.7"
# Buildpack ID and metadata
[buildpack]
id = "samples/hello-world"
version = "0.0.1"
name = "Hello World Buildpack"
sbom-formats = ["application/vnd.cyclonedx+json"]
# Stacks that the buildpack will work with
[[stacks]]

View File

@ -0,0 +1,8 @@
# Buildpack API version
api = "0.9"
# Extension ID and metadata
[extension]
id = "samples/hello-world"
version = "0.0.1"
name = "Hello World Extension"

View File

@ -0,0 +1,9 @@
[[order]]
[[order.group]]
id = "samples/hello-world"
version = "0.0.1"
[[order-extensions]]
[[order-extensions.group]]
id = "samples/hello-world"
version = "0.0.1"

View File

@ -0,0 +1,5 @@
[[images]]
image = "some-run-image-from-run-toml"
[[images]]
image = "some-other-run-image"

View File

@ -0,0 +1 @@
{"architecture":"amd64","config":{"Hostname":"","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sh"],"Image":"sha256:688db7a53b2e8d0358c0e1f309856290bb25ce7acabbf9938f580582e921833f","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":null},"container":"65aaed1d1f89cd3cd5aac9137c4786831e99a845ad823496c6008a22a725c780","container_config":{"Hostname":"65aaed1d1f89","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh","-c","#(nop) ","CMD [\"sh\"]"],"Image":"sha256:688db7a53b2e8d0358c0e1f309856290bb25ce7acabbf9938f580582e921833f","Volumes":null,"WorkingDir":"","Entrypoint":null,"OnBuild":null,"Labels":{}},"created":"2022-11-18T01:19:29.442257773Z","docker_version":"20.10.12","history":[{"created":"2022-11-18T01:19:29.321465538Z","created_by":"/bin/sh -c #(nop) ADD file:36d9f497f679d56737ac1379d93f7b6a2e4c814e38e868a5a8e719c4b226ef6e in / "},{"created":"2022-11-18T01:19:29.442257773Z","created_by":"/bin/sh -c #(nop) CMD [\"sh\"]","empty_layer":true}],"os":"linux","rootfs":{"type":"layers","diff_ids":["sha256:40cf597a9181e86497f4121c604f9f0ab208950a98ca21db883f26b0a548a2eb"]}}

View File

@ -0,0 +1,16 @@
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"size": 1457,
"digest": "sha256:9d5226e6ce3fb6aee2822206a5ef85f38c303d2b37bfc894b419fca2c0501269"
},
"layers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"size": 772999,
"digest": "sha256:405fecb6a2fa4f29683f977e7e3b852bf6f8975a2aba647d234d2371894943da"
}
]
}

View File

@ -0,0 +1,14 @@
{
"schemaVersion": 2,
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 527,
"digest": "sha256:f75f3d1a317fc82c793d567de94fc8df2bece37acd5f2bd364a0d91a0d1f3dab",
"platform": {
"architecture": "amd64",
"os": "linux"
}
}
]
}

View File

@ -0,0 +1,3 @@
{
"imageLayoutVersion": "1.0.0"
}

View File

@ -1,4 +1,4 @@
FROM ubuntu:bionic
FROM ubuntu:jammy
ARG cnb_uid=1234
ARG cnb_gid=1000

View File

@ -0,0 +1 @@
val-from-build-config

View File

@ -0,0 +1,5 @@
api = "0.1"
[buildpack]
id = "bad_api"
version = "bad_api_version"
name = "Bad API Buildpack"

View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
echo "ENV"
env
plan_path=$2
cat >> "${plan_path}" <<EOL
[[requires]]
name = "some_requirement"
[requires.metadata]
version = "some_version" # Optional
some_metadata_key = "some_metadata_val" # Optional
EOL

View File

@ -0,0 +1,6 @@
api = "0.10"
[buildpack]
id = "buildpack_for_ext"
version = "buildpack_for_ext_version"
name = "Buildpack for Extensions"

View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
echo "Opted out of detection"
exit 100

View File

@ -0,0 +1,5 @@
api = "0.9"
[buildpack]
id = "fail_detect_buildpack"
version = "some_version"
name = "Fail Detect Buildpack"

View File

@ -1,5 +1,12 @@
api = "0.3"
api = "0.9"
[buildpack]
id = "simple_buildpack"
version = "simple_buildpack_version"
name = "Simple Buildpack"
id = "simple_buildpack"
version = "simple_buildpack_version"
name = "Simple Buildpack"
[[stacks]]
id = "io.buildpacks.stacks.bionic"
[[stacks]]
id = "io.buildpacks.stacks.jammy"

View File

@ -1,4 +1,5 @@
api = "0.6"
api = "0.10"
[buildpack]
id = "always_detect_buildpack"
version = "always_detect_buildpack_version"

View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
plan_path=$2
cat >> "${plan_path}" <<EOL
[[provides]]
name = "some_requirement"
EOL
echo "simple_extension: output from /bin/detect"

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
cat >> "${CNB_OUTPUT_DIR}/run.Dockerfile" <<EOL
FROM some-run-image-from-extension
EOL
echo "simple_extension: output from /bin/generate"

View File

@ -0,0 +1,5 @@
api = "0.9"
[extension]
id = "simple_extension"
version = "simple_extension_version"
name = "Simple Extension"

View File

@ -0,0 +1,5 @@
[[order]]
[[order.group]]
id = "bad_api"
version = "bad_api_version"

View File

@ -0,0 +1,5 @@
[[order]]
[[order.group]]
id = "fail_detect_buildpack"
version = "some_version"

View File

@ -0,0 +1,9 @@
[[order]]
[[order.group]]
id = "buildpack_for_ext"
version = "buildpack_for_ext_version"
[[order-extensions]]
[[order-extensions.group]]
id = "simple_extension"
version = "simple_extension_version"

View File

@ -0,0 +1,5 @@
[[images]]
image = "some-run-image-from-extension"
[[images]]
image = "some-other-run-image"

View File

@ -0,0 +1,2 @@
[run-image]
reference = "some-old-run-image"

View File

@ -13,6 +13,12 @@ RUN groupadd cnb --gid ${cnb_gid} && \
# chown the directories so the tests do not have to run as root
RUN chown -R "${cnb_uid}:${cnb_gid}" "/layers"
RUN chown -R "${cnb_uid}:${cnb_gid}" "/layout-repo"
RUN chown -R "${cnb_uid}:${cnb_gid}" "/other_layers"
# create and chown a custom oci layout directory to export images
RUN mkdir /my-layout-dir
RUN chown -R "${cnb_uid}:${cnb_gid}" "/my-layout-dir"
WORKDIR /layers

View File

@ -0,0 +1,17 @@
{
"buildpacks": [
{
"key": "corrupted_buildpack",
"version": "corrupted_v1",
"layers": {
"corrupted-layer": {
"sha": "sha256:258dfa0cc987efebc17559694866ebc91139e7c0e574f60d1d4092f53d7dff59",
"data": null,
"build": false,
"launch": true,
"cache": true
}
}
}
]
}

View File

@ -0,0 +1,3 @@
[[images]]
image = "REPLACE"
mirrors = ["mirror1", "mirror2"]

View File

@ -0,0 +1,2 @@
[run-image]
reference = "host.docker.internal/bar"

View File

@ -1 +1 @@
sha256:b89860e2f9c62e6b5d66d3ce019e18cdabae30273c25150b7f20a82f7a70e494
sha256:2d9c9c638d5c4f0df067eeae7b9c99ad05776a89d19ab863c28850a91e5f2944

View File

@ -1,3 +1,4 @@
[types]
build = false
launch = false
cache = true

View File

@ -0,0 +1,2 @@
[types]
launch = true

View File

@ -0,0 +1 @@
launch-data

View File

@ -0,0 +1 @@
digest-not-match-data

View File

@ -1,9 +1,14 @@
[[group]]
id = "some-buildpack-id"
version = "some-buildpack-version"
api = "0.2"
api = "0.7"
[[group]]
id = "cacher_buildpack"
version = "cacher_v1"
api = "0.3"
api = "0.8"
[[group]]
id = "corrupted_buildpack"
version = "corrupted_v1"
api = "0.8"

View File

@ -0,0 +1,3 @@
[run-image]
reference = "REPLACE"
name = "REPLACE"

View File

@ -0,0 +1,3 @@
[run-image]
reference = "REPLACE"
extend = true

View File

@ -0,0 +1,47 @@
{
"architecture": "amd64",
"created": "0001-01-01T00:00:00Z",
"history": [
{
"author": "some-base-image-author",
"created": "2023-03-06T17:34:39.0316521Z",
"created_by": "FROM some-base-image"
},
{
"author": "kaniko",
"created": "0001-01-01T00:00:00Z",
"created_by": "Layer: 'RUN mkdir /some-dir && echo some-data > /some-dir/some-file && echo some-data > /some-file', Created by extension: first-extension"
},
{
"author": "kaniko",
"created": "0001-01-01T00:00:00Z",
"created_by": "Layer: 'RUN mkdir /some-other-dir && echo some-data > /some-other-dir/some-file && echo some-data > /some-other-file', Created by extension: second-extension"
}
],
"os": "linux",
"rootfs": {
"type": "layers",
"diff_ids": [
"sha256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c",
"sha256:d8dea3a780ba766c08bd11800809652ce5e9eba50b7b94ac09cb7f5e98e07f08",
"sha256:36f3735021a89a605c3da10b9659f0ec69e7c4c72abc802dc32471f1b080fd78"
]
},
"config": {
"Cmd": [
"/bin/bash"
],
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"CNB_USER_ID=1234",
"CNB_GROUP_ID=1000",
"CNB_STACK_ID=some-stack-id"
],
"Labels": {
"io.buildpacks.rebasable": "false",
"org.opencontainers.image.ref.name": "ubuntu",
"org.opencontainers.image.version": "18.04"
},
"User": "root"
}
}

Some files were not shown because too many files have changed in this diff Show More