From eadbe920fe0e644314245ebec6fb7b34414f85e8 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Tue, 12 Mar 2024 21:42:58 -0600 Subject: [PATCH] config: fix docker Go API deprecation Signed-off-by: Matthew Penner --- config/config_docker.go | 4 ++-- system/system.go | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/config_docker.go b/config/config_docker.go index dafe6bf..74bfdaf 100644 --- a/config/config_docker.go +++ b/config/config_docker.go @@ -4,8 +4,8 @@ import ( "encoding/base64" "sort" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/registry" "github.com/goccy/go-json" ) @@ -115,7 +115,7 @@ type RegistryConfiguration struct { // Base64 returns the authentication for a given registry as a base64 encoded // string value. func (c RegistryConfiguration) Base64() (string, error) { - b, err := json.Marshal(types.AuthConfig{ + b, err := json.Marshal(registry.AuthConfig{ Username: c.Username, Password: c.Password, }) diff --git a/system/system.go b/system/system.go index 0d3f3cd..d268a35 100644 --- a/system/system.go +++ b/system/system.go @@ -6,6 +6,7 @@ import ( "github.com/acobaugh/osrelease" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/client" "github.com/docker/docker/pkg/parsers/kernel" ) @@ -121,22 +122,22 @@ func GetSystemInformation() (*Information, error) { }, nil } -func GetDockerInfo(ctx context.Context) (types.Version, types.Info, error) { +func GetDockerInfo(ctx context.Context) (types.Version, system.Info, error) { // TODO: find a way to re-use the client from the docker environment. c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) if err != nil { - return types.Version{}, types.Info{}, err + return types.Version{}, system.Info{}, err } defer c.Close() dockerVersion, err := c.ServerVersion(ctx) if err != nil { - return types.Version{}, types.Info{}, err + return types.Version{}, system.Info{}, err } dockerInfo, err := c.Info(ctx) if err != nil { - return types.Version{}, types.Info{}, err + return types.Version{}, system.Info{}, err } return dockerVersion, dockerInfo, nil