config: fix docker Go API deprecation
Signed-off-by: Matthew Penner <me@matthewp.io>
This commit is contained in:
parent
3e804b81fe
commit
eadbe920fe
|
@ -4,8 +4,8 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/goccy/go-json"
|
"github.com/goccy/go-json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ type RegistryConfiguration struct {
|
||||||
// Base64 returns the authentication for a given registry as a base64 encoded
|
// Base64 returns the authentication for a given registry as a base64 encoded
|
||||||
// string value.
|
// string value.
|
||||||
func (c RegistryConfiguration) Base64() (string, error) {
|
func (c RegistryConfiguration) Base64() (string, error) {
|
||||||
b, err := json.Marshal(types.AuthConfig{
|
b, err := json.Marshal(registry.AuthConfig{
|
||||||
Username: c.Username,
|
Username: c.Username,
|
||||||
Password: c.Password,
|
Password: c.Password,
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/acobaugh/osrelease"
|
"github.com/acobaugh/osrelease"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/system"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/docker/docker/pkg/parsers/kernel"
|
"github.com/docker/docker/pkg/parsers/kernel"
|
||||||
)
|
)
|
||||||
|
@ -121,22 +122,22 @@ func GetSystemInformation() (*Information, error) {
|
||||||
}, nil
|
}, 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.
|
// TODO: find a way to re-use the client from the docker environment.
|
||||||
c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.Version{}, types.Info{}, err
|
return types.Version{}, system.Info{}, err
|
||||||
}
|
}
|
||||||
defer c.Close()
|
defer c.Close()
|
||||||
|
|
||||||
dockerVersion, err := c.ServerVersion(ctx)
|
dockerVersion, err := c.ServerVersion(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.Version{}, types.Info{}, err
|
return types.Version{}, system.Info{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dockerInfo, err := c.Info(ctx)
|
dockerInfo, err := c.Info(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.Version{}, types.Info{}, err
|
return types.Version{}, system.Info{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dockerVersion, dockerInfo, nil
|
return dockerVersion, dockerInfo, nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user