Compare commits
338 Commits
Author | SHA1 | Date |
---|---|---|
|
0f224448e5 | |
|
d2f4fccf02 | |
|
4fd9dc8da9 | |
|
84bbd62a05 | |
|
3eec76970d | |
|
828680fd2d | |
|
c2d348fe76 | |
|
998df22b75 | |
|
22f90fc35f | |
|
d61099a58b | |
|
c4730aeb7f | |
|
61101937d3 | |
|
b26e08c712 | |
|
c924316f12 | |
|
d99c20ea89 | |
|
ced3359adc | |
|
24b93c486f | |
|
5ac11c505d | |
|
8f1b15834c | |
|
e25dc2d2f2 | |
|
f27995af70 | |
|
f3e3719918 | |
|
3a692e4a34 | |
|
f8bf3ed25e | |
|
f992fd6a6d | |
|
669686636a | |
|
21a01a93f5 | |
|
187d6555ad | |
|
d5a70ecfd6 | |
|
096e921bc0 | |
|
9f602ab430 | |
|
eff4eb9d82 | |
|
ed61c00263 | |
|
07705bb60a | |
|
ee501aec0a | |
|
4e5936a962 | |
|
f4c7a93419 | |
|
64b78965f6 | |
|
906b0e0779 | |
|
fb74763226 | |
|
c121049b41 | |
|
b98b668838 | |
|
761d2bdbb8 | |
|
14a6c36c78 | |
|
40c408d453 | |
|
99e4c87d75 | |
|
8bdb640857 | |
|
997840b2f2 | |
|
4f7f331816 | |
|
55c8b988a5 | |
|
92d9833a46 | |
|
5f776886ec | |
|
d34588e569 | |
|
f923ae5e07 | |
|
3d23976f2d | |
|
c895ed4002 | |
|
0adc6dd8ad | |
|
d4fe8f0554 | |
|
0727354ebf | |
|
e9bb570999 | |
|
3760f4bb9c | |
|
1b84db28e2 | |
|
ed2e33c6e6 | |
|
248343e3b7 | |
|
83faba2a2f | |
|
d71de96b56 | |
|
05b0768a0b | |
|
d1f38655a8 | |
|
60a94c4b03 | |
|
3a30c0b597 | |
|
c0cbaf1e02 | |
|
ba82c0d126 | |
|
fd1604734b | |
|
7bd8e735ea | |
|
e2ec390385 | |
|
3109b04667 | |
|
fe4a50b65f | |
|
036e579e28 | |
|
93c8b8b133 | |
|
b05882d689 | |
|
5d193d0374 | |
|
c8585e10fd | |
|
3a09c6dc98 | |
|
2c0f9bd6cd | |
|
35e4fb90bc | |
|
9a7a3b586f | |
|
93d5de7423 | |
|
45b52d389a | |
|
89aeb9ca7a | |
|
b58433202e | |
|
92c59d39d9 | |
|
952997fe48 | |
|
6fd74a9d56 | |
|
d5e9ad18c5 | |
|
890ce690cf | |
|
e38a4b5eb6 | |
|
2191fc1b5f | |
|
2062d5fefc | |
|
1534af909b | |
|
84c043350b | |
|
60bf07f8de | |
|
7fd497eac2 | |
|
ddcded12be | |
|
81ef5987de | |
|
acd4499d35 | |
|
68703b6cb7 | |
|
8cfa351ee8 | |
|
564dcd3ef3 | |
|
32f1113b28 | |
|
23922f4d08 | |
|
605a233fcf | |
|
85540b4c90 | |
|
eea0ba6a02 | |
|
3985f2e33a | |
|
a058e93f60 | |
|
21811fa4dc | |
|
0690d133ca | |
|
58f58e58a6 | |
|
5517e86a56 | |
|
e6091c97d3 | |
|
095affa914 | |
|
0872e08127 | |
|
4a52e3c9e7 | |
|
4d5a1b4437 | |
|
0d51c49e94 | |
|
2a5bb2f847 | |
|
dd23dd7de8 | |
|
ed3df30e1b | |
|
13adc3a8a8 | |
|
2e76236d20 | |
|
191e6c4790 | |
|
a43d5993a4 | |
|
9f262b3e5d | |
|
df6be88240 | |
|
a87e12e6cd | |
|
12e2de8449 | |
|
4c40dcadaf | |
|
04f1ad1d03 | |
|
f2a3bd78a8 | |
|
a02be035c8 | |
|
7b5a8ec1cf | |
|
36c0af0d81 | |
|
85b745ca87 | |
|
73f6927abc | |
|
1a1de0850a | |
|
83efa75a14 | |
|
c0590cda08 | |
|
8a148423a3 | |
|
effdf24b2c | |
|
44b70410fe | |
|
13d3691dd0 | |
|
37d69857b6 | |
|
82fdf23a6d | |
|
27ee43580b | |
|
85f22a0fa5 | |
|
267025743f | |
|
137225b961 | |
|
fea544183a | |
|
f309b50003 | |
|
cd50eb8848 | |
|
bb9eb96766 | |
|
9c8340112a | |
|
feb0d757c9 | |
|
955ab5e7c9 | |
|
a4e33e218a | |
|
9eaafdcfa8 | |
|
9f9ac3cbc6 | |
|
dff6494f28 | |
|
435d226f1e | |
|
5128c1360c | |
|
3a05fdea09 | |
|
548854fdf8 | |
|
f25f22c1de | |
|
de7bcf582c | |
|
1148b713e0 | |
|
f3f292c6b5 | |
|
41d885b2b4 | |
|
73af3c126d | |
|
f885774719 | |
|
553c041228 | |
|
2d2da0b9f0 | |
|
200b00a4a4 | |
|
4ec55dce9b | |
|
92bb4fb450 | |
|
7bdfb331bb | |
|
e2b30d8fe5 | |
|
d4e8609f49 | |
|
be5e24be99 | |
|
2f507d0121 | |
|
121d349e68 | |
|
ecbcbd94d4 | |
|
751c7a2737 | |
|
72671535c2 | |
|
7ab0850c64 | |
|
3c8876ce04 | |
|
2548af4b8b | |
|
b6a76bff09 | |
|
c8c4fc4f56 | |
|
6e199e6a64 | |
|
e9a83ae69a | |
|
f8b8669119 | |
|
b8a92ac78d | |
|
dbd27bdef0 | |
|
33c5b89004 | |
|
73648d2423 | |
|
7c591d11d6 | |
|
2b75adb9e5 | |
|
cdd883cdaf | |
|
736b776093 | |
|
653a46fa26 | |
|
9eec0f4f5c | |
|
2bf3ae75a0 | |
|
367b451eb7 | |
|
66472bc154 | |
|
a00c3832e3 | |
|
885847a4d5 | |
|
ab2fe4f2f3 | |
|
6885b2e6ff | |
|
292aa492a7 | |
|
7ce5b70299 | |
|
d0ed30b36f | |
|
be881f29d5 | |
|
6c7d16a718 | |
|
7ffcd58e74 | |
|
5b02ac1c8f | |
|
2b81abb8c4 | |
|
06ffeedd58 | |
|
874e2c17e8 | |
|
b384d8c3e6 | |
|
aeb177ca46 | |
|
105808ccf0 | |
|
a12fbff57d | |
|
325676eb6e | |
|
7fda8e271f | |
|
f1e60ccc34 | |
|
f82c23bd4f | |
|
c72dc20a93 | |
|
df9ae90e17 | |
|
56083d0680 | |
|
c3998654d3 | |
|
85fd513b83 | |
|
7001b6a594 | |
|
f8b3419877 | |
|
cc194b8666 | |
|
28c0253427 | |
|
8cb8336642 | |
|
9099967d7a | |
|
217a234476 | |
|
1a36a3b642 | |
|
1ca5500ad9 | |
|
8f0cb5886a | |
|
ae64f8848f | |
|
1ff8931f47 | |
|
9f7f501b95 | |
|
9c455eb4dd | |
|
e18a752b06 | |
|
d14bae1e26 | |
|
e06b69b5ac | |
|
94c3d31ec0 | |
|
44f4a7d8ab | |
|
8cdec9dc8e | |
|
1744539c83 | |
|
477aa7197d | |
|
c8e89ce07b | |
|
84a94d59df | |
|
f7708d95e6 | |
|
94da70f6b6 | |
|
12cb541fd1 | |
|
91593cf917 | |
|
7b886e0b80 | |
|
b1dd93cd14 | |
|
081106052c | |
|
9d07aa934c | |
|
7f4666ed2b | |
|
8bd0003a19 | |
|
82da83291a | |
|
29e694f8c3 | |
|
5ae441444e | |
|
eac881f32a | |
|
1fc9483341 | |
|
df5fca4fc0 | |
|
f9b8e9325a | |
|
28084b7412 | |
|
f506545986 | |
|
aa86fc68f7 | |
|
0e55ae5ea9 | |
|
c2609a0a52 | |
|
e1a8e5451d | |
|
3f1a3461ca | |
|
ae5c3e572c | |
|
89a1cfebef | |
|
5dbedd3ca0 | |
|
5c29f544ea | |
|
da6d62cec1 | |
|
a11cb6a5f0 | |
|
cf19426cf0 | |
|
1057837bae | |
|
a2dfc786a6 | |
|
e9072582a6 | |
|
68b4ce9a55 | |
|
710d938cf9 | |
|
5eb4eac531 | |
|
f48162ee68 | |
|
e0e30117b3 | |
|
627deb6dfb | |
|
c5a3549b07 | |
|
0a96158154 | |
|
1698cfaf58 | |
|
af79390a0b | |
|
1431839fad | |
|
39c4a7b571 | |
|
21fb915dce | |
|
4aa121f4dc | |
|
b7f652a764 | |
|
2b6ddbb7af | |
|
47594c2c29 | |
|
1299eb80d1 | |
|
00b292eb4a | |
|
584c6cbd35 | |
|
611dee801f | |
|
a6d834bbf4 | |
|
d409e5a939 | |
|
310acf90e1 | |
|
fa9a11abd2 | |
|
6d6b469717 | |
|
2f308e4f08 | |
|
b6af8b5515 | |
|
1400e8edce | |
|
d99d58f834 | |
|
cad291f00a | |
|
4cb2bdcbc5 | |
|
03ee829704 | |
|
6a10b63c67 | |
|
4e537685ce | |
|
e3e3590866 | |
|
3be3585644 | |
|
014ccebcee | |
|
5382f323cf |
|
@ -2,12 +2,14 @@
|
||||||
name: Bug
|
name: Bug
|
||||||
about: Bug report
|
about: Bug report
|
||||||
title: ''
|
title: ''
|
||||||
labels: status/triage, type/bug
|
labels: type/bug, status/triage
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Summary
|
### Summary
|
||||||
<!--- Please provide a general summary of the issue. -->
|
<!-- Please provide a general summary of the issue. -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -15,17 +17,20 @@ assignees: ''
|
||||||
### Reproduction
|
### Reproduction
|
||||||
|
|
||||||
##### Steps
|
##### Steps
|
||||||
<!--- What steps should be taken to reproduce the issue? -->
|
<!-- What steps should be taken to reproduce the issue? -->
|
||||||
|
|
||||||
1.
|
1.
|
||||||
2.
|
2.
|
||||||
3.
|
3.
|
||||||
|
|
||||||
##### Current behavior
|
##### 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
|
### Context
|
||||||
|
|
||||||
##### lifecycle version
|
##### 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)
|
##### 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?
|
##### anything else?
|
||||||
<!--- Tekton task version, kpack version, etc. -->
|
<!-- Add any other context that may help (e.g., Tekton task version, kpack version, etc.). -->
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,20 @@ assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Description
|
### Summary
|
||||||
<!-- A concise description of why this chore matters, who will enjoy it and how. -->
|
<!-- 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. -->
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,27 @@ assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Description
|
### Summary
|
||||||
<!-- A concise description of what problem the feature solves and why solving it matters. -->
|
<!-- 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. -->
|
||||||
|
|
||||||
|
|
|
@ -3,5 +3,14 @@ updates:
|
||||||
- package-ecosystem: gomod
|
- package-ecosystem: gomod
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: daily
|
interval: weekly
|
||||||
open-pull-requests-limit: 10
|
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
|
||||||
|
|
|
@ -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.). -->
|
||||||
|
|
|
@ -14,10 +14,13 @@ jobs:
|
||||||
test-linux-amd64:
|
test-linux-amd64:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Set up go
|
|
||||||
uses: actions/setup-go@v3
|
|
||||||
with:
|
with:
|
||||||
|
fetch-depth: '0'
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
check-latest: true
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'go.mod'
|
||||||
- name: Install jq
|
- name: Install jq
|
||||||
run: |
|
run: |
|
||||||
|
@ -30,8 +33,9 @@ jobs:
|
||||||
TEST_COVERAGE: 1
|
TEST_COVERAGE: 1
|
||||||
run: make test
|
run: make test
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
file: ./out/tests/coverage-unit.txt
|
file: ./out/tests/coverage-unit.txt
|
||||||
flags: unit,os_linux
|
flags: unit,os_linux
|
||||||
fail_ci_if_error: true
|
fail_ci_if_error: true
|
||||||
|
@ -39,91 +43,47 @@ jobs:
|
||||||
test-linux-arm64:
|
test-linux-arm64:
|
||||||
runs-on: linux-arm64
|
runs-on: linux-arm64
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Set up go
|
|
||||||
uses: actions/setup-go@v3
|
|
||||||
with:
|
with:
|
||||||
|
fetch-depth: '0'
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
check-latest: true
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'go.mod'
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
make format || true
|
make format || true
|
||||||
make test
|
make test
|
||||||
test-windows:
|
|
||||||
runs-on: windows-2019
|
|
||||||
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@v3
|
|
||||||
with:
|
|
||||||
go-version-file: 'go.mod'
|
|
||||||
- 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 | Add-Member -Force -Name "insecure-registries" -value @("$IPAddress/32") -MemberType NoteProperty
|
|
||||||
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@v2
|
|
||||||
with:
|
|
||||||
args: install codecov -y
|
|
||||||
- name: Run Codecov
|
|
||||||
run: |
|
|
||||||
codecov.exe -f .\out\tests\coverage-unit.txt -v --flag os_windows
|
|
||||||
build-and-publish:
|
build-and-publish:
|
||||||
needs:
|
needs:
|
||||||
- test-linux-amd64
|
- test-linux-amd64
|
||||||
- test-linux-arm64
|
- test-linux-arm64
|
||||||
- test-windows
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # fetch all history for all branches and tags
|
fetch-depth: 0 # fetch all history for all branches and tags
|
||||||
- name: Set up go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
|
check-latest: true
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'go.mod'
|
||||||
- name: Install Cosign
|
- name: Install Cosign
|
||||||
uses: sigstore/cosign-installer@v1.0.0
|
uses: sigstore/cosign-installer@v3
|
||||||
with:
|
|
||||||
cosign-release: 'v1.0.0'
|
|
||||||
- name: Set version
|
- name: Set version
|
||||||
run: |
|
run: |
|
||||||
echo "LIFECYCLE_VERSION=$(go run tools/version/main.go)" | tee -a $GITHUB_ENV version.txt
|
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:
|
with:
|
||||||
name: version
|
name: version
|
||||||
path: version.txt
|
path: version.txt
|
||||||
- name: Set tag
|
- name: Set tag
|
||||||
run: |
|
run: |
|
||||||
echo "LIFECYCLE_IMAGE_TAG=$(git describe --always --abbrev=7)" >> tag.txt
|
echo "LIFECYCLE_IMAGE_TAG=$(git describe --always --abbrev=7)" >> tag.txt
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: tag
|
name: tag
|
||||||
path: tag.txt
|
path: tag.txt
|
||||||
|
@ -132,71 +92,65 @@ jobs:
|
||||||
make clean
|
make clean
|
||||||
make build
|
make build
|
||||||
make package
|
make package
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: lifecycle-linux-x86-64
|
name: lifecycle-linux-x86-64
|
||||||
path: out/lifecycle-v*+linux.x86-64.tgz
|
path: out/lifecycle-v*+linux.x86-64.tgz
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: lifecycle-linux-x86-64-sha256
|
name: lifecycle-linux-x86-64-sha256
|
||||||
path: out/lifecycle-v*+linux.x86-64.tgz.sha256
|
path: out/lifecycle-v*+linux.x86-64.tgz.sha256
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: lifecycle-linux-arm64
|
name: lifecycle-linux-arm64
|
||||||
path: out/lifecycle-v*+linux.arm64.tgz
|
path: out/lifecycle-v*+linux.arm64.tgz
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: lifecycle-linux-arm64-sha256
|
name: lifecycle-linux-arm64-sha256
|
||||||
path: out/lifecycle-v*+linux.arm64.tgz.sha256
|
path: out/lifecycle-v*+linux.arm64.tgz.sha256
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: lifecycle-windows-x86-64
|
name: lifecycle-linux-ppc64le
|
||||||
path: out/lifecycle-v*+windows.x86-64.tgz
|
path: out/lifecycle-v*+linux.ppc64le.tgz
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: lifecycle-windows-x86-64-sha256
|
name: lifecycle-linux-ppc64le-sha256
|
||||||
path: out/lifecycle-v*+windows.x86-64.tgz.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
|
- name: Generate SBOM JSON
|
||||||
uses: CycloneDX/gh-gomod-generate-sbom@v1
|
uses: CycloneDX/gh-gomod-generate-sbom@v2
|
||||||
with:
|
with:
|
||||||
args: mod -licenses -json -output lifecycle-v${{ env.LIFECYCLE_VERSION }}-bom.cdx.json
|
args: mod -licenses -json -output lifecycle-v${{ env.LIFECYCLE_VERSION }}-bom.cdx.json
|
||||||
version: ^v1
|
version: ^v1
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: lifecycle-bom-cdx
|
name: lifecycle-bom-cdx
|
||||||
path: lifecycle-v*-bom.cdx.json
|
path: lifecycle-v*-bom.cdx.json
|
||||||
- name: Calculate SBOM sha
|
- name: Calculate SBOM sha
|
||||||
run: |
|
run: |
|
||||||
shasum -a 256 lifecycle-v${{ env.LIFECYCLE_VERSION }}-bom.cdx.json > lifecycle-v${{ env.LIFECYCLE_VERSION }}-bom.cdx.json.sha256
|
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:
|
with:
|
||||||
name: lifecycle-bom-cdx-sha256
|
name: lifecycle-bom-cdx-sha256
|
||||||
path: lifecycle-v*-bom.cdx.json.sha256
|
path: lifecycle-v*-bom.cdx.json.sha256
|
||||||
- uses: azure/docker-login@v1
|
- uses: azure/docker-login@v2
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: tag
|
name: tag
|
||||||
- name: Set env
|
- name: Set env
|
||||||
run: |
|
run: |
|
||||||
cat tag.txt >> $GITHUB_ENV
|
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
|
- name: Publish images
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
run: |
|
run: |
|
||||||
|
@ -209,25 +163,32 @@ 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}')
|
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"
|
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}')
|
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 "WINDOWS_AMD64_SHA: $WINDOWS_AMD64_SHA"
|
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} \
|
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-x86-64@${LINUX_AMD64_SHA} \
|
||||||
buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}-linux-arm64@${LINUX_ARM64_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})
|
MANIFEST_SHA=$(docker manifest push buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG})
|
||||||
echo "MANIFEST_SHA: $MANIFEST_SHA"
|
echo "MANIFEST_SHA: $MANIFEST_SHA"
|
||||||
|
|
||||||
COSIGN_PASSWORD=${{ secrets.COSIGN_PASSWORD }} cosign sign -r \
|
cosign sign -r -y \
|
||||||
-key <(echo -n "${{ secrets.COSIGN_PRIVATE_KEY }}" | base64 --decode) \
|
|
||||||
-a tag=${LIFECYCLE_IMAGE_TAG} \
|
-a tag=${LIFECYCLE_IMAGE_TAG} \
|
||||||
buildpacksio/lifecycle:${LIFECYCLE_IMAGE_TAG}@${MANIFEST_SHA}
|
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
|
- name: Scan image
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
uses: anchore/scan-action@v3
|
uses: anchore/scan-action@v6
|
||||||
with:
|
with:
|
||||||
image: buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}
|
image: buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}
|
||||||
pack-acceptance-linux:
|
pack-acceptance-linux:
|
||||||
|
@ -235,27 +196,27 @@ jobs:
|
||||||
needs: build-and-publish
|
needs: build-and-publish
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
repository: 'buildpacks/pack'
|
repository: 'buildpacks/pack'
|
||||||
path: 'pack'
|
path: 'pack'
|
||||||
ref: 'main'
|
ref: 'main'
|
||||||
fetch-depth: 0 # fetch all history for all branches and tags
|
fetch-depth: 0 # fetch all history for all branches and tags
|
||||||
- name: Set up go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: 'pack/go.mod'
|
go-version-file: 'pack/go.mod'
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: version
|
name: version
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: tag
|
name: tag
|
||||||
- name: Set env
|
- name: Set env
|
||||||
run: |
|
run: |
|
||||||
cat version.txt >> $GITHUB_ENV
|
cat version.txt >> $GITHUB_ENV
|
||||||
cat tag.txt >> $GITHUB_ENV
|
cat tag.txt >> $GITHUB_ENV
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v5
|
||||||
with:
|
with:
|
||||||
name: lifecycle-linux-x86-64
|
name: lifecycle-linux-x86-64
|
||||||
path: pack
|
path: pack
|
||||||
|
@ -266,75 +227,3 @@ jobs:
|
||||||
LIFECYCLE_PATH="../lifecycle-v${{ env.LIFECYCLE_VERSION }}+linux.x86-64.tgz" \
|
LIFECYCLE_PATH="../lifecycle-v${{ env.LIFECYCLE_VERSION }}+linux.x86-64.tgz" \
|
||||||
LIFECYCLE_IMAGE="buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}" \
|
LIFECYCLE_IMAGE="buildpacksio/lifecycle:${{ env.LIFECYCLE_IMAGE_TAG }}" \
|
||||||
make acceptance
|
make acceptance
|
||||||
pack-acceptance-windows:
|
|
||||||
if: github.event_name == 'push'
|
|
||||||
needs: build-and-publish
|
|
||||||
runs-on: windows-2019
|
|
||||||
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
|
|
||||||
with:
|
|
||||||
repository: 'buildpacks/pack'
|
|
||||||
path: 'pack'
|
|
||||||
ref: 'main'
|
|
||||||
fetch-depth: 0 # fetch all history for all branches and tags
|
|
||||||
- name: Set up go
|
|
||||||
uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version-file: 'pack/go.mod'
|
|
||||||
- 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 | Add-Member -Force -Name "insecure-registries" -value @("$IPAddress/32") -MemberType NoteProperty
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name: Check latest lifecycle release
|
name: check-latest-release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
|
@ -9,13 +9,29 @@ jobs:
|
||||||
check-release:
|
check-release:
|
||||||
runs-on:
|
runs-on:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v3
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
|
check-latest: true
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'go.mod'
|
||||||
- name: Read go versions
|
- name: Get previous release tag
|
||||||
id: read-go
|
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:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
|
@ -25,19 +41,19 @@ jobs:
|
||||||
|
|
||||||
LATEST_GO_VERSION=$(go version | cut -d ' ' -f 3)
|
LATEST_GO_VERSION=$(go version | cut -d ' ' -f 3)
|
||||||
|
|
||||||
LATEST_RELEASE_VERSION=$(gh release list -L 1 | cut -d $'\t' -f 1 | cut -d ' ' -f 2)
|
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
|
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
|
tar xzf lifecycle.tgz
|
||||||
LATEST_RELEASE_GO_VERSION=$(go version ./lifecycle/lifecycle | cut -d ' ' -f 2)
|
LATEST_RELEASE_GO_VERSION=$(go version ./lifecycle/lifecycle | cut -d ' ' -f 2)
|
||||||
|
|
||||||
echo "::set-output name=latest-go-version::${LATEST_GO_VERSION}"
|
echo "latest-go-version=${LATEST_GO_VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
echo "::set-output name=latest-release-go-version::${LATEST_RELEASE_GO_VERSION}"
|
echo "latest-release-go-version=${LATEST_RELEASE_GO_VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
LATEST_RELEASE_VERSION=$(echo $LATEST_RELEASE_VERSION | cut -d \v -f 2)
|
LATEST_RELEASE_VERSION=$(echo $LATEST_RELEASE_VERSION | cut -d \v -f 2)
|
||||||
echo "::set-output name=latest-release-version::${LATEST_RELEASE_VERSION}"
|
echo "latest-release-version=${LATEST_RELEASE_VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
- name: Create issue if needed
|
- name: Create issue if needed
|
||||||
if: ${{ steps.read-go.outputs.latest-go-version != steps.read-go.outputs.latest-release-go-version }}
|
if: ${{ steps.read-versions.outputs.latest-go-version != steps.read-versions.outputs.latest-release-go-version }}
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
|
@ -45,15 +61,15 @@ jobs:
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
title="Upgrade lifecycle to ${{ steps.read-go.outputs.latest-go-version }}"
|
title="Upgrade lifecycle to ${{ steps.read-versions.outputs.latest-go-version }}"
|
||||||
label=${{ steps.read-go.outputs.latest-go-version }}
|
label=${{ steps.read-versions.outputs.latest-go-version }}
|
||||||
|
|
||||||
# Create label to use for exact search
|
# Create label to use for exact search
|
||||||
gh label create "$label" || true
|
gh label create "$label" || true
|
||||||
|
|
||||||
search_output=$(gh issue list --search "$title" --label "$label")
|
search_output=$(gh issue list --search "$title" --label "$label")
|
||||||
|
|
||||||
body="Latest lifecycle release v${{ steps.read-go.outputs.latest-release-version }} is built with Go version ${{ steps.read-go.outputs.latest-release-go-version }}; newer version ${{ steps.read-go.outputs.latest-go-version }} is available."
|
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// }" ]
|
if [ -z "${search_output// }" ]
|
||||||
then
|
then
|
||||||
|
@ -70,9 +86,12 @@ jobs:
|
||||||
fi
|
fi
|
||||||
- name: Scan latest release image
|
- name: Scan latest release image
|
||||||
id: scan-image
|
id: scan-image
|
||||||
uses: anchore/scan-action@v3
|
uses: anchore/scan-action@v6
|
||||||
with:
|
with:
|
||||||
image: buildpacksio/lifecycle:${{ steps.read-go.outputs.latest-release-version }}
|
image: buildpacksio/lifecycle:${{ steps.read-versions.outputs.latest-release-version }}
|
||||||
|
fail-build: true
|
||||||
|
severity-cutoff: medium
|
||||||
|
output-format: json
|
||||||
- name: Create issue if needed
|
- name: Create issue if needed
|
||||||
if: failure() && steps.scan-image.outcome == 'failure'
|
if: failure() && steps.scan-image.outcome == 'failure'
|
||||||
env:
|
env:
|
||||||
|
@ -82,7 +101,7 @@ jobs:
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
title="CVE(s) found"
|
title="CVE(s) found in v${{ steps.read-versions.outputs.latest-release-version }}"
|
||||||
label=cve
|
label=cve
|
||||||
|
|
||||||
# Create label to use for exact search
|
# Create label to use for exact search
|
||||||
|
@ -91,7 +110,7 @@ jobs:
|
||||||
search_output=$(gh issue list --search "$title" --label "$label")
|
search_output=$(gh issue list --search "$title" --label "$label")
|
||||||
|
|
||||||
GITHUB_WORKFLOW_URL=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
|
GITHUB_WORKFLOW_URL=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
|
||||||
body="Latest lifecycle release v${{ steps.read-go.outputs.latest-release-version }} triggered CVE(s) from Grype. For further details, see: $GITHUB_WORKFLOW_URL"
|
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// }" ]
|
if [ -z "${search_output// }" ]
|
||||||
then
|
then
|
||||||
|
|
|
@ -6,8 +6,10 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
draft-release:
|
draft-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Install jq
|
- name: Install jq
|
||||||
run: |
|
run: |
|
||||||
mkdir -p deps/bin
|
mkdir -p deps/bin
|
||||||
|
@ -22,9 +24,10 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "LIFECYCLE_VERSION=$version" >> $GITHUB_ENV
|
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
|
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:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
script: |
|
script: |
|
||||||
|
@ -80,7 +83,10 @@ jobs:
|
||||||
throw "no artifacts found"
|
throw "no artifacts found"
|
||||||
}
|
}
|
||||||
if (urlList.length != 10) {
|
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(",")
|
return urlList.join(",")
|
||||||
})
|
})
|
||||||
|
@ -104,34 +110,80 @@ jobs:
|
||||||
cat *.sha256 | sort > lifecycle-v${{ env.LIFECYCLE_VERSION }}-checksums.txt
|
cat *.sha256 | sort > lifecycle-v${{ env.LIFECYCLE_VERSION }}-checksums.txt
|
||||||
rm *.sha256
|
rm *.sha256
|
||||||
- name: Set pre-release kind
|
- 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: |
|
run: |
|
||||||
echo "RELEASE_KIND=pre-release" >> $GITHUB_ENV
|
echo "RELEASE_KIND=pre-release" >> $GITHUB_ENV
|
||||||
- name: Set release kind
|
- name: Set release kind
|
||||||
if: "!contains(env.LIFECYCLE_VERSION, 'rc')"
|
if: "!contains(env.LIFECYCLE_VERSION, 'rc') && !contains(env.LIFECYCLE_VERSION, 'pre')"
|
||||||
run: |
|
run: |
|
||||||
echo "RELEASE_KIND=release" >> $GITHUB_ENV
|
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
|
- name: Set release body text
|
||||||
run: |
|
run: |
|
||||||
cat << EOF > body.txt
|
cat << EOF > body.txt
|
||||||
# lifecycle v${{ env.LIFECYCLE_VERSION }}
|
# 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
|
## 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
|
## 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
|
## Lifecycle Image
|
||||||
|
|
||||||
An OCI image containing the lifecycle binaries is available at buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}.
|
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
|
EOF
|
||||||
- name: Create Pre Release
|
- name: Create pre-release
|
||||||
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: |
|
run: |
|
||||||
cd ${{ env.ARTIFACTS_PATH }}
|
cd ${{ env.ARTIFACTS_PATH }}
|
||||||
gh release create v${{ env.LIFECYCLE_VERSION }} \
|
gh release create v${{ env.LIFECYCLE_VERSION }} \
|
||||||
|
@ -139,19 +191,19 @@ jobs:
|
||||||
--draft \
|
--draft \
|
||||||
--notes-file ../body.txt \
|
--notes-file ../body.txt \
|
||||||
--prerelease \
|
--prerelease \
|
||||||
--target $GITHUB_REF \
|
--target $GITHUB_REF_NAME \
|
||||||
--title "lifecycle v${{ env.LIFECYCLE_VERSION }}"
|
--title "lifecycle v${{ env.LIFECYCLE_VERSION }}"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Create Release
|
- name: Create release
|
||||||
if: "!contains(env.LIFECYCLE_VERSION, 'rc')"
|
if: "!contains(env.LIFECYCLE_VERSION, 'rc') && !contains(env.LIFECYCLE_VERSION, 'pre')"
|
||||||
run: |
|
run: |
|
||||||
cd ${{ env.ARTIFACTS_PATH }}
|
cd ${{ env.ARTIFACTS_PATH }}
|
||||||
gh release create v${{ env.LIFECYCLE_VERSION }} \
|
gh release create v${{ env.LIFECYCLE_VERSION }} \
|
||||||
$(ls | sort | paste -sd " " -) \
|
$(ls | sort | paste -sd " " -) \
|
||||||
--draft \
|
--draft \
|
||||||
--notes-file ../body.txt \
|
--notes-file ../body.txt \
|
||||||
--target $GITHUB_REF \
|
--target $GITHUB_REF_NAME \
|
||||||
--title "lifecycle v${{ env.LIFECYCLE_VERSION }}"
|
--title "lifecycle v${{ env.LIFECYCLE_VERSION }}"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
|
@ -8,20 +8,21 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
retag-lifecycle-images:
|
retag-lifecycle-images:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Set up go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
|
check-latest: true
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'go.mod'
|
||||||
- name: Install crane
|
- name: Install crane
|
||||||
run: |
|
run: |
|
||||||
go install github.com/google/go-containerregistry/cmd/crane@latest
|
go install github.com/google/go-containerregistry/cmd/crane@latest
|
||||||
- name: Install cosign
|
- name: Install cosign
|
||||||
uses: sigstore/cosign-installer@main
|
uses: sigstore/cosign-installer@v3
|
||||||
with:
|
- uses: azure/docker-login@v2
|
||||||
cosign-release: 'v1.2.0'
|
|
||||||
- uses: azure/docker-login@v1
|
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
@ -31,17 +32,22 @@ jobs:
|
||||||
echo "LIFECYCLE_IMAGE_TAG=$(git describe --always --abbrev=7)" >> $GITHUB_ENV
|
echo "LIFECYCLE_IMAGE_TAG=$(git describe --always --abbrev=7)" >> $GITHUB_ENV
|
||||||
- name: Verify lifecycle images
|
- name: Verify lifecycle images
|
||||||
run: |
|
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"
|
||||||
echo "LINUX_AMD64_SHA=$LINUX_AMD64_SHA" >> $GITHUB_ENV
|
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"
|
||||||
echo "LINUX_ARM64_SHA=$LINUX_ARM64_SHA" >> $GITHUB_ENV
|
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\")
|
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 "WINDOWS_AMD64_SHA: $WINDOWS_AMD64_SHA"
|
echo "LINUX_PPC64LE_SHA: $LINUX_PPC64LE_SHA"
|
||||||
echo "WINDOWS_AMD64_SHA=$WINDOWS_AMD64_SHA" >> $GITHUB_ENV
|
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
|
- name: Download SBOM
|
||||||
run: |
|
run: |
|
||||||
gh release download --pattern '*-bom.cdx.json' ${{ github.event.release.tag_name }}
|
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-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 }}-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 }} \
|
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-x86-64@${{ env.LINUX_AMD64_SHA }} \
|
||||||
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}-linux-arm64@${{ env.LINUX_ARM64_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 }})
|
MANIFEST_SHA=$(docker manifest push buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }})
|
||||||
echo "MANIFEST_SHA: $MANIFEST_SHA"
|
echo "MANIFEST_SHA: $MANIFEST_SHA"
|
||||||
|
|
||||||
COSIGN_PASSWORD=${{ secrets.COSIGN_PASSWORD }} cosign sign -r \
|
cosign sign -r -y \
|
||||||
-key <(echo -n "${{ secrets.COSIGN_PRIVATE_KEY }}" | base64 --decode) \
|
|
||||||
-a tag=${{ env.LIFECYCLE_VERSION }} \
|
-a tag=${{ env.LIFECYCLE_VERSION }} \
|
||||||
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}@${MANIFEST_SHA}
|
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 attach sbom --sbom ./*-bom.cdx.json --type cyclonedx buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}
|
||||||
COSIGN_PASSWORD=${{ secrets.COSIGN_PASSWORD }} cosign sign -r \
|
cosign sign -r -y \
|
||||||
-key <(echo -n "${{ secrets.COSIGN_PRIVATE_KEY }}" | base64 --decode) \
|
-a tag=${{ env.LIFECYCLE_VERSION }} --attachment sbom \
|
||||||
-a tag=${{ env.LIFECYCLE_VERSION }} -attachment sbom \
|
|
||||||
buildpacksio/lifecycle:${{ env.LIFECYCLE_VERSION }}@${MANIFEST_SHA}
|
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
|
- 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: |
|
run: |
|
||||||
DOCKER_CLI_EXPERIMENTAL=enabled
|
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-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 }}-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 \
|
docker manifest create buildpacksio/lifecycle:latest \
|
||||||
buildpacksio/lifecycle:latest-linux-x86-64@${{ env.LINUX_AMD64_SHA }} \
|
buildpacksio/lifecycle:latest-linux-x86-64@${{ env.LINUX_AMD64_SHA }} \
|
||||||
buildpacksio/lifecycle:latest-linux-arm64@${{ env.LINUX_ARM64_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)
|
MANIFEST_SHA=$(docker manifest push buildpacksio/lifecycle:latest)
|
||||||
echo "MANIFEST_SHA: $MANIFEST_SHA"
|
echo "MANIFEST_SHA: $MANIFEST_SHA"
|
||||||
|
|
||||||
COSIGN_PASSWORD=${{ secrets.COSIGN_PASSWORD }} cosign sign -r \
|
cosign sign -r -y \
|
||||||
-key <(echo -n "${{ secrets.COSIGN_PRIVATE_KEY }}" | base64 --decode) \
|
|
||||||
-a tag=latest \
|
-a tag=latest \
|
||||||
buildpacksio/lifecycle:latest@${MANIFEST_SHA}
|
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 attach sbom --sbom ./*-bom.cdx.json --type cyclonedx buildpacksio/lifecycle:latest
|
||||||
COSIGN_PASSWORD=${{ secrets.COSIGN_PASSWORD }} cosign sign -r \
|
cosign sign -r -y \
|
||||||
-key <(echo -n "${{ secrets.COSIGN_PRIVATE_KEY }}" | base64 --decode) \
|
-a tag=${{ env.LIFECYCLE_VERSION }} --attachment sbom \
|
||||||
-a tag=${{ env.LIFECYCLE_VERSION }} -attachment sbom \
|
|
||||||
buildpacksio/lifecycle:latest@${MANIFEST_SHA}
|
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
|
||||||
|
|
|
@ -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
|
|
@ -6,7 +6,12 @@
|
||||||
.tool-versions
|
.tool-versions
|
||||||
/out
|
/out
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
acceptance/testdata/*/**/container/cnb/lifecycle/*
|
acceptance/testdata/*/**/container/cnb/lifecycle/*
|
||||||
acceptance/testdata/*/**/container/docker-config/*
|
acceptance/testdata/*/**/container/docker-config/*
|
||||||
|
|
||||||
|
acceptance/testdata/exporter/container/cnb/run.toml
|
||||||
acceptance/testdata/exporter/container/layers/*analyzed.toml
|
acceptance/testdata/exporter/container/layers/*analyzed.toml
|
||||||
acceptance/testdata/exporter/container/other_layers/*analyzed.toml
|
acceptance/testdata/exporter/container/other_layers/*analyzed.toml
|
||||||
|
|
||||||
|
acceptance/testdata/restorer/container/layers/*analyzed.toml
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
ignore:
|
ignore:
|
||||||
- vulnerability: CVE-2015-5237 # false positive, see https://github.com/anchore/grype/issues/558
|
- 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-2021-22570 # false positive, see https://github.com/anchore/grype/issues/558
|
||||||
- vulnerability: GHSA-f3fp-gc8g-vw66 # can't update github.com/opencontainers/runc until it is updated in github.com/docker/docker
|
- vulnerability: CVE-2024-41110 # non-impactful as we only use docker as a client
|
||||||
- vulnerability: GHSA-v95c-p5hm-xq8f # can't update github.com/opencontainers/runc until it is updated in github.com/docker/docker
|
- vulnerability: GHSA-v23v-6jw2-98fq # non-impactful as we only use docker as a client
|
||||||
|
|
|
@ -36,20 +36,18 @@
|
||||||
|
|
||||||
The lifecycle release process involves chaining a series of GitHub actions together such that:
|
The lifecycle release process involves chaining a series of GitHub actions together such that:
|
||||||
* The "build" workflow creates the artifacts
|
* 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)
|
* 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 "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
|
* 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.
|
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:
|
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_PASSWORD (if not using ghcr.io)
|
||||||
* DOCKER_USERNAME (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.
|
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>`
|
It can be invoked like so: `./tools/test-fork.sh <registry repo name>`
|
||||||
|
|
||||||
## Tasks
|
## Tasks
|
||||||
|
|
||||||
|
@ -77,6 +75,16 @@ Formats, vets, and tests the code.
|
||||||
$ make test
|
$ 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
|
### Build
|
||||||
|
|
||||||
Builds binaries to `out/linux/lifecycle/` and `out/windows/lifecycle/`.
|
Builds binaries to `out/linux/lifecycle/` and `out/windows/lifecycle/`.
|
||||||
|
|
17
IMAGE.md
17
IMAGE.md
|
@ -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:
|
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/amd64`
|
||||||
* `linux/arm64`
|
* `linux/arm64`
|
||||||
* `windows/amd64`
|
|
||||||
|
|
||||||
# About this image
|
# 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:
|
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:
|
* 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:
|
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:
|
* Run:
|
||||||
```
|
```
|
||||||
cosign version # must be at least 1.2.0
|
cosign version # must be at least 2.0.0
|
||||||
cosign verify -key cosign.pub -a tag=<tag> -attachment sbom buildpacksio/lifecycle:<tag>
|
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>
|
cosign download sbom buildpacksio/lifecycle:<tag>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
274
Makefile
274
Makefile
|
@ -30,7 +30,6 @@ LDFLAGS+=-X 'github.com/buildpacks/lifecycle/cmd.Version=$(LIFECYCLE_VERSION)'
|
||||||
GOBUILD:=go build $(GOFLAGS) -ldflags "$(LDFLAGS)"
|
GOBUILD:=go build $(GOFLAGS) -ldflags "$(LDFLAGS)"
|
||||||
GOTEST=$(GOCMD) test $(GOFLAGS)
|
GOTEST=$(GOCMD) test $(GOFLAGS)
|
||||||
BUILD_DIR?=$(PWD)$/out
|
BUILD_DIR?=$(PWD)$/out
|
||||||
WINDOWS_COMPILATION_IMAGE?=golang:1.19-windowsservercore-1809
|
|
||||||
SOURCE_COMPILATION_IMAGE?=lifecycle-img
|
SOURCE_COMPILATION_IMAGE?=lifecycle-img
|
||||||
BUILD_CTR?=lifecycle-ctr
|
BUILD_CTR?=lifecycle-ctr
|
||||||
DOCKER_CMD?=make test
|
DOCKER_CMD?=make test
|
||||||
|
@ -39,11 +38,9 @@ GOFILES := $(shell $(GOCMD) run tools$/lister$/main.go)
|
||||||
|
|
||||||
all: test build package
|
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: build-linux-amd64 build-linux-arm64 build-linux-ppc64le build-linux-s390x
|
||||||
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-image-linux-amd64: build-linux-amd64 package-linux-amd64
|
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
|
build-image-linux-amd64: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+linux.x86-64.tgz
|
||||||
|
@ -55,173 +52,60 @@ build-image-linux-arm64: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSIO
|
||||||
build-image-linux-arm64:
|
build-image-linux-arm64:
|
||||||
$(GOCMD) run ./tools/image/main.go -daemon -lifecyclePath $(ARCHIVE_PATH) -os linux -arch arm64 -tag lifecycle:$(LIFECYCLE_IMAGE_TAG)
|
$(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-linux-ppc64le: build-linux-ppc64le package-linux-ppc64le
|
||||||
build-image-windows-amd64: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+windows.x86-64.tgz
|
build-image-linux-ppc64le: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+linux.ppc64le.tgz
|
||||||
build-image-windows-amd64:
|
build-image-linux-ppc64le:
|
||||||
$(GOCMD) run ./tools/image/main.go -daemon -lifecyclePath $(ARCHIVE_PATH) -os windows -arch amd64 -tag lifecycle:$(LIFECYCLE_IMAGE_TAG)
|
$(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-$(1)-$(2)-lifecycle: $(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle
|
||||||
$(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_DIR)/linux-arm64/lifecycle/lifecycle: export GOOS:=linux
|
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle: export GOOS:=$(1)
|
||||||
$(BUILD_DIR)/linux-arm64/lifecycle/lifecycle: export GOARCH:=arm64
|
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle: export GOARCH:=$(2)
|
||||||
$(BUILD_DIR)/linux-arm64/lifecycle/lifecycle: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
|
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle: OUT_DIR?=$$(BUILD_DIR)/$$(GOOS)-$$(GOARCH)/lifecycle
|
||||||
$(BUILD_DIR)/linux-arm64/lifecycle/lifecycle: $(GOFILES)
|
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle: $$(GOFILES)
|
||||||
$(BUILD_DIR)/linux-arm64/lifecycle/lifecycle:
|
$$(BUILD_DIR)/$(1)-$(2)/lifecycle/lifecycle:
|
||||||
@echo "> Building lifecycle/lifecycle for $(GOOS)/$(GOARCH)..."
|
@echo "> Building lifecycle/lifecycle for $$(GOOS)/$$(GOARCH)..."
|
||||||
mkdir -p $(OUT_DIR)
|
mkdir -p $$(OUT_DIR)
|
||||||
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/lifecycle -a ./cmd/lifecycle
|
$$(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-$(1)-$(2)-launcher: $$(BUILD_DIR)/$(1)-$(2)/lifecycle/launcher
|
||||||
$(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-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
|
$(foreach ga,$(GOOS_ARCHS),$(eval $(call build_targets,$(word 1, $(subst /, ,$(ga))),$(word 2, $(subst /, ,$(ga))))))
|
||||||
$(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
|
|
||||||
|
|
||||||
build-linux-amd64-symlinks: export GOOS:=linux
|
generate-sbom: run-syft-linux-amd64 run-syft-linux-arm64 run-syft-linux-ppc64le run-syft-linux-s390x
|
||||||
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
|
|
||||||
ln -sf lifecycle $(OUT_DIR)/extender
|
|
||||||
|
|
||||||
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
|
|
||||||
ln -sf lifecycle $(OUT_DIR)/extender
|
|
||||||
|
|
||||||
build-windows-amd64-lifecycle: $(BUILD_DIR)/windows-amd64/lifecycle/lifecycle.exe
|
|
||||||
|
|
||||||
$(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
|
|
||||||
|
|
||||||
build-windows-amd64-launcher: $(BUILD_DIR)/windows-amd64/lifecycle/launcher.exe
|
|
||||||
|
|
||||||
$(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
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
generate-sbom: run-syft-windows run-syft-linux-amd64 run-syft-linux-arm64
|
|
||||||
|
|
||||||
run-syft-windows: install-syft
|
|
||||||
run-syft-windows: export GOOS:=windows
|
|
||||||
run-syft-windows: export GOARCH:=amd64
|
|
||||||
run-syft-windows:
|
|
||||||
@echo "> Running syft..."
|
|
||||||
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.exe -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.exe -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
|
|
||||||
|
|
||||||
run-syft-linux-amd64: install-syft
|
run-syft-linux-amd64: install-syft
|
||||||
run-syft-linux-amd64: export GOOS:=linux
|
run-syft-linux-amd64: export GOOS:=linux
|
||||||
|
@ -239,25 +123,46 @@ run-syft-linux-arm64:
|
||||||
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/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
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
install-syft:
|
install-syft:
|
||||||
@echo "> Installing syft..."
|
@echo "> Installing syft..."
|
||||||
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
|
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
|
||||||
|
|
||||||
|
define install-go-tool
|
||||||
|
@echo "> Installing $(1)..."
|
||||||
|
$(GOCMD) install $(1)@$(shell $(GOCMD) list -m -f '{{.Version}}' $(2))
|
||||||
|
endef
|
||||||
|
|
||||||
install-goimports:
|
install-goimports:
|
||||||
@echo "> Installing 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:
|
install-yj:
|
||||||
@echo "> Installing 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:
|
install-mockgen:
|
||||||
@echo "> Installing 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:
|
install-golangci-lint:
|
||||||
@echo "> Installing golangci-lint..."
|
@echo "> Installing golangci-lint..."
|
||||||
$(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0
|
$(call install-go-tool,github.com/golangci/golangci-lint/v2/cmd/golangci-lint,github.com/golangci/golangci-lint/v2)
|
||||||
|
|
||||||
lint: install-golangci-lint
|
lint: install-golangci-lint
|
||||||
@echo "> Linting code..."
|
@echo "> Linting code..."
|
||||||
|
@ -300,7 +205,7 @@ clean:
|
||||||
@echo "> Cleaning workspace..."
|
@echo "> Cleaning workspace..."
|
||||||
rm -rf $(BUILD_DIR)
|
rm -rf $(BUILD_DIR)
|
||||||
|
|
||||||
package: generate-sbom 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: GOOS:=linux
|
||||||
package-linux-amd64: GOARCH:=amd64
|
package-linux-amd64: GOARCH:=amd64
|
||||||
|
@ -320,25 +225,20 @@ package-linux-arm64:
|
||||||
@echo "> Packaging lifecycle for $(GOOS)/$(GOARCH)..."
|
@echo "> Packaging lifecycle for $(GOOS)/$(GOARCH)..."
|
||||||
$(GOCMD) run $(PACKAGER) --inputDir $(INPUT_DIR) -archivePath $(ARCHIVE_PATH) -descriptorPath $(LIFECYCLE_DESCRIPTOR_PATH) -version $(LIFECYCLE_VERSION)
|
$(GOCMD) run $(PACKAGER) --inputDir $(INPUT_DIR) -archivePath $(ARCHIVE_PATH) -descriptorPath $(LIFECYCLE_DESCRIPTOR_PATH) -version $(LIFECYCLE_VERSION)
|
||||||
|
|
||||||
package-windows-amd64: GOOS:=windows
|
package-linux-ppc64le: GOOS:=linux
|
||||||
package-windows-amd64: GOARCH:=amd64
|
package-linux-ppc64le: GOARCH:=ppc64le
|
||||||
package-windows-amd64: INPUT_DIR:=$(BUILD_DIR)$/$(GOOS)-$(GOARCH)$/lifecycle
|
package-linux-ppc64le: INPUT_DIR:=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
|
||||||
package-windows-amd64: ARCHIVE_PATH=$(BUILD_DIR)$/lifecycle-v$(LIFECYCLE_VERSION)+$(GOOS).x86-64.tgz
|
package-linux-ppc64le: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+$(GOOS).ppc64le.tgz
|
||||||
package-windows-amd64: PACKAGER=.$/tools$/packager$/main.go
|
package-linux-ppc64le: PACKAGER=./tools/packager/main.go
|
||||||
package-windows-amd64:
|
package-linux-ppc64le:
|
||||||
@echo "> Packaging lifecycle for $(GOOS)/$(GOARCH)..."
|
@echo "> Packaging lifecycle for $(GOOS)/$(GOARCH)..."
|
||||||
$(GOCMD) run $(PACKAGER) --inputDir $(INPUT_DIR) -archivePath $(ARCHIVE_PATH) -descriptorPath $(LIFECYCLE_DESCRIPTOR_PATH) -version $(LIFECYCLE_VERSION)
|
$(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
|
package-linux-s390x: GOOS:=linux
|
||||||
docker-build-source-image-windows: $(GOFILES)
|
package-linux-s390x: GOARCH:=s390x
|
||||||
docker-build-source-image-windows:
|
package-linux-s390x: INPUT_DIR:=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
|
||||||
$(if $(shell git status --short), @echo Uncommitted changes. Refusing to run. && exit 1)
|
package-linux-s390x: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+$(GOOS).s390x.tgz
|
||||||
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
|
package-linux-s390x: PACKAGER=./tools/packager/main.go
|
||||||
|
package-linux-s390x:
|
||||||
docker-run-windows: docker-build-source-image-windows
|
@echo "> Packaging lifecycle for $(GOOS)/$(GOARCH)..."
|
||||||
docker-run-windows:
|
$(GOCMD) run $(PACKAGER) --inputDir $(INPUT_DIR) -archivePath $(ARCHIVE_PATH) -descriptorPath $(LIFECYCLE_DESCRIPTOR_PATH) -version $(LIFECYCLE_VERSION)
|
||||||
@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
|
|
||||||
|
|
22
README.md
22
README.md
|
@ -10,17 +10,15 @@ A reference implementation of the [Cloud Native Buildpacks specification](https:
|
||||||
|
|
||||||
## Supported APIs
|
## Supported APIs
|
||||||
| Lifecycle Version | Platform APIs | Buildpack APIs |
|
| Lifecycle Version | Platform APIs | Buildpack APIs |
|
||||||
|-------------------|------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|
|
|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| 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.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.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] |
|
| 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] |
|
|
||||||
|
|
||||||
[b/0.2]: https://github.com/buildpacks/spec/blob/buildpack/v0.2/buildpack.md
|
[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
|
[b/0.3]: https://github.com/buildpacks/spec/tree/buildpack/v0.3/buildpack.md
|
||||||
|
@ -30,6 +28,8 @@ A reference implementation of the [Cloud Native Buildpacks specification](https:
|
||||||
[b/0.7]: https://github.com/buildpacks/spec/tree/buildpack/v0.7/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.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.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.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.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
|
[p/0.4]: https://github.com/buildpacks/spec/blob/platform/v0.4/platform.md
|
||||||
|
@ -39,6 +39,10 @@ A reference implementation of the [Cloud Native Buildpacks specification](https:
|
||||||
[p/0.8]: https://github.com/buildpacks/spec/blob/platform/v0.8/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.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.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
|
\* denotes unreleased version
|
||||||
|
|
||||||
|
|
83
RELEASE.md
83
RELEASE.md
|
@ -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. 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>`.
|
* For final releases (not pre-releases), remove the pre-release note (`*`) for the latest apis.
|
||||||
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.
|
|
||||||
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.
|
|
||||||
|
|
||||||
To cut a release:
|
**For final releases (not pre-releases):**
|
||||||
1. Ensure the relevant spec APIs have been released.
|
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. 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. 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. If applicable, ensure the README is updated with the latest supported apis (example PR: https://github.com/buildpacks/lifecycle/pull/550) and remove the pre-release note for the latest apis.
|
### Step 2 - Publish the Release
|
||||||
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.
|
|
||||||
|
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. Edit the release notes as necessary.
|
||||||
1. Perform any manual validation of the artifacts.
|
1. Perform any manual validation of the artifacts as necessary (usually none).
|
||||||
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. Edit the release page and click "Publish release".
|
||||||
1. Once released
|
* This will trigger the `post-release` workflow that will re-tag the lifecycle image from `buildpacksio/lifecycle:<commit sha>` to `buildpacksio/lifecycle:<release version>`.
|
||||||
- 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`.
|
* For final releases ONLY, this will also re-tag the lifecycle image from `buildpacksio/lifecycle:<commit sha>` to `buildpacksio/lifecycle:latest`.
|
||||||
- Ask the learning team to merge the `release/lifecycle/0.99` branch into `main` on the docs repo.
|
|
||||||
|
### 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
|
||||||
|
|
|
@ -141,6 +141,7 @@ func testVersion(t *testing.T, when spec.G, it spec.S) {
|
||||||
w(tc.description, func() {
|
w(tc.description, func() {
|
||||||
it("only prints the version", func() {
|
it("only prints the version", func() {
|
||||||
cmd := lifecycleCmd(tc.command, tc.args...)
|
cmd := lifecycleCmd(tc.command, tc.args...)
|
||||||
|
cmd.Env = []string{fmt.Sprintf("CNB_PLATFORM_API=%s", api.Platform.Latest().String())}
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to run %v\n OUTPUT: %s\n ERROR: %s\n", cmd.Args, output, err)
|
t.Fatalf("failed to run %v\n OUTPUT: %s\n ERROR: %s\n", cmd.Args, output, err)
|
||||||
|
|
|
@ -2,26 +2,22 @@ package acceptance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
|
||||||
"github.com/sclevine/spec"
|
"github.com/sclevine/spec"
|
||||||
"github.com/sclevine/spec/report"
|
"github.com/sclevine/spec/report"
|
||||||
|
|
||||||
"github.com/buildpacks/lifecycle/api"
|
"github.com/buildpacks/lifecycle/api"
|
||||||
"github.com/buildpacks/lifecycle/platform"
|
"github.com/buildpacks/lifecycle/cmd"
|
||||||
|
"github.com/buildpacks/lifecycle/internal/path"
|
||||||
|
"github.com/buildpacks/lifecycle/platform/files"
|
||||||
h "github.com/buildpacks/lifecycle/testhelpers"
|
h "github.com/buildpacks/lifecycle/testhelpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cacheFixtureDir string
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
analyzeImage string
|
analyzeImage string
|
||||||
analyzeRegAuthConfig string
|
analyzeRegAuthConfig string
|
||||||
|
@ -33,8 +29,6 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAnalyzer(t *testing.T) {
|
func TestAnalyzer(t *testing.T) {
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
|
||||||
|
|
||||||
testImageDockerContext := filepath.Join("testdata", "analyzer")
|
testImageDockerContext := filepath.Join("testdata", "analyzer")
|
||||||
analyzeTest = NewPhaseTest(t, "analyzer", testImageDockerContext)
|
analyzeTest = NewPhaseTest(t, "analyzer", testImageDockerContext)
|
||||||
analyzeTest.Start(t)
|
analyzeTest.Start(t)
|
||||||
|
@ -42,7 +36,6 @@ func TestAnalyzer(t *testing.T) {
|
||||||
|
|
||||||
analyzeImage = analyzeTest.testImageRef
|
analyzeImage = analyzeTest.testImageRef
|
||||||
analyzerPath = analyzeTest.containerBinaryPath
|
analyzerPath = analyzeTest.containerBinaryPath
|
||||||
cacheFixtureDir = filepath.Join("testdata", "cache-dir")
|
|
||||||
analyzeRegAuthConfig = analyzeTest.targetRegistry.authConfig
|
analyzeRegAuthConfig = analyzeTest.targetRegistry.authConfig
|
||||||
analyzeRegNetwork = analyzeTest.targetRegistry.network
|
analyzeRegNetwork = analyzeTest.targetRegistry.network
|
||||||
analyzeDaemonFixtures = analyzeTest.targetDaemon.fixtures
|
analyzeDaemonFixtures = analyzeTest.targetDaemon.fixtures
|
||||||
|
@ -74,6 +67,23 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
os.RemoveAll(copyDir)
|
os.RemoveAll(copyDir)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
when("CNB_PLATFORM_API not provided", func() {
|
||||||
|
it("errors", func() {
|
||||||
|
cmd := exec.Command(
|
||||||
|
"docker", "run", "--rm",
|
||||||
|
"--env", "CNB_PLATFORM_API= ",
|
||||||
|
analyzeImage,
|
||||||
|
ctrPath(analyzerPath),
|
||||||
|
"some-image",
|
||||||
|
) // #nosec G204
|
||||||
|
output, err := cmd.CombinedOutput()
|
||||||
|
|
||||||
|
h.AssertNotNil(t, err)
|
||||||
|
expected := "please set 'CNB_PLATFORM_API'"
|
||||||
|
h.AssertStringContains(t, string(output), expected)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
when("called without an app image", func() {
|
when("called without an app image", func() {
|
||||||
it("errors", func() {
|
it("errors", func() {
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
|
@ -90,73 +100,34 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when("called with group", func() {
|
|
||||||
it("errors", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.7"), "Platform API < 0.7 accepts a -group flag")
|
|
||||||
cmd := exec.Command(
|
|
||||||
"docker", "run", "--rm",
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
analyzeImage,
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-group", "group.toml",
|
|
||||||
"some-image",
|
|
||||||
) // #nosec G204
|
|
||||||
output, err := cmd.CombinedOutput()
|
|
||||||
|
|
||||||
h.AssertNotNil(t, err)
|
|
||||||
expected := "flag provided but not defined: -group"
|
|
||||||
h.AssertStringContains(t, string(output), expected)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("called with skip layers", func() {
|
when("called with skip layers", func() {
|
||||||
it("errors", func() {
|
it("writes analyzed.toml and does not restore previous image SBOM", func() {
|
||||||
h.SkipIf(t,
|
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.9"), "Platform API < 0.9 does not accept a -skip-layers flag")
|
||||||
api.MustParse(platformAPI).LessThan("0.7") || api.MustParse(platformAPI).AtLeast("0.9"),
|
output := h.DockerRunAndCopy(t,
|
||||||
"Platform API < 0.7 or Platform API > 0.9 accepts a -skip-layers flag")
|
containerName,
|
||||||
cmd := exec.Command(
|
copyDir,
|
||||||
"docker", "run", "--rm",
|
ctrPath("/layers"),
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
analyzeImage,
|
analyzeImage,
|
||||||
|
h.WithFlags(append(
|
||||||
|
dockerSocketMount,
|
||||||
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
|
)...),
|
||||||
|
h.WithArgs(
|
||||||
ctrPath(analyzerPath),
|
ctrPath(analyzerPath),
|
||||||
|
"-daemon",
|
||||||
|
"-run-image", analyzeRegFixtures.ReadOnlyRunImage,
|
||||||
"-skip-layers",
|
"-skip-layers",
|
||||||
"some-image",
|
analyzeDaemonFixtures.AppImage,
|
||||||
) // #nosec G204
|
),
|
||||||
output, err := cmd.CombinedOutput()
|
)
|
||||||
|
assertAnalyzedMetadata(t, filepath.Join(copyDir, "layers", "analyzed.toml"))
|
||||||
h.AssertNotNil(t, err)
|
h.AssertStringDoesNotContain(t, output, "Restoring data for SBOM from previous image")
|
||||||
expected := "flag provided but not defined: -skip-layers"
|
|
||||||
h.AssertStringContains(t, string(output), expected)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("called with cache dir", func() {
|
|
||||||
it("errors", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.7"), "Platform API < 0.7 accepts a -cache-dir flag")
|
|
||||||
cmd := exec.Command(
|
|
||||||
"docker", "run", "--rm",
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
analyzeImage,
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-cache-dir", "/cache",
|
|
||||||
"some-image",
|
|
||||||
) // #nosec G204
|
|
||||||
output, err := cmd.CombinedOutput()
|
|
||||||
|
|
||||||
h.AssertNotNil(t, err)
|
|
||||||
expected := "flag provided but not defined: -cache-dir"
|
|
||||||
h.AssertStringContains(t, string(output), expected)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when("the provided layers directory isn't writeable", func() {
|
when("the provided layers directory isn't writeable", func() {
|
||||||
it("recursively chowns the directory", func() {
|
it("recursively chowns the directory", func() {
|
||||||
h.SkipIf(t, runtime.GOOS == "windows", "Not relevant on Windows")
|
analyzeFlags := []string{"-run-image", analyzeRegFixtures.ReadOnlyRunImage}
|
||||||
|
|
||||||
var analyzeFlags []string
|
|
||||||
if api.MustParse(platformAPI).AtLeast("0.7") {
|
|
||||||
analyzeFlags = append(analyzeFlags, []string{"-run-image", analyzeRegFixtures.ReadOnlyRunImage}...)
|
|
||||||
}
|
|
||||||
|
|
||||||
output := h.DockerRun(t,
|
output := h.DockerRun(t,
|
||||||
analyzeImage,
|
analyzeImage,
|
||||||
|
@ -178,61 +149,11 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when("group path is provided", func() {
|
when("called with analyzed", func() {
|
||||||
it("uses the provided group path", func() {
|
it("uses the provided analyzed.toml path", func() {
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not accept a -group flag")
|
analyzeFlags := []string{
|
||||||
|
"-analyzed", ctrPath("/some-dir/some-analyzed.toml"),
|
||||||
h.DockerSeedRunAndCopy(t,
|
"-run-image", analyzeRegFixtures.ReadOnlyRunImage,
|
||||||
containerName,
|
|
||||||
cacheFixtureDir, ctrPath("/cache"),
|
|
||||||
copyDir, ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-cache-dir", ctrPath("/cache"),
|
|
||||||
"-group", ctrPath("/layers/other-group.toml"),
|
|
||||||
"some-image",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
h.AssertPathExists(t, filepath.Join(copyDir, "layers", "some-other-buildpack-id"))
|
|
||||||
h.AssertPathDoesNotExist(t, filepath.Join(copyDir, "layers", "some-buildpack-id"))
|
|
||||||
})
|
|
||||||
|
|
||||||
when("group contains unsupported buildpacks", func() {
|
|
||||||
it("errors", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not accept a -group flag")
|
|
||||||
|
|
||||||
cmd := exec.Command(
|
|
||||||
"docker", "run", "--rm",
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
analyzeImage,
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-group", ctrPath("/layers/unsupported-group.toml"),
|
|
||||||
"some-image",
|
|
||||||
) // #nosec G204
|
|
||||||
output, err := cmd.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 incompatibility
|
|
||||||
expected := "buildpack API version '0.1' is incompatible with the lifecycle"
|
|
||||||
h.AssertStringContains(t, string(output), expected)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("analyzed path is provided", func() {
|
|
||||||
it("uses the provided analyzed path", func() {
|
|
||||||
analyzeFlags := []string{"-analyzed", ctrPath("/some-dir/some-analyzed.toml")}
|
|
||||||
if api.MustParse(platformAPI).AtLeast("0.7") {
|
|
||||||
analyzeFlags = append(analyzeFlags, "-run-image", analyzeRegFixtures.ReadOnlyRunImage)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var execArgs []string
|
var execArgs []string
|
||||||
|
@ -256,12 +177,31 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("drops privileges", func() {
|
when("called with run", func() {
|
||||||
h.SkipIf(t, runtime.GOOS == "windows", "Not relevant on Windows")
|
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="+analyzeRegAuthConfig,
|
||||||
|
"--network", analyzeRegNetwork,
|
||||||
|
analyzeImage,
|
||||||
|
ctrPath(analyzerPath),
|
||||||
|
"-run", "/cnb/run.toml",
|
||||||
|
analyzeRegFixtures.SomeAppImage,
|
||||||
|
) // #nosec G204
|
||||||
|
output, err := cmd.CombinedOutput()
|
||||||
|
|
||||||
analyzeArgs := []string{"-analyzed", "/some-dir/some-analyzed.toml"}
|
h.AssertNotNil(t, err)
|
||||||
if api.MustParse(platformAPI).AtLeast("0.7") {
|
expected := "failed to find accessible run image"
|
||||||
analyzeArgs = append(analyzeArgs, "-run-image", analyzeRegFixtures.ReadOnlyRunImage)
|
h.AssertStringContains(t, string(output), expected)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("drops privileges", func() {
|
||||||
|
analyzeArgs := []string{
|
||||||
|
"-analyzed", "/some-dir/some-analyzed.toml",
|
||||||
|
"-run-image", analyzeRegFixtures.ReadOnlyRunImage,
|
||||||
}
|
}
|
||||||
|
|
||||||
output := h.DockerRun(t,
|
output := h.DockerRun(t,
|
||||||
|
@ -286,8 +226,6 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
when("run image", func() {
|
when("run image", func() {
|
||||||
when("provided", func() {
|
when("provided", func() {
|
||||||
it("is recorded in analyzed.toml", func() {
|
it("is recorded in analyzed.toml", func() {
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.7"), "Platform API < 0.7 does not accept run image")
|
|
||||||
|
|
||||||
h.DockerRunAndCopy(t,
|
h.DockerRunAndCopy(t,
|
||||||
containerName,
|
containerName,
|
||||||
copyDir,
|
copyDir,
|
||||||
|
@ -308,8 +246,6 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
|
|
||||||
when("not provided", func() {
|
when("not provided", func() {
|
||||||
it("falls back to CNB_RUN_IMAGE", func() {
|
it("falls back to CNB_RUN_IMAGE", func() {
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.7"), "Platform API < 0.7 does not accept run image")
|
|
||||||
|
|
||||||
h.DockerRunAndCopy(t,
|
h.DockerRunAndCopy(t,
|
||||||
containerName,
|
containerName,
|
||||||
copyDir,
|
copyDir,
|
||||||
|
@ -332,9 +268,9 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
|
|
||||||
when("daemon case", func() {
|
when("daemon case", func() {
|
||||||
it("writes analyzed.toml", func() {
|
it("writes analyzed.toml", func() {
|
||||||
analyzeFlags := []string{"-daemon"}
|
analyzeFlags := []string{
|
||||||
if api.MustParse(platformAPI).AtLeast("0.7") {
|
"-daemon",
|
||||||
analyzeFlags = append(analyzeFlags, []string{"-run-image", "some-run-image"}...)
|
"-run-image", "some-run-image",
|
||||||
}
|
}
|
||||||
|
|
||||||
var execArgs []string
|
var execArgs []string
|
||||||
|
@ -357,9 +293,7 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
})
|
})
|
||||||
|
|
||||||
when("app image exists", func() {
|
when("app image exists", func() {
|
||||||
it("does not restore app metadata", func() {
|
it("does not restore app metadata to the layers directory", func() {
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.7"), "Platform API < 0.7 restores app metadata")
|
|
||||||
|
|
||||||
analyzeFlags := []string{"-daemon", "-run-image", "some-run-image"}
|
analyzeFlags := []string{"-daemon", "-run-image", "some-run-image"}
|
||||||
|
|
||||||
var execArgs []string
|
var execArgs []string
|
||||||
|
@ -380,248 +314,12 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
|
|
||||||
assertNoRestoreOfAppMetadata(t, copyDir, output)
|
assertNoRestoreOfAppMetadata(t, copyDir, output)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("restores app metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not restore app metadata")
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(append(
|
|
||||||
dockerSocketMount,
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
)...),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-daemon",
|
|
||||||
analyzeDaemonFixtures.AppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresAppMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
|
|
||||||
when("skip layers is provided", func() {
|
|
||||||
it("writes analyzed.toml and does not write buildpack layer metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not accept a -skip-layers flag")
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(append(
|
|
||||||
dockerSocketMount,
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
)...),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-daemon",
|
|
||||||
"-skip-layers",
|
|
||||||
analyzeDaemonFixtures.AppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertAnalyzedMetadata(t, filepath.Join(copyDir, "layers", "analyzed.toml"))
|
|
||||||
assertWritesStoreTomlOnly(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("cache is provided", func() {
|
|
||||||
when("cache image case", func() {
|
|
||||||
when("cache image is in a daemon", func() {
|
|
||||||
it("ignores the cache", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read from the cache")
|
|
||||||
|
|
||||||
h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(append(
|
|
||||||
dockerSocketMount,
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
)...),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-daemon",
|
|
||||||
"-cache-image", analyzeDaemonFixtures.CacheImage,
|
|
||||||
"some-image",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
h.AssertPathDoesNotExist(t, filepath.Join(copyDir, "layers", "some-buildpack-id", "some-layer.sha"))
|
|
||||||
h.AssertPathDoesNotExist(t, filepath.Join(copyDir, "layers", "some-buildpack-id", "some-layer.toml"))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("cache image is in a registry", func() {
|
|
||||||
when("auth registry", func() {
|
|
||||||
when("registry creds are provided in CNB_REGISTRY_AUTH", func() {
|
|
||||||
it("restores cache metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read from the cache")
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
"/layers",
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(append(
|
|
||||||
dockerSocketMount,
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--env", "CNB_REGISTRY_AUTH="+analyzeRegAuthConfig,
|
|
||||||
"--network", analyzeRegNetwork,
|
|
||||||
)...),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-daemon",
|
|
||||||
"-cache-image", analyzeRegFixtures.SomeCacheImage,
|
|
||||||
analyzeRegFixtures.SomeAppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresCacheMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("registry creds are provided in the docker config.json", func() {
|
|
||||||
it("restores cache metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read from the cache")
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--env", "DOCKER_CONFIG=/docker-config",
|
|
||||||
"--network", analyzeRegNetwork,
|
|
||||||
),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-cache-image",
|
|
||||||
analyzeRegFixtures.SomeCacheImage,
|
|
||||||
analyzeRegFixtures.SomeAppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresCacheMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("no auth registry", func() {
|
|
||||||
it("restores cache metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read from the cache")
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(append(
|
|
||||||
dockerSocketMount,
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--network", analyzeRegNetwork,
|
|
||||||
)...),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-daemon",
|
|
||||||
"-cache-image",
|
|
||||||
analyzeRegFixtures.ReadOnlyCacheImage,
|
|
||||||
analyzeRegFixtures.ReadOnlyAppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresCacheMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("cache directory case", func() {
|
|
||||||
it("restores cache metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read from the cache")
|
|
||||||
output := h.DockerSeedRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
cacheFixtureDir, ctrPath("/cache"),
|
|
||||||
copyDir, ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(append(
|
|
||||||
dockerSocketMount,
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
)...),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-daemon",
|
|
||||||
"-cache-dir", ctrPath("/cache"),
|
|
||||||
"some-image",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresCacheMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
|
|
||||||
when("the provided cache directory isn't writeable by the CNB user's group", func() {
|
|
||||||
it("recursively chowns the directory", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read from the cache")
|
|
||||||
h.SkipIf(t, runtime.GOOS == "windows", "Not relevant on Windows")
|
|
||||||
|
|
||||||
cacheVolume := h.SeedDockerVolume(t, cacheFixtureDir)
|
|
||||||
defer h.DockerVolumeRemove(t, cacheVolume)
|
|
||||||
|
|
||||||
output := h.DockerRun(t,
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(append(
|
|
||||||
dockerSocketMount,
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--volume", cacheVolume+":/cache",
|
|
||||||
)...),
|
|
||||||
h.WithBash(
|
|
||||||
fmt.Sprintf("chown -R 9999:9999 /cache; chmod -R 775 /cache; %s -daemon -cache-dir /cache some-image; ls -alR /cache", analyzerPath),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
h.AssertMatch(t, output, "2222 3333 .+ \\.")
|
|
||||||
h.AssertMatch(t, output, "2222 3333 .+ committed")
|
|
||||||
h.AssertMatch(t, output, "2222 3333 .+ staging")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("the provided cache directory is writeable by the CNB user's group", func() {
|
|
||||||
it("doesn't chown the directory", func() {
|
|
||||||
h.SkipIf(t, runtime.GOOS == "windows", "Not relevant on Windows")
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read from the cache")
|
|
||||||
|
|
||||||
cacheVolume := h.SeedDockerVolume(t, cacheFixtureDir)
|
|
||||||
defer h.DockerVolumeRemove(t, cacheVolume)
|
|
||||||
|
|
||||||
output := h.DockerRun(t,
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(append(
|
|
||||||
dockerSocketMount,
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--volume", cacheVolume+":/cache",
|
|
||||||
)...),
|
|
||||||
h.WithBash(
|
|
||||||
fmt.Sprintf("chown -R 9999:3333 /cache; chmod -R 775 /cache; %s -daemon -cache-dir /cache some-image; ls -alR /cache", analyzerPath),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
h.AssertMatch(t, output, "9999 3333 .+ \\.")
|
|
||||||
h.AssertMatch(t, output, "9999 3333 .+ committed")
|
|
||||||
h.AssertMatch(t, output, "2222 3333 .+ staging")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when("registry case", func() {
|
when("registry case", func() {
|
||||||
it("writes analyzed.toml", func() {
|
it("writes analyzed.toml", func() {
|
||||||
var analyzeFlags []string
|
analyzeFlags := []string{"-run-image", analyzeRegFixtures.ReadOnlyRunImage}
|
||||||
if api.MustParse(platformAPI).AtLeast("0.7") {
|
|
||||||
analyzeFlags = append(analyzeFlags, []string{"-run-image", analyzeRegFixtures.ReadOnlyRunImage}...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var execArgs []string
|
var execArgs []string
|
||||||
execArgs = append([]string{ctrPath(analyzerPath)}, analyzeFlags...)
|
execArgs = append([]string{ctrPath(analyzerPath)}, analyzeFlags...)
|
||||||
|
@ -643,139 +341,13 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
assertAnalyzedMetadata(t, filepath.Join(copyDir, "analyzed.toml"))
|
assertAnalyzedMetadata(t, filepath.Join(copyDir, "analyzed.toml"))
|
||||||
})
|
})
|
||||||
|
|
||||||
when("app image exists", func() {
|
|
||||||
when("auth registry", func() {
|
|
||||||
when("registry creds are provided in CNB_REGISTRY_AUTH", func() {
|
|
||||||
it("restores app metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read app layer metadata")
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--env", "CNB_REGISTRY_AUTH="+analyzeRegAuthConfig,
|
|
||||||
"--network", analyzeRegNetwork,
|
|
||||||
),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
analyzeRegFixtures.SomeAppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresAppMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("registry creds are provided in the docker config.json", func() {
|
|
||||||
it("restores app metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read app layer metadata")
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--env", "DOCKER_CONFIG=/docker-config",
|
|
||||||
"--network", analyzeRegNetwork,
|
|
||||||
),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
analyzeRegFixtures.SomeAppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresAppMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("skip layers is provided", func() {
|
|
||||||
it("writes analyzed.toml and does not write buildpack layer metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not accept a -skip-layers flag")
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--env", "CNB_REGISTRY_AUTH="+analyzeRegAuthConfig,
|
|
||||||
"--network", analyzeRegNetwork,
|
|
||||||
),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-skip-layers",
|
|
||||||
analyzeRegFixtures.SomeAppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertAnalyzedMetadata(t, filepath.Join(copyDir, "layers", "analyzed.toml"))
|
|
||||||
assertWritesStoreTomlOnly(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("no auth registry", func() {
|
|
||||||
it("restores app metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read app layer metadata")
|
|
||||||
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--network", analyzeRegNetwork,
|
|
||||||
),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
analyzeRegFixtures.ReadOnlyAppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresAppMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
|
|
||||||
when("skip layers is provided", func() {
|
|
||||||
it("writes analyzed.toml and does not write buildpack layer metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not accept a -skip-layers flag")
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--network", analyzeRegNetwork,
|
|
||||||
),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-skip-layers",
|
|
||||||
analyzeRegFixtures.ReadOnlyAppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertAnalyzedMetadata(t, filepath.Join(copyDir, "layers", "analyzed.toml"))
|
|
||||||
assertWritesStoreTomlOnly(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("called with previous image", func() {
|
when("called with previous image", func() {
|
||||||
it.Before(func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.7"), "Platform API < 0.7 does not support -previous-image")
|
|
||||||
})
|
|
||||||
|
|
||||||
when("auth registry", func() {
|
when("auth registry", func() {
|
||||||
when("the destination image does not exist", func() {
|
when("the destination image does not exist", func() {
|
||||||
it("writes analyzed.toml with previous image identifier", func() {
|
it("writes analyzed.toml with previous image identifier", func() {
|
||||||
analyzeFlags := []string{"-previous-image", analyzeRegFixtures.ReadWriteAppImage}
|
analyzeFlags := []string{
|
||||||
if api.MustParse(platformAPI).AtLeast("0.7") {
|
"-previous-image", analyzeRegFixtures.ReadWriteAppImage,
|
||||||
analyzeFlags = append(analyzeFlags, []string{"-run-image", analyzeRegFixtures.ReadOnlyRunImage}...)
|
"-run-image", analyzeRegFixtures.ReadOnlyRunImage,
|
||||||
}
|
}
|
||||||
|
|
||||||
var execArgs []string
|
var execArgs []string
|
||||||
|
@ -795,15 +367,15 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
h.WithArgs(execArgs...),
|
h.WithArgs(execArgs...),
|
||||||
)
|
)
|
||||||
analyzedMD := assertAnalyzedMetadata(t, filepath.Join(copyDir, "analyzed.toml"))
|
analyzedMD := assertAnalyzedMetadata(t, filepath.Join(copyDir, "analyzed.toml"))
|
||||||
h.AssertStringContains(t, analyzedMD.PreviousImage.Reference, analyzeRegFixtures.ReadWriteAppImage)
|
h.AssertStringContains(t, analyzedMD.PreviousImageRef(), analyzeRegFixtures.ReadWriteAppImage)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when("the destination image exists", func() {
|
when("the destination image exists", func() {
|
||||||
it("writes analyzed.toml with previous image identifier", func() {
|
it("writes analyzed.toml with previous image identifier", func() {
|
||||||
analyzeFlags := []string{"-previous-image", analyzeRegFixtures.ReadWriteAppImage}
|
analyzeFlags := []string{
|
||||||
if api.MustParse(platformAPI).AtLeast("0.7") {
|
"-previous-image", analyzeRegFixtures.ReadWriteAppImage,
|
||||||
analyzeFlags = append(analyzeFlags, []string{"-run-image", analyzeRegFixtures.ReadOnlyRunImage}...)
|
"-run-image", analyzeRegFixtures.ReadOnlyRunImage,
|
||||||
}
|
}
|
||||||
|
|
||||||
var execArgs []string
|
var execArgs []string
|
||||||
|
@ -824,117 +396,15 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
)
|
)
|
||||||
|
|
||||||
analyzedMD := assertAnalyzedMetadata(t, filepath.Join(copyDir, "analyzed.toml"))
|
analyzedMD := assertAnalyzedMetadata(t, filepath.Join(copyDir, "analyzed.toml"))
|
||||||
h.AssertStringContains(t, analyzedMD.PreviousImage.Reference, analyzeRegFixtures.ReadWriteAppImage)
|
h.AssertStringContains(t, analyzedMD.PreviousImageRef(), analyzeRegFixtures.ReadWriteAppImage)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when("cache is provided", func() {
|
|
||||||
when("cache image case", func() {
|
|
||||||
when("auth registry", func() {
|
|
||||||
when("registry creds are provided in CNB_REGISTRY_AUTH", func() {
|
|
||||||
it("restores cache metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read from the cache")
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--env", "CNB_REGISTRY_AUTH="+analyzeRegAuthConfig,
|
|
||||||
"--network", analyzeRegNetwork,
|
|
||||||
),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-cache-image", analyzeRegFixtures.SomeCacheImage,
|
|
||||||
"some-image",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresCacheMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("registry creds are provided in the docker config.json", func() {
|
|
||||||
it("restores cache metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read from the cache")
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--env", "DOCKER_CONFIG=/docker-config",
|
|
||||||
"--network", analyzeRegNetwork,
|
|
||||||
),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-cache-image",
|
|
||||||
analyzeRegFixtures.SomeCacheImage,
|
|
||||||
analyzeRegFixtures.SomeAppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresCacheMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("no auth registry", func() {
|
|
||||||
it("restores cache metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read from the cache")
|
|
||||||
|
|
||||||
output := h.DockerRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
copyDir,
|
|
||||||
ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
"--network", analyzeRegNetwork,
|
|
||||||
),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-cache-image", analyzeRegFixtures.ReadOnlyCacheImage,
|
|
||||||
analyzeRegFixtures.ReadOnlyAppImage,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresCacheMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("cache directory case", func() {
|
|
||||||
it("restores cache metadata", func() {
|
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 does not read from the cache")
|
|
||||||
output := h.DockerSeedRunAndCopy(t,
|
|
||||||
containerName,
|
|
||||||
cacheFixtureDir, ctrPath("/cache"),
|
|
||||||
copyDir, ctrPath("/layers"),
|
|
||||||
analyzeImage,
|
|
||||||
h.WithFlags(
|
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
|
||||||
),
|
|
||||||
h.WithArgs(
|
|
||||||
ctrPath(analyzerPath),
|
|
||||||
"-cache-dir", ctrPath("/cache"),
|
|
||||||
"some-image",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
assertLogsAndRestoresCacheMetadata(t, copyDir, output)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("called with tag", func() {
|
when("called with tag", func() {
|
||||||
when("read/write access to registry", func() {
|
when("read/write access to registry", func() {
|
||||||
it("passes read/write validation and writes analyzed.toml", func() {
|
it("passes read/write validation and writes analyzed.toml", func() {
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.7"), "Platform API < 0.7 does not use tag flag")
|
|
||||||
execArgs := []string{
|
execArgs := []string{
|
||||||
ctrPath(analyzerPath),
|
ctrPath(analyzerPath),
|
||||||
"-tag", analyzeRegFixtures.ReadWriteOtherAppImage,
|
"-tag", analyzeRegFixtures.ReadWriteOtherAppImage,
|
||||||
|
@ -954,13 +424,12 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
h.WithArgs(execArgs...),
|
h.WithArgs(execArgs...),
|
||||||
)
|
)
|
||||||
analyzedMD := assertAnalyzedMetadata(t, filepath.Join(copyDir, "analyzed.toml"))
|
analyzedMD := assertAnalyzedMetadata(t, filepath.Join(copyDir, "analyzed.toml"))
|
||||||
h.AssertStringContains(t, analyzedMD.PreviousImage.Reference, analyzeRegFixtures.ReadWriteAppImage)
|
h.AssertStringContains(t, analyzedMD.PreviousImageRef(), analyzeRegFixtures.ReadWriteAppImage)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when("no read/write access to registry", func() {
|
when("no read/write access to registry", func() {
|
||||||
it("throws read/write error accessing destination tag", func() {
|
it("throws read/write error accessing destination tag", func() {
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.7"), "Platform API < 0.7 does not use tag flag")
|
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
"docker", "run", "--rm",
|
"docker", "run", "--rm",
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
|
@ -975,44 +444,83 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
|
|
||||||
h.AssertNotNil(t, err)
|
h.AssertNotNil(t, err)
|
||||||
expected := "validating registry write access: ensure registry read/write access to " + analyzeRegFixtures.InaccessibleImage
|
expected := "ensure registry read/write access to " + analyzeRegFixtures.InaccessibleImage
|
||||||
h.AssertStringContains(t, string(output), expected)
|
h.AssertStringContains(t, string(output), expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
when("layout case", func() {
|
||||||
|
layoutDir := filepath.Join(path.RootDir, "layout-repo")
|
||||||
|
when("experimental mode is enabled", func() {
|
||||||
|
it("writes analyzed.toml", func() {
|
||||||
|
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "Platform API < 0.12 does not accept a -layout flag")
|
||||||
|
|
||||||
|
analyzeFlags := []string{
|
||||||
|
"-layout",
|
||||||
|
"-layout-dir", layoutDir,
|
||||||
|
"-run-image", "busybox",
|
||||||
|
}
|
||||||
|
var execArgs []string
|
||||||
|
execArgs = append([]string{ctrPath(analyzerPath)}, analyzeFlags...)
|
||||||
|
execArgs = append(execArgs, "my-app")
|
||||||
|
|
||||||
|
h.DockerRunAndCopy(t,
|
||||||
|
containerName,
|
||||||
|
copyDir,
|
||||||
|
ctrPath("/layers/analyzed.toml"),
|
||||||
|
analyzeImage,
|
||||||
|
h.WithFlags(
|
||||||
|
"--env", "CNB_EXPERIMENTAL_MODE=warn",
|
||||||
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
|
),
|
||||||
|
h.WithArgs(execArgs...),
|
||||||
|
)
|
||||||
|
|
||||||
|
analyzer := assertAnalyzedMetadata(t, filepath.Join(copyDir, "analyzed.toml"))
|
||||||
|
h.AssertNotNil(t, analyzer.RunImage)
|
||||||
|
analyzedImagePath := filepath.Join(path.RootDir, "layout-repo", "index.docker.io", "library", "busybox", "latest")
|
||||||
|
reference := fmt.Sprintf("%s@%s", analyzedImagePath, "sha256:f75f3d1a317fc82c793d567de94fc8df2bece37acd5f2bd364a0d91a0d1f3dab")
|
||||||
|
h.AssertEq(t, analyzer.RunImage.Reference, reference)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
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,
|
||||||
|
"--env", "CNB_LAYOUT_DIR="+layoutDir,
|
||||||
|
analyzeImage,
|
||||||
|
ctrPath(analyzerPath),
|
||||||
|
"-layout",
|
||||||
|
"-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)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertAnalyzedMetadata(t *testing.T, path string) *platform.AnalyzedMetadata {
|
func assertAnalyzedMetadata(t *testing.T, path string) *files.Analyzed {
|
||||||
contents, err := os.ReadFile(path)
|
contents, err := os.ReadFile(path)
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertEq(t, len(contents) > 0, true)
|
h.AssertEq(t, len(contents) > 0, true)
|
||||||
|
|
||||||
var analyzedMD platform.AnalyzedMetadata
|
analyzedMD, err := files.Handler.ReadAnalyzed(path, cmd.DefaultLogger)
|
||||||
_, err = toml.Decode(string(contents), &analyzedMD)
|
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
|
|
||||||
return &analyzedMD
|
return &analyzedMD
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertLogsAndRestoresAppMetadata(t *testing.T, dir, output string) {
|
|
||||||
layerFilenames := []string{
|
|
||||||
"launch-layer.sha",
|
|
||||||
"launch-layer.toml",
|
|
||||||
"store.toml",
|
|
||||||
}
|
|
||||||
for _, filename := range layerFilenames {
|
|
||||||
h.AssertPathExists(t, filepath.Join(dir, "layers", "some-buildpack-id", filename))
|
|
||||||
}
|
|
||||||
layerNames := []string{
|
|
||||||
"launch-layer",
|
|
||||||
}
|
|
||||||
for _, layerName := range layerNames {
|
|
||||||
h.AssertStringContains(t, output, fmt.Sprintf("Restoring metadata for \"some-buildpack-id:%s\"", layerName))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertNoRestoreOfAppMetadata(t *testing.T, dir, output string) {
|
func assertNoRestoreOfAppMetadata(t *testing.T, dir, output string) {
|
||||||
layerFilenames := []string{
|
layerFilenames := []string{
|
||||||
"launch-build-cache-layer.sha",
|
"launch-build-cache-layer.sha",
|
||||||
|
@ -1028,28 +536,6 @@ func assertNoRestoreOfAppMetadata(t *testing.T, dir, output string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertLogsAndRestoresCacheMetadata(t *testing.T, dir, output string) {
|
|
||||||
h.AssertPathExists(t, filepath.Join(dir, "layers", "some-buildpack-id", "some-layer.sha"))
|
|
||||||
h.AssertPathExists(t, filepath.Join(dir, "layers", "some-buildpack-id", "some-layer.toml"))
|
|
||||||
h.AssertStringContains(t, output, "Restoring metadata for \"some-buildpack-id:some-layer\" from cache")
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertWritesStoreTomlOnly(t *testing.T, dir, output string) {
|
|
||||||
h.AssertPathExists(t, filepath.Join(dir, "layers", "some-buildpack-id", "store.toml"))
|
|
||||||
layerFilenames := []string{
|
|
||||||
"launch-build-cache-layer.sha",
|
|
||||||
"launch-build-cache-layer.toml",
|
|
||||||
"launch-cache-layer.sha",
|
|
||||||
"launch-cache-layer.toml",
|
|
||||||
"launch-layer.sha",
|
|
||||||
"launch-layer.toml",
|
|
||||||
}
|
|
||||||
for _, filename := range layerFilenames {
|
|
||||||
h.AssertPathDoesNotExist(t, filepath.Join(dir, "layers", "some-buildpack-id", filename))
|
|
||||||
}
|
|
||||||
h.AssertStringContains(t, output, "Skipping buildpack layer analysis")
|
|
||||||
}
|
|
||||||
|
|
||||||
func flatPrint(arr []string) string {
|
func flatPrint(arr []string) string {
|
||||||
return strings.Join(arr, " ")
|
return strings.Join(arr, " ")
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,20 +3,16 @@ package acceptance
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
|
||||||
"github.com/sclevine/spec"
|
"github.com/sclevine/spec"
|
||||||
"github.com/sclevine/spec/report"
|
"github.com/sclevine/spec/report"
|
||||||
|
|
||||||
"github.com/buildpacks/lifecycle/api"
|
"github.com/buildpacks/lifecycle/api"
|
||||||
"github.com/buildpacks/lifecycle/platform"
|
"github.com/buildpacks/lifecycle/platform/files"
|
||||||
h "github.com/buildpacks/lifecycle/testhelpers"
|
h "github.com/buildpacks/lifecycle/testhelpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,11 +24,6 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBuilder(t *testing.T) {
|
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())
|
info, err := h.DockerCli(t).Info(context.TODO())
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
|
|
||||||
|
@ -43,6 +34,8 @@ func TestBuilder(t *testing.T) {
|
||||||
builderDaemonArch = info.Architecture
|
builderDaemonArch = info.Architecture
|
||||||
if builderDaemonArch == "x86_64" {
|
if builderDaemonArch == "x86_64" {
|
||||||
builderDaemonArch = "amd64"
|
builderDaemonArch = "amd64"
|
||||||
|
} else if builderDaemonArch == "aarch64" {
|
||||||
|
builderDaemonArch = "arm64"
|
||||||
}
|
}
|
||||||
|
|
||||||
h.MakeAndCopyLifecycle(t, builderDaemonOS, builderDaemonArch, builderBinaryDir)
|
h.MakeAndCopyLifecycle(t, builderDaemonOS, builderDaemonArch, builderBinaryDir)
|
||||||
|
@ -132,7 +125,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
// check builder metadata.toml for success test
|
// 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].ID, "hello_world")
|
||||||
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
|
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
|
||||||
})
|
})
|
||||||
|
@ -156,7 +149,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
|
|
||||||
// prevent regression of inline table serialization
|
// prevent regression of inline table serialization
|
||||||
h.AssertStringDoesNotContain(t, contents, "processes =")
|
h.AssertStringDoesNotContain(t, contents, "processes =")
|
||||||
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].ID, "hello_world")
|
||||||
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
|
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
|
||||||
h.AssertEq(t, len(md.Processes), 1)
|
h.AssertEq(t, len(md.Processes), 1)
|
||||||
|
@ -165,7 +158,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
h.AssertEq(t, md.Processes[0].Command.Entries[0], "echo world")
|
h.AssertEq(t, md.Processes[0].Command.Entries[0], "echo world")
|
||||||
h.AssertEq(t, len(md.Processes[0].Args), 1)
|
h.AssertEq(t, len(md.Processes[0].Args), 1)
|
||||||
h.AssertEq(t, md.Processes[0].Args[0], "arg1")
|
h.AssertEq(t, md.Processes[0].Args[0], "arg1")
|
||||||
h.AssertEq(t, md.Processes[0].Direct, false)
|
h.AssertEq(t, md.Processes[0].Direct, true)
|
||||||
h.AssertEq(t, md.Processes[0].WorkingDirectory, "")
|
h.AssertEq(t, md.Processes[0].WorkingDirectory, "")
|
||||||
h.AssertEq(t, md.Processes[0].Default, false)
|
h.AssertEq(t, md.Processes[0].Default, false)
|
||||||
})
|
})
|
||||||
|
@ -188,7 +181,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
|
|
||||||
// prevent regression of inline table serialization
|
// prevent regression of inline table serialization
|
||||||
h.AssertStringDoesNotContain(t, contents, "processes =")
|
h.AssertStringDoesNotContain(t, contents, "processes =")
|
||||||
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].ID, "hello_world")
|
||||||
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
|
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
|
||||||
h.AssertEq(t, len(md.Processes), 1)
|
h.AssertEq(t, len(md.Processes), 1)
|
||||||
|
@ -197,7 +190,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
h.AssertEq(t, md.Processes[0].Command.Entries[0], "echo world")
|
h.AssertEq(t, md.Processes[0].Command.Entries[0], "echo world")
|
||||||
h.AssertEq(t, len(md.Processes[0].Args), 1)
|
h.AssertEq(t, len(md.Processes[0].Args), 1)
|
||||||
h.AssertEq(t, md.Processes[0].Args[0], "arg1")
|
h.AssertEq(t, md.Processes[0].Args[0], "arg1")
|
||||||
h.AssertEq(t, md.Processes[0].Direct, false)
|
h.AssertEq(t, md.Processes[0].Direct, true)
|
||||||
h.AssertEq(t, md.Processes[0].WorkingDirectory, "")
|
h.AssertEq(t, md.Processes[0].WorkingDirectory, "")
|
||||||
h.AssertEq(t, md.Processes[0].Default, false)
|
h.AssertEq(t, md.Processes[0].Default, false)
|
||||||
})
|
})
|
||||||
|
@ -220,11 +213,10 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
// check builder metadata.toml for success test
|
// 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].ID, "hello_world")
|
||||||
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
|
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
|
||||||
h.AssertStringContains(t, md.Extensions[0].API, "0.9")
|
h.AssertStringContains(t, md.Extensions[0].API, "0.10")
|
||||||
h.AssertEq(t, md.Extensions[0].Extension, false) // this shows that `extension = true` is not redundantly printed in group.toml
|
|
||||||
h.AssertStringContains(t, md.Extensions[0].ID, "hello_world")
|
h.AssertStringContains(t, md.Extensions[0].ID, "hello_world")
|
||||||
h.AssertStringContains(t, md.Extensions[0].Version, "0.0.1")
|
h.AssertStringContains(t, md.Extensions[0].Version, "0.0.1")
|
||||||
})
|
})
|
||||||
|
@ -245,7 +237,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
)
|
)
|
||||||
output, err := command.CombinedOutput()
|
output, err := command.CombinedOutput()
|
||||||
h.AssertNotNil(t, err)
|
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)
|
h.AssertStringContains(t, string(output), expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -282,7 +274,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
)
|
)
|
||||||
output, err := command.CombinedOutput()
|
output, err := command.CombinedOutput()
|
||||||
h.AssertNotNil(t, err)
|
h.AssertNotNil(t, err)
|
||||||
expected := "failed to read buildpack group: toml: line 1: expected '.' or '=', but got 'a' instead"
|
expected := "failed to read group file: toml: line 1: expected '.' or '=', but got 'a' instead"
|
||||||
h.AssertStringContains(t, string(output), expected)
|
h.AssertStringContains(t, string(output), expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -321,7 +313,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
)
|
)
|
||||||
output, err := command.CombinedOutput()
|
output, err := command.CombinedOutput()
|
||||||
h.AssertNotNil(t, err)
|
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)
|
h.AssertStringContains(t, string(output), expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -342,7 +334,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
// check builder metadata.toml for success test
|
// 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].ID, "hello_world")
|
||||||
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
|
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.1")
|
||||||
})
|
})
|
||||||
|
@ -361,7 +353,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
)
|
)
|
||||||
output, err := command.CombinedOutput()
|
output, err := command.CombinedOutput()
|
||||||
h.AssertNotNil(t, err)
|
h.AssertNotNil(t, err)
|
||||||
expected := "failed to parse detect plan: toml: line 1: expected '.' or '=', but got 'a' instead"
|
expected := "failed to read plan file: toml: line 1: expected '.' or '=', but got 'a' instead"
|
||||||
h.AssertStringContains(t, string(output), expected)
|
h.AssertStringContains(t, string(output), expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -385,7 +377,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
)
|
)
|
||||||
_, 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].ID, "hello_world_2")
|
||||||
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.2")
|
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.2")
|
||||||
})
|
})
|
||||||
|
@ -407,7 +399,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
)
|
)
|
||||||
_, 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].ID, "hello_world_2")
|
||||||
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.2")
|
h.AssertStringContains(t, md.Buildpacks[0].Version, "0.0.2")
|
||||||
})
|
})
|
||||||
|
@ -507,16 +499,37 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
|
||||||
h.AssertStringContains(t, string(output), expected)
|
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) (string, *platform.BuildMetadata) {
|
func getBuilderMetadata(t *testing.T, path string) (string, *files.BuildMetadata) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
contents, _ := os.ReadFile(path)
|
contents, _ := os.ReadFile(path)
|
||||||
h.AssertEq(t, len(contents) > 0, true)
|
h.AssertEq(t, len(contents) > 0, true)
|
||||||
|
|
||||||
var buildMD platform.BuildMetadata
|
buildMD, err := files.Handler.ReadBuildMetadata(path, api.MustParse(latestPlatformAPI))
|
||||||
_, err := toml.Decode(string(contents), &buildMD)
|
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
|
|
||||||
return string(contents), &buildMD
|
return string(contents), buildMD
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
//go:build acceptance
|
//go:build acceptance
|
||||||
// +build acceptance
|
|
||||||
|
|
||||||
package acceptance
|
package acceptance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/buildpacks/lifecycle/internal/path"
|
||||||
|
|
||||||
"github.com/sclevine/spec"
|
"github.com/sclevine/spec"
|
||||||
"github.com/sclevine/spec/report"
|
"github.com/sclevine/spec/report"
|
||||||
|
|
||||||
|
@ -30,10 +29,6 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreator(t *testing.T) {
|
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")
|
testImageDockerContext := filepath.Join("testdata", "creator")
|
||||||
createTest = NewPhaseTest(t, "creator", testImageDockerContext)
|
createTest = NewPhaseTest(t, "creator", testImageDockerContext)
|
||||||
createTest.Start(t)
|
createTest.Start(t)
|
||||||
|
@ -41,7 +36,6 @@ func TestCreator(t *testing.T) {
|
||||||
|
|
||||||
createImage = createTest.testImageRef
|
createImage = createTest.testImageRef
|
||||||
creatorPath = createTest.containerBinaryPath
|
creatorPath = createTest.containerBinaryPath
|
||||||
cacheFixtureDir = filepath.Join("testdata", "creator", "cache-dir")
|
|
||||||
createRegAuthConfig = createTest.targetRegistry.authConfig
|
createRegAuthConfig = createTest.targetRegistry.authConfig
|
||||||
createRegNetwork = createTest.targetRegistry.network
|
createRegNetwork = createTest.targetRegistry.network
|
||||||
createDaemonFixtures = createTest.targetDaemon.fixtures
|
createDaemonFixtures = createTest.targetDaemon.fixtures
|
||||||
|
@ -56,6 +50,50 @@ func testCreatorFunc(platformAPI string) func(t *testing.T, when spec.G, it spec
|
||||||
return func(t *testing.T, when spec.G, it spec.S) {
|
return func(t *testing.T, when spec.G, it spec.S) {
|
||||||
var createdImageName string
|
var createdImageName string
|
||||||
|
|
||||||
|
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("daemon case", func() {
|
||||||
it.After(func() {
|
it.After(func() {
|
||||||
h.DockerImageRemove(t, createdImageName)
|
h.DockerImageRemove(t, createdImageName)
|
||||||
|
@ -330,5 +368,78 @@ func testCreatorFunc(platformAPI string) func(t *testing.T, when spec.G, it spec
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
containerName = "test-container-" + h.RandString(10)
|
||||||
|
layoutDir = filepath.Join(path.RootDir, "layout-repo")
|
||||||
|
})
|
||||||
|
|
||||||
|
it.After(func() {
|
||||||
|
if h.DockerContainerExists(t, containerName) {
|
||||||
|
h.Run(t, exec.Command("docker", "rm", containerName))
|
||||||
|
}
|
||||||
|
h.DockerImageRemove(t, createdImageName)
|
||||||
|
|
||||||
|
// removes all images created
|
||||||
|
os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,21 @@
|
||||||
//go:build acceptance
|
//go:build acceptance
|
||||||
// +build acceptance
|
|
||||||
|
|
||||||
package acceptance
|
package acceptance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
|
||||||
"github.com/sclevine/spec"
|
"github.com/sclevine/spec"
|
||||||
"github.com/sclevine/spec/report"
|
"github.com/sclevine/spec/report"
|
||||||
|
|
||||||
"github.com/buildpacks/lifecycle/api"
|
"github.com/buildpacks/lifecycle/api"
|
||||||
"github.com/buildpacks/lifecycle/buildpack"
|
"github.com/buildpacks/lifecycle/cmd"
|
||||||
"github.com/buildpacks/lifecycle/platform"
|
"github.com/buildpacks/lifecycle/platform/files"
|
||||||
h "github.com/buildpacks/lifecycle/testhelpers"
|
h "github.com/buildpacks/lifecycle/testhelpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,15 +24,23 @@ var (
|
||||||
detectorBinaryDir = filepath.Join("testdata", "detector", "container", "cnb", "lifecycle")
|
detectorBinaryDir = filepath.Join("testdata", "detector", "container", "cnb", "lifecycle")
|
||||||
detectImage = "lifecycle/acceptance/detector"
|
detectImage = "lifecycle/acceptance/detector"
|
||||||
userID = "1234"
|
userID = "1234"
|
||||||
|
detectorDaemonOS, detectorDaemonArch string
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDetector(t *testing.T) {
|
func TestDetector(t *testing.T) {
|
||||||
h.SkipIf(t, runtime.GOOS == "windows", "Detector acceptance tests are not yet supported on Windows")
|
info, err := h.DockerCli(t).Info(context.TODO())
|
||||||
h.SkipIf(t, runtime.GOARCH != "amd64", "Detector acceptance tests are not yet supported on non-amd64")
|
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,
|
h.DockerBuild(t,
|
||||||
detectImage,
|
detectImage,
|
||||||
detectDockerContext,
|
detectDockerContext,
|
||||||
|
@ -44,17 +48,24 @@ func TestDetector(t *testing.T) {
|
||||||
)
|
)
|
||||||
defer h.DockerImageRemove(t, detectImage)
|
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) {
|
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() {
|
when("called with arguments", func() {
|
||||||
it("errors", func() {
|
it("errors", func() {
|
||||||
command := exec.Command(
|
command := exec.Command(
|
||||||
"docker",
|
"docker",
|
||||||
"run",
|
"run",
|
||||||
"--rm",
|
"--rm",
|
||||||
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
detectImage,
|
detectImage,
|
||||||
"some-arg",
|
"some-arg",
|
||||||
)
|
)
|
||||||
|
@ -73,7 +84,7 @@ func testDetector(t *testing.T, when spec.G, it spec.S) {
|
||||||
"--rm",
|
"--rm",
|
||||||
"--user",
|
"--user",
|
||||||
"root",
|
"root",
|
||||||
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
detectImage,
|
detectImage,
|
||||||
)
|
)
|
||||||
output, err := command.CombinedOutput()
|
output, err := command.CombinedOutput()
|
||||||
|
@ -90,7 +101,7 @@ func testDetector(t *testing.T, when spec.G, it spec.S) {
|
||||||
"docker",
|
"docker",
|
||||||
"run",
|
"run",
|
||||||
"--rm",
|
"--rm",
|
||||||
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
detectImage,
|
detectImage,
|
||||||
)
|
)
|
||||||
output, err := command.CombinedOutput()
|
output, err := command.CombinedOutput()
|
||||||
|
@ -107,7 +118,7 @@ func testDetector(t *testing.T, when spec.G, it spec.S) {
|
||||||
"run",
|
"run",
|
||||||
"--rm",
|
"--rm",
|
||||||
"--env", "CNB_ORDER_PATH=/cnb/orders/fail_detect_order.toml",
|
"--env", "CNB_ORDER_PATH=/cnb/orders/fail_detect_order.toml",
|
||||||
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
detectImage,
|
detectImage,
|
||||||
)
|
)
|
||||||
output, err := command.CombinedOutput()
|
output, err := command.CombinedOutput()
|
||||||
|
@ -121,8 +132,7 @@ func testDetector(t *testing.T, when spec.G, it spec.S) {
|
||||||
expected1 := `======== Output: fail_detect_buildpack@some_version ========
|
expected1 := `======== Output: fail_detect_buildpack@some_version ========
|
||||||
Opted out of detection
|
Opted out of detection
|
||||||
======== Results ========
|
======== Results ========
|
||||||
fail: fail_detect_buildpack@some_version
|
fail: fail_detect_buildpack@some_version`
|
||||||
`
|
|
||||||
h.AssertStringContains(t, string(output), expected1)
|
h.AssertStringContains(t, string(output), expected1)
|
||||||
expected2 := "No buildpack groups passed detection."
|
expected2 := "No buildpack groups passed detection."
|
||||||
h.AssertStringContains(t, string(output), expected2)
|
h.AssertStringContains(t, string(output), expected2)
|
||||||
|
@ -154,23 +164,21 @@ fail: fail_detect_buildpack@some_version
|
||||||
detectImage,
|
detectImage,
|
||||||
h.WithFlags("--user", userID,
|
h.WithFlags("--user", userID,
|
||||||
"--env", "CNB_ORDER_PATH=/cnb/orders/simple_order.toml",
|
"--env", "CNB_ORDER_PATH=/cnb/orders/simple_order.toml",
|
||||||
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
),
|
),
|
||||||
h.WithArgs(),
|
h.WithArgs(),
|
||||||
)
|
)
|
||||||
|
|
||||||
// check group.toml
|
// check group.toml
|
||||||
foundGroupTOML := filepath.Join(copyDir, "layers", "group.toml")
|
foundGroupTOML := filepath.Join(copyDir, "layers", "group.toml")
|
||||||
var buildpackGroup buildpack.Group
|
group, err := files.Handler.ReadGroup(foundGroupTOML)
|
||||||
_, err := toml.DecodeFile(foundGroupTOML, &buildpackGroup)
|
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertEq(t, buildpackGroup.Group[0].ID, "simple_buildpack")
|
h.AssertEq(t, group.Group[0].ID, "simple_buildpack")
|
||||||
h.AssertEq(t, buildpackGroup.Group[0].Version, "simple_buildpack_version")
|
h.AssertEq(t, group.Group[0].Version, "simple_buildpack_version")
|
||||||
|
|
||||||
// check plan.toml
|
// check plan.toml
|
||||||
tempPlanToml := filepath.Join(copyDir, "layers", "plan.toml")
|
foundPlanTOML := filepath.Join(copyDir, "layers", "plan.toml")
|
||||||
var buildPlan platform.BuildPlan
|
buildPlan, err := files.Handler.ReadPlan(foundPlanTOML)
|
||||||
_, err = toml.DecodeFile(tempPlanToml, &buildPlan)
|
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertEq(t, buildPlan.Entries[0].Providers[0].ID, "simple_buildpack")
|
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].Providers[0].Version, "simple_buildpack_version")
|
||||||
|
@ -214,18 +222,17 @@ fail: fail_detect_buildpack@some_version
|
||||||
"--env", "CNB_GROUP_PATH=./custom_group.toml",
|
"--env", "CNB_GROUP_PATH=./custom_group.toml",
|
||||||
"--env", "CNB_PLAN_PATH=./custom_plan.toml",
|
"--env", "CNB_PLAN_PATH=./custom_plan.toml",
|
||||||
"--env", "CNB_PLATFORM_DIR=/custom_platform",
|
"--env", "CNB_PLATFORM_DIR=/custom_platform",
|
||||||
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
),
|
),
|
||||||
h.WithArgs("-log-level=debug"),
|
h.WithArgs("-log-level=debug"),
|
||||||
)
|
)
|
||||||
|
|
||||||
// check group.toml
|
// check group.toml
|
||||||
foundGroupTOML := filepath.Join(copyDir, "layers", "custom_group.toml")
|
foundGroupTOML := filepath.Join(copyDir, "layers", "custom_group.toml")
|
||||||
var buildpackGroup buildpack.Group
|
group, err := files.Handler.ReadGroup(foundGroupTOML)
|
||||||
_, err := toml.DecodeFile(foundGroupTOML, &buildpackGroup)
|
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertEq(t, buildpackGroup.Group[0].ID, "always_detect_buildpack")
|
h.AssertEq(t, group.Group[0].ID, "always_detect_buildpack")
|
||||||
h.AssertEq(t, buildpackGroup.Group[0].Version, "always_detect_buildpack_version")
|
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"
|
// 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")
|
tempPlanToml := filepath.Join(copyDir, "layers", "custom_plan.toml")
|
||||||
|
@ -272,7 +279,7 @@ fail: fail_detect_buildpack@some_version
|
||||||
detectImage,
|
detectImage,
|
||||||
h.WithFlags("--user", userID,
|
h.WithFlags("--user", userID,
|
||||||
"--volume", expectedOrderTOMLPath+":/custom/order.toml",
|
"--volume", expectedOrderTOMLPath+":/custom/order.toml",
|
||||||
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
),
|
),
|
||||||
h.WithArgs(
|
h.WithArgs(
|
||||||
"-log-level=debug",
|
"-log-level=debug",
|
||||||
|
@ -282,11 +289,10 @@ fail: fail_detect_buildpack@some_version
|
||||||
|
|
||||||
// check group.toml
|
// check group.toml
|
||||||
foundGroupTOML := filepath.Join(copyDir, "layers", "group.toml")
|
foundGroupTOML := filepath.Join(copyDir, "layers", "group.toml")
|
||||||
var buildpackGroup buildpack.Group
|
group, err := files.Handler.ReadGroup(foundGroupTOML)
|
||||||
_, err := toml.DecodeFile(foundGroupTOML, &buildpackGroup)
|
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertEq(t, buildpackGroup.Group[0].ID, "simple_buildpack")
|
h.AssertEq(t, group.Group[0].ID, "simple_buildpack")
|
||||||
h.AssertEq(t, buildpackGroup.Group[0].Version, "simple_buildpack_version")
|
h.AssertEq(t, group.Group[0].Version, "simple_buildpack_version")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -295,7 +301,7 @@ fail: fail_detect_buildpack@some_version
|
||||||
command := exec.Command("docker", "run",
|
command := exec.Command("docker", "run",
|
||||||
"--user", userID,
|
"--user", userID,
|
||||||
"--rm",
|
"--rm",
|
||||||
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
detectImage,
|
detectImage,
|
||||||
"-order=/custom/order.toml")
|
"-order=/custom/order.toml")
|
||||||
output, err := command.CombinedOutput()
|
output, err := command.CombinedOutput()
|
||||||
|
@ -310,7 +316,7 @@ fail: fail_detect_buildpack@some_version
|
||||||
command := exec.Command("docker", "run",
|
command := exec.Command("docker", "run",
|
||||||
"--user", userID,
|
"--user", userID,
|
||||||
"--rm",
|
"--rm",
|
||||||
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
detectImage,
|
detectImage,
|
||||||
"-order=/cnb/orders/bad_api.toml")
|
"-order=/cnb/orders/bad_api.toml")
|
||||||
output, err := command.CombinedOutput()
|
output, err := command.CombinedOutput()
|
||||||
|
@ -346,6 +352,11 @@ fail: fail_detect_buildpack@some_version
|
||||||
})
|
})
|
||||||
|
|
||||||
it("processes the provided order.toml", func() {
|
it("processes the provided order.toml", func() {
|
||||||
|
experimentalMode := "warn"
|
||||||
|
if api.MustParse(platformAPI).AtLeast("0.13") {
|
||||||
|
experimentalMode = "error"
|
||||||
|
}
|
||||||
|
|
||||||
output := h.DockerRunAndCopy(t,
|
output := h.DockerRunAndCopy(t,
|
||||||
containerName,
|
containerName,
|
||||||
copyDir,
|
copyDir,
|
||||||
|
@ -354,75 +365,58 @@ fail: fail_detect_buildpack@some_version
|
||||||
h.WithFlags(
|
h.WithFlags(
|
||||||
"--user", userID,
|
"--user", userID,
|
||||||
"--volume", orderPath+":/layers/order.toml",
|
"--volume", orderPath+":/layers/order.toml",
|
||||||
"--env", "CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
"--env", "CNB_EXPERIMENTAL_MODE=warn", // required as the default is `error` if unset
|
"--env", "CNB_EXPERIMENTAL_MODE="+experimentalMode,
|
||||||
),
|
),
|
||||||
h.WithArgs(
|
h.WithArgs(
|
||||||
"-analyzed=/layers/analyzed.toml",
|
"-analyzed=/layers/analyzed.toml",
|
||||||
"-extensions=/cnb/extensions",
|
"-extensions=/cnb/extensions",
|
||||||
"-generated=/layers/generated",
|
"-generated=/layers/generated",
|
||||||
"-log-level=debug",
|
"-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")
|
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, "Platform requested experimental feature 'Dockerfiles'")
|
||||||
|
}
|
||||||
|
h.AssertStringContains(t, output, "FOO=val-from-build-config")
|
||||||
h.AssertStringContains(t, output, "simple_extension: output from /bin/detect")
|
h.AssertStringContains(t, output, "simple_extension: output from /bin/detect")
|
||||||
t.Log("writes group.toml")
|
t.Log("writes group.toml")
|
||||||
foundGroupTOML := filepath.Join(copyDir, "layers", "group.toml")
|
foundGroupTOML := filepath.Join(copyDir, "layers", "group.toml")
|
||||||
var buildpackGroup buildpack.Group
|
group, err := files.Handler.ReadGroup(foundGroupTOML)
|
||||||
_, err := toml.DecodeFile(foundGroupTOML, &buildpackGroup)
|
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertEq(t, buildpackGroup.GroupExtensions[0].ID, "simple_extension")
|
h.AssertEq(t, group.GroupExtensions[0].ID, "simple_extension")
|
||||||
h.AssertEq(t, buildpackGroup.GroupExtensions[0].Version, "simple_extension_version")
|
h.AssertEq(t, group.GroupExtensions[0].Version, "simple_extension_version")
|
||||||
h.AssertEq(t, buildpackGroup.GroupExtensions[0].Extension, false) // this shows that `extension = true` is not redundantly printed in group.toml
|
h.AssertEq(t, group.Group[0].ID, "buildpack_for_ext")
|
||||||
h.AssertEq(t, buildpackGroup.Group[0].ID, "buildpack_for_ext")
|
h.AssertEq(t, group.Group[0].Version, "buildpack_for_ext_version")
|
||||||
h.AssertEq(t, buildpackGroup.Group[0].Version, "buildpack_for_ext_version")
|
h.AssertEq(t, group.Group[0].Extension, false)
|
||||||
h.AssertEq(t, buildpackGroup.Group[0].Extension, false)
|
|
||||||
t.Log("writes plan.toml")
|
t.Log("writes plan.toml")
|
||||||
foundPlanTOML := filepath.Join(copyDir, "layers", "plan.toml")
|
foundPlanTOML := filepath.Join(copyDir, "layers", "plan.toml")
|
||||||
var plan platform.BuildPlan
|
buildPlan, err := files.Handler.ReadPlan(foundPlanTOML)
|
||||||
_, err = toml.DecodeFile(foundPlanTOML, &plan)
|
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertEq(t, len(plan.Entries), 0) // this shows that the plan was filtered to remove `requires` provided by extensions
|
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")
|
t.Log("runs /bin/generate for extensions")
|
||||||
h.AssertStringContains(t, output, "simple_extension: output from /bin/generate")
|
h.AssertStringContains(t, output, "simple_extension: output from /bin/generate")
|
||||||
t.Log("copies the generated dockerfiles to the output directory")
|
|
||||||
dockerfilePath := filepath.Join(copyDir, "layers", "generated", "run", "simple_extension", "Dockerfile")
|
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)
|
h.AssertPathExists(t, dockerfilePath)
|
||||||
contents, err := os.ReadFile(dockerfilePath)
|
contents, err := os.ReadFile(dockerfilePath)
|
||||||
h.AssertEq(t, string(contents), "FROM some-run-image-from-extension\n")
|
h.AssertEq(t, string(contents), "FROM some-run-image-from-extension\n")
|
||||||
t.Log("records the new run image in analyzed.toml")
|
t.Log("records the new run image in analyzed.toml")
|
||||||
foundAnalyzedTOML := filepath.Join(copyDir, "layers", "analyzed.toml")
|
foundAnalyzedTOML := filepath.Join(copyDir, "layers", "analyzed.toml")
|
||||||
var analyzed platform.AnalyzedMetadata
|
analyzedMD, err := files.Handler.ReadAnalyzed(foundAnalyzedTOML, cmd.DefaultLogger)
|
||||||
_, err = toml.DecodeFile(foundAnalyzedTOML, &analyzed)
|
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertEq(t, analyzed.RunImage.Reference, "some-run-image-from-extension")
|
h.AssertEq(t, analyzedMD.RunImage.Image, "some-run-image-from-extension")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when("platform api < 0.6", func() {
|
|
||||||
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/empty_order.toml",
|
|
||||||
"--env", "CNB_PLATFORM_API=0.5",
|
|
||||||
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(), 100) // platform code for failed detect
|
|
||||||
expected := "No buildpack groups passed detection."
|
|
||||||
h.AssertStringContains(t, string(output), expected)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,35 @@
|
||||||
//go:build acceptance
|
//go:build acceptance
|
||||||
// +build acceptance
|
|
||||||
|
|
||||||
package acceptance
|
package acceptance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/buildpacks/imgutil"
|
"github.com/buildpacks/imgutil"
|
||||||
"github.com/google/go-containerregistry/pkg/authn"
|
"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"
|
||||||
"github.com/sclevine/spec/report"
|
"github.com/sclevine/spec/report"
|
||||||
|
|
||||||
"github.com/buildpacks/lifecycle/api"
|
"github.com/buildpacks/lifecycle/api"
|
||||||
|
"github.com/buildpacks/lifecycle/auth"
|
||||||
"github.com/buildpacks/lifecycle/cache"
|
"github.com/buildpacks/lifecycle/cache"
|
||||||
"github.com/buildpacks/lifecycle/internal/encoding"
|
"github.com/buildpacks/lifecycle/cmd"
|
||||||
|
"github.com/buildpacks/lifecycle/internal/fsutil"
|
||||||
"github.com/buildpacks/lifecycle/internal/path"
|
"github.com/buildpacks/lifecycle/internal/path"
|
||||||
"github.com/buildpacks/lifecycle/platform"
|
"github.com/buildpacks/lifecycle/platform/files"
|
||||||
h "github.com/buildpacks/lifecycle/testhelpers"
|
h "github.com/buildpacks/lifecycle/testhelpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,26 +44,19 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestExporter(t *testing.T) {
|
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")
|
testImageDockerContext := filepath.Join("testdata", "exporter")
|
||||||
exportTest = NewPhaseTest(t, "exporter", testImageDockerContext)
|
exportTest = NewPhaseTest(t, "exporter", testImageDockerContext)
|
||||||
|
|
||||||
exportTest.Start(t, updateAnalyzedTOMLFixturesWithRegRepoName)
|
exportTest.Start(t, updateTOMLFixturesWithTestRegistry)
|
||||||
defer exportTest.Stop(t)
|
defer exportTest.Stop(t)
|
||||||
|
|
||||||
exportImage = exportTest.testImageRef
|
exportImage = exportTest.testImageRef
|
||||||
exporterPath = exportTest.containerBinaryPath
|
exporterPath = exportTest.containerBinaryPath
|
||||||
cacheFixtureDir = filepath.Join("testdata", "exporter", "cache-dir")
|
|
||||||
exportRegAuthConfig = exportTest.targetRegistry.authConfig
|
exportRegAuthConfig = exportTest.targetRegistry.authConfig
|
||||||
exportRegNetwork = exportTest.targetRegistry.network
|
exportRegNetwork = exportTest.targetRegistry.network
|
||||||
exportDaemonFixtures = exportTest.targetDaemon.fixtures
|
exportDaemonFixtures = exportTest.targetDaemon.fixtures
|
||||||
exportRegFixtures = exportTest.targetRegistry.fixtures
|
exportRegFixtures = exportTest.targetRegistry.fixtures
|
||||||
|
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
|
||||||
|
|
||||||
for _, platformAPI := range api.Platform.Supported {
|
for _, platformAPI := range api.Platform.Supported {
|
||||||
spec.Run(t, "acceptance-exporter/"+platformAPI.String(), testExporterFunc(platformAPI.String()), spec.Parallel(), spec.Report(report.Terminal{}))
|
spec.Run(t, "acceptance-exporter/"+platformAPI.String(), testExporterFunc(platformAPI.String()), spec.Parallel(), spec.Report(report.Terminal{}))
|
||||||
}
|
}
|
||||||
|
@ -66,21 +64,16 @@ func TestExporter(t *testing.T) {
|
||||||
|
|
||||||
func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spec.S) {
|
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) {
|
return func(t *testing.T, when spec.G, it spec.S) {
|
||||||
|
|
||||||
|
when("daemon case", func() {
|
||||||
var exportedImageName string
|
var exportedImageName string
|
||||||
|
|
||||||
it.After(func() {
|
it.After(func() {
|
||||||
_, _, _ = h.RunE(exec.Command("docker", "rmi", exportedImageName)) // #nosec G204
|
_, _, _ = h.RunE(exec.Command("docker", "rmi", exportedImageName)) // #nosec G204
|
||||||
})
|
})
|
||||||
|
|
||||||
when("daemon case", func() {
|
it("app is created", func() {
|
||||||
when("first build", func() {
|
|
||||||
when("app", func() {
|
|
||||||
it("is created", func() {
|
|
||||||
exportFlags := []string{"-daemon", "-log-level", "debug"}
|
exportFlags := []string{"-daemon", "-log-level", "debug"}
|
||||||
if api.MustParse(platformAPI).LessThan("0.7") {
|
|
||||||
exportFlags = append(exportFlags, []string{"-run-image", exportRegFixtures.ReadOnlyRunImage}...)
|
|
||||||
}
|
|
||||||
|
|
||||||
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
|
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
|
||||||
exportedImageName = "some-exported-image-" + h.RandString(10)
|
exportedImageName = "some-exported-image-" + h.RandString(10)
|
||||||
exportArgs = append(exportArgs, exportedImageName)
|
exportArgs = append(exportArgs, exportedImageName)
|
||||||
|
@ -90,8 +83,6 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
h.WithFlags(append(
|
h.WithFlags(append(
|
||||||
dockerSocketMount,
|
dockerSocketMount,
|
||||||
"--env", "CNB_PLATFORM_API="+platformAPI,
|
"--env", "CNB_PLATFORM_API="+platformAPI,
|
||||||
"--env", "CNB_REGISTRY_AUTH="+exportRegAuthConfig,
|
|
||||||
"--network", exportRegNetwork,
|
|
||||||
)...),
|
)...),
|
||||||
h.WithArgs(exportArgs...),
|
h.WithArgs(exportArgs...),
|
||||||
)
|
)
|
||||||
|
@ -107,21 +98,115 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
h.AssertStringDoesNotContain(t, output, "Copying SBOM")
|
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)
|
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() {
|
when("SOURCE_DATE_EPOCH is set", func() {
|
||||||
it("Image CreatedAt is set to SOURCE_DATE_EPOCH", 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")
|
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)
|
expectedTime := time.Date(2022, 1, 5, 5, 5, 5, 0, time.UTC)
|
||||||
|
|
||||||
exportFlags := []string{"-daemon"}
|
exportFlags := []string{"-daemon"}
|
||||||
if api.MustParse(platformAPI).LessThan("0.7") {
|
|
||||||
exportFlags = append(exportFlags, []string{"-run-image", exportRegFixtures.ReadOnlyRunImage}...)
|
|
||||||
}
|
|
||||||
|
|
||||||
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
|
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
|
||||||
exportedImageName = "some-exported-image-" + h.RandString(10)
|
exportedImageName = "some-exported-image-" + h.RandString(10)
|
||||||
exportArgs = append(exportArgs, exportedImageName)
|
exportArgs = append(exportArgs, exportedImageName)
|
||||||
|
@ -145,14 +230,14 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
})
|
})
|
||||||
|
|
||||||
when("registry case", func() {
|
when("registry case", func() {
|
||||||
when("first build", func() {
|
var exportedImageName string
|
||||||
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}...)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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...)
|
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
|
||||||
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
|
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
|
||||||
exportArgs = append(exportArgs, exportedImageName)
|
exportArgs = append(exportArgs, exportedImageName)
|
||||||
|
@ -171,17 +256,40 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
h.Run(t, exec.Command("docker", "pull", exportedImageName))
|
h.Run(t, exec.Command("docker", "pull", exportedImageName))
|
||||||
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, imgutil.NormalizedDateTime)
|
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() {
|
when("SOURCE_DATE_EPOCH is set", func() {
|
||||||
it("Image CreatedAt is set to SOURCE_DATE_EPOCH", 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")
|
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)
|
expectedTime := time.Date(2022, 1, 5, 5, 5, 5, 0, time.UTC)
|
||||||
|
|
||||||
var exportFlags []string
|
var exportFlags []string
|
||||||
if api.MustParse(platformAPI).LessThan("0.7") {
|
|
||||||
exportFlags = append(exportFlags, []string{"-run-image", exportRegFixtures.ReadOnlyRunImage}...)
|
|
||||||
}
|
|
||||||
|
|
||||||
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
|
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
|
||||||
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
|
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
|
||||||
exportArgs = append(exportArgs, exportedImageName)
|
exportArgs = append(exportArgs, exportedImageName)
|
||||||
|
@ -202,15 +310,37 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, expectedTime)
|
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, expectedTime)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// FIXME: move this out of the registry block
|
||||||
when("cache", func() {
|
when("cache", func() {
|
||||||
when("cache image case", func() {
|
when("image case", func() {
|
||||||
it("is created", func() {
|
it("cache is created", func() {
|
||||||
cacheImageName := exportTest.RegRepoName("some-cache-image-" + h.RandString(10))
|
cacheImageName := exportTest.RegRepoName("some-cache-image-" + h.RandString(10))
|
||||||
exportFlags := []string{"-cache-image", cacheImageName}
|
exportFlags := []string{"-cache-image", cacheImageName}
|
||||||
if api.MustParse(platformAPI).LessThan("0.7") {
|
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
|
||||||
exportFlags = append(exportFlags, "-run-image", exportRegFixtures.ReadOnlyRunImage)
|
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)
|
||||||
|
// To detect whether the export of cacheImage and exportedImage is successful
|
||||||
|
h.Run(t, exec.Command("docker", "pull", exportedImageName))
|
||||||
|
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, imgutil.NormalizedDateTime)
|
||||||
|
h.Run(t, exec.Command("docker", "pull", cacheImageName))
|
||||||
|
})
|
||||||
|
|
||||||
|
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...)
|
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
|
||||||
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
|
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
|
||||||
exportArgs = append(exportArgs, exportedImageName)
|
exportArgs = append(exportArgs, exportedImageName)
|
||||||
|
@ -228,15 +358,14 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
|
|
||||||
h.Run(t, exec.Command("docker", "pull", exportedImageName))
|
h.Run(t, exec.Command("docker", "pull", exportedImageName))
|
||||||
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, imgutil.NormalizedDateTime)
|
assertImageOSAndArchAndCreatedAt(t, exportedImageName, exportTest, imgutil.NormalizedDateTime)
|
||||||
|
h.Run(t, exec.Command("docker", "pull", cacheImageName))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("is created with empty layer", func() {
|
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))
|
cacheImageName := exportTest.RegRepoName("some-empty-cache-image-" + h.RandString(10))
|
||||||
exportFlags := []string{"-cache-image", cacheImageName, "-layers", "/other_layers"}
|
exportFlags := []string{"-cache-image", cacheImageName, "-layers", "/other_layers"}
|
||||||
if api.MustParse(platformAPI).LessThan("0.7") {
|
|
||||||
exportFlags = append(exportFlags, "-run-image", exportRegFixtures.ReadOnlyRunImage)
|
|
||||||
}
|
|
||||||
|
|
||||||
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
|
exportArgs := append([]string{ctrPath(exporterPath)}, exportFlags...)
|
||||||
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
|
exportedImageName = exportTest.RegRepoName("some-exported-image-" + h.RandString(10))
|
||||||
exportArgs = append(exportArgs, exportedImageName)
|
exportArgs = append(exportArgs, exportedImageName)
|
||||||
|
@ -256,7 +385,9 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
|
|
||||||
// Retrieve the cache image from the ephemeral registry
|
// Retrieve the cache image from the ephemeral registry
|
||||||
h.Run(t, exec.Command("docker", "pull", cacheImageName))
|
h.Run(t, exec.Command("docker", "pull", cacheImageName))
|
||||||
subject, err := cache.NewImageCacheFromName(cacheImageName, authn.DefaultKeychain)
|
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)
|
h.AssertNil(t, err)
|
||||||
|
|
||||||
//Assert the cache image was created with an empty layer
|
//Assert the cache image was created with an empty layer
|
||||||
|
@ -266,42 +397,275 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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) {
|
func assertDaemonImageDoesNotHaveHistory(t *testing.T, repoName string) {
|
||||||
inspect, _, err := h.DockerCli(t).ImageInspectWithRaw(context.TODO(), imageName)
|
history, err := h.DockerCli(t).ImageHistory(context.TODO(), repoName)
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertEq(t, inspect.Os, phaseTest.targetDaemon.os)
|
for _, hs := range history {
|
||||||
h.AssertEq(t, inspect.Architecture, phaseTest.targetDaemon.arch)
|
h.AssertEq(t, hs.Created, imgutil.NormalizedDateTime.Unix())
|
||||||
|
h.AssertEq(t, hs.CreatedBy, "")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertImageOSAndArchAndCreatedAt(t *testing.T, imageName string, phaseTest *PhaseTest, expectedCreatedAt time.Time) {
|
func assertDaemonImageHasHistory(t *testing.T, repoName string, expectedHistory []string) {
|
||||||
inspect, _, err := h.DockerCli(t).ImageInspectWithRaw(context.TODO(), imageName)
|
history, err := h.DockerCli(t).ImageHistory(context.TODO(), repoName)
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertEq(t, inspect.Os, phaseTest.targetDaemon.os)
|
h.AssertEq(t, len(history), len(expectedHistory))
|
||||||
h.AssertEq(t, inspect.Architecture, phaseTest.targetDaemon.arch)
|
for idx, hs := range history {
|
||||||
h.AssertEq(t, inspect.Created, expectedCreatedAt.Format(time.RFC3339))
|
h.AssertEq(t, hs.Created, imgutil.NormalizedDateTime.Unix())
|
||||||
}
|
h.AssertEq(t, hs.CreatedBy, expectedHistory[idx])
|
||||||
|
}
|
||||||
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}
|
|
||||||
encoding.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}
|
|
||||||
encoding.WriteTOML(strings.TrimSuffix(placeHolderPath, ".placeholder"), analyzedMD)
|
|
||||||
|
|
||||||
placeHolderPath = filepath.Join("testdata", "exporter", "container", "other_layers", "analyzed.toml.placeholder")
|
|
||||||
analyzedMD = assertAnalyzedMetadata(t, placeHolderPath)
|
|
||||||
analyzedMD.RunImage = &platform.ImageIdentifier{Reference: phaseTest.targetRegistry.fixtures.ReadOnlyRunImage}
|
|
||||||
encoding.WriteTOML(strings.TrimSuffix(placeHolderPath, ".placeholder"), analyzedMD)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func calculateEmptyLayerSha(t *testing.T) string {
|
func calculateEmptyLayerSha(t *testing.T) string {
|
||||||
|
|
|
@ -1,29 +1,26 @@
|
||||||
//go:build acceptance
|
//go:build acceptance
|
||||||
// +build acceptance
|
|
||||||
|
|
||||||
package acceptance
|
package acceptance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
|
"github.com/buildpacks/imgutil/layout/sparse"
|
||||||
"github.com/google/go-containerregistry/pkg/authn"
|
"github.com/google/go-containerregistry/pkg/authn"
|
||||||
"github.com/google/go-containerregistry/pkg/v1/empty"
|
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/google/go-containerregistry/pkg/v1/remote"
|
||||||
"github.com/sclevine/spec"
|
"github.com/sclevine/spec"
|
||||||
"github.com/sclevine/spec/report"
|
"github.com/sclevine/spec/report"
|
||||||
|
|
||||||
"github.com/buildpacks/lifecycle/api"
|
"github.com/buildpacks/lifecycle/api"
|
||||||
"github.com/buildpacks/lifecycle/auth"
|
"github.com/buildpacks/lifecycle/auth"
|
||||||
"github.com/buildpacks/lifecycle/internal/encoding"
|
"github.com/buildpacks/lifecycle/cmd"
|
||||||
"github.com/buildpacks/lifecycle/internal/selective"
|
"github.com/buildpacks/lifecycle/platform/files"
|
||||||
"github.com/buildpacks/lifecycle/platform"
|
|
||||||
h "github.com/buildpacks/lifecycle/testhelpers"
|
h "github.com/buildpacks/lifecycle/testhelpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,11 +34,16 @@ var (
|
||||||
extendTest *PhaseTest
|
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) {
|
func TestExtender(t *testing.T) {
|
||||||
h.SkipIf(t, runtime.GOOS == "windows", "Extender is not supported on Windows")
|
|
||||||
|
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
|
||||||
|
|
||||||
testImageDockerContext := filepath.Join("testdata", "extender")
|
testImageDockerContext := filepath.Join("testdata", "extender")
|
||||||
extendTest = NewPhaseTest(t, "extender", testImageDockerContext)
|
extendTest = NewPhaseTest(t, "extender", testImageDockerContext)
|
||||||
extendTest.Start(t)
|
extendTest.Start(t)
|
||||||
|
@ -55,53 +57,76 @@ func TestExtender(t *testing.T) {
|
||||||
extendRegFixtures = extendTest.targetRegistry.fixtures
|
extendRegFixtures = extendTest.targetRegistry.fixtures
|
||||||
|
|
||||||
for _, platformAPI := range api.Platform.Supported {
|
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{}))
|
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) {
|
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) {
|
return func(t *testing.T, when spec.G, it spec.S) {
|
||||||
|
var generatedDir = "/layers/generated"
|
||||||
|
|
||||||
it.Before(func() {
|
it.Before(func() {
|
||||||
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.10"), "")
|
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() {
|
when("kaniko case", func() {
|
||||||
var kanikoDir, analyzedPath string
|
var extendedDir, kanikoDir, analyzedPath string
|
||||||
|
|
||||||
it.Before(func() {
|
it.Before(func() {
|
||||||
var err error
|
var err error
|
||||||
|
extendedDir, err = os.MkdirTemp("", "lifecycle-acceptance")
|
||||||
|
h.AssertNil(t, err)
|
||||||
kanikoDir, err = os.MkdirTemp("", "lifecycle-acceptance")
|
kanikoDir, err = os.MkdirTemp("", "lifecycle-acceptance")
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
|
|
||||||
// push "builder" image to test registry
|
// push base image to test registry
|
||||||
h.Run(t, exec.Command("docker", "tag", extendImage, extendTest.RegRepoName(extendImage)))
|
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()))
|
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:
|
// mimic what the restorer would have done in the previous phase:
|
||||||
|
|
||||||
// warm kaniko cache
|
// warm kaniko cache
|
||||||
|
|
||||||
|
// get remote image
|
||||||
os.Setenv("DOCKER_CONFIG", extendTest.targetRegistry.dockerConfigDir)
|
os.Setenv("DOCKER_CONFIG", extendTest.targetRegistry.dockerConfigDir)
|
||||||
ref, auth, err := auth.ReferenceForRepoName(authn.DefaultKeychain, extendTest.RegRepoName(extendImage))
|
ref, auth, err := auth.ReferenceForRepoName(authn.DefaultKeychain, extendTest.RegRepoName(extendImage))
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
remoteImage, err := remote.Image(ref, remote.WithAuth(auth))
|
remoteImage, err := remote.Image(ref, remote.WithAuth(auth))
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
buildImageHash, err := remoteImage.Digest()
|
baseImageHash, err := remoteImage.Digest()
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
buildImageDigest := buildImageHash.String()
|
baseImageDigest := baseImageHash.String()
|
||||||
baseCacheDir := filepath.Join(kanikoDir, "cache", "base")
|
baseCacheDir := filepath.Join(kanikoDir, "cache", "base")
|
||||||
h.AssertNil(t, os.MkdirAll(baseCacheDir, 0755))
|
h.AssertNil(t, os.MkdirAll(baseCacheDir, 0755))
|
||||||
layoutPath, err := selective.Write(filepath.Join(baseCacheDir, buildImageDigest), empty.Index)
|
|
||||||
h.AssertNil(t, err)
|
|
||||||
h.AssertNil(t, layoutPath.AppendImage(remoteImage))
|
|
||||||
|
|
||||||
// write build image reference in analyzed.toml
|
// write sparse image
|
||||||
analyzedMD := platform.AnalyzedMetadata{BuildImage: &platform.ImageIdentifier{Reference: fmt.Sprintf("%s@%s", extendTest.RegRepoName(extendImage), buildImageDigest)}}
|
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")
|
analyzedPath = h.TempFile(t, "", "analyzed.toml")
|
||||||
h.AssertNil(t, encoding.WriteTOML(analyzedPath, analyzedMD))
|
h.AssertNil(t, files.Handler.WriteAnalyzed(analyzedPath, &analyzedMD, cmd.DefaultLogger))
|
||||||
})
|
})
|
||||||
|
|
||||||
it.After(func() {
|
it.After(func() {
|
||||||
_ = os.RemoveAll(kanikoDir)
|
_ = os.RemoveAll(kanikoDir)
|
||||||
|
_ = os.RemoveAll(extendedDir)
|
||||||
})
|
})
|
||||||
|
|
||||||
when("extending the build image", func() {
|
when("extending the build image", func() {
|
||||||
|
@ -109,7 +134,7 @@ func testExtenderFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
extendArgs := []string{
|
extendArgs := []string{
|
||||||
ctrPath(extenderPath),
|
ctrPath(extenderPath),
|
||||||
"-analyzed", "/layers/analyzed.toml",
|
"-analyzed", "/layers/analyzed.toml",
|
||||||
"-generated", "/layers/generated",
|
"-generated", generatedDir,
|
||||||
"-log-level", "debug",
|
"-log-level", "debug",
|
||||||
"-gid", "1000",
|
"-gid", "1000",
|
||||||
"-uid", "1234",
|
"-uid", "1234",
|
||||||
|
@ -127,8 +152,7 @@ func testExtenderFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
h.WithFlags(extendFlags...),
|
h.WithFlags(extendFlags...),
|
||||||
h.WithArgs(extendArgs...),
|
h.WithArgs(extendArgs...),
|
||||||
)
|
)
|
||||||
h.AssertStringDoesNotContain(t, firstOutput, "Did not find cache key, pulling remote image...")
|
h.AssertStringDoesNotContain(t, firstOutput, msgErrRetrievingImageFromCache)
|
||||||
h.AssertStringDoesNotContain(t, firstOutput, "Error while retrieving image from cache: oci")
|
|
||||||
h.AssertStringContains(t, firstOutput, "ca-certificates")
|
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
|
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")
|
t.Log("sets environment variables from the extended build image in the build context")
|
||||||
|
@ -146,12 +170,119 @@ func testExtenderFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
h.WithFlags(extendFlags...),
|
h.WithFlags(extendFlags...),
|
||||||
h.WithArgs(extendArgs...),
|
h.WithArgs(extendArgs...),
|
||||||
)
|
)
|
||||||
h.AssertStringDoesNotContain(t, secondOutput, "Did not find cache key, pulling remote image...")
|
h.AssertStringDoesNotContain(t, secondOutput, msgErrRetrievingImageFromCache)
|
||||||
h.AssertStringDoesNotContain(t, secondOutput, "Error while retrieving image from cache: oci")
|
h.AssertStringDoesNotContain(t, secondOutput, "ca-certificates") // shows that first cache layer was used
|
||||||
h.AssertStringDoesNotContain(t, secondOutput, "ca-certificates") // shows that 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
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -25,9 +24,6 @@ func TestLauncher(t *testing.T) {
|
||||||
launchTest = NewPhaseTest(t, "launcher", testImageDockerContext, withoutDaemonFixtures, withoutRegistry)
|
launchTest = NewPhaseTest(t, "launcher", testImageDockerContext, withoutDaemonFixtures, withoutRegistry)
|
||||||
|
|
||||||
containerBinaryDir := filepath.Join("testdata", "launcher", "linux", "container", "cnb", "lifecycle")
|
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) {
|
withCustomContainerBinaryDir := func(_ *testing.T, phaseTest *PhaseTest) {
|
||||||
phaseTest.containerBinaryDir = containerBinaryDir
|
phaseTest.containerBinaryDir = containerBinaryDir
|
||||||
}
|
}
|
||||||
|
@ -41,10 +37,9 @@ func TestLauncher(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testLauncher(t *testing.T, when spec.G, it spec.S) {
|
func testLauncher(t *testing.T, when spec.G, it spec.S) {
|
||||||
when("Buildpack API >= 0.5", func() {
|
|
||||||
when("exec.d", func() {
|
when("exec.d", func() {
|
||||||
it("executes the binaries and modifies env before running profiles", func() {
|
it("executes the binaries and modifies env before running profiles", func() {
|
||||||
cmd := exec.Command("docker", "run", "--rm",
|
cmd := exec.Command("docker", "run", "--rm", //nolint
|
||||||
"--env=CNB_PLATFORM_API=0.7",
|
"--env=CNB_PLATFORM_API=0.7",
|
||||||
"--entrypoint=exec.d-checker"+exe,
|
"--entrypoint=exec.d-checker"+exe,
|
||||||
"--env=VAR_FROM_EXEC_D=orig-val",
|
"--env=VAR_FROM_EXEC_D=orig-val",
|
||||||
|
@ -66,12 +61,10 @@ func testLauncher(t *testing.T, when spec.G, it spec.S) {
|
||||||
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() {
|
it("launches that process", func() {
|
||||||
cmd := exec.Command("docker", "run", "--rm",
|
cmd := exec.Command("docker", "run", "--rm", //nolint
|
||||||
"--entrypoint=web",
|
"--entrypoint=web",
|
||||||
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
|
||||||
launchImage)
|
launchImage)
|
||||||
|
@ -89,31 +82,25 @@ func testLauncher(t *testing.T, when spec.G, it spec.S) {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("appends any args to the process args", func() {
|
it("appends any args to the process args", func() {
|
||||||
cmd := exec.Command("docker", "run", "--rm",
|
cmd := exec.Command( //nolint
|
||||||
|
"docker", "run", "--rm",
|
||||||
"--entrypoint=web",
|
"--entrypoint=web",
|
||||||
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
|
||||||
launchImage, "with user provided args")
|
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 web process-type with user provided args")
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when("entrypoint is a not a process", func() {
|
when("entrypoint is a not a process", func() {
|
||||||
it("builds a process from the arguments", func() {
|
it("builds a process from the arguments", func() {
|
||||||
cmd := exec.Command("docker", "run", "--rm",
|
cmd := exec.Command( //nolint
|
||||||
|
"docker", "run", "--rm",
|
||||||
"--entrypoint=launcher",
|
"--entrypoint=launcher",
|
||||||
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
|
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
|
||||||
launchImage, "--", "env")
|
launchImage, "--",
|
||||||
if runtime.GOOS == "windows" {
|
"env",
|
||||||
cmd = exec.Command("docker", "run", "--rm",
|
|
||||||
`--entrypoint=launcher`,
|
|
||||||
"--env=CNB_PLATFORM_API=0.4",
|
|
||||||
launchImage, "--", "cmd", "/c", "set",
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
assertOutput(t, cmd,
|
assertOutput(t, cmd,
|
||||||
"SOME_VAR=some-bp-val",
|
"SOME_VAR=some-bp-val",
|
||||||
|
@ -137,145 +124,36 @@ func testLauncher(t *testing.T, when spec.G, it spec.S) {
|
||||||
h.AssertStringContains(t, string(out), "ERROR: failed to launch: determine start command: when there is no default process a command is required")
|
h.AssertStringContains(t, string(out), "ERROR: failed to launch: determine start command: when there is no default process a command is required")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
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", "--env=CNB_PLATFORM_API=0.3", launchImage)
|
|
||||||
assertOutput(t, cmd, "Executing web process-type")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("CNB_PROCESS_TYPE is set", func() {
|
|
||||||
it("should run the specified CNB_PROCESS_TYPE", func() {
|
|
||||||
cmd := exec.Command("docker", "run", "--rm", "--env=CNB_PLATFORM_API=0.3", "--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")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("process-type provided in CMD", func() {
|
|
||||||
it("launches that process-type", func() {
|
|
||||||
cmd := exec.Command("docker", "run", "--rm", "--env=CNB_PLATFORM_API=0.3", 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", "--env=CNB_PLATFORM_API=0.3", 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=CNB_PLATFORM_API=0.3",
|
|
||||||
"--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=CNB_PLATFORM_API=0.3",
|
|
||||||
"--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",
|
|
||||||
"--env=CNB_PLATFORM_API=0.3", 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",
|
|
||||||
"--env=CNB_PLATFORM_API=0.3", 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", "--env=CNB_PLATFORM_API=0.3", 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() {
|
|
||||||
cmd := exec.Command("docker", "run", "--rm",
|
|
||||||
"--env=CNB_PLATFORM_API=0.3",
|
|
||||||
"--env", "CNB_APP_DIR="+ctrPath("/other-app"),
|
|
||||||
"--env", "CNB_LAYERS_DIR=/other-layers",
|
|
||||||
launchImage) // #nosec G204
|
|
||||||
assertOutput(t, cmd, "sourced other app profile\nExecuting other-layers web process-type")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
when("provided CMD is not a process-type", func() {
|
when("provided CMD is not a process-type", func() {
|
||||||
it("sources profiles and executes the command in a shell", func() {
|
it("sources profiles and executes the command in a shell", func() {
|
||||||
cmd := exec.Command("docker", "run", "--rm", launchImage, "echo", "something")
|
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")
|
assertOutput(t, cmd, "sourced bp profile\nsourced app profile\nsomething")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("sets env vars from layers", func() {
|
it("sets env vars from layers", func() {
|
||||||
cmd := exec.Command("docker", "run", "--rm", launchImage, "echo", "$SOME_VAR", "$OTHER_VAR", "$WORKER_VAR")
|
cmd := exec.Command( //nolint
|
||||||
if runtime.GOOS == "windows" {
|
"docker", "run", "--rm",
|
||||||
cmd = exec.Command("docker", "run", "--rm", launchImage, "echo", "%SOME_VAR%", "%OTHER_VAR%", "%WORKER_VAR%")
|
"--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")
|
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() {
|
it("passes through env vars from user, excluding excluded vars", func() {
|
||||||
args := []string{"echo", "$SOME_USER_VAR, $CNB_APP_DIR, $OTHER_VAR"}
|
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",
|
cmd := exec.Command("docker",
|
||||||
append(
|
append(
|
||||||
[]string{
|
[]string{
|
||||||
"run", "--rm",
|
"run", "--rm",
|
||||||
"--env", "CNB_APP_DIR=" + ctrPath("/workspace"),
|
"--env", "CNB_APP_DIR=" + ctrPath("/workspace"),
|
||||||
|
"--env=CNB_PLATFORM_API=" + latestPlatformAPI,
|
||||||
"--env", "SOME_USER_VAR=some-user-val",
|
"--env", "SOME_USER_VAR=some-user-val",
|
||||||
"--env", "OTHER_VAR=other-user-val",
|
"--env", "OTHER_VAR=other-user-val",
|
||||||
launchImage,
|
launchImage,
|
||||||
|
@ -283,37 +161,38 @@ func testLauncher(t *testing.T, when spec.G, it spec.S) {
|
||||||
args...)...,
|
args...)...,
|
||||||
) // #nosec G204
|
) // #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")
|
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() {
|
it("adds buildpack bin dirs to the path", func() {
|
||||||
cmd := exec.Command("docker", "run", "--rm", launchImage, "bp-executable")
|
cmd := exec.Command( //nolint
|
||||||
|
"docker", "run", "--rm",
|
||||||
|
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
|
||||||
|
launchImage,
|
||||||
|
"bp-executable",
|
||||||
|
)
|
||||||
assertOutput(t, cmd, "bp executable")
|
assertOutput(t, cmd, "bp executable")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when("CMD provided starts with --", func() {
|
when("CMD provided starts with --", func() {
|
||||||
it("launches command directly", func() {
|
it("launches command directly", func() {
|
||||||
if runtime.GOOS == "windows" {
|
cmd := exec.Command( //nolint
|
||||||
cmd := exec.Command("docker", "run", "--rm", launchImage, "--", "ping", "/?")
|
"docker", "run", "--rm",
|
||||||
assertOutput(t, cmd, "Usage: ping")
|
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
|
||||||
} else {
|
launchImage, "--",
|
||||||
cmd := exec.Command("docker", "run", "--rm", launchImage, "--", "echo", "something")
|
"echo", "something",
|
||||||
|
)
|
||||||
assertOutput(t, cmd, "something")
|
assertOutput(t, cmd, "something")
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("sets env vars from layers", func() {
|
it("sets env vars from layers", func() {
|
||||||
cmd := exec.Command("docker", "run", "--rm", launchImage, "--", "env")
|
cmd := exec.Command( //nolint
|
||||||
if runtime.GOOS == "windows" {
|
"docker", "run", "--rm",
|
||||||
cmd = exec.Command("docker", "run", "--rm", launchImage, "--", "cmd", "/c", "set")
|
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
|
||||||
}
|
launchImage, "--",
|
||||||
|
"env",
|
||||||
|
)
|
||||||
|
|
||||||
assertOutput(t, cmd,
|
assertOutput(t, cmd,
|
||||||
"SOME_VAR=some-bp-val",
|
"SOME_VAR=some-bp-val",
|
||||||
|
@ -322,20 +201,14 @@ func testLauncher(t *testing.T, when spec.G, it spec.S) {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("passes through env vars from user, excluding excluded vars", func() {
|
it("passes through env vars from user, excluding excluded vars", func() {
|
||||||
cmd := exec.Command("docker", "run", "--rm",
|
cmd := exec.Command( //nolint
|
||||||
|
"docker", "run", "--rm",
|
||||||
"--env", "CNB_APP_DIR=/workspace",
|
"--env", "CNB_APP_DIR=/workspace",
|
||||||
|
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
|
||||||
"--env", "SOME_USER_VAR=some-user-val",
|
"--env", "SOME_USER_VAR=some-user-val",
|
||||||
launchImage, "--",
|
launchImage, "--",
|
||||||
"env",
|
"env",
|
||||||
)
|
)
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
cmd = exec.Command("docker", "run", "--rm",
|
|
||||||
"--env", "CNB_APP_DIR=/workspace",
|
|
||||||
"--env", "SOME_USER_VAR=some-user-val",
|
|
||||||
launchImage, "--",
|
|
||||||
"cmd", "/c", "set",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -352,7 +225,12 @@ func testLauncher(t *testing.T, when spec.G, it spec.S) {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adds buildpack bin dirs to the path before looking up command", func() {
|
it("adds buildpack bin dirs to the path before looking up command", func() {
|
||||||
cmd := exec.Command("docker", "run", "--rm", launchImage, "--", "bp-executable")
|
cmd := exec.Command( //nolint
|
||||||
|
"docker", "run", "--rm",
|
||||||
|
"--env=CNB_PLATFORM_API="+latestPlatformAPI,
|
||||||
|
launchImage, "--",
|
||||||
|
"bp-executable",
|
||||||
|
)
|
||||||
assertOutput(t, cmd, "bp executable")
|
assertOutput(t, cmd, "bp executable")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,6 +2,8 @@ package acceptance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -13,15 +15,19 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types/image"
|
||||||
|
|
||||||
ih "github.com/buildpacks/imgutil/testhelpers"
|
ih "github.com/buildpacks/imgutil/testhelpers"
|
||||||
"github.com/google/go-containerregistry/pkg/authn"
|
"github.com/google/go-containerregistry/pkg/authn"
|
||||||
"github.com/google/go-containerregistry/pkg/registry"
|
"github.com/google/go-containerregistry/pkg/registry"
|
||||||
|
|
||||||
"github.com/buildpacks/lifecycle/internal/encoding"
|
|
||||||
|
|
||||||
"github.com/buildpacks/lifecycle/auth"
|
"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"
|
||||||
|
"github.com/buildpacks/lifecycle/platform/files"
|
||||||
h "github.com/buildpacks/lifecycle/testhelpers"
|
h "github.com/buildpacks/lifecycle/testhelpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -124,8 +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.MakeAndCopyLifecycle(t, p.targetDaemon.os, p.targetDaemon.arch, p.containerBinaryDir)
|
||||||
|
// 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)
|
copyFakeSboms(t)
|
||||||
h.DockerBuild(t, p.testImageRef, p.testImageDockerContext, h.WithArgs("-f", filepath.Join(p.testImageDockerContext, dockerfileName)))
|
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) {
|
func (p *PhaseTest) Stop(t *testing.T) {
|
||||||
|
@ -147,7 +174,7 @@ func (d *targetDaemon) createFixtures(t *testing.T) {
|
||||||
|
|
||||||
var fixtures daemonImageFixtures
|
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{})
|
cacheMeta := minifyMetadata(t, filepath.Join("testdata", "cache_image_metadata.json"), platform.CacheMetadata{})
|
||||||
|
|
||||||
fixtures.AppImage = "some-app-image-" + h.RandString(10)
|
fixtures.AppImage = "some-app-image-" + h.RandString(10)
|
||||||
|
@ -220,7 +247,7 @@ func (r *targetRegistry) start(t *testing.T) {
|
||||||
func (r *targetRegistry) createFixtures(t *testing.T) {
|
func (r *targetRegistry) createFixtures(t *testing.T) {
|
||||||
var fixtures regImageFixtures
|
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{})
|
cacheMeta := minifyMetadata(t, filepath.Join("testdata", "cache_image_metadata.json"), platform.CacheMetadata{})
|
||||||
|
|
||||||
// With Permissions
|
// With Permissions
|
||||||
|
@ -399,3 +426,97 @@ func SBOMExtensions() []string {
|
||||||
func SBOMComponents() []string {
|
func SBOMComponents() []string {
|
||||||
return []string{"lifecycle", "launcher"}
|
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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -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")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,25 +1,25 @@
|
||||||
//go:build acceptance
|
//go:build acceptance
|
||||||
// +build acceptance
|
|
||||||
|
|
||||||
package acceptance
|
package acceptance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
|
"github.com/google/go-containerregistry/pkg/name"
|
||||||
"github.com/sclevine/spec"
|
"github.com/sclevine/spec"
|
||||||
"github.com/sclevine/spec/report"
|
"github.com/sclevine/spec/report"
|
||||||
|
|
||||||
"github.com/buildpacks/lifecycle"
|
|
||||||
"github.com/buildpacks/lifecycle/api"
|
"github.com/buildpacks/lifecycle/api"
|
||||||
|
"github.com/buildpacks/lifecycle/cmd"
|
||||||
|
"github.com/buildpacks/lifecycle/platform/files"
|
||||||
h "github.com/buildpacks/lifecycle/testhelpers"
|
h "github.com/buildpacks/lifecycle/testhelpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const emptyImageSHA = "03cbce912ef1a8a658f73c660ab9c539d67188622f00b15c4f15b89b884f0e10"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
restoreImage string
|
restoreImage string
|
||||||
restoreRegAuthConfig string
|
restoreRegAuthConfig string
|
||||||
|
@ -31,14 +31,9 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRestorer(t *testing.T) {
|
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")
|
|
||||||
|
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
|
||||||
|
|
||||||
testImageDockerContext := filepath.Join("testdata", "restorer")
|
testImageDockerContext := filepath.Join("testdata", "restorer")
|
||||||
restoreTest = NewPhaseTest(t, "restorer", testImageDockerContext)
|
restoreTest = NewPhaseTest(t, "restorer", testImageDockerContext)
|
||||||
restoreTest.Start(t)
|
restoreTest.Start(t, updateTOMLFixturesWithTestRegistry)
|
||||||
defer restoreTest.Stop(t)
|
defer restoreTest.Stop(t)
|
||||||
|
|
||||||
restoreImage = restoreTest.testImageRef
|
restoreImage = restoreTest.testImageRef
|
||||||
|
@ -72,7 +67,7 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
|
|
||||||
when("called with arguments", func() {
|
when("called with arguments", func() {
|
||||||
it("errors", func() {
|
it("errors", func() {
|
||||||
command := exec.Command("docker", "run", "--rm", restoreImage, "some-arg")
|
command := exec.Command("docker", "run", "--rm", "--env", "CNB_PLATFORM_API="+platformAPI, restoreImage, "some-arg")
|
||||||
output, err := command.CombinedOutput()
|
output, err := command.CombinedOutput()
|
||||||
h.AssertNotNil(t, err)
|
h.AssertNotNil(t, err)
|
||||||
expected := "failed to parse arguments: received unexpected Args"
|
expected := "failed to parse arguments: received unexpected Args"
|
||||||
|
@ -80,28 +75,6 @@ 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", restoreImage, "-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", restoreImage, "-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() {
|
when("called without any cache flag", func() {
|
||||||
it("outputs it will not restore cache layer data", func() {
|
it("outputs it will not restore cache layer data", func() {
|
||||||
command := exec.Command("docker", "run", "--rm", "--env", "CNB_PLATFORM_API="+platformAPI, restoreImage)
|
command := exec.Command("docker", "run", "--rm", "--env", "CNB_PLATFORM_API="+platformAPI, restoreImage)
|
||||||
|
@ -114,7 +87,6 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
|
|
||||||
when("analyzed.toml exists with app metadata", func() {
|
when("analyzed.toml exists with app metadata", func() {
|
||||||
it("restores app metadata", func() {
|
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,
|
output := h.DockerRunAndCopy(t,
|
||||||
containerName,
|
containerName,
|
||||||
copyDir,
|
copyDir,
|
||||||
|
@ -129,6 +101,27 @@ 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\"")
|
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("using cache-dir", func() {
|
||||||
|
@ -154,7 +147,7 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
})
|
})
|
||||||
|
|
||||||
it("does not restore cache=true layers not in cache", func() {
|
it("does not restore cache=true layers not in cache", func() {
|
||||||
output := h.DockerRunAndCopy(t,
|
h.DockerRunAndCopy(t,
|
||||||
containerName,
|
containerName,
|
||||||
copyDir,
|
copyDir,
|
||||||
"/layers",
|
"/layers",
|
||||||
|
@ -166,12 +159,9 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
// check uncached layer is not restored
|
// check uncached layer is not restored
|
||||||
uncachedFile := filepath.Join(copyDir, "layers", "cacher_buildpack", "uncached-layer")
|
uncachedFile := filepath.Join(copyDir, "layers", "cacher_buildpack", "uncached-layer")
|
||||||
h.AssertPathDoesNotExist(t, uncachedFile)
|
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,
|
h.DockerRunAndCopy(t,
|
||||||
containerName,
|
containerName,
|
||||||
copyDir,
|
copyDir,
|
||||||
|
@ -185,12 +175,27 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
unusedBpLayer := filepath.Join(copyDir, "layers", "unused_buildpack")
|
unusedBpLayer := filepath.Join(copyDir, "layers", "unused_buildpack")
|
||||||
h.AssertPathDoesNotExist(t, unusedBpLayer)
|
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("using kaniko cache", func() {
|
when("restoring builder image metadata for extensions", func() {
|
||||||
it("accepts -build-image", 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 use kaniko")
|
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.10"), "Platform API < 0.10 does not restore builder image metadata")
|
||||||
h.DockerRunAndCopy(t,
|
h.DockerRunAndCopy(t,
|
||||||
containerName,
|
containerName,
|
||||||
copyDir,
|
copyDir,
|
||||||
|
@ -204,14 +209,129 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
|
||||||
h.WithArgs("-build-image", restoreRegFixtures.SomeCacheImage), // some-cache-image simulates a builder image in a registry
|
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")
|
t.Log("records builder image digest in analyzed.toml")
|
||||||
analyzedMD, err := lifecycle.Config.ReadAnalyzed(filepath.Join(copyDir, "layers", "analyzed.toml"))
|
analyzedMD, err := files.Handler.ReadAnalyzed(filepath.Join(copyDir, "layers", "analyzed.toml"), cmd.DefaultLogger)
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertStringContains(t, analyzedMD.BuildImage.Reference, restoreRegFixtures.SomeCacheImage+"@sha256:")
|
h.AssertStringContains(t, analyzedMD.BuildImage.Reference, restoreRegFixtures.SomeCacheImage+"@sha256:")
|
||||||
t.Log("writes builder manifest and config to the kaniko cache")
|
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"))
|
fis, err := os.ReadDir(filepath.Join(copyDir, "kaniko", "cache", "base"))
|
||||||
h.AssertNil(t, err)
|
h.AssertNil(t, err)
|
||||||
h.AssertEq(t, len(fis), 1)
|
h.AssertEq(t, len(fis), 1)
|
||||||
h.AssertPathExists(t, filepath.Join(copyDir, "kaniko", "cache", "base", fis[0].Name(), "oci-layout"))
|
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
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
FROM ubuntu:bionic
|
FROM ubuntu:bionic
|
||||||
ARG cnb_platform_api
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y ca-certificates
|
RUN apt-get update && apt-get install -y ca-certificates
|
||||||
|
|
||||||
|
@ -11,6 +10,7 @@ ENV CNB_USER_ID=2222
|
||||||
|
|
||||||
ENV CNB_GROUP_ID=3333
|
ENV CNB_GROUP_ID=3333
|
||||||
|
|
||||||
|
ARG cnb_platform_api
|
||||||
ENV CNB_PLATFORM_API=${cnb_platform_api}
|
ENV CNB_PLATFORM_API=${cnb_platform_api}
|
||||||
|
|
||||||
RUN chown -R $CNB_USER_ID:$CNB_GROUP_ID /some-dir
|
RUN chown -R $CNB_USER_ID:$CNB_GROUP_ID /some-dir
|
||||||
|
|
|
@ -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}
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
[[images]]
|
||||||
|
image = "some-run-image-from-run-toml"
|
||||||
|
|
||||||
|
[[images]]
|
||||||
|
image = "some-other-run-image"
|
|
@ -1,4 +1,4 @@
|
||||||
[[group]]
|
[[group]]
|
||||||
id = "some-buildpack-id"
|
id = "some-buildpack-id"
|
||||||
version = "some-buildpack-version"
|
version = "some-buildpack-version"
|
||||||
api = "0.2"
|
api = "0.10"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[[group]]
|
[[group]]
|
||||||
id = "some-other-buildpack-id"
|
id = "some-other-buildpack-id"
|
||||||
version = "some-other-buildpack-version"
|
version = "some-other-buildpack-version"
|
||||||
api = "0.3"
|
api = "0.10"
|
||||||
|
|
Binary file not shown.
|
@ -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"]}}
|
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
14
acceptance/testdata/analyzer/container/layout-repo/index.docker.io/library/busybox/latest/index.json
vendored
Executable file
14
acceptance/testdata/analyzer/container/layout-repo/index.docker.io/library/busybox/latest/index.json
vendored
Executable 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
3
acceptance/testdata/analyzer/container/layout-repo/index.docker.io/library/busybox/latest/oci-layout
vendored
Executable file
3
acceptance/testdata/analyzer/container/layout-repo/index.docker.io/library/busybox/latest/oci-layout
vendored
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"imageLayoutVersion": "1.0.0"
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
[[group]]
|
[[group]]
|
||||||
id = "another-buildpack-id"
|
id = "another-buildpack-id"
|
||||||
version = "another-buildpack-version"
|
version = "another-buildpack-version"
|
||||||
api = "0.2"
|
api = "0.10"
|
||||||
|
|
|
@ -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}
|
|
|
@ -28,9 +28,8 @@ echo
|
||||||
cat > "${layers_dir}/launch.toml" << EOL
|
cat > "${layers_dir}/launch.toml" << EOL
|
||||||
[[processes]]
|
[[processes]]
|
||||||
type = "hello"
|
type = "hello"
|
||||||
command = "echo world"
|
command = ["echo world"]
|
||||||
args = ["arg1"]
|
args = ["arg1"]
|
||||||
direct = false
|
|
||||||
EOL
|
EOL
|
||||||
|
|
||||||
echo "---> Done"
|
echo "---> Done"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Buildpack API version
|
# Buildpack API version
|
||||||
api = "0.2"
|
api = "0.10"
|
||||||
|
|
||||||
# Buildpack ID and metadata
|
# Buildpack ID and metadata
|
||||||
[buildpack]
|
[buildpack]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Buildpack API version
|
# Buildpack API version
|
||||||
api = "0.2"
|
api = "0.10"
|
||||||
|
|
||||||
# Buildpack ID and metadata
|
# Buildpack ID and metadata
|
||||||
[buildpack]
|
[buildpack]
|
||||||
|
|
33
acceptance/testdata/builder/container/cnb/buildpacks/hello_world_3/0.0.3/bin/build
vendored
Executable file
33
acceptance/testdata/builder/container/cnb/buildpacks/hello_world_3/0.0.3/bin/build
vendored
Executable 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"
|
7
acceptance/testdata/builder/container/cnb/buildpacks/hello_world_3/0.0.3/buildpack.toml
vendored
Normal file
7
acceptance/testdata/builder/container/cnb/buildpacks/hello_world_3/0.0.3/buildpack.toml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Buildpack API version
|
||||||
|
api = "0.10"
|
||||||
|
|
||||||
|
# Buildpack ID and metadata
|
||||||
|
[buildpack]
|
||||||
|
id = "hello_world_3"
|
||||||
|
version = "0.0.3"
|
|
@ -1,4 +1,4 @@
|
||||||
[[group]]
|
[[group]]
|
||||||
api = "0.2"
|
api = "0.10"
|
||||||
id = "hello_world"
|
id = "hello_world"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
|
@ -1,4 +1,4 @@
|
||||||
[[group]]
|
[[group]]
|
||||||
api = "0.2"
|
api = "0.10"
|
||||||
id = "hello_world_2"
|
id = "hello_world_2"
|
||||||
version = "0.0.2"
|
version = "0.0.2"
|
|
@ -1,9 +1,9 @@
|
||||||
[[group]]
|
[[group]]
|
||||||
api = "0.2"
|
api = "0.10"
|
||||||
id = "hello_world"
|
id = "hello_world"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
|
||||||
[[group-extensions]]
|
[[group-extensions]]
|
||||||
api = "0.9"
|
api = "0.10"
|
||||||
id = "hello_world"
|
id = "hello_world"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
|
10
acceptance/testdata/builder/container/cnb/plan_tomls/always_detect_plan_buildpack_3.toml
vendored
Normal file
10
acceptance/testdata/builder/container/cnb/plan_tomls/always_detect_plan_buildpack_3.toml
vendored
Normal 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
|
|
@ -1,5 +1,5 @@
|
||||||
# Buildpack API version
|
# Buildpack API version
|
||||||
api = "0.2"
|
api = "0.10"
|
||||||
|
|
||||||
# Buildpack ID and metadata
|
# Buildpack ID and metadata
|
||||||
[buildpack]
|
[buildpack]
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
[[group]]
|
||||||
|
api = "0.10"
|
||||||
|
id = "hello_world_3"
|
||||||
|
version = "0.0.3"
|
|
@ -0,0 +1,6 @@
|
||||||
|
[[entries]]
|
||||||
|
|
||||||
|
[[entries.providers]]
|
||||||
|
id = "hello_world_3"
|
||||||
|
version = "0.0.3"
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
[run-image]
|
||||||
|
[target]
|
||||||
|
id = "software"
|
||||||
|
os = "linux"
|
||||||
|
arch = "amd64"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[[group]]
|
[[group]]
|
||||||
api = "0.2"
|
api = "0.10"
|
||||||
id = "hello_world_2"
|
id = "hello_world_2"
|
||||||
version = "0.0.2"
|
version = "0.0.2"
|
|
@ -13,6 +13,7 @@ RUN groupadd cnb --gid ${cnb_gid} && \
|
||||||
|
|
||||||
# chown the directories so the tests do not have to run as root
|
# 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}" "/layers"
|
||||||
|
RUN chown -R "${cnb_uid}:${cnb_gid}" "/layout-repo"
|
||||||
|
|
||||||
WORKDIR /layers
|
WORKDIR /layers
|
||||||
|
|
||||||
|
|
|
@ -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"
|
|
@ -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"
|
|
@ -0,0 +1,5 @@
|
||||||
|
[[images]]
|
||||||
|
image = "some-run-image-from-run-toml"
|
||||||
|
|
||||||
|
[[images]]
|
||||||
|
image = "some-other-run-image"
|
Binary file not shown.
|
@ -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"]}}
|
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
14
acceptance/testdata/creator/container/layout-repo/index.docker.io/library/busybox/latest/index.json
vendored
Executable file
14
acceptance/testdata/creator/container/layout-repo/index.docker.io/library/busybox/latest/index.json
vendored
Executable 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
3
acceptance/testdata/creator/container/layout-repo/index.docker.io/library/busybox/latest/oci-layout
vendored
Executable file
3
acceptance/testdata/creator/container/layout-repo/index.docker.io/library/busybox/latest/oci-layout
vendored
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"imageLayoutVersion": "1.0.0"
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
FROM ubuntu:bionic
|
FROM ubuntu:jammy
|
||||||
|
|
||||||
ARG cnb_uid=1234
|
ARG cnb_uid=1234
|
||||||
ARG cnb_gid=1000
|
ARG cnb_gid=1000
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
val-from-build-config
|
|
@ -1,5 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo "ENV"
|
||||||
|
env
|
||||||
|
|
||||||
plan_path=$2
|
plan_path=$2
|
||||||
|
|
||||||
cat >> "${plan_path}" <<EOL
|
cat >> "${plan_path}" <<EOL
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
api = "0.3"
|
api = "0.10"
|
||||||
|
|
||||||
[buildpack]
|
[buildpack]
|
||||||
id = "buildpack_for_ext"
|
id = "buildpack_for_ext"
|
||||||
version = "buildpack_for_ext_version"
|
version = "buildpack_for_ext_version"
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
api = "0.3"
|
api = "0.9"
|
||||||
|
|
||||||
[buildpack]
|
[buildpack]
|
||||||
id = "simple_buildpack"
|
id = "simple_buildpack"
|
||||||
version = "simple_buildpack_version"
|
version = "simple_buildpack_version"
|
||||||
name = "Simple Buildpack"
|
name = "Simple Buildpack"
|
||||||
|
|
||||||
|
[[stacks]]
|
||||||
|
id = "io.buildpacks.stacks.bionic"
|
||||||
|
|
||||||
|
[[stacks]]
|
||||||
|
id = "io.buildpacks.stacks.jammy"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
api = "0.6"
|
api = "0.10"
|
||||||
|
|
||||||
[buildpack]
|
[buildpack]
|
||||||
id = "always_detect_buildpack"
|
id = "always_detect_buildpack"
|
||||||
version = "always_detect_buildpack_version"
|
version = "always_detect_buildpack_version"
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
[[images]]
|
||||||
|
image = "some-run-image-from-extension"
|
||||||
|
|
||||||
|
[[images]]
|
||||||
|
image = "some-other-run-image"
|
|
@ -0,0 +1,2 @@
|
||||||
|
[run-image]
|
||||||
|
reference = "some-old-run-image"
|
|
@ -13,8 +13,13 @@ RUN groupadd cnb --gid ${cnb_gid} && \
|
||||||
|
|
||||||
# chown the directories so the tests do not have to run as root
|
# 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}" "/layers"
|
||||||
|
RUN chown -R "${cnb_uid}:${cnb_gid}" "/layout-repo"
|
||||||
RUN chown -R "${cnb_uid}:${cnb_gid}" "/other_layers"
|
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
|
WORKDIR /layers
|
||||||
|
|
||||||
USER ${cnb_uid}:${cnb_gid}
|
USER ${cnb_uid}:${cnb_gid}
|
||||||
|
|
17
acceptance/testdata/exporter/cache-dir/committed/io.buildpacks.lifecycle.cache.metadata
vendored
Normal file
17
acceptance/testdata/exporter/cache-dir/committed/io.buildpacks.lifecycle.cache.metadata
vendored
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
[[images]]
|
||||||
|
image = "REPLACE"
|
||||||
|
mirrors = ["mirror1", "mirror2"]
|
|
@ -0,0 +1,2 @@
|
||||||
|
[run-image]
|
||||||
|
reference = "host.docker.internal/bar"
|
|
@ -1 +1 @@
|
||||||
sha256:b89860e2f9c62e6b5d66d3ce019e18cdabae30273c25150b7f20a82f7a70e494
|
sha256:2d9c9c638d5c4f0df067eeae7b9c99ad05776a89d19ab863c28850a91e5f2944
|
|
@ -1,3 +1,4 @@
|
||||||
|
[types]
|
||||||
build = false
|
build = false
|
||||||
launch = false
|
launch = false
|
||||||
cache = true
|
cache = true
|
||||||
|
|
2
acceptance/testdata/exporter/container/layers/cacher_buildpack/launch-layer.toml
vendored
Normal file
2
acceptance/testdata/exporter/container/layers/cacher_buildpack/launch-layer.toml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[types]
|
||||||
|
launch = true
|
1
acceptance/testdata/exporter/container/layers/cacher_buildpack/launch-layer/data
vendored
Normal file
1
acceptance/testdata/exporter/container/layers/cacher_buildpack/launch-layer/data
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
launch-data
|
1
acceptance/testdata/exporter/container/layers/corrupted_buildpack/corrupted-layer/data
vendored
Normal file
1
acceptance/testdata/exporter/container/layers/corrupted_buildpack/corrupted-layer/data
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
digest-not-match-data
|
|
@ -1,9 +1,14 @@
|
||||||
[[group]]
|
[[group]]
|
||||||
id = "some-buildpack-id"
|
id = "some-buildpack-id"
|
||||||
version = "some-buildpack-version"
|
version = "some-buildpack-version"
|
||||||
api = "0.2"
|
api = "0.7"
|
||||||
|
|
||||||
[[group]]
|
[[group]]
|
||||||
id = "cacher_buildpack"
|
id = "cacher_buildpack"
|
||||||
version = "cacher_v1"
|
version = "cacher_v1"
|
||||||
api = "0.3"
|
api = "0.8"
|
||||||
|
|
||||||
|
[[group]]
|
||||||
|
id = "corrupted_buildpack"
|
||||||
|
version = "corrupted_v1"
|
||||||
|
api = "0.8"
|
||||||
|
|
3
acceptance/testdata/exporter/container/layers/layout-analyzed.toml.placeholder
vendored
Normal file
3
acceptance/testdata/exporter/container/layers/layout-analyzed.toml.placeholder
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[run-image]
|
||||||
|
reference = "REPLACE"
|
||||||
|
name = "REPLACE"
|
3
acceptance/testdata/exporter/container/layers/run-image-extended-analyzed.toml.placeholder
vendored
Normal file
3
acceptance/testdata/exporter/container/layers/run-image-extended-analyzed.toml.placeholder
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[run-image]
|
||||||
|
reference = "REPLACE"
|
||||||
|
extend = true
|
Binary file not shown.
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"schemaVersion": 2,
|
||||||
|
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||||
|
"config": {
|
||||||
|
"mediaType": "application/vnd.docker.container.image.v1+json",
|
||||||
|
"size": 2771,
|
||||||
|
"digest": "sha256:2dc6ef9f627c01f3f9e4f735c90f0251b5adaf6ad5685c5afb5cf638412fad67"
|
||||||
|
},
|
||||||
|
"layers": [
|
||||||
|
{
|
||||||
|
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
|
||||||
|
"size": 26711153,
|
||||||
|
"digest": "sha256:0064b1b97ec0775813740e8cb92821a6d84fd38eee70bafba9c12d9c37534661"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
|
||||||
|
"size": 38445484,
|
||||||
|
"digest": "sha256:65c2873d397056a5cb4169790654d787579b005f18b903082b177d4d9b4aecf5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
|
||||||
|
"size": 146545,
|
||||||
|
"digest": "sha256:0fb9b88c9cbe9f11b4c8da645f390df59f5949632985a0bfc2a842ef17b2ad18"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"schemaVersion": 2,
|
||||||
|
"manifests": [
|
||||||
|
{
|
||||||
|
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||||
|
"size": 1083,
|
||||||
|
"digest": "sha256:40007d6086160bcdf45770ed12d23f0c594013cf0cd5e65ffc67be8f46e0d9c9"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"imageLayoutVersion": "1.0.0"
|
||||||
|
}
|
Binary file not shown.
|
@ -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"]}}
|
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
14
acceptance/testdata/exporter/container/layout-repo/index.docker.io/library/busybox/latest/index.json
vendored
Executable file
14
acceptance/testdata/exporter/container/layout-repo/index.docker.io/library/busybox/latest/index.json
vendored
Executable 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
3
acceptance/testdata/exporter/container/layout-repo/index.docker.io/library/busybox/latest/oci-layout
vendored
Executable file
3
acceptance/testdata/exporter/container/layout-repo/index.docker.io/library/busybox/latest/oci-layout
vendored
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"imageLayoutVersion": "1.0.0"
|
||||||
|
}
|
9
acceptance/testdata/extender/container/layers/generated-with-contexts/curl/build.Dockerfile
vendored
Normal file
9
acceptance/testdata/extender/container/layers/generated-with-contexts/curl/build.Dockerfile
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
ARG base_image
|
||||||
|
FROM ${base_image}
|
||||||
|
|
||||||
|
USER root
|
||||||
|
RUN apt-get update && apt-get install -y curl
|
||||||
|
COPY build-file /
|
||||||
|
|
||||||
|
ARG build_id=0
|
||||||
|
RUN echo ${build_id}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue