mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 09:17:49 +08:00

also needs to update docker/docker to a60b458 (22.06 branch) otherwise build breaks since docker/cli#3512 with: # github.com/docker/cli/cli/flags vendor/github.com/docker/cli/cli/flags/common.go:40:37: undefined: client.EnvOverrideCertPath vendor/github.com/docker/cli/cli/flags/common.go:41:37: undefined: client.EnvTLSVerify vendor/github.com/docker/cli/cli/flags/common.go:89:76: undefined: client.EnvOverrideHost needs also to update github.com/spf13/cobra to v1.5.0 otherwise build breaks with: # github.com/docker/cli/cli-plugins/plugin vendor/github.com/docker/cli/cli-plugins/plugin/plugin.go:130:4: unknown field 'HiddenDefaultCmd' in struct literal of type cobra.CompletionOptions Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package client // import "github.com/docker/docker/client"
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"encoding/json"
|
|
"io"
|
|
"net/url"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
)
|
|
|
|
// NetworkInspect returns the information for a specific network configured in the docker host.
|
|
func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) {
|
|
networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID, options)
|
|
return networkResource, err
|
|
}
|
|
|
|
// NetworkInspectWithRaw returns the information for a specific network configured in the docker host and its raw representation.
|
|
func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) {
|
|
if networkID == "" {
|
|
return types.NetworkResource{}, nil, objectNotFoundError{object: "network", id: networkID}
|
|
}
|
|
var (
|
|
networkResource types.NetworkResource
|
|
resp serverResponse
|
|
err error
|
|
)
|
|
query := url.Values{}
|
|
if options.Verbose {
|
|
query.Set("verbose", "true")
|
|
}
|
|
if options.Scope != "" {
|
|
query.Set("scope", options.Scope)
|
|
}
|
|
resp, err = cli.get(ctx, "/networks/"+networkID, query, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return networkResource, nil, err
|
|
}
|
|
|
|
body, err := io.ReadAll(resp.body)
|
|
if err != nil {
|
|
return networkResource, nil, err
|
|
}
|
|
rdr := bytes.NewReader(body)
|
|
err = json.NewDecoder(rdr).Decode(&networkResource)
|
|
return networkResource, body, err
|
|
}
|