detached de0c4ec

refactor: Update Docker API types and method signatures

- Replace deprecated `types.EventsOptions` with `events.ListOptions` in container event listening
- Update `ImageLoad` method to use `client.ImageLoadWithQuiet` option for image loading
- Improve type consistency with Docker client API imports
commit
de0c4ec493b2c6716071d45236a69b0da7be245d
author
bamen · · 2025-03-10 13:46 UTC
parent
c525bd7
signature
unsigned
2 files · +4 -2
M pkg/docker/containers.go +2 -1
@@ -11,6 +11,7 @@ import (
1111 "github.com/charmbracelet/log"
1212 "github.com/docker/docker/api/types"
1313 "github.com/docker/docker/api/types/container"
14+ "github.com/docker/docker/api/types/events"
1415 "github.com/docker/docker/api/types/filters"
1516 "github.com/docker/docker/api/types/network"
1617 "github.com/docker/docker/client"
@@ -768,7 +769,7 @@ func ListenForContainerEvents(networkFilter string, callback func(string, string
768769 filters := makeEventFilters(networkFilter)
769770
770771 // Start listening for events
771- messages, errs := dockerCli.Events(ctx, types.EventsOptions{
772+ messages, errs := dockerCli.Events(ctx, events.ListOptions{
772773 Filters: filters,
773774 })
774775
@@ -11,6 +11,7 @@ import (
11 "github.com/charmbracelet/log"11 "github.com/charmbracelet/log"
12 "github.com/docker/docker/api/types"12 "github.com/docker/docker/api/types"
13 "github.com/docker/docker/api/types/container"13 "github.com/docker/docker/api/types/container"
14+ "github.com/docker/docker/api/types/events"
14 "github.com/docker/docker/api/types/filters"15 "github.com/docker/docker/api/types/filters"
15 "github.com/docker/docker/api/types/network"16 "github.com/docker/docker/api/types/network"
16 "github.com/docker/docker/client"17 "github.com/docker/docker/client"
@@ -768,7 +769,7 @@ func ListenForContainerEvents(networkFilter string, callback func(string, string
768 filters := makeEventFilters(networkFilter)769 filters := makeEventFilters(networkFilter)
769 770
770 // Start listening for events771 // Start listening for events
771- messages, errs := dockerCli.Events(ctx, types.EventsOptions{772+ messages, errs := dockerCli.Events(ctx, events.ListOptions{
772 Filters: filters,773 Filters: filters,
773 })774 })
774 775
M pkg/docker/images.go +2 -1
@@ -14,6 +14,7 @@ import (
1414 "github.com/charmbracelet/log"
1515 "github.com/docker/docker/api/types"
1616 "github.com/docker/docker/api/types/image"
17+ "github.com/docker/docker/client"
1718 )
1819
1920 func ListContainerImages() ([]image.Summary, error) {
@@ -153,7 +154,7 @@ func ImportImageToEngine(imageFilePath string) (string, error) {
153154 return "", fmt.Errorf("failed to reset file pointer: %w", err)
154155 }
155156
156- resp, err := dockerCli.ImageLoad(context.Background(), imageFile, true)
157+ resp, err := dockerCli.ImageLoad(context.Background(), imageFile, client.ImageLoadWithQuiet(true))
157158 if err != nil {
158159 return "", fmt.Errorf("failed to load image: %w", err)
159160 }
@@ -14,6 +14,7 @@ import (
14 "github.com/charmbracelet/log"14 "github.com/charmbracelet/log"
15 "github.com/docker/docker/api/types"15 "github.com/docker/docker/api/types"
16 "github.com/docker/docker/api/types/image"16 "github.com/docker/docker/api/types/image"
17+ "github.com/docker/docker/client"
17 )18 )
18 19
19 func ListContainerImages() ([]image.Summary, error) {20 func ListContainerImages() ([]image.Summary, error) {
@@ -153,7 +154,7 @@ func ImportImageToEngine(imageFilePath string) (string, error) {
153 return "", fmt.Errorf("failed to reset file pointer: %w", err)154 return "", fmt.Errorf("failed to reset file pointer: %w", err)
154 }155 }
155 156
156- resp, err := dockerCli.ImageLoad(context.Background(), imageFile, true)157+ resp, err := dockerCli.ImageLoad(context.Background(), imageFile, client.ImageLoadWithQuiet(true))
157 if err != nil {158 if err != nil {
158 return "", fmt.Errorf("failed to load image: %w", err)159 return "", fmt.Errorf("failed to load image: %w", err)
159 }160 }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close