estesp / manifest-tool

Command line tool to create and query container image manifest list/indexes
Apache License 2.0
741 stars 92 forks source link

Fix segv with docker-cfg flag and allow custom files #168

Closed estesp closed 2 years ago

estesp commented 2 years ago

Closes: #163

Fixes a segmentation fault if a file was passed in to --docker-cfg instead of a directory (which was expected). Now allows a path or a file to be specified via the flag and updated the help text appropriately.

Signed-off-by: Phil Estes estesp@gmail.com

jsoref commented 2 years ago

Hi, I'm not sure how this is supposed to work, but...

$ git checkout -q 109b3ad39ce709dbae0f607e5a06a357abfe5211; make all; manifest-tool inspect busybox:latest
cd v2 && go build -ldflags "-X main.gitCommit="109b3ad39ce709dbae0f607e5a06a357abfe5211"" -o ../manifest-tool github.com/estesp/manifest-tool/v2/cmd/manifest-tool
unable to set client authconfig to context: no such flag -authconfig

NAME:
   manifest-tool - registry client to inspect and push multi-platform OCI & Docker v2 images

USAGE:
   manifest-tool [global options] command [command options] [arguments...]

VERSION:
   2.0.4-dev (commit: 109b3ad39ce709dbae0f607e5a06a357abfe5211)

COMMANDS:
   inspect  fetch image manifests in a container registry
   push     push a manifest list/OCI index entry to a registry with provided image details
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --debug             enable debug output
   --insecure          allow insecure registry communication
   --plain-http        allow registry communication over plain http
   --username value    registry username
   --password value    registry password
   --docker-cfg value  directory path containing a Docker-formatted config.json or path to a file formatted for Docker auth (default: "/Users/jsoref/.docker")
   --help, -h          show help
   --version, -v       print the version
ERRO[0000] manifest-tool failed with error: unable to set client authconfig to context: no such flag -authconfig 
$ git checkout -q 109b3ad39ce709dbae0f607e5a06a357abfe5211~; make all; manifest-tool inspect busybox:latest
cd v2 && go build -ldflags "-X main.gitCommit="a6cf40a0492ddda698cf4a32e004a649b6cbc74e"" -o ../manifest-tool github.com/estesp/manifest-tool/v2/cmd/manifest-tool
Name:   busybox:latest (Type: application/vnd.docker.distribution.manifest.list.v2+json)
Digest: sha256:3614ca5eacf0a3a1bcc361c939202a974b4902b9334ff36eb29ffe9011aaad83
 * Contains 10 manifest references:
[1]     Type: application/vnd.docker.distribution.manifest.v2+json
[1]   Digest: sha256:dcdf379c574e1773d703f0c0d56d67594e7a91d6b84d11ff46799f60fb081c52
[1]   Length: 527
[1] Platform:
[1]    -      OS: linux
[1]    -    Arch: amd64
[1] # Layers: 1
     layer 01: digest = sha256:19d511225f94f9b5cbf3836eb02b5273c01b95da50735742560e3e45b8c8bfcc

[2]     Type: application/vnd.docker.distribution.manifest.v2+json
[2]   Digest: sha256:897ee244eb86a38fa6f7d21e6a9e22aae41f105c574fc47b2c77cff8be98e29d
[2]   Length: 527
[2] Platform:
[2]    -      OS: linux
[2]    -    Arch: arm
[2]    - Variant: v5
[2] # Layers: 1
     layer 01: digest = sha256:94b622d2880b7640fe5cf6da80a87db008e0529da67218311bc90f0fb1205091

[3]     Type: application/vnd.docker.distribution.manifest.v2+json
[3]   Digest: sha256:da1b5115bf7e41d123977962115034c67d019ef63fc0c3b9ddfdea3b6f9f9992
[3]   Length: 527
[3] Platform:
[3]    -      OS: linux
[3]    -    Arch: arm
[3]    - Variant: v6
[3] # Layers: 1
     layer 01: digest = sha256:7bc0df393b289d450de141fd2c095776adb8cb79f976c1dacb787c9fc9a4d201

[4]     Type: application/vnd.docker.distribution.manifest.v2+json
[4]   Digest: sha256:c940f8509c36033b11bd7468bf9d9cb60b51f4be13033cfe70e86581944d66cc
[4]   Length: 527
[4] Platform:
[4]    -      OS: linux
[4]    -    Arch: arm
[4]    - Variant: v7
[4] # Layers: 1
     layer 01: digest = sha256:7ceae7886eafad2b1357f06c9477a2d217e23c9d62c8d217b5d0ed7447e76a6a

[5]     Type: application/vnd.docker.distribution.manifest.v2+json
[5]   Digest: sha256:2c5e2045f35086c019e80c86880fd5b7c7a619878b59e3b7592711e1781df51a
[5]   Length: 527
[5] Platform:
[5]    -      OS: linux
[5]    -    Arch: arm64
[5]    - Variant: v8
[5] # Layers: 1
     layer 01: digest = sha256:87379020f3b6731a4b64976e614d305f5c121d153c049d14ba600ff24bbac012

[6]     Type: application/vnd.docker.distribution.manifest.v2+json
[6]   Digest: sha256:0dc78806f5885db569f7389b0e0df2e190346b0df59937268c5862d5bfc5f933
[6]   Length: 527
[6] Platform:
[6]    -      OS: linux
[6]    -    Arch: 386
[6] # Layers: 1
     layer 01: digest = sha256:122c52305f257cb504fa1e6417a0e2be0a91c6e8597236feced3168597406ed8

[7]     Type: application/vnd.docker.distribution.manifest.v2+json
[7]   Digest: sha256:d339093e7bda33949fb5f3ddb6eeb6b51b8b0950183a132831c74cba05f0a1ea
[7]   Length: 527
[7] Platform:
[7]    -      OS: linux
[7]    -    Arch: mips64le
[7] # Layers: 1
     layer 01: digest = sha256:ff2d9c2b154fd3b791f0dcffed0c3c63e3cc5b3549781f2f471478ef124fa11e

[8]     Type: application/vnd.docker.distribution.manifest.v2+json
[8]   Digest: sha256:0d4b25aec0a40382a3eaea29e3af360f2c5908c91b3b12ded5492fdc5e74050c
[8]   Length: 528
[8] Platform:
[8]    -      OS: linux
[8]    -    Arch: ppc64le
[8] # Layers: 1
     layer 01: digest = sha256:cd719190bb511a8ac7cf73b99bec41e528f046a4b96921c93a22ad0813bcd87a

[9]     Type: application/vnd.docker.distribution.manifest.v2+json
[9]   Digest: sha256:3cb3c11a9bac8d6ca264766461deae86cdd58c174ecb26cdf2222e8e489c4132
[9]   Length: 527
[9] Platform:
[9]    -      OS: linux
[9]    -    Arch: riscv64
[9] # Layers: 1
     layer 01: digest = sha256:46b5947a368c82da2a25216b85057a03081fa6e86e9b72c2ec471115009a2123

[10]     Type: application/vnd.docker.distribution.manifest.v2+json
[10]   Digest: sha256:ac0e2006c03b435ee605c4bf84464d9fb665353643fa6295962bd69c23ced5dc
[10]   Length: 528
[10] Platform:
[10]    -      OS: linux
[10]    -    Arch: s390x
[10] # Layers: 1
     layer 01: digest = sha256:55b62457923c4f107ac9cb1d535ca1afbdad4b04bae1ffcbebd9f2f381378eca
estesp commented 2 years ago

@jsoref embarrassing; I tested this locally yesterday and thought I had everything working. Clearly I was using the wrong binary or ??

Have opened #169 to fix it correctly this time.