From 6c6e97018768ab5e0eeccc34ee4de64887fde119 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 24 May 2022 11:51:25 +0200 Subject: pkg/bindings/images: remove TODOs re: system context A global system context does not make sense for the _bindings_, so remove the TODOs. [NO TESTS NEEDED] Signed-off-by: Valentin Rothberg --- pkg/bindings/images/images.go | 2 -- pkg/bindings/images/pull.go | 1 - 2 files changed, 3 deletions(-) (limited to 'pkg') diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go index 8e3b07929..32372019b 100644 --- a/pkg/bindings/images/images.go +++ b/pkg/bindings/images/images.go @@ -280,7 +280,6 @@ func Push(ctx context.Context, source string, destination string, options *PushO if err != nil { return err } - // TODO: have a global system context we can pass around (1st argument) header, err := auth.MakeXRegistryAuthHeader(&imageTypes.SystemContext{AuthFilePath: options.GetAuthfile()}, options.GetUsername(), options.GetPassword()) if err != nil { return err @@ -329,7 +328,6 @@ func Search(ctx context.Context, term string, options *SearchOptions) ([]entitie params.Set("tlsVerify", strconv.FormatBool(!options.GetSkipTLSVerify())) } - // TODO: have a global system context we can pass around (1st argument) header, err := auth.MakeXRegistryAuthHeader(&imageTypes.SystemContext{AuthFilePath: options.GetAuthfile()}, "", "") if err != nil { return nil, err diff --git a/pkg/bindings/images/pull.go b/pkg/bindings/images/pull.go index 20e47179c..de02c62fd 100644 --- a/pkg/bindings/images/pull.go +++ b/pkg/bindings/images/pull.go @@ -42,7 +42,6 @@ func Pull(ctx context.Context, rawImage string, options *PullOptions) ([]string, params.Set("tlsVerify", strconv.FormatBool(!options.GetSkipTLSVerify())) } - // TODO: have a global system context we can pass around (1st argument) header, err := auth.MakeXRegistryAuthHeader(&types.SystemContext{AuthFilePath: options.GetAuthfile()}, options.GetUsername(), options.GetPassword()) if err != nil { return nil, err -- cgit v1.2.3-54-g00ecf From d3d3a207de06935f77edd937980e2540f62bc11c Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 24 May 2022 13:04:36 +0200 Subject: pkg/bindings/images/rm.go: remove redundant FIXME The Remove endpoint is being tested in the meantime. Signed-off-by: Valentin Rothberg --- pkg/bindings/images/rm.go | 3 --- 1 file changed, 3 deletions(-) (limited to 'pkg') diff --git a/pkg/bindings/images/rm.go b/pkg/bindings/images/rm.go index b80bacf45..eb3eef10c 100644 --- a/pkg/bindings/images/rm.go +++ b/pkg/bindings/images/rm.go @@ -16,9 +16,6 @@ func Remove(ctx context.Context, images []string, options *RemoveOptions) (*enti if options == nil { options = new(RemoveOptions) } - // FIXME - bindings tests are missing for this endpoint. Once the CI is - // re-enabled for bindings, we need to add them. At the time of writing, - // the tests don't compile. var report types.LibpodImagesRemoveReport conn, err := bindings.GetClient(ctx) if err != nil { -- cgit v1.2.3-54-g00ecf From 5268314e5376c3da7a1123ee1954b466baf2d911 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 24 May 2022 13:18:56 +0200 Subject: podman image mount: print pretty table Make sure that `podman image mount` prints a pretty table unless there is only argument passed and without a custom format. Fixing a TODO item brought me to the specific code location and revealed the fart in the logic. Signed-off-by: Valentin Rothberg --- cmd/podman/images/mount.go | 15 +++++---------- pkg/domain/entities/images.go | 1 - pkg/domain/infra/abi/images.go | 4 ---- test/system/060-mount.bats | 8 ++++++-- 4 files changed, 11 insertions(+), 17 deletions(-) (limited to 'pkg') diff --git a/cmd/podman/images/mount.go b/cmd/podman/images/mount.go index d5ab3d274..532d96196 100644 --- a/cmd/podman/images/mount.go +++ b/cmd/podman/images/mount.go @@ -7,7 +7,6 @@ import ( "github.com/containers/common/pkg/report" "github.com/containers/podman/v4/cmd/podman/common" "github.com/containers/podman/v4/cmd/podman/registry" - "github.com/containers/podman/v4/cmd/podman/utils" "github.com/containers/podman/v4/pkg/domain/entities" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -71,16 +70,12 @@ func mount(cmd *cobra.Command, args []string) error { return err } - if len(args) > 0 || mountOpts.All { - var errs utils.OutputErrors - for _, r := range reports { - if r.Err == nil { - fmt.Println(r.Path) - continue - } - errs = append(errs, r.Err) + if len(args) == 1 && mountOpts.Format == "" && !mountOpts.All { + if len(reports) != 1 { + return fmt.Errorf("internal error: expected 1 report but got %d", len(reports)) } - return errs.PrintErrors() + fmt.Println(reports[0].Path) + return nil } switch { diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go index 7081c5d25..553be1157 100644 --- a/pkg/domain/entities/images.go +++ b/pkg/domain/entities/images.go @@ -398,7 +398,6 @@ type ImageUnmountOptions struct { // ImageMountReport describes the response from image mount type ImageMountReport struct { - Err error Id string // nolint Name string Repositories []string diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go index c3ec7dd8a..d469fa0ca 100644 --- a/pkg/domain/infra/abi/images.go +++ b/pkg/domain/infra/abi/images.go @@ -159,10 +159,6 @@ func (ir *ImageEngine) Mount(ctx context.Context, nameOrIDs []string, opts entit mountReports := []*entities.ImageMountReport{} listMountsOnly := !opts.All && len(nameOrIDs) == 0 for _, i := range images { - // TODO: the .Err fields are not used. This pre-dates the - // libimage migration but should be addressed at some point. - // A quick glimpse at cmd/podman/image/mount.go suggests that - // the errors needed to be handled there as well. var mountPoint string var err error if listMountsOnly { diff --git a/test/system/060-mount.bats b/test/system/060-mount.bats index 7addbd88e..2735d2afd 100644 --- a/test/system/060-mount.bats +++ b/test/system/060-mount.bats @@ -50,6 +50,10 @@ load helpers run_podman image mount $IMAGE mount_path="$output" + # Make sure that `mount -a` prints a table + run_podman image mount -a + is "$output" "$IMAGE .*$mount_path" + test -d $mount_path # Image is custom-built and has a file containing the YMD tag. Check it. @@ -62,8 +66,8 @@ load helpers run_podman image mount is "$output" "$IMAGE *$mount_path" "podman image mount with no args" - # Clean up - run_podman image umount $IMAGE + # Clean up: -f since we mounted it twice + run_podman image umount -f $IMAGE is "$output" "$iid" "podman image umount: image ID of what was umounted" run_podman image umount $IMAGE -- cgit v1.2.3-54-g00ecf From 90a6f39d0f107059571ad9e640476dc1f3901f8c Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 24 May 2022 13:52:39 +0200 Subject: pkg/inspect: remove unused ImageResult type [NO NEW TESTS NEEDED] Signed-off-by: Valentin Rothberg --- pkg/inspect/inspect.go | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'pkg') diff --git a/pkg/inspect/inspect.go b/pkg/inspect/inspect.go index 767d86daf..15943858f 100644 --- a/pkg/inspect/inspect.go +++ b/pkg/inspect/inspect.go @@ -41,18 +41,3 @@ type RootFS struct { Type string `json:"Type"` Layers []digest.Digest `json:"Layers"` } - -// ImageResult is used for podman images for collection and output. -type ImageResult struct { - Tag string - Repository string - RepoDigests []string - RepoTags []string - ID string - Digest digest.Digest - ConfigDigest digest.Digest - Created time.Time - Size *uint64 - Labels map[string]string - Dangling bool -} -- cgit v1.2.3-54-g00ecf From fbeef1d70065913625f70e19283f9ba7c21ec249 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 24 May 2022 13:53:54 +0200 Subject: image list: remove unused ConfigDigest Remove the `ConfigDigest` field from `entities.ImageSummary` which has never been populated (or documented) until now. Unless there is a specific request or need to support it, remove the TODO that was added during the libimage migration. Signed-off-by: Valentin Rothberg --- pkg/domain/entities/images.go | 1 - pkg/domain/infra/abi/images_list.go | 2 -- 2 files changed, 3 deletions(-) (limited to 'pkg') diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go index 553be1157..28ffcfbdf 100644 --- a/pkg/domain/entities/images.go +++ b/pkg/domain/entities/images.go @@ -68,7 +68,6 @@ type ImageSummary struct { // Podman extensions Names []string `json:",omitempty"` Digest string `json:",omitempty"` - ConfigDigest string `json:",omitempty"` History []string `json:",omitempty"` } diff --git a/pkg/domain/infra/abi/images_list.go b/pkg/domain/infra/abi/images_list.go index 9a0aaaf3a..25cddc503 100644 --- a/pkg/domain/infra/abi/images_list.go +++ b/pkg/domain/infra/abi/images_list.go @@ -37,8 +37,6 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) e := entities.ImageSummary{ ID: img.ID(), - // TODO: libpod/image didn't set it but libimage should - // ConfigDigest: string(img.ConfigDigest), Created: img.Created().Unix(), Dangling: isDangling, Digest: string(img.Digest()), -- cgit v1.2.3-54-g00ecf From 956e2e1b842b5e753a5a2476465deb3ab25ca370 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 24 May 2022 13:56:58 +0200 Subject: pkg/domain/infra/abi/images_test.go: remove commented code Signed-off-by: Valentin Rothberg --- pkg/domain/infra/abi/images_test.go | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'pkg') diff --git a/pkg/domain/infra/abi/images_test.go b/pkg/domain/infra/abi/images_test.go index 311ab3ed7..3999de457 100644 --- a/pkg/domain/infra/abi/images_test.go +++ b/pkg/domain/infra/abi/images_test.go @@ -16,39 +16,3 @@ func TestToDomainHistoryLayer(t *testing.T) { newLayer := toDomainHistoryLayer(&layer) assert.Equal(t, layer.Size, newLayer.Size) } - -// -// import ( -// "context" -// "testing" -// -// "github.com/stretchr/testify/mock" -// ) -// -// type MockImageRuntime struct { -// mock.Mock -// } -// -// func (m *MockImageRuntime) Delete(ctx context.Context, renderer func() interface{}, name string) error { -// _ = m.Called(ctx, renderer, name) -// return nil -// } -// -// func TestImageSuccess(t *testing.T) { -// actual := func() interface{} { return nil } -// -// m := new(MockImageRuntime) -// m.On( -// "Delete", -// mock.AnythingOfType("*context.emptyCtx"), -// mock.AnythingOfType("func() interface {}"), -// "fedora"). -// Return(nil) -// -// r := DirectImageRuntime{m} -// err := r.Delete(context.TODO(), actual, "fedora") -// if err != nil { -// t.Errorf("should be nil, got: %v", err) -// } -// m.AssertExpectations(t) -// } -- cgit v1.2.3-54-g00ecf From 2400d1d52ff4199778781446445eef39a6e2c6b9 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 24 May 2022 14:24:37 +0200 Subject: go format previosly touched files Signed-off-by: Valentin Rothberg --- pkg/domain/entities/images.go | 6 +++--- pkg/domain/infra/abi/images_list.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'pkg') diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go index 28ffcfbdf..2bb4ceb5b 100644 --- a/pkg/domain/entities/images.go +++ b/pkg/domain/entities/images.go @@ -66,9 +66,9 @@ type ImageSummary struct { Dangling bool `json:",omitempty"` // Podman extensions - Names []string `json:",omitempty"` - Digest string `json:",omitempty"` - History []string `json:",omitempty"` + Names []string `json:",omitempty"` + Digest string `json:",omitempty"` + History []string `json:",omitempty"` } func (i *ImageSummary) Id() string { // nolint diff --git a/pkg/domain/infra/abi/images_list.go b/pkg/domain/infra/abi/images_list.go index 25cddc503..8f5591e92 100644 --- a/pkg/domain/infra/abi/images_list.go +++ b/pkg/domain/infra/abi/images_list.go @@ -36,7 +36,7 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) } e := entities.ImageSummary{ - ID: img.ID(), + ID: img.ID(), Created: img.Created().Unix(), Dangling: isDangling, Digest: string(img.Digest()), -- cgit v1.2.3-54-g00ecf