rancher / wharfie

Pulls and unpacks a container image to the local filesystem. Usable both as a standalone CLI tool, and as a go module.
Apache License 2.0
25 stars 14 forks source link

Fix symlink/hardlink support and add path mapping support to CLI #5

Closed brandond closed 2 years ago

brandond commented 2 years ago

Signed-off-by: Brad Davidson brad.davidson@rancher.com

brandond commented 2 years ago

@phillipsj the second commit here seems to get me the proper behavior on Windows.

brandond commented 2 years ago

Output on Linux:

brandond@dev01:/var/lib/repos/go/src/github.com/rancher/wharfie$ ./wharfie --debug rancher/k3s:v1.22.2-k3s2 /etc:./k3s/etc
INFO[0000] Extract mapping /etc => /var/lib/repos/go/src/github.com/rancher/wharfie/k3s/etc
INFO[0000] Pulling image index.docker.io/rancher/k3s:v1.22.2-k3s2
INFO[0001] Extracting file etc/nsswitch.conf to /var/lib/repos/go/src/github.com/rancher/wharfie/k3s/etc/nsswitch.conf
INFO[0001] Extracting file etc/os-release to /var/lib/repos/go/src/github.com/rancher/wharfie/k3s/etc/os-release
DEBU[0001] Skipping file tmp/
DEBU[0001] Skipping file bin/

Output on Windows:

C:\Users\brandond\repos\github.com\rancher\wharfie>wharfie.exe --debug --os=linux rancher/k3s:v1.22.2-k3s2 /etc:C:\temp\k3s\etc
time="2021-11-03T12:11:49-07:00" level=info msg="Extract mapping /etc => C:\\temp\\k3s\\etc"
time="2021-11-03T12:11:49-07:00" level=info msg="Pulling image index.docker.io/rancher/k3s:v1.22.2-k3s2"
time="2021-11-03T12:11:50-07:00" level=info msg="Extracting file etc/nsswitch.conf to C:\\temp\\k3s\\etc\\nsswitch.conf"
time="2021-11-03T12:11:50-07:00" level=info msg="Extracting file etc/os-release to C:\\temp\\k3s\\etc\\os-release"
time="2021-11-03T12:11:50-07:00" level=debug msg="Skipping file tmp/"
time="2021-11-03T12:11:50-07:00" level=debug msg="Skipping file bin/"
phillipsj commented 2 years ago

@brandond can you please pull a Windows image on Windows to make sure that it works, your test is only doing Linux.

dweomer commented 2 years ago

@brandond can you please pull a Windows image on Windows to make sure that it works, your test is only doing Linux.

@brandond please do pull the Windows image as @phillipsj suggests

brandond commented 2 years ago

@phillipsj can you provide a sample Windows image?

A tarfile is a tarfile so I can't imagine it'll make a difference but I'm glad to show an example.

phillipsj commented 2 years ago

That was the exact use case that was failing.

docker pull rancher/system-agent-installer-rke2:v1.22.3-rc2-rke2r1

This one also works: v1.21.6-rke2r1

The path to extract is: /Files/bin

brandond commented 2 years ago

When in doubt, add tests! Then fix them. Apologies for not having these in the first place. CI doesn't test Windows but I'm building and testing there locally.

brandond commented 2 years ago

@phillipsj output on windows:

C:\Users\brandond\repos\github.com\rancher\wharfie>wharfie.exe --debug rancher/system-agent-installer-rke2:v1.22.3-rc2-rke2r1 /Files/bin:C:\temp\bin\
time="2021-11-03T16:47:48-07:00" level=info msg="Extract mapping /Files/bin => C:\\temp\\bin"
time="2021-11-03T16:47:48-07:00" level=info msg="Pulling image index.docker.io/rancher/system-agent-installer-rke2:v1.22.3-rc2-rke2r1"
time="2021-11-03T16:47:49-07:00" level=debug msg="Skipping file Files"
time="2021-11-03T16:47:49-07:00" level=debug msg="Skipping file Hives"
time="2021-11-03T16:47:49-07:00" level=debug msg="Skipping file Hives/DefaultUser_Delta"
time="2021-11-03T16:47:49-07:00" level=debug msg="Skipping file Hives/Sam_Delta"
time="2021-11-03T16:47:49-07:00" level=debug msg="Skipping file Hives/Security_Delta"
time="2021-11-03T16:47:49-07:00" level=debug msg="Skipping file Hives/Software_Delta"
time="2021-11-03T16:47:49-07:00" level=debug msg="Skipping file Hives/System_Delta"
time="2021-11-03T16:47:50-07:00" level=info msg="Creating directory C:\\temp\\bin"
time="2021-11-03T16:47:50-07:00" level=info msg="Extracting file Files/bin/installer.ps1 to C:\\temp\\bin\\installer.ps1"
time="2021-11-03T16:47:50-07:00" level=info msg="Extracting file Files/bin/rke2.windows-amd64.tar.gz to C:\\temp\\bin\\rke2.windows-amd64.tar.gz"
time="2021-11-03T16:47:52-07:00" level=info msg="Extracting file Files/bin/sha256sum-amd64.txt to C:\\temp\\bin\\sha256sum-amd64.txt"
time="2021-11-03T16:47:52-07:00" level=info msg="Extracting file Files/bin/run.ps1 to C:\\temp\\bin\\run.ps1"
time="2021-11-03T16:47:53-07:00" level=debug msg="Skipping file Files/License.txt"
time="2021-11-03T16:47:53-07:00" level=debug msg="Skipping file Files/ProgramData"
sirredbeard commented 2 years ago

@brandond Can I ask why this was merged when #4 was already in?

brandond commented 2 years ago

4 didn't pass tests, which I was in the process of adding when that PR was merged despite my reservations. This PR (minus the windows path changes) was rebased on top of that commit, after which I added tests. That revealed some problems, which I fixed in the next commit. You can see the CI results above.