repo
stringlengths
6
47
file_url
stringlengths
77
269
file_path
stringlengths
5
186
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-07 08:35:43
2026-01-07 08:55:24
truncated
bool
2 classes
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/config_create.go
vendor/github.com/docker/docker/client/config_create.go
package client import ( "context" "encoding/json" "github.com/docker/docker/api/types/swarm" ) // ConfigCreate creates a new config. func (cli *Client) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (swarm.ConfigCreateResponse, error) { var response swarm.ConfigCreateResponse if err := cli.NewVersionError(ctx, "1.30", "config create"); err != nil { return response, err } resp, err := cli.post(ctx, "/configs/create", nil, config, nil) defer ensureReaderClosed(resp) if err != nil { return response, err } err = json.NewDecoder(resp.Body).Decode(&response) return response, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/volume_inspect.go
vendor/github.com/docker/docker/client/volume_inspect.go
package client import ( "bytes" "context" "encoding/json" "io" "github.com/docker/docker/api/types/volume" ) // VolumeInspect returns the information about a specific volume in the docker host. func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) { vol, _, err := cli.VolumeInspectWithRaw(ctx, volumeID) return vol, err } // VolumeInspectWithRaw returns the information about a specific volume in the docker host and its raw representation func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error) { volumeID, err := trimID("volume", volumeID) if err != nil { return volume.Volume{}, nil, err } resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil) defer ensureReaderClosed(resp) if err != nil { return volume.Volume{}, nil, err } body, err := io.ReadAll(resp.Body) if err != nil { return volume.Volume{}, nil, err } var vol volume.Volume rdr := bytes.NewReader(body) err = json.NewDecoder(rdr).Decode(&vol) return vol, body, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/plugin_upgrade.go
vendor/github.com/docker/docker/client/plugin_upgrade.go
package client import ( "context" "io" "net/http" "net/url" "github.com/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/registry" "github.com/pkg/errors" ) // PluginUpgrade upgrades a plugin func (cli *Client) PluginUpgrade(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error) { name, err := trimID("plugin", name) if err != nil { return nil, err } if err := cli.NewVersionError(ctx, "1.26", "plugin upgrade"); err != nil { return nil, err } query := url.Values{} if _, err := reference.ParseNormalizedNamed(options.RemoteRef); err != nil { return nil, errors.Wrap(err, "invalid remote reference") } query.Set("remote", options.RemoteRef) privileges, err := cli.checkPluginPermissions(ctx, query, options) if err != nil { return nil, err } resp, err := cli.tryPluginUpgrade(ctx, query, privileges, name, options.RegistryAuth) if err != nil { return nil, err } return resp.Body, nil } func (cli *Client) tryPluginUpgrade(ctx context.Context, query url.Values, privileges types.PluginPrivileges, name, registryAuth string) (*http.Response, error) { return cli.post(ctx, "/plugins/"+name+"/upgrade", query, privileges, http.Header{ registry.AuthHeader: {registryAuth}, }) }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/swarm_get_unlock_key.go
vendor/github.com/docker/docker/client/swarm_get_unlock_key.go
package client import ( "context" "encoding/json" "github.com/docker/docker/api/types/swarm" ) // SwarmGetUnlockKey retrieves the swarm's unlock key. func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error) { resp, err := cli.get(ctx, "/swarm/unlockkey", nil, nil) defer ensureReaderClosed(resp) if err != nil { return swarm.UnlockKeyResponse{}, err } var response swarm.UnlockKeyResponse err = json.NewDecoder(resp.Body).Decode(&response) return response, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/network_disconnect.go
vendor/github.com/docker/docker/client/network_disconnect.go
package client import ( "context" "github.com/docker/docker/api/types/network" ) // NetworkDisconnect disconnects a container from an existent network in the docker host. func (cli *Client) NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error { networkID, err := trimID("network", networkID) if err != nil { return err } containerID, err = trimID("container", containerID) if err != nil { return err } nd := network.DisconnectOptions{ Container: containerID, Force: force, } resp, err := cli.post(ctx, "/networks/"+networkID+"/disconnect", nil, nd, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_load_opts.go
vendor/github.com/docker/docker/client/image_load_opts.go
package client import ( "fmt" "github.com/docker/docker/api/types/image" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) // ImageLoadOption is a type representing functional options for the image load operation. type ImageLoadOption interface { Apply(*imageLoadOpts) error } type imageLoadOptionFunc func(opt *imageLoadOpts) error func (f imageLoadOptionFunc) Apply(o *imageLoadOpts) error { return f(o) } type imageLoadOpts struct { apiOptions image.LoadOptions } // ImageLoadWithQuiet sets the quiet option for the image load operation. func ImageLoadWithQuiet(quiet bool) ImageLoadOption { return imageLoadOptionFunc(func(opt *imageLoadOpts) error { opt.apiOptions.Quiet = quiet return nil }) } // ImageLoadWithPlatforms sets the platforms to be loaded from the image. func ImageLoadWithPlatforms(platforms ...ocispec.Platform) ImageLoadOption { return imageLoadOptionFunc(func(opt *imageLoadOpts) error { if opt.apiOptions.Platforms != nil { return fmt.Errorf("platforms already set to %v", opt.apiOptions.Platforms) } opt.apiOptions.Platforms = platforms return nil }) }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/build_prune.go
vendor/github.com/docker/docker/client/build_prune.go
package client import ( "context" "encoding/json" "net/url" "strconv" "github.com/docker/docker/api/types/build" "github.com/docker/docker/api/types/filters" "github.com/pkg/errors" ) // BuildCachePrune requests the daemon to delete unused cache data func (cli *Client) BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error) { if err := cli.NewVersionError(ctx, "1.31", "build prune"); err != nil { return nil, err } query := url.Values{} if opts.All { query.Set("all", "1") } if opts.KeepStorage != 0 { query.Set("keep-storage", strconv.Itoa(int(opts.KeepStorage))) } if opts.ReservedSpace != 0 { query.Set("reserved-space", strconv.Itoa(int(opts.ReservedSpace))) } if opts.MaxUsedSpace != 0 { query.Set("max-used-space", strconv.Itoa(int(opts.MaxUsedSpace))) } if opts.MinFreeSpace != 0 { query.Set("min-free-space", strconv.Itoa(int(opts.MinFreeSpace))) } f, err := filters.ToJSON(opts.Filters) if err != nil { return nil, errors.Wrap(err, "prune could not marshal filters option") } query.Set("filters", f) resp, err := cli.post(ctx, "/build/prune", query, nil, nil) defer ensureReaderClosed(resp) if err != nil { return nil, err } report := build.CachePruneReport{} if err := json.NewDecoder(resp.Body).Decode(&report); err != nil { return nil, errors.Wrap(err, "error retrieving disk usage") } return &report, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_inspect.go
vendor/github.com/docker/docker/client/image_inspect.go
package client import ( "bytes" "context" "encoding/json" "fmt" "io" "net/url" "github.com/docker/docker/api/types/image" ) // ImageInspect returns the image information. func (cli *Client) ImageInspect(ctx context.Context, imageID string, inspectOpts ...ImageInspectOption) (image.InspectResponse, error) { if imageID == "" { return image.InspectResponse{}, objectNotFoundError{object: "image", id: imageID} } var opts imageInspectOpts for _, opt := range inspectOpts { if err := opt.Apply(&opts); err != nil { return image.InspectResponse{}, fmt.Errorf("error applying image inspect option: %w", err) } } query := url.Values{} if opts.apiOptions.Manifests { if err := cli.NewVersionError(ctx, "1.48", "manifests"); err != nil { return image.InspectResponse{}, err } query.Set("manifests", "1") } if opts.apiOptions.Platform != nil { if err := cli.NewVersionError(ctx, "1.49", "platform"); err != nil { return image.InspectResponse{}, err } platform, err := encodePlatform(opts.apiOptions.Platform) if err != nil { return image.InspectResponse{}, err } query.Set("platform", platform) } resp, err := cli.get(ctx, "/images/"+imageID+"/json", query, nil) defer ensureReaderClosed(resp) if err != nil { return image.InspectResponse{}, err } buf := opts.raw if buf == nil { buf = &bytes.Buffer{} } if _, err := io.Copy(buf, resp.Body); err != nil { return image.InspectResponse{}, err } var response image.InspectResponse err = json.Unmarshal(buf.Bytes(), &response) return response, err } // ImageInspectWithRaw returns the image information and its raw representation. // // Deprecated: Use [Client.ImageInspect] instead. Raw response can be obtained using the [ImageInspectWithRawResponse] option. func (cli *Client) ImageInspectWithRaw(ctx context.Context, imageID string) (image.InspectResponse, []byte, error) { var buf bytes.Buffer resp, err := cli.ImageInspect(ctx, imageID, ImageInspectWithRawResponse(&buf)) if err != nil { return image.InspectResponse{}, nil, err } return resp, buf.Bytes(), err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/secret_update.go
vendor/github.com/docker/docker/client/secret_update.go
package client import ( "context" "net/url" "github.com/docker/docker/api/types/swarm" ) // SecretUpdate attempts to update a secret. func (cli *Client) SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error { id, err := trimID("secret", id) if err != nil { return err } if err := cli.NewVersionError(ctx, "1.25", "secret update"); err != nil { return err } query := url.Values{} query.Set("version", version.String()) resp, err := cli.post(ctx, "/secrets/"+id+"/update", query, secret, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_inspect_opts.go
vendor/github.com/docker/docker/client/image_inspect_opts.go
package client import ( "bytes" "github.com/docker/docker/api/types/image" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) // ImageInspectOption is a type representing functional options for the image inspect operation. type ImageInspectOption interface { Apply(*imageInspectOpts) error } type imageInspectOptionFunc func(opt *imageInspectOpts) error func (f imageInspectOptionFunc) Apply(o *imageInspectOpts) error { return f(o) } // ImageInspectWithRawResponse instructs the client to additionally store the // raw inspect response in the provided buffer. func ImageInspectWithRawResponse(raw *bytes.Buffer) ImageInspectOption { return imageInspectOptionFunc(func(opts *imageInspectOpts) error { opts.raw = raw return nil }) } // ImageInspectWithManifests sets manifests API option for the image inspect operation. // This option is only available for API version 1.48 and up. // With this option set, the image inspect operation response will have the // [image.InspectResponse.Manifests] field populated if the server is multi-platform capable. func ImageInspectWithManifests(manifests bool) ImageInspectOption { return imageInspectOptionFunc(func(clientOpts *imageInspectOpts) error { clientOpts.apiOptions.Manifests = manifests return nil }) } // ImageInspectWithPlatform sets platform API option for the image inspect operation. // This option is only available for API version 1.49 and up. // With this option set, the image inspect operation will return information for the // specified platform variant of the multi-platform image. func ImageInspectWithPlatform(platform *ocispec.Platform) ImageInspectOption { return imageInspectOptionFunc(func(clientOpts *imageInspectOpts) error { clientOpts.apiOptions.Platform = platform return nil }) } // ImageInspectWithAPIOpts sets the API options for the image inspect operation. func ImageInspectWithAPIOpts(opts image.InspectOptions) ImageInspectOption { return imageInspectOptionFunc(func(clientOpts *imageInspectOpts) error { clientOpts.apiOptions = opts return nil }) } type imageInspectOpts struct { raw *bytes.Buffer apiOptions image.InspectOptions }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/client_interfaces.go
vendor/github.com/docker/docker/client/client_interfaces.go
package client import ( "context" "io" "net" "net/http" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/build" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/system" "github.com/docker/docker/api/types/volume" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) // CommonAPIClient is the common methods between stable and experimental versions of APIClient. // // Deprecated: use [APIClient] instead. This type will be an alias for [APIClient] in the next release, and removed after. type CommonAPIClient = stableAPIClient // APIClient is an interface that clients that talk with a docker server must implement. type APIClient interface { stableAPIClient CheckpointAPIClient // CheckpointAPIClient is still experimental. } type stableAPIClient interface { ConfigAPIClient ContainerAPIClient DistributionAPIClient ImageAPIClient NetworkAPIClient PluginAPIClient SystemAPIClient VolumeAPIClient ClientVersion() string DaemonHost() string HTTPClient() *http.Client ServerVersion(ctx context.Context) (types.Version, error) NegotiateAPIVersion(ctx context.Context) NegotiateAPIVersionPing(types.Ping) HijackDialer Dialer() func(context.Context) (net.Conn, error) Close() error SwarmManagementAPIClient } // SwarmManagementAPIClient defines all methods for managing Swarm-specific // objects. type SwarmManagementAPIClient interface { SwarmAPIClient NodeAPIClient ServiceAPIClient SecretAPIClient ConfigAPIClient } // HijackDialer defines methods for a hijack dialer. type HijackDialer interface { DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error) } // ContainerAPIClient defines API client methods for the containers type ContainerAPIClient interface { ContainerAttach(ctx context.Context, container string, options container.AttachOptions) (types.HijackedResponse, error) ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (container.CommitResponse, error) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) ContainerDiff(ctx context.Context, container string) ([]container.FilesystemChange, error) ContainerExecAttach(ctx context.Context, execID string, options container.ExecAttachOptions) (types.HijackedResponse, error) ContainerExecCreate(ctx context.Context, container string, options container.ExecOptions) (container.ExecCreateResponse, error) ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error) ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error ContainerExecStart(ctx context.Context, execID string, options container.ExecStartOptions) error ContainerExport(ctx context.Context, container string) (io.ReadCloser, error) ContainerInspect(ctx context.Context, container string) (container.InspectResponse, error) ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (container.InspectResponse, []byte, error) ContainerKill(ctx context.Context, container, signal string) error ContainerList(ctx context.Context, options container.ListOptions) ([]container.Summary, error) ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error) ContainerPause(ctx context.Context, container string) error ContainerRemove(ctx context.Context, container string, options container.RemoveOptions) error ContainerRename(ctx context.Context, container, newContainerName string) error ContainerResize(ctx context.Context, container string, options container.ResizeOptions) error ContainerRestart(ctx context.Context, container string, options container.StopOptions) error ContainerStatPath(ctx context.Context, container, path string) (container.PathStat, error) ContainerStats(ctx context.Context, container string, stream bool) (container.StatsResponseReader, error) ContainerStatsOneShot(ctx context.Context, container string) (container.StatsResponseReader, error) ContainerStart(ctx context.Context, container string, options container.StartOptions) error ContainerStop(ctx context.Context, container string, options container.StopOptions) error ContainerTop(ctx context.Context, container string, arguments []string) (container.TopResponse, error) ContainerUnpause(ctx context.Context, container string) error ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.UpdateResponse, error) ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, container.PathStat, error) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options container.CopyToContainerOptions) error ContainersPrune(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error) } // DistributionAPIClient defines API client methods for the registry type DistributionAPIClient interface { DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error) } // ImageAPIClient defines API client methods for the images type ImageAPIClient interface { ImageBuild(ctx context.Context, context io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error) BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error) BuildCancel(ctx context.Context, id string) error ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error) ImageImport(ctx context.Context, source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error) ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error) ImagePush(ctx context.Context, ref string, options image.PushOptions) (io.ReadCloser, error) ImageRemove(ctx context.Context, image string, options image.RemoveOptions) ([]image.DeleteResponse, error) ImageSearch(ctx context.Context, term string, options registry.SearchOptions) ([]registry.SearchResult, error) ImageTag(ctx context.Context, image, ref string) error ImagesPrune(ctx context.Context, pruneFilter filters.Args) (image.PruneReport, error) ImageInspect(ctx context.Context, image string, _ ...ImageInspectOption) (image.InspectResponse, error) ImageHistory(ctx context.Context, image string, _ ...ImageHistoryOption) ([]image.HistoryResponseItem, error) ImageLoad(ctx context.Context, input io.Reader, _ ...ImageLoadOption) (image.LoadResponse, error) ImageSave(ctx context.Context, images []string, _ ...ImageSaveOption) (io.ReadCloser, error) ImageAPIClientDeprecated } // ImageAPIClientDeprecated defines deprecated methods of the ImageAPIClient. type ImageAPIClientDeprecated interface { // ImageInspectWithRaw returns the image information and its raw representation. // // Deprecated: Use [Client.ImageInspect] instead. Raw response can be obtained using the [ImageInspectWithRawResponse] option. ImageInspectWithRaw(ctx context.Context, image string) (image.InspectResponse, []byte, error) } // NetworkAPIClient defines API client methods for the networks type NetworkAPIClient interface { NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) NetworkDisconnect(ctx context.Context, network, container string, force bool) error NetworkInspect(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, error) NetworkInspectWithRaw(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, []byte, error) NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error) NetworkRemove(ctx context.Context, network string) error NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error) } // NodeAPIClient defines API client methods for the nodes type NodeAPIClient interface { NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error) NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) NodeRemove(ctx context.Context, nodeID string, options swarm.NodeRemoveOptions) error NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error } // PluginAPIClient defines API client methods for the plugins type PluginAPIClient interface { PluginList(ctx context.Context, filter filters.Args) (types.PluginsListResponse, error) PluginRemove(ctx context.Context, name string, options types.PluginRemoveOptions) error PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error PluginDisable(ctx context.Context, name string, options types.PluginDisableOptions) error PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error) PluginUpgrade(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error) PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error) PluginSet(ctx context.Context, name string, args []string) error PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) PluginCreate(ctx context.Context, createContext io.Reader, options types.PluginCreateOptions) error } // ServiceAPIClient defines API client methods for the services type ServiceAPIClient interface { ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options swarm.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) ServiceInspectWithRaw(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) ServiceList(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) ServiceRemove(ctx context.Context, serviceID string) error ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error) TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) } // SwarmAPIClient defines API client methods for the swarm type SwarmAPIClient interface { SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error SwarmLeave(ctx context.Context, force bool) error SwarmInspect(ctx context.Context) (swarm.Swarm, error) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error } // SystemAPIClient defines API client methods for the system type SystemAPIClient interface { Events(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error) Info(ctx context.Context) (system.Info, error) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) Ping(ctx context.Context) (types.Ping, error) } // VolumeAPIClient defines API client methods for the volumes type VolumeAPIClient interface { VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error) VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error) VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) VolumeRemove(ctx context.Context, volumeID string, force bool) error VolumesPrune(ctx context.Context, pruneFilter filters.Args) (volume.PruneReport, error) VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error } // SecretAPIClient defines API client methods for secrets type SecretAPIClient interface { SecretList(ctx context.Context, options swarm.SecretListOptions) ([]swarm.Secret, error) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (swarm.SecretCreateResponse, error) SecretRemove(ctx context.Context, id string) error SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error) SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error } // ConfigAPIClient defines API client methods for configs type ConfigAPIClient interface { ConfigList(ctx context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (swarm.ConfigCreateResponse, error) ConfigRemove(ctx context.Context, id string) error ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error) ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_resize.go
vendor/github.com/docker/docker/client/container_resize.go
package client import ( "context" "net/url" "strconv" "github.com/docker/docker/api/types/container" ) // ContainerResize changes the size of the tty for a container. func (cli *Client) ContainerResize(ctx context.Context, containerID string, options container.ResizeOptions) error { containerID, err := trimID("container", containerID) if err != nil { return err } return cli.resize(ctx, "/containers/"+containerID, options.Height, options.Width) } // ContainerExecResize changes the size of the tty for an exec process running inside a container. func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error { execID, err := trimID("exec", execID) if err != nil { return err } return cli.resize(ctx, "/exec/"+execID, options.Height, options.Width) } func (cli *Client) resize(ctx context.Context, basePath string, height, width uint) error { // FIXME(thaJeztah): the API / backend accepts uint32, but container.ResizeOptions uses uint. query := url.Values{} query.Set("h", strconv.FormatUint(uint64(height), 10)) query.Set("w", strconv.FormatUint(uint64(width), 10)) resp, err := cli.post(ctx, basePath+"/resize", query, nil, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_history.go
vendor/github.com/docker/docker/client/image_history.go
package client import ( "context" "encoding/json" "fmt" "net/url" "github.com/docker/docker/api/types/image" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) // ImageHistoryWithPlatform sets the platform for the image history operation. func ImageHistoryWithPlatform(platform ocispec.Platform) ImageHistoryOption { return imageHistoryOptionFunc(func(opt *imageHistoryOpts) error { if opt.apiOptions.Platform != nil { return fmt.Errorf("platform already set to %s", *opt.apiOptions.Platform) } opt.apiOptions.Platform = &platform return nil }) } // ImageHistory returns the changes in an image in history format. func (cli *Client) ImageHistory(ctx context.Context, imageID string, historyOpts ...ImageHistoryOption) ([]image.HistoryResponseItem, error) { query := url.Values{} var opts imageHistoryOpts for _, o := range historyOpts { if err := o.Apply(&opts); err != nil { return nil, err } } if opts.apiOptions.Platform != nil { if err := cli.NewVersionError(ctx, "1.48", "platform"); err != nil { return nil, err } p, err := encodePlatform(opts.apiOptions.Platform) if err != nil { return nil, err } query.Set("platform", p) } resp, err := cli.get(ctx, "/images/"+imageID+"/history", query, nil) defer ensureReaderClosed(resp) if err != nil { return nil, err } var history []image.HistoryResponseItem err = json.NewDecoder(resp.Body).Decode(&history) return history, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/task_inspect.go
vendor/github.com/docker/docker/client/task_inspect.go
package client import ( "bytes" "context" "encoding/json" "io" "github.com/docker/docker/api/types/swarm" ) // TaskInspectWithRaw returns the task information and its raw representation. func (cli *Client) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) { taskID, err := trimID("task", taskID) if err != nil { return swarm.Task{}, nil, err } resp, err := cli.get(ctx, "/tasks/"+taskID, nil, nil) defer ensureReaderClosed(resp) if err != nil { return swarm.Task{}, nil, err } body, err := io.ReadAll(resp.Body) if err != nil { return swarm.Task{}, nil, err } var response swarm.Task rdr := bytes.NewReader(body) err = json.NewDecoder(rdr).Decode(&response) return response, body, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_build.go
vendor/github.com/docker/docker/client/image_build.go
package client import ( "context" "encoding/base64" "encoding/json" "io" "net/http" "net/url" "strconv" "strings" "github.com/docker/docker/api/types/build" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" ) // ImageBuild sends a request to the daemon to build images. // The Body in the response implements an io.ReadCloser and it's up to the caller to // close it. func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error) { query, err := cli.imageBuildOptionsToQuery(ctx, options) if err != nil { return build.ImageBuildResponse{}, err } buf, err := json.Marshal(options.AuthConfigs) if err != nil { return build.ImageBuildResponse{}, err } headers := http.Header{} headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf)) headers.Set("Content-Type", "application/x-tar") resp, err := cli.postRaw(ctx, "/build", query, buildContext, headers) if err != nil { return build.ImageBuildResponse{}, err } return build.ImageBuildResponse{ Body: resp.Body, OSType: resp.Header.Get("Ostype"), }, nil } func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options build.ImageBuildOptions) (url.Values, error) { query := url.Values{} if len(options.Tags) > 0 { query["t"] = options.Tags } if len(options.SecurityOpt) > 0 { query["securityopt"] = options.SecurityOpt } if len(options.ExtraHosts) > 0 { query["extrahosts"] = options.ExtraHosts } if options.SuppressOutput { query.Set("q", "1") } if options.RemoteContext != "" { query.Set("remote", options.RemoteContext) } if options.NoCache { query.Set("nocache", "1") } if !options.Remove { // only send value when opting out because the daemon's default is // to remove intermediate containers after a successful build, // // TODO(thaJeztah): deprecate "Remove" option, and provide a "NoRemove" or "Keep" option instead. query.Set("rm", "0") } if options.ForceRemove { query.Set("forcerm", "1") } if options.PullParent { query.Set("pull", "1") } if options.Squash { if err := cli.NewVersionError(ctx, "1.25", "squash"); err != nil { return query, err } query.Set("squash", "1") } if !container.Isolation.IsDefault(options.Isolation) { query.Set("isolation", string(options.Isolation)) } if options.CPUSetCPUs != "" { query.Set("cpusetcpus", options.CPUSetCPUs) } if options.NetworkMode != "" && options.NetworkMode != network.NetworkDefault { query.Set("networkmode", options.NetworkMode) } if options.CPUSetMems != "" { query.Set("cpusetmems", options.CPUSetMems) } if options.CPUShares != 0 { query.Set("cpushares", strconv.FormatInt(options.CPUShares, 10)) } if options.CPUQuota != 0 { query.Set("cpuquota", strconv.FormatInt(options.CPUQuota, 10)) } if options.CPUPeriod != 0 { query.Set("cpuperiod", strconv.FormatInt(options.CPUPeriod, 10)) } if options.Memory != 0 { query.Set("memory", strconv.FormatInt(options.Memory, 10)) } if options.MemorySwap != 0 { query.Set("memswap", strconv.FormatInt(options.MemorySwap, 10)) } if options.CgroupParent != "" { query.Set("cgroupparent", options.CgroupParent) } if options.ShmSize != 0 { query.Set("shmsize", strconv.FormatInt(options.ShmSize, 10)) } if options.Dockerfile != "" { query.Set("dockerfile", options.Dockerfile) } if options.Target != "" { query.Set("target", options.Target) } if len(options.Ulimits) != 0 { ulimitsJSON, err := json.Marshal(options.Ulimits) if err != nil { return query, err } query.Set("ulimits", string(ulimitsJSON)) } if len(options.BuildArgs) != 0 { buildArgsJSON, err := json.Marshal(options.BuildArgs) if err != nil { return query, err } query.Set("buildargs", string(buildArgsJSON)) } if len(options.Labels) != 0 { labelsJSON, err := json.Marshal(options.Labels) if err != nil { return query, err } query.Set("labels", string(labelsJSON)) } if len(options.CacheFrom) != 0 { cacheFromJSON, err := json.Marshal(options.CacheFrom) if err != nil { return query, err } query.Set("cachefrom", string(cacheFromJSON)) } if options.SessionID != "" { query.Set("session", options.SessionID) } if options.Platform != "" { if err := cli.NewVersionError(ctx, "1.32", "platform"); err != nil { return query, err } query.Set("platform", strings.ToLower(options.Platform)) } if options.BuildID != "" { query.Set("buildid", options.BuildID) } if options.Version != "" { query.Set("version", string(options.Version)) } if options.Outputs != nil { outputsJSON, err := json.Marshal(options.Outputs) if err != nil { return query, err } query.Set("outputs", string(outputsJSON)) } return query, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_load.go
vendor/github.com/docker/docker/client/image_load.go
package client import ( "context" "io" "net/http" "net/url" "github.com/docker/docker/api/types/image" ) // ImageLoad loads an image in the docker host from the client host. // It's up to the caller to close the io.ReadCloser in the // ImageLoadResponse returned by this function. // // Platform is an optional parameter that specifies the platform to load from // the provided multi-platform image. This is only has effect if the input image // is a multi-platform image. func (cli *Client) ImageLoad(ctx context.Context, input io.Reader, loadOpts ...ImageLoadOption) (image.LoadResponse, error) { var opts imageLoadOpts for _, opt := range loadOpts { if err := opt.Apply(&opts); err != nil { return image.LoadResponse{}, err } } query := url.Values{} query.Set("quiet", "0") if opts.apiOptions.Quiet { query.Set("quiet", "1") } if len(opts.apiOptions.Platforms) > 0 { if err := cli.NewVersionError(ctx, "1.48", "platform"); err != nil { return image.LoadResponse{}, err } p, err := encodePlatforms(opts.apiOptions.Platforms...) if err != nil { return image.LoadResponse{}, err } query["platform"] = p } resp, err := cli.postRaw(ctx, "/images/load", query, input, http.Header{ "Content-Type": {"application/x-tar"}, }) if err != nil { return image.LoadResponse{}, err } return image.LoadResponse{ Body: resp.Body, JSON: resp.Header.Get("Content-Type") == "application/json", }, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/client.go
vendor/github.com/docker/docker/client/client.go
/* Package client is a Go client for the Docker Engine API. For more information about the Engine API, see the documentation: https://docs.docker.com/reference/api/engine/ # Usage You use the library by constructing a client object using [NewClientWithOpts] and calling methods on it. The client can be configured from environment variables by passing the [FromEnv] option, or configured manually by passing any of the other available [Opts]. For example, to list running containers (the equivalent of "docker ps"): package main import ( "context" "fmt" "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" ) func main() { cli, err := client.NewClientWithOpts(client.FromEnv) if err != nil { panic(err) } containers, err := cli.ContainerList(context.Background(), container.ListOptions{}) if err != nil { panic(err) } for _, ctr := range containers { fmt.Printf("%s %s\n", ctr.ID, ctr.Image) } } */ package client import ( "context" "crypto/tls" "net" "net/http" "net/url" "path" "strings" "sync" "sync/atomic" "time" "github.com/docker/docker/api" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" "github.com/docker/go-connections/sockets" "github.com/pkg/errors" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ) // DummyHost is a hostname used for local communication. // // It acts as a valid formatted hostname for local connections (such as "unix://" // or "npipe://") which do not require a hostname. It should never be resolved, // but uses the special-purpose ".localhost" TLD (as defined in [RFC 2606, Section 2] // and [RFC 6761, Section 6.3]). // // [RFC 7230, Section 5.4] defines that an empty header must be used for such // cases: // // If the authority component is missing or undefined for the target URI, // then a client MUST send a Host header field with an empty field-value. // // However, [Go stdlib] enforces the semantics of HTTP(S) over TCP, does not // allow an empty header to be used, and requires req.URL.Scheme to be either // "http" or "https". // // For further details, refer to: // // - https://github.com/docker/engine-api/issues/189 // - https://github.com/golang/go/issues/13624 // - https://github.com/golang/go/issues/61076 // - https://github.com/moby/moby/issues/45935 // // [RFC 2606, Section 2]: https://www.rfc-editor.org/rfc/rfc2606.html#section-2 // [RFC 6761, Section 6.3]: https://www.rfc-editor.org/rfc/rfc6761#section-6.3 // [RFC 7230, Section 5.4]: https://datatracker.ietf.org/doc/html/rfc7230#section-5.4 // [Go stdlib]: https://github.com/golang/go/blob/6244b1946bc2101b01955468f1be502dbadd6807/src/net/http/transport.go#L558-L569 const DummyHost = "api.moby.localhost" // fallbackAPIVersion is the version to fallback to if API-version negotiation // fails. This version is the highest version of the API before API-version // negotiation was introduced. If negotiation fails (or no API version was // included in the API response), we assume the API server uses the most // recent version before negotiation was introduced. const fallbackAPIVersion = "1.24" // Ensure that Client always implements APIClient. var _ APIClient = &Client{} // Client is the API client that performs all operations // against a docker server. type Client struct { // scheme sets the scheme for the client scheme string // host holds the server address to connect to host string // proto holds the client protocol i.e. unix. proto string // addr holds the client address. addr string // basePath holds the path to prepend to the requests. basePath string // client used to send and receive http requests. client *http.Client // version of the server to talk to. version string // userAgent is the User-Agent header to use for HTTP requests. It takes // precedence over User-Agent headers set in customHTTPHeaders, and other // header variables. When set to an empty string, the User-Agent header // is removed, and no header is sent. userAgent *string // custom HTTP headers configured by users. customHTTPHeaders map[string]string // manualOverride is set to true when the version was set by users. manualOverride bool // negotiateVersion indicates if the client should automatically negotiate // the API version to use when making requests. API version negotiation is // performed on the first request, after which negotiated is set to "true" // so that subsequent requests do not re-negotiate. negotiateVersion bool // negotiated indicates that API version negotiation took place negotiated atomic.Bool // negotiateLock is used to single-flight the version negotiation process negotiateLock sync.Mutex traceOpts []otelhttp.Option // When the client transport is an *http.Transport (default) we need to do some extra things (like closing idle connections). // Store the original transport as the http.Client transport will be wrapped with tracing libs. baseTransport *http.Transport } // ErrRedirect is the error returned by checkRedirect when the request is non-GET. var ErrRedirect = errors.New("unexpected redirect in response") // CheckRedirect specifies the policy for dealing with redirect responses. It // can be set on [http.Client.CheckRedirect] to prevent HTTP redirects for // non-GET requests. It returns an [ErrRedirect] for non-GET request, otherwise // returns a [http.ErrUseLastResponse], which is special-cased by http.Client // to use the last response. // // Go 1.8 changed behavior for HTTP redirects (specifically 301, 307, and 308) // in the client. The client (and by extension API client) can be made to send // a request like "POST /containers//start" where what would normally be in the // name section of the URL is empty. This triggers an HTTP 301 from the daemon. // // In go 1.8 this 301 is converted to a GET request, and ends up getting // a 404 from the daemon. This behavior change manifests in the client in that // before, the 301 was not followed and the client did not generate an error, // but now results in a message like "Error response from daemon: page not found". func CheckRedirect(_ *http.Request, via []*http.Request) error { if via[0].Method == http.MethodGet { return http.ErrUseLastResponse } return ErrRedirect } // NewClientWithOpts initializes a new API client with a default HTTPClient, and // default API host and version. It also initializes the custom HTTP headers to // add to each request. // // It takes an optional list of [Opt] functional arguments, which are applied in // the order they're provided, which allows modifying the defaults when creating // the client. For example, the following initializes a client that configures // itself with values from environment variables ([FromEnv]), and has automatic // API version negotiation enabled ([WithAPIVersionNegotiation]). // // cli, err := client.NewClientWithOpts( // client.FromEnv, // client.WithAPIVersionNegotiation(), // ) func NewClientWithOpts(ops ...Opt) (*Client, error) { hostURL, err := ParseHostURL(DefaultDockerHost) if err != nil { return nil, err } client, err := defaultHTTPClient(hostURL) if err != nil { return nil, err } c := &Client{ host: DefaultDockerHost, version: api.DefaultVersion, client: client, proto: hostURL.Scheme, addr: hostURL.Host, traceOpts: []otelhttp.Option{ otelhttp.WithSpanNameFormatter(func(_ string, req *http.Request) string { return req.Method + " " + req.URL.Path }), }, } for _, op := range ops { if err := op(c); err != nil { return nil, err } } if tr, ok := c.client.Transport.(*http.Transport); ok { // Store the base transport before we wrap it in tracing libs below // This is used, as an example, to close idle connections when the client is closed c.baseTransport = tr } if c.scheme == "" { // TODO(stevvooe): This isn't really the right way to write clients in Go. // `NewClient` should probably only take an `*http.Client` and work from there. // Unfortunately, the model of having a host-ish/url-thingy as the connection // string has us confusing protocol and transport layers. We continue doing // this to avoid breaking existing clients but this should be addressed. if c.tlsConfig() != nil { c.scheme = "https" } else { c.scheme = "http" } } c.client.Transport = otelhttp.NewTransport(c.client.Transport, c.traceOpts...) return c, nil } func (cli *Client) tlsConfig() *tls.Config { if cli.baseTransport == nil { return nil } return cli.baseTransport.TLSClientConfig } func defaultHTTPClient(hostURL *url.URL) (*http.Client, error) { transport := &http.Transport{} // Necessary to prevent long-lived processes using the // client from leaking connections due to idle connections // not being released. // TODO: see if we can also address this from the server side, // or in go-connections. // see: https://github.com/moby/moby/issues/45539 transport.MaxIdleConns = 6 transport.IdleConnTimeout = 30 * time.Second err := sockets.ConfigureTransport(transport, hostURL.Scheme, hostURL.Host) if err != nil { return nil, err } return &http.Client{ Transport: transport, CheckRedirect: CheckRedirect, }, nil } // Close the transport used by the client func (cli *Client) Close() error { if cli.baseTransport != nil { cli.baseTransport.CloseIdleConnections() return nil } return nil } // checkVersion manually triggers API version negotiation (if configured). // This allows for version-dependent code to use the same version as will // be negotiated when making the actual requests, and for which cases // we cannot do the negotiation lazily. func (cli *Client) checkVersion(ctx context.Context) error { if !cli.manualOverride && cli.negotiateVersion && !cli.negotiated.Load() { // Ensure exclusive write access to version and negotiated fields cli.negotiateLock.Lock() defer cli.negotiateLock.Unlock() // May have been set during last execution of critical zone if cli.negotiated.Load() { return nil } ping, err := cli.Ping(ctx) if err != nil { return err } cli.negotiateAPIVersionPing(ping) } return nil } // getAPIPath returns the versioned request path to call the API. // It appends the query parameters to the path if they are not empty. func (cli *Client) getAPIPath(ctx context.Context, p string, query url.Values) string { var apiPath string _ = cli.checkVersion(ctx) if cli.version != "" { apiPath = path.Join(cli.basePath, "/v"+strings.TrimPrefix(cli.version, "v"), p) } else { apiPath = path.Join(cli.basePath, p) } return (&url.URL{Path: apiPath, RawQuery: query.Encode()}).String() } // ClientVersion returns the API version used by this client. func (cli *Client) ClientVersion() string { return cli.version } // NegotiateAPIVersion queries the API and updates the version to match the API // version. NegotiateAPIVersion downgrades the client's API version to match the // APIVersion if the ping version is lower than the default version. If the API // version reported by the server is higher than the maximum version supported // by the client, it uses the client's maximum version. // // If a manual override is in place, either through the "DOCKER_API_VERSION" // ([EnvOverrideAPIVersion]) environment variable, or if the client is initialized // with a fixed version ([WithVersion]), no negotiation is performed. // // If the API server's ping response does not contain an API version, or if the // client did not get a successful ping response, it assumes it is connected with // an old daemon that does not support API version negotiation, in which case it // downgrades to the latest version of the API before version negotiation was // added (1.24). func (cli *Client) NegotiateAPIVersion(ctx context.Context) { if !cli.manualOverride { // Avoid concurrent modification of version-related fields cli.negotiateLock.Lock() defer cli.negotiateLock.Unlock() ping, err := cli.Ping(ctx) if err != nil { // FIXME(thaJeztah): Ping returns an error when failing to connect to the API; we should not swallow the error here, and instead returning it. return } cli.negotiateAPIVersionPing(ping) } } // NegotiateAPIVersionPing downgrades the client's API version to match the // APIVersion in the ping response. If the API version in pingResponse is higher // than the maximum version supported by the client, it uses the client's maximum // version. // // If a manual override is in place, either through the "DOCKER_API_VERSION" // ([EnvOverrideAPIVersion]) environment variable, or if the client is initialized // with a fixed version ([WithVersion]), no negotiation is performed. // // If the API server's ping response does not contain an API version, we assume // we are connected with an old daemon without API version negotiation support, // and downgrade to the latest version of the API before version negotiation was // added (1.24). func (cli *Client) NegotiateAPIVersionPing(pingResponse types.Ping) { if !cli.manualOverride { // Avoid concurrent modification of version-related fields cli.negotiateLock.Lock() defer cli.negotiateLock.Unlock() cli.negotiateAPIVersionPing(pingResponse) } } // negotiateAPIVersionPing queries the API and updates the version to match the // API version from the ping response. func (cli *Client) negotiateAPIVersionPing(pingResponse types.Ping) { // default to the latest version before versioning headers existed if pingResponse.APIVersion == "" { pingResponse.APIVersion = fallbackAPIVersion } // if the client is not initialized with a version, start with the latest supported version if cli.version == "" { cli.version = api.DefaultVersion } // if server version is lower than the client version, downgrade if versions.LessThan(pingResponse.APIVersion, cli.version) { cli.version = pingResponse.APIVersion } // Store the results, so that automatic API version negotiation (if enabled) // won't be performed on the next request. if cli.negotiateVersion { cli.negotiated.Store(true) } } // DaemonHost returns the host address used by the client func (cli *Client) DaemonHost() string { return cli.host } // HTTPClient returns a copy of the HTTP client bound to the server func (cli *Client) HTTPClient() *http.Client { c := *cli.client return &c } // ParseHostURL parses a url string, validates the string is a host url, and // returns the parsed URL func ParseHostURL(host string) (*url.URL, error) { proto, addr, ok := strings.Cut(host, "://") if !ok || addr == "" { return nil, errors.Errorf("unable to parse docker host `%s`", host) } var basePath string if proto == "tcp" { parsed, err := url.Parse("tcp://" + addr) if err != nil { return nil, err } addr = parsed.Host basePath = parsed.Path } return &url.URL{ Scheme: proto, Host: addr, Path: basePath, }, nil } func (cli *Client) dialerFromTransport() func(context.Context, string, string) (net.Conn, error) { if cli.baseTransport == nil || cli.baseTransport.DialContext == nil { return nil } if cli.baseTransport.TLSClientConfig != nil { // When using a tls config we don't use the configured dialer but instead a fallback dialer... // Note: It seems like this should use the normal dialer and wrap the returned net.Conn in a tls.Conn // I honestly don't know why it doesn't do that, but it doesn't and such a change is entirely unrelated to the change in this commit. return nil } return cli.baseTransport.DialContext } // Dialer returns a dialer for a raw stream connection, with an HTTP/1.1 header, // that can be used for proxying the daemon connection. It is used by // ["docker dial-stdio"]. // // ["docker dial-stdio"]: https://github.com/docker/cli/pull/1014 func (cli *Client) Dialer() func(context.Context) (net.Conn, error) { return cli.dialer() } func (cli *Client) dialer() func(context.Context) (net.Conn, error) { return func(ctx context.Context) (net.Conn, error) { if dialFn := cli.dialerFromTransport(); dialFn != nil { return dialFn(ctx, cli.proto, cli.addr) } switch cli.proto { case "unix": return net.Dial(cli.proto, cli.addr) case "npipe": ctx, cancel := context.WithTimeout(ctx, 32*time.Second) defer cancel() return dialPipeContext(ctx, cli.addr) default: if tlsConfig := cli.tlsConfig(); tlsConfig != nil { return tls.Dial(cli.proto, cli.addr, tlsConfig) } return net.Dial(cli.proto, cli.addr) } } }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_unpause.go
vendor/github.com/docker/docker/client/container_unpause.go
package client import "context" // ContainerUnpause resumes the process execution within a container func (cli *Client) ContainerUnpause(ctx context.Context, containerID string) error { containerID, err := trimID("container", containerID) if err != nil { return err } resp, err := cli.post(ctx, "/containers/"+containerID+"/unpause", nil, nil, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_prune.go
vendor/github.com/docker/docker/client/image_prune.go
package client import ( "context" "encoding/json" "fmt" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/image" ) // ImagesPrune requests the daemon to delete unused data func (cli *Client) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (image.PruneReport, error) { if err := cli.NewVersionError(ctx, "1.25", "image prune"); err != nil { return image.PruneReport{}, err } query, err := getFiltersQuery(pruneFilters) if err != nil { return image.PruneReport{}, err } resp, err := cli.post(ctx, "/images/prune", query, nil, nil) defer ensureReaderClosed(resp) if err != nil { return image.PruneReport{}, err } var report image.PruneReport if err := json.NewDecoder(resp.Body).Decode(&report); err != nil { return image.PruneReport{}, fmt.Errorf("Error retrieving disk usage: %v", err) } return report, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/client_unix.go
vendor/github.com/docker/docker/client/client_unix.go
//go:build !windows package client import ( "context" "net" "syscall" ) // DefaultDockerHost defines OS-specific default host if the DOCKER_HOST // (EnvOverrideHost) environment variable is unset or empty. const DefaultDockerHost = "unix:///var/run/docker.sock" // dialPipeContext connects to a Windows named pipe. It is not supported on non-Windows. func dialPipeContext(_ context.Context, _ string) (net.Conn, error) { return nil, syscall.EAFNOSUPPORT }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/envvars.go
vendor/github.com/docker/docker/client/envvars.go
package client const ( // EnvOverrideHost is the name of the environment variable that can be used // to override the default host to connect to (DefaultDockerHost). // // This env-var is read by FromEnv and WithHostFromEnv and when set to a // non-empty value, takes precedence over the default host (which is platform // specific), or any host already set. EnvOverrideHost = "DOCKER_HOST" // EnvOverrideAPIVersion is the name of the environment variable that can // be used to override the API version to use. Value should be // formatted as MAJOR.MINOR, for example, "1.19". // // This env-var is read by FromEnv and WithVersionFromEnv and when set to a // non-empty value, takes precedence over API version negotiation. // // This environment variable should be used for debugging purposes only, as // it can set the client to use an incompatible (or invalid) API version. EnvOverrideAPIVersion = "DOCKER_API_VERSION" // EnvOverrideCertPath is the name of the environment variable that can be // used to specify the directory from which to load the TLS certificates // (ca.pem, cert.pem, key.pem) from. These certificates are used to configure // the Client for a TCP connection protected by TLS client authentication. // // TLS certificate verification is enabled by default if the Client is configured // to use a TLS connection. Refer to EnvTLSVerify below to learn how to // disable verification for testing purposes. // // WARNING: Access to the remote API is equivalent to root access to the // host where the daemon runs. Do not expose the API without protection, // and only if needed. Make sure you are familiar with the "daemon attack // surface" (https://docs.docker.com/go/attack-surface/). // // For local access to the API, it is recommended to connect with the daemon // using the default local socket connection (on Linux), or the named pipe // (on Windows). // // If you need to access the API of a remote daemon, consider using an SSH // (ssh://) connection, which is easier to set up, and requires no additional // configuration if the host is accessible using ssh. // // If you cannot use the alternatives above, and you must expose the API over // a TCP connection, refer to https://docs.docker.com/engine/security/protect-access/ // to learn how to configure the daemon and client to use a TCP connection // with TLS client authentication. Make sure you know the differences between // a regular TLS connection and a TLS connection protected by TLS client // authentication, and verify that the API cannot be accessed by other clients. EnvOverrideCertPath = "DOCKER_CERT_PATH" // EnvTLSVerify is the name of the environment variable that can be used to // enable or disable TLS certificate verification. When set to a non-empty // value, TLS certificate verification is enabled, and the client is configured // to use a TLS connection, using certificates from the default directories // (within `~/.docker`); refer to EnvOverrideCertPath above for additional // details. // // WARNING: Access to the remote API is equivalent to root access to the // host where the daemon runs. Do not expose the API without protection, // and only if needed. Make sure you are familiar with the "daemon attack // surface" (https://docs.docker.com/go/attack-surface/). // // Before setting up your client and daemon to use a TCP connection with TLS // client authentication, consider using one of the alternatives mentioned // in EnvOverrideCertPath above. // // Disabling TLS certificate verification (for testing purposes) // // TLS certificate verification is enabled by default if the Client is configured // to use a TLS connection, and it is highly recommended to keep verification // enabled to prevent machine-in-the-middle attacks. Refer to the documentation // at https://docs.docker.com/engine/security/protect-access/ and pages linked // from that page to learn how to configure the daemon and client to use a // TCP connection with TLS client authentication enabled. // // Set the "DOCKER_TLS_VERIFY" environment to an empty string ("") to // disable TLS certificate verification. Disabling verification is insecure, // so should only be done for testing purposes. From the Go documentation // (https://pkg.go.dev/crypto/tls#Config): // // InsecureSkipVerify controls whether a client verifies the server's // certificate chain and host name. If InsecureSkipVerify is true, crypto/tls // accepts any certificate presented by the server and any host name in that // certificate. In this mode, TLS is susceptible to machine-in-the-middle // attacks unless custom verification is used. This should be used only for // testing or in combination with VerifyConnection or VerifyPeerCertificate. EnvTLSVerify = "DOCKER_TLS_VERIFY" )
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_export.go
vendor/github.com/docker/docker/client/container_export.go
package client import ( "context" "io" "net/url" ) // ContainerExport retrieves the raw contents of a container // and returns them as an io.ReadCloser. It's up to the caller // to close the stream. func (cli *Client) ContainerExport(ctx context.Context, containerID string) (io.ReadCloser, error) { containerID, err := trimID("container", containerID) if err != nil { return nil, err } resp, err := cli.get(ctx, "/containers/"+containerID+"/export", url.Values{}, nil) if err != nil { return nil, err } return resp.Body, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/service_update.go
vendor/github.com/docker/docker/client/service_update.go
package client import ( "context" "encoding/json" "net/http" "net/url" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/versions" ) // ServiceUpdate updates a Service. The version number is required to avoid conflicting writes. // It should be the value as set *before* the update. You can find this value in the Meta field // of swarm.Service, which can be found using ServiceInspectWithRaw. func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) { serviceID, err := trimID("service", serviceID) if err != nil { return swarm.ServiceUpdateResponse{}, err } // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // // Normally, version-negotiation (if enabled) would not happen until // the API request is made. if err := cli.checkVersion(ctx); err != nil { return swarm.ServiceUpdateResponse{}, err } query := url.Values{} if options.RegistryAuthFrom != "" { query.Set("registryAuthFrom", options.RegistryAuthFrom) } if options.Rollback != "" { query.Set("rollback", options.Rollback) } query.Set("version", version.String()) if err := validateServiceSpec(service); err != nil { return swarm.ServiceUpdateResponse{}, err } // ensure that the image is tagged var resolveWarning string switch { case service.TaskTemplate.ContainerSpec != nil: if taggedImg := imageWithTagString(service.TaskTemplate.ContainerSpec.Image); taggedImg != "" { service.TaskTemplate.ContainerSpec.Image = taggedImg } if options.QueryRegistry { resolveWarning = resolveContainerSpecImage(ctx, cli, &service.TaskTemplate, options.EncodedRegistryAuth) } case service.TaskTemplate.PluginSpec != nil: if taggedImg := imageWithTagString(service.TaskTemplate.PluginSpec.Remote); taggedImg != "" { service.TaskTemplate.PluginSpec.Remote = taggedImg } if options.QueryRegistry { resolveWarning = resolvePluginSpecRemote(ctx, cli, &service.TaskTemplate, options.EncodedRegistryAuth) } } headers := http.Header{} if versions.LessThan(cli.version, "1.30") { // the custom "version" header was used by engine API before 20.10 // (API 1.30) to switch between client- and server-side lookup of // image digests. headers["version"] = []string{cli.version} } if options.EncodedRegistryAuth != "" { headers[registry.AuthHeader] = []string{options.EncodedRegistryAuth} } resp, err := cli.post(ctx, "/services/"+serviceID+"/update", query, service, headers) defer ensureReaderClosed(resp) if err != nil { return swarm.ServiceUpdateResponse{}, err } var response swarm.ServiceUpdateResponse err = json.NewDecoder(resp.Body).Decode(&response) if resolveWarning != "" { response.Warnings = append(response.Warnings, resolveWarning) } return response, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/swarm_inspect.go
vendor/github.com/docker/docker/client/swarm_inspect.go
package client import ( "context" "encoding/json" "github.com/docker/docker/api/types/swarm" ) // SwarmInspect inspects the swarm. func (cli *Client) SwarmInspect(ctx context.Context) (swarm.Swarm, error) { resp, err := cli.get(ctx, "/swarm", nil, nil) defer ensureReaderClosed(resp) if err != nil { return swarm.Swarm{}, err } var response swarm.Swarm err = json.NewDecoder(resp.Body).Decode(&response) return response, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/swarm_init.go
vendor/github.com/docker/docker/client/swarm_init.go
package client import ( "context" "encoding/json" "github.com/docker/docker/api/types/swarm" ) // SwarmInit initializes the swarm. func (cli *Client) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) { resp, err := cli.post(ctx, "/swarm/init", nil, req, nil) defer ensureReaderClosed(resp) if err != nil { return "", err } var response string err = json.NewDecoder(resp.Body).Decode(&response) return response, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_wait.go
vendor/github.com/docker/docker/client/container_wait.go
package client import ( "bytes" "context" "encoding/json" "errors" "io" "net/url" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/versions" ) const containerWaitErrorMsgLimit = 2 * 1024 /* Max: 2KiB */ // ContainerWait waits until the specified container is in a certain state // indicated by the given condition, either "not-running" (default), // "next-exit", or "removed". // // If this client's API version is before 1.30, condition is ignored and // ContainerWait will return immediately with the two channels, as the server // will wait as if the condition were "not-running". // // If this client's API version is at least 1.30, ContainerWait blocks until // the request has been acknowledged by the server (with a response header), // then returns two channels on which the caller can wait for the exit status // of the container or an error if there was a problem either beginning the // wait request or in getting the response. This allows the caller to // synchronize ContainerWait with other calls, such as specifying a // "next-exit" condition before issuing a ContainerStart request. func (cli *Client) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) { resultC := make(chan container.WaitResponse) errC := make(chan error, 1) containerID, err := trimID("container", containerID) if err != nil { errC <- err return resultC, errC } // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // // Normally, version-negotiation (if enabled) would not happen until // the API request is made. if err := cli.checkVersion(ctx); err != nil { errC <- err return resultC, errC } if versions.LessThan(cli.ClientVersion(), "1.30") { return cli.legacyContainerWait(ctx, containerID) } query := url.Values{} if condition != "" { query.Set("condition", string(condition)) } resp, err := cli.post(ctx, "/containers/"+containerID+"/wait", query, nil, nil) if err != nil { defer ensureReaderClosed(resp) errC <- err return resultC, errC } go func() { defer ensureReaderClosed(resp) responseText := bytes.NewBuffer(nil) stream := io.TeeReader(resp.Body, responseText) var res container.WaitResponse if err := json.NewDecoder(stream).Decode(&res); err != nil { // NOTE(nicks): The /wait API does not work well with HTTP proxies. // At any time, the proxy could cut off the response stream. // // But because the HTTP status has already been written, the proxy's // only option is to write a plaintext error message. // // If there's a JSON parsing error, read the real error message // off the body and send it to the client. if errors.As(err, new(*json.SyntaxError)) { _, _ = io.ReadAll(io.LimitReader(stream, containerWaitErrorMsgLimit)) errC <- errors.New(responseText.String()) } else { errC <- err } return } resultC <- res }() return resultC, errC } // legacyContainerWait returns immediately and doesn't have an option to wait // until the container is removed. func (cli *Client) legacyContainerWait(ctx context.Context, containerID string) (<-chan container.WaitResponse, <-chan error) { resultC := make(chan container.WaitResponse) errC := make(chan error) go func() { resp, err := cli.post(ctx, "/containers/"+containerID+"/wait", nil, nil, nil) if err != nil { errC <- err return } defer ensureReaderClosed(resp) var res container.WaitResponse if err := json.NewDecoder(resp.Body).Decode(&res); err != nil { errC <- err return } resultC <- res }() return resultC, errC }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_prune.go
vendor/github.com/docker/docker/client/container_prune.go
package client import ( "context" "encoding/json" "fmt" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" ) // ContainersPrune requests the daemon to delete unused data func (cli *Client) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error) { if err := cli.NewVersionError(ctx, "1.25", "container prune"); err != nil { return container.PruneReport{}, err } query, err := getFiltersQuery(pruneFilters) if err != nil { return container.PruneReport{}, err } resp, err := cli.post(ctx, "/containers/prune", query, nil, nil) defer ensureReaderClosed(resp) if err != nil { return container.PruneReport{}, err } var report container.PruneReport if err := json.NewDecoder(resp.Body).Decode(&report); err != nil { return container.PruneReport{}, fmt.Errorf("Error retrieving disk usage: %v", err) } return report, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_create.go
vendor/github.com/docker/docker/client/image_create.go
package client import ( "context" "io" "net/http" "net/url" "strings" "github.com/distribution/reference" "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" ) // ImageCreate creates a new image based on the parent options. // It returns the JSON content in the response body. func (cli *Client) ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error) { ref, err := reference.ParseNormalizedNamed(parentReference) if err != nil { return nil, err } query := url.Values{} query.Set("fromImage", ref.Name()) query.Set("tag", getAPITagFromNamedRef(ref)) if options.Platform != "" { query.Set("platform", strings.ToLower(options.Platform)) } resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth) if err != nil { return nil, err } return resp.Body, nil } func (cli *Client) tryImageCreate(ctx context.Context, query url.Values, registryAuth string) (*http.Response, error) { return cli.post(ctx, "/images/create", query, nil, http.Header{ registry.AuthHeader: {registryAuth}, }) }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/volume_remove.go
vendor/github.com/docker/docker/client/volume_remove.go
package client import ( "context" "net/url" "github.com/docker/docker/api/types/versions" ) // VolumeRemove removes a volume from the docker host. func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, force bool) error { volumeID, err := trimID("volume", volumeID) if err != nil { return err } query := url.Values{} if force { // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // // Normally, version-negotiation (if enabled) would not happen until // the API request is made. if err := cli.checkVersion(ctx); err != nil { return err } if versions.GreaterThanOrEqualTo(cli.version, "1.25") { query.Set("force", "1") } } resp, err := cli.delete(ctx, "/volumes/"+volumeID, query, nil) defer ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/errors.go
vendor/github.com/docker/docker/client/errors.go
package client import ( "context" "errors" "fmt" "net/http" cerrdefs "github.com/containerd/errdefs" "github.com/containerd/errdefs/pkg/errhttp" "github.com/docker/docker/api/types/versions" ) // errConnectionFailed implements an error returned when connection failed. type errConnectionFailed struct { error } // Error returns a string representation of an errConnectionFailed func (e errConnectionFailed) Error() string { return e.error.Error() } func (e errConnectionFailed) Unwrap() error { return e.error } // IsErrConnectionFailed returns true if the error is caused by connection failed. func IsErrConnectionFailed(err error) bool { return errors.As(err, &errConnectionFailed{}) } // ErrorConnectionFailed returns an error with host in the error message when connection to docker daemon failed. // // Deprecated: this function was only used internally, and will be removed in the next release. func ErrorConnectionFailed(host string) error { return connectionFailed(host) } // connectionFailed returns an error with host in the error message when connection // to docker daemon failed. func connectionFailed(host string) error { var err error if host == "" { err = errors.New("Cannot connect to the Docker daemon. Is the docker daemon running on this host?") } else { err = fmt.Errorf("Cannot connect to the Docker daemon at %s. Is the docker daemon running?", host) } return errConnectionFailed{error: err} } // IsErrNotFound returns true if the error is a NotFound error, which is returned // by the API when some object is not found. It is an alias for [cerrdefs.IsNotFound]. // // Deprecated: use [cerrdefs.IsNotFound] instead. func IsErrNotFound(err error) bool { return cerrdefs.IsNotFound(err) } type objectNotFoundError struct { object string id string } func (e objectNotFoundError) NotFound() {} func (e objectNotFoundError) Error() string { return fmt.Sprintf("Error: No such %s: %s", e.object, e.id) } // NewVersionError returns an error if the APIVersion required is less than the // current supported version. // // It performs API-version negotiation if the Client is configured with this // option, otherwise it assumes the latest API version is used. func (cli *Client) NewVersionError(ctx context.Context, APIrequired, feature string) error { // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // // Normally, version-negotiation (if enabled) would not happen until // the API request is made. if err := cli.checkVersion(ctx); err != nil { return err } if cli.version != "" && versions.LessThan(cli.version, APIrequired) { return fmt.Errorf("%q requires API version %s, but the Docker daemon API version is %s", feature, APIrequired, cli.version) } return nil } type httpError struct { err error errdef error } func (e *httpError) Error() string { return e.err.Error() } func (e *httpError) Unwrap() error { return e.err } func (e *httpError) Is(target error) bool { return errors.Is(e.errdef, target) } // httpErrorFromStatusCode creates an errdef error, based on the provided HTTP status-code func httpErrorFromStatusCode(err error, statusCode int) error { if err == nil { return nil } base := errhttp.ToNative(statusCode) if base != nil { return &httpError{err: err, errdef: base} } switch { case statusCode >= http.StatusOK && statusCode < http.StatusBadRequest: // it's a client error return err case statusCode >= http.StatusBadRequest && statusCode < http.StatusInternalServerError: return &httpError{err: err, errdef: cerrdefs.ErrInvalidArgument} case statusCode >= http.StatusInternalServerError && statusCode < 600: return &httpError{err: err, errdef: cerrdefs.ErrInternal} default: return &httpError{err: err, errdef: cerrdefs.ErrUnknown} } }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_list.go
vendor/github.com/docker/docker/client/image_list.go
package client import ( "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/versions" ) // ImageList returns a list of images in the docker host. // // Experimental: Setting the [options.Manifest] will populate // [image.Summary.Manifests] with information about image manifests. // This is experimental and might change in the future without any backward // compatibility. func (cli *Client) ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error) { var images []image.Summary // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // // Normally, version-negotiation (if enabled) would not happen until // the API request is made. if err := cli.checkVersion(ctx); err != nil { return images, err } query := url.Values{} optionFilters := options.Filters referenceFilters := optionFilters.Get("reference") if versions.LessThan(cli.version, "1.25") && len(referenceFilters) > 0 { query.Set("filter", referenceFilters[0]) for _, filterValue := range referenceFilters { optionFilters.Del("reference", filterValue) } } if optionFilters.Len() > 0 { //nolint:staticcheck // ignore SA1019 for old code filterJSON, err := filters.ToParamWithVersion(cli.version, optionFilters) if err != nil { return images, err } query.Set("filters", filterJSON) } if options.All { query.Set("all", "1") } if options.SharedSize && versions.GreaterThanOrEqualTo(cli.version, "1.42") { query.Set("shared-size", "1") } if options.Manifests && versions.GreaterThanOrEqualTo(cli.version, "1.47") { query.Set("manifests", "1") } resp, err := cli.get(ctx, "/images/json", query, nil) defer ensureReaderClosed(resp) if err != nil { return images, err } err = json.NewDecoder(resp.Body).Decode(&images) return images, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/utils.go
vendor/github.com/docker/docker/client/utils.go
package client import ( "encoding/json" "fmt" "net/url" "strings" cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/filters" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) type emptyIDError string func (e emptyIDError) InvalidParameter() {} func (e emptyIDError) Error() string { return "invalid " + string(e) + " name or ID: value is empty" } // trimID trims the given object-ID / name, returning an error if it's empty. func trimID(objType, id string) (string, error) { id = strings.TrimSpace(id) if id == "" { return "", emptyIDError(objType) } return id, nil } // getFiltersQuery returns a url query with "filters" query term, based on the // filters provided. func getFiltersQuery(f filters.Args) (url.Values, error) { query := url.Values{} if f.Len() > 0 { filterJSON, err := filters.ToJSON(f) if err != nil { return query, err } query.Set("filters", filterJSON) } return query, nil } // encodePlatforms marshals the given platform(s) to JSON format, to // be used for query-parameters for filtering / selecting platforms. func encodePlatforms(platform ...ocispec.Platform) ([]string, error) { if len(platform) == 0 { return []string{}, nil } if len(platform) == 1 { p, err := encodePlatform(&platform[0]) if err != nil { return nil, err } return []string{p}, nil } seen := make(map[string]struct{}, len(platform)) out := make([]string, 0, len(platform)) for i := range platform { p, err := encodePlatform(&platform[i]) if err != nil { return nil, err } if _, ok := seen[p]; !ok { out = append(out, p) seen[p] = struct{}{} } } return out, nil } // encodePlatform marshals the given platform to JSON format, to // be used for query-parameters for filtering / selecting platforms. It // is used as a helper for encodePlatforms, func encodePlatform(platform *ocispec.Platform) (string, error) { p, err := json.Marshal(platform) if err != nil { return "", fmt.Errorf("%w: invalid platform: %v", cerrdefs.ErrInvalidArgument, err) } return string(p), nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/network_prune.go
vendor/github.com/docker/docker/client/network_prune.go
package client import ( "context" "encoding/json" "fmt" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/network" ) // NetworksPrune requests the daemon to delete unused networks func (cli *Client) NetworksPrune(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error) { if err := cli.NewVersionError(ctx, "1.25", "network prune"); err != nil { return network.PruneReport{}, err } query, err := getFiltersQuery(pruneFilters) if err != nil { return network.PruneReport{}, err } resp, err := cli.post(ctx, "/networks/prune", query, nil, nil) defer ensureReaderClosed(resp) if err != nil { return network.PruneReport{}, err } var report network.PruneReport if err := json.NewDecoder(resp.Body).Decode(&report); err != nil { return network.PruneReport{}, fmt.Errorf("Error retrieving network prune report: %v", err) } return report, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_diff.go
vendor/github.com/docker/docker/client/container_diff.go
package client import ( "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/container" ) // ContainerDiff shows differences in a container filesystem since it was started. func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]container.FilesystemChange, error) { containerID, err := trimID("container", containerID) if err != nil { return nil, err } resp, err := cli.get(ctx, "/containers/"+containerID+"/changes", url.Values{}, nil) defer ensureReaderClosed(resp) if err != nil { return nil, err } var changes []container.FilesystemChange err = json.NewDecoder(resp.Body).Decode(&changes) if err != nil { return nil, err } return changes, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/plugin_install.go
vendor/github.com/docker/docker/client/plugin_install.go
package client import ( "context" "encoding/json" "io" "net/http" "net/url" cerrdefs "github.com/containerd/errdefs" "github.com/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/registry" "github.com/pkg/errors" ) // PluginInstall installs a plugin func (cli *Client) PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (_ io.ReadCloser, retErr error) { query := url.Values{} if _, err := reference.ParseNormalizedNamed(options.RemoteRef); err != nil { return nil, errors.Wrap(err, "invalid remote reference") } query.Set("remote", options.RemoteRef) privileges, err := cli.checkPluginPermissions(ctx, query, options) if err != nil { return nil, err } // set name for plugin pull, if empty should default to remote reference query.Set("name", name) resp, err := cli.tryPluginPull(ctx, query, privileges, options.RegistryAuth) if err != nil { return nil, err } name = resp.Header.Get("Docker-Plugin-Name") pr, pw := io.Pipe() go func() { // todo: the client should probably be designed more around the actual api _, err := io.Copy(pw, resp.Body) if err != nil { _ = pw.CloseWithError(err) return } defer func() { if retErr != nil { delResp, _ := cli.delete(ctx, "/plugins/"+name, nil, nil) ensureReaderClosed(delResp) } }() if len(options.Args) > 0 { if err := cli.PluginSet(ctx, name, options.Args); err != nil { _ = pw.CloseWithError(err) return } } if options.Disabled { _ = pw.Close() return } enableErr := cli.PluginEnable(ctx, name, types.PluginEnableOptions{Timeout: 0}) _ = pw.CloseWithError(enableErr) }() return pr, nil } func (cli *Client) tryPluginPrivileges(ctx context.Context, query url.Values, registryAuth string) (*http.Response, error) { return cli.get(ctx, "/plugins/privileges", query, http.Header{ registry.AuthHeader: {registryAuth}, }) } func (cli *Client) tryPluginPull(ctx context.Context, query url.Values, privileges types.PluginPrivileges, registryAuth string) (*http.Response, error) { return cli.post(ctx, "/plugins/pull", query, privileges, http.Header{ registry.AuthHeader: {registryAuth}, }) } func (cli *Client) checkPluginPermissions(ctx context.Context, query url.Values, options types.PluginInstallOptions) (types.PluginPrivileges, error) { resp, err := cli.tryPluginPrivileges(ctx, query, options.RegistryAuth) if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil { // todo: do inspect before to check existing name before checking privileges newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx) if privilegeErr != nil { ensureReaderClosed(resp) return nil, privilegeErr } options.RegistryAuth = newAuthHeader resp, err = cli.tryPluginPrivileges(ctx, query, options.RegistryAuth) } if err != nil { ensureReaderClosed(resp) return nil, err } var privileges types.PluginPrivileges if err := json.NewDecoder(resp.Body).Decode(&privileges); err != nil { ensureReaderClosed(resp) return nil, err } ensureReaderClosed(resp) if !options.AcceptAllPermissions && options.AcceptPermissionsFunc != nil && len(privileges) > 0 { accept, err := options.AcceptPermissionsFunc(ctx, privileges) if err != nil { return nil, err } if !accept { return nil, errors.Errorf("permission denied while installing plugin %s", options.RemoteRef) } } return privileges, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/node_remove.go
vendor/github.com/docker/docker/client/node_remove.go
package client import ( "context" "net/url" "github.com/docker/docker/api/types/swarm" ) // NodeRemove removes a Node. func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options swarm.NodeRemoveOptions) error { nodeID, err := trimID("node", nodeID) if err != nil { return err } query := url.Values{} if options.Force { query.Set("force", "1") } resp, err := cli.delete(ctx, "/nodes/"+nodeID, query, nil) defer ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/distribution_inspect.go
vendor/github.com/docker/docker/client/distribution_inspect.go
package client import ( "context" "encoding/json" "net/http" "net/url" "github.com/docker/docker/api/types/registry" ) // DistributionInspect returns the image digest with the full manifest. func (cli *Client) DistributionInspect(ctx context.Context, imageRef, encodedRegistryAuth string) (registry.DistributionInspect, error) { if imageRef == "" { return registry.DistributionInspect{}, objectNotFoundError{object: "distribution", id: imageRef} } if err := cli.NewVersionError(ctx, "1.30", "distribution inspect"); err != nil { return registry.DistributionInspect{}, err } var headers http.Header if encodedRegistryAuth != "" { headers = http.Header{ registry.AuthHeader: {encodedRegistryAuth}, } } // Contact the registry to retrieve digest and platform information resp, err := cli.get(ctx, "/distribution/"+imageRef+"/json", url.Values{}, headers) defer ensureReaderClosed(resp) if err != nil { return registry.DistributionInspect{}, err } var distributionInspect registry.DistributionInspect err = json.NewDecoder(resp.Body).Decode(&distributionInspect) return distributionInspect, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_exec.go
vendor/github.com/docker/docker/client/container_exec.go
package client import ( "context" "encoding/json" "net/http" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/versions" ) // ContainerExecCreate creates a new exec configuration to run an exec process. func (cli *Client) ContainerExecCreate(ctx context.Context, containerID string, options container.ExecOptions) (container.ExecCreateResponse, error) { containerID, err := trimID("container", containerID) if err != nil { return container.ExecCreateResponse{}, err } // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // // Normally, version-negotiation (if enabled) would not happen until // the API request is made. if err := cli.checkVersion(ctx); err != nil { return container.ExecCreateResponse{}, err } if err := cli.NewVersionError(ctx, "1.25", "env"); len(options.Env) != 0 && err != nil { return container.ExecCreateResponse{}, err } if versions.LessThan(cli.ClientVersion(), "1.42") { options.ConsoleSize = nil } resp, err := cli.post(ctx, "/containers/"+containerID+"/exec", nil, options, nil) defer ensureReaderClosed(resp) if err != nil { return container.ExecCreateResponse{}, err } var response container.ExecCreateResponse err = json.NewDecoder(resp.Body).Decode(&response) return response, err } // ContainerExecStart starts an exec process already created in the docker host. func (cli *Client) ContainerExecStart(ctx context.Context, execID string, config container.ExecStartOptions) error { if versions.LessThan(cli.ClientVersion(), "1.42") { config.ConsoleSize = nil } resp, err := cli.post(ctx, "/exec/"+execID+"/start", nil, config, nil) ensureReaderClosed(resp) return err } // ContainerExecAttach attaches a connection to an exec process in the server. // It returns a types.HijackedConnection with the hijacked connection // and the a reader to get output. It's up to the called to close // the hijacked connection by calling types.HijackedResponse.Close. func (cli *Client) ContainerExecAttach(ctx context.Context, execID string, config container.ExecAttachOptions) (types.HijackedResponse, error) { if versions.LessThan(cli.ClientVersion(), "1.42") { config.ConsoleSize = nil } return cli.postHijacked(ctx, "/exec/"+execID+"/start", nil, config, http.Header{ "Content-Type": {"application/json"}, }) } // ContainerExecInspect returns information about a specific exec process on the docker host. func (cli *Client) ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error) { var response container.ExecInspect resp, err := cli.get(ctx, "/exec/"+execID+"/json", nil, nil) if err != nil { return response, err } err = json.NewDecoder(resp.Body).Decode(&response) ensureReaderClosed(resp) return response, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/swarm_update.go
vendor/github.com/docker/docker/client/swarm_update.go
package client import ( "context" "net/url" "strconv" "github.com/docker/docker/api/types/swarm" ) // SwarmUpdate updates the swarm. func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error { query := url.Values{} query.Set("version", version.String()) query.Set("rotateWorkerToken", strconv.FormatBool(flags.RotateWorkerToken)) query.Set("rotateManagerToken", strconv.FormatBool(flags.RotateManagerToken)) query.Set("rotateManagerUnlockKey", strconv.FormatBool(flags.RotateManagerUnlockKey)) resp, err := cli.post(ctx, "/swarm/update", query, swarm, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/hijack.go
vendor/github.com/docker/docker/client/hijack.go
package client import ( "bufio" "context" "fmt" "net" "net/http" "net/url" "time" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" "github.com/pkg/errors" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ) // postHijacked sends a POST request and hijacks the connection. func (cli *Client) postHijacked(ctx context.Context, path string, query url.Values, body interface{}, headers map[string][]string) (types.HijackedResponse, error) { bodyEncoded, err := encodeData(body) if err != nil { return types.HijackedResponse{}, err } req, err := cli.buildRequest(ctx, http.MethodPost, cli.getAPIPath(ctx, path, query), bodyEncoded, headers) if err != nil { return types.HijackedResponse{}, err } conn, mediaType, err := setupHijackConn(cli.dialer(), req, "tcp") if err != nil { return types.HijackedResponse{}, err } if versions.LessThan(cli.ClientVersion(), "1.42") { // Prior to 1.42, Content-Type is always set to raw-stream and not relevant mediaType = "" } return types.NewHijackedResponse(conn, mediaType), nil } // DialHijack returns a hijacked connection with negotiated protocol proto. func (cli *Client) DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error) { req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, http.NoBody) if err != nil { return nil, err } req = cli.addHeaders(req, meta) conn, _, err := setupHijackConn(cli.Dialer(), req, proto) return conn, err } func setupHijackConn(dialer func(context.Context) (net.Conn, error), req *http.Request, proto string) (_ net.Conn, _ string, retErr error) { ctx := req.Context() req.Header.Set("Connection", "Upgrade") req.Header.Set("Upgrade", proto) conn, err := dialer(ctx) if err != nil { return nil, "", errors.Wrap(err, "cannot connect to the Docker daemon. Is 'docker daemon' running on this host?") } defer func() { if retErr != nil { conn.Close() } }() // When we set up a TCP connection for hijack, there could be long periods // of inactivity (a long running command with no output) that in certain // network setups may cause ECONNTIMEOUT, leaving the client in an unknown // state. Setting TCP KeepAlive on the socket connection will prohibit // ECONNTIMEOUT unless the socket connection truly is broken if tcpConn, ok := conn.(*net.TCPConn); ok { _ = tcpConn.SetKeepAlive(true) _ = tcpConn.SetKeepAlivePeriod(30 * time.Second) } hc := &hijackedConn{conn, bufio.NewReader(conn)} // Server hijacks the connection, error 'connection closed' expected resp, err := otelhttp.NewTransport(hc).RoundTrip(req) if err != nil { return nil, "", err } if resp.StatusCode != http.StatusSwitchingProtocols { _ = resp.Body.Close() return nil, "", fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode) } if hc.r.Buffered() > 0 { // If there is buffered content, wrap the connection. We return an // object that implements CloseWrite if the underlying connection // implements it. if _, ok := hc.Conn.(types.CloseWriter); ok { conn = &hijackedConnCloseWriter{hc} } else { conn = hc } } else { hc.r.Reset(nil) } return conn, resp.Header.Get("Content-Type"), nil } // hijackedConn wraps a net.Conn and is returned by setupHijackConn in the case // that a) there was already buffered data in the http layer when Hijack() was // called, and b) the underlying net.Conn does *not* implement CloseWrite(). // hijackedConn does not implement CloseWrite() either. type hijackedConn struct { net.Conn r *bufio.Reader } func (c *hijackedConn) RoundTrip(req *http.Request) (*http.Response, error) { if err := req.Write(c.Conn); err != nil { return nil, err } return http.ReadResponse(c.r, req) } func (c *hijackedConn) Read(b []byte) (int, error) { return c.r.Read(b) } // hijackedConnCloseWriter is a hijackedConn which additionally implements // CloseWrite(). It is returned by setupHijackConn in the case that a) there // was already buffered data in the http layer when Hijack() was called, and b) // the underlying net.Conn *does* implement CloseWrite(). type hijackedConnCloseWriter struct { *hijackedConn } var _ types.CloseWriter = &hijackedConnCloseWriter{} func (c *hijackedConnCloseWriter) CloseWrite() error { conn := c.Conn.(types.CloseWriter) return conn.CloseWrite() }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/node_list.go
vendor/github.com/docker/docker/client/node_list.go
package client import ( "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" ) // NodeList returns the list of nodes. func (cli *Client) NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) { query := url.Values{} if options.Filters.Len() > 0 { filterJSON, err := filters.ToJSON(options.Filters) if err != nil { return nil, err } query.Set("filters", filterJSON) } resp, err := cli.get(ctx, "/nodes", query, nil) defer ensureReaderClosed(resp) if err != nil { return nil, err } var nodes []swarm.Node err = json.NewDecoder(resp.Body).Decode(&nodes) return nodes, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_copy.go
vendor/github.com/docker/docker/client/container_copy.go
package client import ( "context" "encoding/base64" "encoding/json" "fmt" "io" "net/http" "net/url" "path/filepath" "strings" "github.com/docker/docker/api/types/container" ) // ContainerStatPath returns stat information about a path inside the container filesystem. func (cli *Client) ContainerStatPath(ctx context.Context, containerID, path string) (container.PathStat, error) { containerID, err := trimID("container", containerID) if err != nil { return container.PathStat{}, err } query := url.Values{} query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API. resp, err := cli.head(ctx, "/containers/"+containerID+"/archive", query, nil) defer ensureReaderClosed(resp) if err != nil { return container.PathStat{}, err } return getContainerPathStatFromHeader(resp.Header) } // CopyToContainer copies content into the container filesystem. // Note that `content` must be a Reader for a TAR archive func (cli *Client) CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, options container.CopyToContainerOptions) error { containerID, err := trimID("container", containerID) if err != nil { return err } query := url.Values{} query.Set("path", filepath.ToSlash(dstPath)) // Normalize the paths used in the API. // Do not allow for an existing directory to be overwritten by a non-directory and vice versa. if !options.AllowOverwriteDirWithFile { query.Set("noOverwriteDirNonDir", "true") } if options.CopyUIDGID { query.Set("copyUIDGID", "true") } response, err := cli.putRaw(ctx, "/containers/"+containerID+"/archive", query, content, nil) defer ensureReaderClosed(response) if err != nil { return err } return nil } // CopyFromContainer gets the content from the container and returns it as a Reader // for a TAR archive to manipulate it in the host. It's up to the caller to close the reader. func (cli *Client) CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, container.PathStat, error) { containerID, err := trimID("container", containerID) if err != nil { return nil, container.PathStat{}, err } query := make(url.Values, 1) query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API. resp, err := cli.get(ctx, "/containers/"+containerID+"/archive", query, nil) if err != nil { return nil, container.PathStat{}, err } // In order to get the copy behavior right, we need to know information // about both the source and the destination. The response headers include // stat info about the source that we can use in deciding exactly how to // copy it locally. Along with the stat info about the local destination, // we have everything we need to handle the multiple possibilities there // can be when copying a file/dir from one location to another file/dir. stat, err := getContainerPathStatFromHeader(resp.Header) if err != nil { return nil, stat, fmt.Errorf("unable to get resource stat from response: %s", err) } return resp.Body, stat, err } func getContainerPathStatFromHeader(header http.Header) (container.PathStat, error) { var stat container.PathStat encodedStat := header.Get("X-Docker-Container-Path-Stat") statDecoder := base64.NewDecoder(base64.StdEncoding, strings.NewReader(encodedStat)) err := json.NewDecoder(statDecoder).Decode(&stat) if err != nil { err = fmt.Errorf("unable to decode container path stat header: %s", err) } return stat, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/volume_update.go
vendor/github.com/docker/docker/client/volume_update.go
package client import ( "context" "net/url" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/volume" ) // VolumeUpdate updates a volume. This only works for Cluster Volumes, and // only some fields can be updated. func (cli *Client) VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error { volumeID, err := trimID("volume", volumeID) if err != nil { return err } if err := cli.NewVersionError(ctx, "1.42", "volume update"); err != nil { return err } query := url.Values{} query.Set("version", version.String()) resp, err := cli.put(ctx, "/volumes/"+volumeID, query, options, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_attach.go
vendor/github.com/docker/docker/client/container_attach.go
package client import ( "context" "net/http" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" ) // ContainerAttach attaches a connection to a container in the server. // It returns a types.HijackedConnection with the hijacked connection // and the a reader to get output. It's up to the called to close // the hijacked connection by calling types.HijackedResponse.Close. // // The stream format on the response will be in one of two formats: // // If the container is using a TTY, there is only a single stream (stdout), and // data is copied directly from the container output stream, no extra // multiplexing or headers. // // If the container is *not* using a TTY, streams for stdout and stderr are // multiplexed. // The format of the multiplexed stream is as follows: // // [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT} // // STREAM_TYPE can be 1 for stdout and 2 for stderr // // SIZE1, SIZE2, SIZE3, and SIZE4 are four bytes of uint32 encoded as big endian. // This is the size of OUTPUT. // // You can use github.com/docker/docker/pkg/stdcopy.StdCopy to demultiplex this // stream. func (cli *Client) ContainerAttach(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error) { containerID, err := trimID("container", containerID) if err != nil { return types.HijackedResponse{}, err } query := url.Values{} if options.Stream { query.Set("stream", "1") } if options.Stdin { query.Set("stdin", "1") } if options.Stdout { query.Set("stdout", "1") } if options.Stderr { query.Set("stderr", "1") } if options.DetachKeys != "" { query.Set("detachKeys", options.DetachKeys) } if options.Logs { query.Set("logs", "1") } return cli.postHijacked(ctx, "/containers/"+containerID+"/attach", query, nil, http.Header{ "Content-Type": {"text/plain"}, }) }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/service_remove.go
vendor/github.com/docker/docker/client/service_remove.go
package client import "context" // ServiceRemove kills and removes a service. func (cli *Client) ServiceRemove(ctx context.Context, serviceID string) error { serviceID, err := trimID("service", serviceID) if err != nil { return err } resp, err := cli.delete(ctx, "/services/"+serviceID, nil, nil) defer ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_commit.go
vendor/github.com/docker/docker/client/container_commit.go
package client import ( "context" "encoding/json" "errors" "net/url" "github.com/distribution/reference" "github.com/docker/docker/api/types/container" ) // ContainerCommit applies changes to a container and creates a new tagged image. func (cli *Client) ContainerCommit(ctx context.Context, containerID string, options container.CommitOptions) (container.CommitResponse, error) { containerID, err := trimID("container", containerID) if err != nil { return container.CommitResponse{}, err } var repository, tag string if options.Reference != "" { ref, err := reference.ParseNormalizedNamed(options.Reference) if err != nil { return container.CommitResponse{}, err } if _, isCanonical := ref.(reference.Canonical); isCanonical { return container.CommitResponse{}, errors.New("refusing to create a tag with a digest reference") } ref = reference.TagNameOnly(ref) if tagged, ok := ref.(reference.Tagged); ok { tag = tagged.Tag() } repository = ref.Name() } query := url.Values{} query.Set("container", containerID) query.Set("repo", repository) query.Set("tag", tag) query.Set("comment", options.Comment) query.Set("author", options.Author) for _, change := range options.Changes { query.Add("changes", change) } if !options.Pause { query.Set("pause", "0") } var response container.CommitResponse resp, err := cli.post(ctx, "/commit", query, options.Config, nil) defer ensureReaderClosed(resp) if err != nil { return response, err } err = json.NewDecoder(resp.Body).Decode(&response) return response, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/ping.go
vendor/github.com/docker/docker/client/ping.go
package client import ( "context" "net/http" "path" "strings" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/build" "github.com/docker/docker/api/types/swarm" ) // Ping pings the server and returns the value of the "Docker-Experimental", // "Builder-Version", "OS-Type" & "API-Version" headers. It attempts to use // a HEAD request on the endpoint, but falls back to GET if HEAD is not supported // by the daemon. It ignores internal server errors returned by the API, which // may be returned if the daemon is in an unhealthy state, but returns errors // for other non-success status codes, failing to connect to the API, or failing // to parse the API response. func (cli *Client) Ping(ctx context.Context) (types.Ping, error) { var ping types.Ping // Using cli.buildRequest() + cli.doRequest() instead of cli.sendRequest() // because ping requests are used during API version negotiation, so we want // to hit the non-versioned /_ping endpoint, not /v1.xx/_ping req, err := cli.buildRequest(ctx, http.MethodHead, path.Join(cli.basePath, "/_ping"), nil, nil) if err != nil { return ping, err } resp, err := cli.doRequest(req) if err != nil { if IsErrConnectionFailed(err) { return ping, err } // We managed to connect, but got some error; continue and try GET request. } else { defer ensureReaderClosed(resp) switch resp.StatusCode { case http.StatusOK, http.StatusInternalServerError: // Server handled the request, so parse the response return parsePingResponse(cli, resp) } } // HEAD failed; fallback to GET. req.Method = http.MethodGet resp, err = cli.doRequest(req) defer ensureReaderClosed(resp) if err != nil { return ping, err } return parsePingResponse(cli, resp) } func parsePingResponse(cli *Client, resp *http.Response) (types.Ping, error) { if resp == nil { return types.Ping{}, nil } var ping types.Ping if resp.Header == nil { return ping, cli.checkResponseErr(resp) } ping.APIVersion = resp.Header.Get("Api-Version") ping.OSType = resp.Header.Get("Ostype") if resp.Header.Get("Docker-Experimental") == "true" { ping.Experimental = true } if bv := resp.Header.Get("Builder-Version"); bv != "" { ping.BuilderVersion = build.BuilderVersion(bv) } if si := resp.Header.Get("Swarm"); si != "" { state, role, _ := strings.Cut(si, "/") ping.SwarmStatus = &swarm.Status{ NodeState: swarm.LocalNodeState(state), ControlAvailable: role == "manager", } } return ping, cli.checkResponseErr(resp) }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/node_update.go
vendor/github.com/docker/docker/client/node_update.go
package client import ( "context" "net/url" "github.com/docker/docker/api/types/swarm" ) // NodeUpdate updates a Node. func (cli *Client) NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error { nodeID, err := trimID("node", nodeID) if err != nil { return err } query := url.Values{} query.Set("version", version.String()) resp, err := cli.post(ctx, "/nodes/"+nodeID+"/update", query, node, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/network_connect.go
vendor/github.com/docker/docker/client/network_connect.go
package client import ( "context" "github.com/docker/docker/api/types/network" ) // NetworkConnect connects a container to an existent network in the docker host. func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error { networkID, err := trimID("network", networkID) if err != nil { return err } containerID, err = trimID("container", containerID) if err != nil { return err } nc := network.ConnectOptions{ Container: containerID, EndpointConfig: config, } resp, err := cli.post(ctx, "/networks/"+networkID+"/connect", nil, nc, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_stop.go
vendor/github.com/docker/docker/client/container_stop.go
package client import ( "context" "net/url" "strconv" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/versions" ) // ContainerStop stops a container. In case the container fails to stop // gracefully within a time frame specified by the timeout argument, // it is forcefully terminated (killed). // // If the timeout is nil, the container's StopTimeout value is used, if set, // otherwise the engine default. A negative timeout value can be specified, // meaning no timeout, i.e. no forceful termination is performed. func (cli *Client) ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error { containerID, err := trimID("container", containerID) if err != nil { return err } query := url.Values{} if options.Timeout != nil { query.Set("t", strconv.Itoa(*options.Timeout)) } if options.Signal != "" { // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // // Normally, version-negotiation (if enabled) would not happen until // the API request is made. if err := cli.checkVersion(ctx); err != nil { return err } if versions.GreaterThanOrEqualTo(cli.version, "1.42") { query.Set("signal", options.Signal) } } resp, err := cli.post(ctx, "/containers/"+containerID+"/stop", query, nil, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/secret_remove.go
vendor/github.com/docker/docker/client/secret_remove.go
package client import "context" // SecretRemove removes a secret. func (cli *Client) SecretRemove(ctx context.Context, id string) error { id, err := trimID("secret", id) if err != nil { return err } if err := cli.NewVersionError(ctx, "1.25", "secret remove"); err != nil { return err } resp, err := cli.delete(ctx, "/secrets/"+id, nil, nil) defer ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/node_inspect.go
vendor/github.com/docker/docker/client/node_inspect.go
package client import ( "bytes" "context" "encoding/json" "io" "github.com/docker/docker/api/types/swarm" ) // NodeInspectWithRaw returns the node information. func (cli *Client) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error) { nodeID, err := trimID("node", nodeID) if err != nil { return swarm.Node{}, nil, err } resp, err := cli.get(ctx, "/nodes/"+nodeID, nil, nil) defer ensureReaderClosed(resp) if err != nil { return swarm.Node{}, nil, err } body, err := io.ReadAll(resp.Body) if err != nil { return swarm.Node{}, nil, err } var response swarm.Node rdr := bytes.NewReader(body) err = json.NewDecoder(rdr).Decode(&response) return response, body, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/service_list.go
vendor/github.com/docker/docker/client/service_list.go
package client import ( "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" ) // ServiceList returns the list of services. func (cli *Client) ServiceList(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) { query := url.Values{} if options.Filters.Len() > 0 { filterJSON, err := filters.ToJSON(options.Filters) if err != nil { return nil, err } query.Set("filters", filterJSON) } if options.Status { query.Set("status", "true") } resp, err := cli.get(ctx, "/services", query, nil) defer ensureReaderClosed(resp) if err != nil { return nil, err } var services []swarm.Service err = json.NewDecoder(resp.Body).Decode(&services) return services, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_stats.go
vendor/github.com/docker/docker/client/container_stats.go
package client import ( "context" "net/url" "github.com/docker/docker/api/types/container" ) // ContainerStats returns near realtime stats for a given container. // It's up to the caller to close the io.ReadCloser returned. func (cli *Client) ContainerStats(ctx context.Context, containerID string, stream bool) (container.StatsResponseReader, error) { containerID, err := trimID("container", containerID) if err != nil { return container.StatsResponseReader{}, err } query := url.Values{} query.Set("stream", "0") if stream { query.Set("stream", "1") } resp, err := cli.get(ctx, "/containers/"+containerID+"/stats", query, nil) if err != nil { return container.StatsResponseReader{}, err } return container.StatsResponseReader{ Body: resp.Body, OSType: resp.Header.Get("Ostype"), }, nil } // ContainerStatsOneShot gets a single stat entry from a container. // It differs from `ContainerStats` in that the API should not wait to prime the stats func (cli *Client) ContainerStatsOneShot(ctx context.Context, containerID string) (container.StatsResponseReader, error) { containerID, err := trimID("container", containerID) if err != nil { return container.StatsResponseReader{}, err } query := url.Values{} query.Set("stream", "0") query.Set("one-shot", "1") resp, err := cli.get(ctx, "/containers/"+containerID+"/stats", query, nil) if err != nil { return container.StatsResponseReader{}, err } return container.StatsResponseReader{ Body: resp.Body, OSType: resp.Header.Get("Ostype"), }, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/client_deprecated.go
vendor/github.com/docker/docker/client/client_deprecated.go
package client import "net/http" // NewClient initializes a new API client for the given host and API version. // It uses the given http client as transport. // It also initializes the custom http headers to add to each request. // // It won't send any version information if the version number is empty. It is // highly recommended that you set a version or your client may break if the // server is upgraded. // // Deprecated: use [NewClientWithOpts] passing the [WithHost], [WithVersion], // [WithHTTPClient] and [WithHTTPHeaders] options. We recommend enabling API // version negotiation by passing the [WithAPIVersionNegotiation] option instead // of WithVersion. func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) { return NewClientWithOpts(WithHost(host), WithVersion(version), WithHTTPClient(client), WithHTTPHeaders(httpHeaders)) } // NewEnvClient initializes a new API client based on environment variables. // See FromEnv for a list of support environment variables. // // Deprecated: use [NewClientWithOpts] passing the [FromEnv] option. func NewEnvClient() (*Client, error) { return NewClientWithOpts(FromEnv) }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/plugin_enable.go
vendor/github.com/docker/docker/client/plugin_enable.go
package client import ( "context" "net/url" "strconv" "github.com/docker/docker/api/types" ) // PluginEnable enables a plugin func (cli *Client) PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error { name, err := trimID("plugin", name) if err != nil { return err } query := url.Values{} query.Set("timeout", strconv.Itoa(options.Timeout)) resp, err := cli.post(ctx, "/plugins/"+name+"/enable", query, nil, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/secret_inspect.go
vendor/github.com/docker/docker/client/secret_inspect.go
package client import ( "bytes" "context" "encoding/json" "io" "github.com/docker/docker/api/types/swarm" ) // SecretInspectWithRaw returns the secret information with raw data func (cli *Client) SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error) { id, err := trimID("secret", id) if err != nil { return swarm.Secret{}, nil, err } if err := cli.NewVersionError(ctx, "1.25", "secret inspect"); err != nil { return swarm.Secret{}, nil, err } resp, err := cli.get(ctx, "/secrets/"+id, nil, nil) defer ensureReaderClosed(resp) if err != nil { return swarm.Secret{}, nil, err } body, err := io.ReadAll(resp.Body) if err != nil { return swarm.Secret{}, nil, err } var secret swarm.Secret rdr := bytes.NewReader(body) err = json.NewDecoder(rdr).Decode(&secret) return secret, body, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/volume_prune.go
vendor/github.com/docker/docker/client/volume_prune.go
package client import ( "context" "encoding/json" "fmt" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/volume" ) // VolumesPrune requests the daemon to delete unused data func (cli *Client) VolumesPrune(ctx context.Context, pruneFilters filters.Args) (volume.PruneReport, error) { if err := cli.NewVersionError(ctx, "1.25", "volume prune"); err != nil { return volume.PruneReport{}, err } query, err := getFiltersQuery(pruneFilters) if err != nil { return volume.PruneReport{}, err } resp, err := cli.post(ctx, "/volumes/prune", query, nil, nil) defer ensureReaderClosed(resp) if err != nil { return volume.PruneReport{}, err } var report volume.PruneReport if err := json.NewDecoder(resp.Body).Decode(&report); err != nil { return volume.PruneReport{}, fmt.Errorf("Error retrieving volume prune report: %v", err) } return report, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_push.go
vendor/github.com/docker/docker/client/image_push.go
package client import ( "context" "encoding/json" "errors" "fmt" "io" "net/http" "net/url" cerrdefs "github.com/containerd/errdefs" "github.com/distribution/reference" "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" ) // ImagePush requests the docker host to push an image to a remote registry. // It executes the privileged function if the operation is unauthorized // and it tries one more time. // It's up to the caller to handle the io.ReadCloser and close it properly. func (cli *Client) ImagePush(ctx context.Context, image string, options image.PushOptions) (io.ReadCloser, error) { ref, err := reference.ParseNormalizedNamed(image) if err != nil { return nil, err } if _, isCanonical := ref.(reference.Canonical); isCanonical { return nil, errors.New("cannot push a digest reference") } query := url.Values{} if !options.All { ref = reference.TagNameOnly(ref) if tagged, ok := ref.(reference.Tagged); ok { query.Set("tag", tagged.Tag()) } } if options.Platform != nil { if err := cli.NewVersionError(ctx, "1.46", "platform"); err != nil { return nil, err } p := *options.Platform pJson, err := json.Marshal(p) if err != nil { return nil, fmt.Errorf("invalid platform: %v", err) } query.Set("platform", string(pJson)) } resp, err := cli.tryImagePush(ctx, ref.Name(), query, options.RegistryAuth) if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil { newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx) if privilegeErr != nil { return nil, privilegeErr } resp, err = cli.tryImagePush(ctx, ref.Name(), query, newAuthHeader) } if err != nil { return nil, err } return resp.Body, nil } func (cli *Client) tryImagePush(ctx context.Context, imageID string, query url.Values, registryAuth string) (*http.Response, error) { // Always send a body (which may be an empty JSON document ("{}")) to prevent // EOF errors on older daemons which had faulty fallback code for handling // authentication in the body when no auth-header was set, resulting in; // // Error response from daemon: bad parameters and missing X-Registry-Auth: invalid X-Registry-Auth header: EOF // // We use [http.NoBody], which gets marshaled to an empty JSON document. // // see: https://github.com/moby/moby/commit/ea29dffaa541289591aa44fa85d2a596ce860e16 return cli.post(ctx, "/images/"+imageID+"/push", query, http.NoBody, http.Header{ registry.AuthHeader: {registryAuth}, }) }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/plugin_set.go
vendor/github.com/docker/docker/client/plugin_set.go
package client import ( "context" ) // PluginSet modifies settings for an existing plugin func (cli *Client) PluginSet(ctx context.Context, name string, args []string) error { name, err := trimID("plugin", name) if err != nil { return err } resp, err := cli.post(ctx, "/plugins/"+name+"/set", nil, args, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/volume_create.go
vendor/github.com/docker/docker/client/volume_create.go
package client import ( "context" "encoding/json" "github.com/docker/docker/api/types/volume" ) // VolumeCreate creates a volume in the docker host. func (cli *Client) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) { resp, err := cli.post(ctx, "/volumes/create", nil, options, nil) defer ensureReaderClosed(resp) if err != nil { return volume.Volume{}, err } var vol volume.Volume err = json.NewDecoder(resp.Body).Decode(&vol) return vol, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_kill.go
vendor/github.com/docker/docker/client/container_kill.go
package client import ( "context" "net/url" ) // ContainerKill terminates the container process but does not remove the container from the docker host. func (cli *Client) ContainerKill(ctx context.Context, containerID, signal string) error { containerID, err := trimID("container", containerID) if err != nil { return err } query := url.Values{} if signal != "" { query.Set("signal", signal) } resp, err := cli.post(ctx, "/containers/"+containerID+"/kill", query, nil, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/disk_usage.go
vendor/github.com/docker/docker/client/disk_usage.go
package client import ( "context" "encoding/json" "fmt" "net/url" "github.com/docker/docker/api/types" ) // DiskUsage requests the current data usage from the daemon func (cli *Client) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) { var query url.Values if len(options.Types) > 0 { query = url.Values{} for _, t := range options.Types { query.Add("type", string(t)) } } resp, err := cli.get(ctx, "/system/df", query, nil) defer ensureReaderClosed(resp) if err != nil { return types.DiskUsage{}, err } var du types.DiskUsage if err := json.NewDecoder(resp.Body).Decode(&du); err != nil { return types.DiskUsage{}, fmt.Errorf("Error retrieving disk usage: %v", err) } return du, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/build_cancel.go
vendor/github.com/docker/docker/client/build_cancel.go
package client import ( "context" "net/url" ) // BuildCancel requests the daemon to cancel the ongoing build request. func (cli *Client) BuildCancel(ctx context.Context, id string) error { query := url.Values{} query.Set("id", id) resp, err := cli.post(ctx, "/build/cancel", query, nil, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/volume_list.go
vendor/github.com/docker/docker/client/volume_list.go
package client import ( "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/volume" ) // VolumeList returns the volumes configured in the docker host. func (cli *Client) VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) { query := url.Values{} if options.Filters.Len() > 0 { //nolint:staticcheck // ignore SA1019 for old code filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters) if err != nil { return volume.ListResponse{}, err } query.Set("filters", filterJSON) } resp, err := cli.get(ctx, "/volumes", query, nil) defer ensureReaderClosed(resp) if err != nil { return volume.ListResponse{}, err } var volumes volume.ListResponse err = json.NewDecoder(resp.Body).Decode(&volumes) return volumes, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/client_windows.go
vendor/github.com/docker/docker/client/client_windows.go
package client import ( "context" "net" "github.com/Microsoft/go-winio" ) // DefaultDockerHost defines OS-specific default host if the DOCKER_HOST // (EnvOverrideHost) environment variable is unset or empty. const DefaultDockerHost = "npipe:////./pipe/docker_engine" // dialPipeContext connects to a Windows named pipe. It is not supported on non-Windows. func dialPipeContext(ctx context.Context, addr string) (net.Conn, error) { return winio.DialPipeContext(ctx, addr) }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/checkpoint_delete.go
vendor/github.com/docker/docker/client/checkpoint_delete.go
package client import ( "context" "net/url" "github.com/docker/docker/api/types/checkpoint" ) // CheckpointDelete deletes the checkpoint with the given name from the given container func (cli *Client) CheckpointDelete(ctx context.Context, containerID string, options checkpoint.DeleteOptions) error { containerID, err := trimID("container", containerID) if err != nil { return err } query := url.Values{} if options.CheckpointDir != "" { query.Set("dir", options.CheckpointDir) } resp, err := cli.delete(ctx, "/containers/"+containerID+"/checkpoints/"+options.CheckpointID, query, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_create.go
vendor/github.com/docker/docker/client/container_create.go
package client import ( "context" "encoding/json" "errors" "net/url" "path" "sort" "strings" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/versions" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) // ContainerCreate creates a new container based on the given configuration. // It can be associated with a name, but it's not mandatory. func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) { var response container.CreateResponse // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // // Normally, version-negotiation (if enabled) would not happen until // the API request is made. if err := cli.checkVersion(ctx); err != nil { return response, err } if err := cli.NewVersionError(ctx, "1.25", "stop timeout"); config != nil && config.StopTimeout != nil && err != nil { return response, err } if err := cli.NewVersionError(ctx, "1.41", "specify container image platform"); platform != nil && err != nil { return response, err } if err := cli.NewVersionError(ctx, "1.44", "specify health-check start interval"); config != nil && config.Healthcheck != nil && config.Healthcheck.StartInterval != 0 && err != nil { return response, err } if err := cli.NewVersionError(ctx, "1.44", "specify mac-address per network"); hasEndpointSpecificMacAddress(networkingConfig) && err != nil { return response, err } if hostConfig != nil { if versions.LessThan(cli.ClientVersion(), "1.25") { // When using API 1.24 and under, the client is responsible for removing the container hostConfig.AutoRemove = false } if versions.GreaterThanOrEqualTo(cli.ClientVersion(), "1.42") || versions.LessThan(cli.ClientVersion(), "1.40") { // KernelMemory was added in API 1.40, and deprecated in API 1.42 hostConfig.KernelMemory = 0 } if platform != nil && platform.OS == "linux" && versions.LessThan(cli.ClientVersion(), "1.42") { // When using API under 1.42, the Linux daemon doesn't respect the ConsoleSize hostConfig.ConsoleSize = [2]uint{0, 0} } if versions.LessThan(cli.ClientVersion(), "1.44") { for _, m := range hostConfig.Mounts { if m.BindOptions != nil { // ReadOnlyNonRecursive can be safely ignored when API < 1.44 if m.BindOptions.ReadOnlyForceRecursive { return response, errors.New("bind-recursive=readonly requires API v1.44 or later") } if m.BindOptions.NonRecursive && versions.LessThan(cli.ClientVersion(), "1.40") { return response, errors.New("bind-recursive=disabled requires API v1.40 or later") } } } } hostConfig.CapAdd = normalizeCapabilities(hostConfig.CapAdd) hostConfig.CapDrop = normalizeCapabilities(hostConfig.CapDrop) } // Since API 1.44, the container-wide MacAddress is deprecated and will trigger a WARNING if it's specified. if versions.GreaterThanOrEqualTo(cli.ClientVersion(), "1.44") { config.MacAddress = "" //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44. } query := url.Values{} if p := formatPlatform(platform); p != "" { query.Set("platform", p) } if containerName != "" { query.Set("name", containerName) } body := container.CreateRequest{ Config: config, HostConfig: hostConfig, NetworkingConfig: networkingConfig, } resp, err := cli.post(ctx, "/containers/create", query, body, nil) defer ensureReaderClosed(resp) if err != nil { return response, err } err = json.NewDecoder(resp.Body).Decode(&response) return response, err } // formatPlatform returns a formatted string representing platform (e.g. linux/arm/v7). // // Similar to containerd's platforms.Format(), but does allow components to be // omitted (e.g. pass "architecture" only, without "os": // https://github.com/containerd/containerd/blob/v1.5.2/platforms/platforms.go#L243-L263 func formatPlatform(platform *ocispec.Platform) string { if platform == nil { return "" } return path.Join(platform.OS, platform.Architecture, platform.Variant) } // hasEndpointSpecificMacAddress checks whether one of the endpoint in networkingConfig has a MacAddress defined. func hasEndpointSpecificMacAddress(networkingConfig *network.NetworkingConfig) bool { if networkingConfig == nil { return false } for _, endpoint := range networkingConfig.EndpointsConfig { if endpoint.MacAddress != "" { return true } } return false } // allCapabilities is a magic value for "all capabilities" const allCapabilities = "ALL" // normalizeCapabilities normalizes capabilities to their canonical form, // removes duplicates, and sorts the results. // // It is similar to [github.com/docker/docker/oci/caps.NormalizeLegacyCapabilities], // but performs no validation based on supported capabilities. func normalizeCapabilities(caps []string) []string { var normalized []string unique := make(map[string]struct{}) for _, c := range caps { c = normalizeCap(c) if _, ok := unique[c]; ok { continue } unique[c] = struct{}{} normalized = append(normalized, c) } sort.Strings(normalized) return normalized } // normalizeCap normalizes a capability to its canonical format by upper-casing // and adding a "CAP_" prefix (if not yet present). It also accepts the "ALL" // magic-value. func normalizeCap(cap string) string { cap = strings.ToUpper(cap) if cap == allCapabilities { return cap } if !strings.HasPrefix(cap, "CAP_") { cap = "CAP_" + cap } return cap }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/config_update.go
vendor/github.com/docker/docker/client/config_update.go
package client import ( "context" "net/url" "github.com/docker/docker/api/types/swarm" ) // ConfigUpdate attempts to update a config func (cli *Client) ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error { id, err := trimID("config", id) if err != nil { return err } if err := cli.NewVersionError(ctx, "1.30", "config update"); err != nil { return err } query := url.Values{} query.Set("version", version.String()) resp, err := cli.post(ctx, "/configs/"+id+"/update", query, config, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/network_inspect.go
vendor/github.com/docker/docker/client/network_inspect.go
package client import ( "bytes" "context" "encoding/json" "io" "net/url" "github.com/docker/docker/api/types/network" ) // NetworkInspect returns the information for a specific network configured in the docker host. func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, 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 network.InspectOptions) (network.Inspect, []byte, error) { networkID, err := trimID("network", networkID) if err != nil { return network.Inspect{}, nil, err } 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 network.Inspect{}, nil, err } raw, err := io.ReadAll(resp.Body) if err != nil { return network.Inspect{}, nil, err } var nw network.Inspect err = json.NewDecoder(bytes.NewReader(raw)).Decode(&nw) return nw, raw, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/service_logs.go
vendor/github.com/docker/docker/client/service_logs.go
package client import ( "context" "io" "net/url" "time" "github.com/docker/docker/api/types/container" timetypes "github.com/docker/docker/api/types/time" "github.com/pkg/errors" ) // ServiceLogs returns the logs generated by a service in an io.ReadCloser. // It's up to the caller to close the stream. func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error) { serviceID, err := trimID("service", serviceID) if err != nil { return nil, err } query := url.Values{} if options.ShowStdout { query.Set("stdout", "1") } if options.ShowStderr { query.Set("stderr", "1") } if options.Since != "" { ts, err := timetypes.GetTimestamp(options.Since, time.Now()) if err != nil { return nil, errors.Wrap(err, `invalid value for "since"`) } query.Set("since", ts) } if options.Timestamps { query.Set("timestamps", "1") } if options.Details { query.Set("details", "1") } if options.Follow { query.Set("follow", "1") } query.Set("tail", options.Tail) resp, err := cli.get(ctx, "/services/"+serviceID+"/logs", query, nil) if err != nil { return nil, err } return resp.Body, nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/service_create.go
vendor/github.com/docker/docker/client/service_create.go
package client import ( "context" "encoding/json" "fmt" "net/http" "strings" "github.com/distribution/reference" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/versions" "github.com/opencontainers/go-digest" "github.com/pkg/errors" ) // ServiceCreate creates a new service. func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options swarm.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) { var response swarm.ServiceCreateResponse // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // // Normally, version-negotiation (if enabled) would not happen until // the API request is made. if err := cli.checkVersion(ctx); err != nil { return response, err } // Make sure containerSpec is not nil when no runtime is set or the runtime is set to container if service.TaskTemplate.ContainerSpec == nil && (service.TaskTemplate.Runtime == "" || service.TaskTemplate.Runtime == swarm.RuntimeContainer) { service.TaskTemplate.ContainerSpec = &swarm.ContainerSpec{} } if err := validateServiceSpec(service); err != nil { return response, err } if versions.LessThan(cli.version, "1.30") { if err := validateAPIVersion(service, cli.version); err != nil { return response, err } } // ensure that the image is tagged var resolveWarning string switch { case service.TaskTemplate.ContainerSpec != nil: if taggedImg := imageWithTagString(service.TaskTemplate.ContainerSpec.Image); taggedImg != "" { service.TaskTemplate.ContainerSpec.Image = taggedImg } if options.QueryRegistry { resolveWarning = resolveContainerSpecImage(ctx, cli, &service.TaskTemplate, options.EncodedRegistryAuth) } case service.TaskTemplate.PluginSpec != nil: if taggedImg := imageWithTagString(service.TaskTemplate.PluginSpec.Remote); taggedImg != "" { service.TaskTemplate.PluginSpec.Remote = taggedImg } if options.QueryRegistry { resolveWarning = resolvePluginSpecRemote(ctx, cli, &service.TaskTemplate, options.EncodedRegistryAuth) } } headers := http.Header{} if versions.LessThan(cli.version, "1.30") { // the custom "version" header was used by engine API before 20.10 // (API 1.30) to switch between client- and server-side lookup of // image digests. headers["version"] = []string{cli.version} } if options.EncodedRegistryAuth != "" { headers[registry.AuthHeader] = []string{options.EncodedRegistryAuth} } resp, err := cli.post(ctx, "/services/create", nil, service, headers) defer ensureReaderClosed(resp) if err != nil { return response, err } err = json.NewDecoder(resp.Body).Decode(&response) if resolveWarning != "" { response.Warnings = append(response.Warnings, resolveWarning) } return response, err } func resolveContainerSpecImage(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string { var warning string if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.ContainerSpec.Image, encodedAuth); err != nil { warning = digestWarning(taskSpec.ContainerSpec.Image) } else { taskSpec.ContainerSpec.Image = img if len(imgPlatforms) > 0 { if taskSpec.Placement == nil { taskSpec.Placement = &swarm.Placement{} } taskSpec.Placement.Platforms = imgPlatforms } } return warning } func resolvePluginSpecRemote(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string { var warning string if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.PluginSpec.Remote, encodedAuth); err != nil { warning = digestWarning(taskSpec.PluginSpec.Remote) } else { taskSpec.PluginSpec.Remote = img if len(imgPlatforms) > 0 { if taskSpec.Placement == nil { taskSpec.Placement = &swarm.Placement{} } taskSpec.Placement.Platforms = imgPlatforms } } return warning } func imageDigestAndPlatforms(ctx context.Context, cli DistributionAPIClient, image, encodedAuth string) (string, []swarm.Platform, error) { distributionInspect, err := cli.DistributionInspect(ctx, image, encodedAuth) var platforms []swarm.Platform if err != nil { return "", nil, err } imageWithDigest := imageWithDigestString(image, distributionInspect.Descriptor.Digest) if len(distributionInspect.Platforms) > 0 { platforms = make([]swarm.Platform, 0, len(distributionInspect.Platforms)) for _, p := range distributionInspect.Platforms { // clear architecture field for arm. This is a temporary patch to address // https://github.com/docker/swarmkit/issues/2294. The issue is that while // image manifests report "arm" as the architecture, the node reports // something like "armv7l" (includes the variant), which causes arm images // to stop working with swarm mode. This patch removes the architecture // constraint for arm images to ensure tasks get scheduled. arch := p.Architecture if strings.ToLower(arch) == "arm" { arch = "" } platforms = append(platforms, swarm.Platform{ Architecture: arch, OS: p.OS, }) } } return imageWithDigest, platforms, err } // imageWithDigestString takes an image string and a digest, and updates // the image string if it didn't originally contain a digest. It returns // image unmodified in other situations. func imageWithDigestString(image string, dgst digest.Digest) string { namedRef, err := reference.ParseNormalizedNamed(image) if err == nil { if _, isCanonical := namedRef.(reference.Canonical); !isCanonical { // ensure that image gets a default tag if none is provided img, err := reference.WithDigest(namedRef, dgst) if err == nil { return reference.FamiliarString(img) } } } return image } // imageWithTagString takes an image string, and returns a tagged image // string, adding a 'latest' tag if one was not provided. It returns an // empty string if a canonical reference was provided func imageWithTagString(image string) string { namedRef, err := reference.ParseNormalizedNamed(image) if err == nil { return reference.FamiliarString(reference.TagNameOnly(namedRef)) } return "" } // digestWarning constructs a formatted warning string using the // image name that could not be pinned by digest. The formatting // is hardcoded, but could me made smarter in the future func digestWarning(image string) string { return fmt.Sprintf("image %s could not be accessed on a registry to record\nits digest. Each node will access %s independently,\npossibly leading to different nodes running different\nversions of the image.\n", image, image) } func validateServiceSpec(s swarm.ServiceSpec) error { if s.TaskTemplate.ContainerSpec != nil && s.TaskTemplate.PluginSpec != nil { return errors.New("must not specify both a container spec and a plugin spec in the task template") } if s.TaskTemplate.PluginSpec != nil && s.TaskTemplate.Runtime != swarm.RuntimePlugin { return errors.New("mismatched runtime with plugin spec") } if s.TaskTemplate.ContainerSpec != nil && (s.TaskTemplate.Runtime != "" && s.TaskTemplate.Runtime != swarm.RuntimeContainer) { return errors.New("mismatched runtime with container spec") } return nil } func validateAPIVersion(c swarm.ServiceSpec, apiVersion string) error { for _, m := range c.TaskTemplate.ContainerSpec.Mounts { if m.BindOptions != nil { if m.BindOptions.NonRecursive && versions.LessThan(apiVersion, "1.40") { return errors.Errorf("bind-recursive=disabled requires API v1.40 or later") } // ReadOnlyNonRecursive can be safely ignored when API < 1.44 if m.BindOptions.ReadOnlyForceRecursive && versions.LessThan(apiVersion, "1.44") { return errors.Errorf("bind-recursive=readonly requires API v1.44 or later") } } } return nil }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_tag.go
vendor/github.com/docker/docker/client/image_tag.go
package client import ( "context" "net/url" "github.com/distribution/reference" "github.com/pkg/errors" ) // ImageTag tags an image in the docker host func (cli *Client) ImageTag(ctx context.Context, source, target string) error { if _, err := reference.ParseAnyReference(source); err != nil { return errors.Wrapf(err, "Error parsing reference: %q is not a valid repository/tag", source) } ref, err := reference.ParseNormalizedNamed(target) if err != nil { return errors.Wrapf(err, "Error parsing reference: %q is not a valid repository/tag", target) } if _, isCanonical := ref.(reference.Canonical); isCanonical { return errors.New("refusing to create a tag with a digest reference") } ref = reference.TagNameOnly(ref) query := url.Values{} query.Set("repo", ref.Name()) if tagged, ok := ref.(reference.Tagged); ok { query.Set("tag", tagged.Tag()) } resp, err := cli.post(ctx, "/images/"+source+"/tag", query, nil, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/plugin_list.go
vendor/github.com/docker/docker/client/plugin_list.go
package client import ( "context" "encoding/json" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" ) // PluginList returns the installed plugins func (cli *Client) PluginList(ctx context.Context, filter filters.Args) (types.PluginsListResponse, error) { var plugins types.PluginsListResponse query := url.Values{} if filter.Len() > 0 { //nolint:staticcheck // ignore SA1019 for old code filterJSON, err := filters.ToParamWithVersion(cli.version, filter) if err != nil { return plugins, err } query.Set("filters", filterJSON) } resp, err := cli.get(ctx, "/plugins", query, nil) defer ensureReaderClosed(resp) if err != nil { return plugins, err } err = json.NewDecoder(resp.Body).Decode(&plugins) return plugins, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/task_list.go
vendor/github.com/docker/docker/client/task_list.go
package client import ( "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" ) // TaskList returns the list of tasks. func (cli *Client) TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) { query := url.Values{} if options.Filters.Len() > 0 { filterJSON, err := filters.ToJSON(options.Filters) if err != nil { return nil, err } query.Set("filters", filterJSON) } resp, err := cli.get(ctx, "/tasks", query, nil) defer ensureReaderClosed(resp) if err != nil { return nil, err } var tasks []swarm.Task err = json.NewDecoder(resp.Body).Decode(&tasks) return tasks, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_rename.go
vendor/github.com/docker/docker/client/container_rename.go
package client import ( "context" "net/url" ) // ContainerRename changes the name of a given container. func (cli *Client) ContainerRename(ctx context.Context, containerID, newContainerName string) error { containerID, err := trimID("container", containerID) if err != nil { return err } query := url.Values{} query.Set("name", newContainerName) resp, err := cli.post(ctx, "/containers/"+containerID+"/rename", query, nil, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/checkpoint_create.go
vendor/github.com/docker/docker/client/checkpoint_create.go
package client import ( "context" "github.com/docker/docker/api/types/checkpoint" ) // CheckpointCreate creates a checkpoint from the given container with the given name func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options checkpoint.CreateOptions) error { containerID, err := trimID("container", containerID) if err != nil { return err } resp, err := cli.post(ctx, "/containers/"+containerID+"/checkpoints", nil, options, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/checkpoint_list.go
vendor/github.com/docker/docker/client/checkpoint_list.go
package client import ( "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/checkpoint" ) // CheckpointList returns the checkpoints of the given container in the docker host func (cli *Client) CheckpointList(ctx context.Context, container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) { var checkpoints []checkpoint.Summary query := url.Values{} if options.CheckpointDir != "" { query.Set("dir", options.CheckpointDir) } resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", query, nil) defer ensureReaderClosed(resp) if err != nil { return checkpoints, err } err = json.NewDecoder(resp.Body).Decode(&checkpoints) return checkpoints, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/options.go
vendor/github.com/docker/docker/client/options.go
package client import ( "context" "net" "net/http" "os" "path/filepath" "strings" "time" "github.com/docker/go-connections/sockets" "github.com/docker/go-connections/tlsconfig" "github.com/pkg/errors" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" "go.opentelemetry.io/otel/trace" ) // Opt is a configuration option to initialize a [Client]. type Opt func(*Client) error // FromEnv configures the client with values from environment variables. It // is the equivalent of using the [WithTLSClientConfigFromEnv], [WithHostFromEnv], // and [WithVersionFromEnv] options. // // FromEnv uses the following environment variables: // // - DOCKER_HOST ([EnvOverrideHost]) to set the URL to the docker server. // - DOCKER_API_VERSION ([EnvOverrideAPIVersion]) to set the version of the // API to use, leave empty for latest. // - DOCKER_CERT_PATH ([EnvOverrideCertPath]) to specify the directory from // which to load the TLS certificates ("ca.pem", "cert.pem", "key.pem'). // - DOCKER_TLS_VERIFY ([EnvTLSVerify]) to enable or disable TLS verification // (off by default). func FromEnv(c *Client) error { ops := []Opt{ WithTLSClientConfigFromEnv(), WithHostFromEnv(), WithVersionFromEnv(), } for _, op := range ops { if err := op(c); err != nil { return err } } return nil } // WithDialContext applies the dialer to the client transport. This can be // used to set the Timeout and KeepAlive settings of the client. It returns // an error if the client does not have a [http.Transport] configured. func WithDialContext(dialContext func(ctx context.Context, network, addr string) (net.Conn, error)) Opt { return func(c *Client) error { if transport, ok := c.client.Transport.(*http.Transport); ok { transport.DialContext = dialContext return nil } return errors.Errorf("cannot apply dialer to transport: %T", c.client.Transport) } } // WithHost overrides the client host with the specified one. func WithHost(host string) Opt { return func(c *Client) error { hostURL, err := ParseHostURL(host) if err != nil { return err } c.host = host c.proto = hostURL.Scheme c.addr = hostURL.Host c.basePath = hostURL.Path if transport, ok := c.client.Transport.(*http.Transport); ok { return sockets.ConfigureTransport(transport, c.proto, c.addr) } return errors.Errorf("cannot apply host to transport: %T", c.client.Transport) } } // WithHostFromEnv overrides the client host with the host specified in the // DOCKER_HOST ([EnvOverrideHost]) environment variable. If DOCKER_HOST is not set, // or set to an empty value, the host is not modified. func WithHostFromEnv() Opt { return func(c *Client) error { if host := os.Getenv(EnvOverrideHost); host != "" { return WithHost(host)(c) } return nil } } // WithHTTPClient overrides the client's HTTP client with the specified one. func WithHTTPClient(client *http.Client) Opt { return func(c *Client) error { if client != nil { c.client = client } return nil } } // WithTimeout configures the time limit for requests made by the HTTP client. func WithTimeout(timeout time.Duration) Opt { return func(c *Client) error { c.client.Timeout = timeout return nil } } // WithUserAgent configures the User-Agent header to use for HTTP requests. // It overrides any User-Agent set in headers. When set to an empty string, // the User-Agent header is removed, and no header is sent. func WithUserAgent(ua string) Opt { return func(c *Client) error { c.userAgent = &ua return nil } } // WithHTTPHeaders appends custom HTTP headers to the client's default headers. // It does not allow for built-in headers (such as "User-Agent", if set) to // be overridden. Also see [WithUserAgent]. func WithHTTPHeaders(headers map[string]string) Opt { return func(c *Client) error { c.customHTTPHeaders = headers return nil } } // WithScheme overrides the client scheme with the specified one. func WithScheme(scheme string) Opt { return func(c *Client) error { c.scheme = scheme return nil } } // WithTLSClientConfig applies a TLS config to the client transport. func WithTLSClientConfig(cacertPath, certPath, keyPath string) Opt { return func(c *Client) error { transport, ok := c.client.Transport.(*http.Transport) if !ok { return errors.Errorf("cannot apply tls config to transport: %T", c.client.Transport) } config, err := tlsconfig.Client(tlsconfig.Options{ CAFile: cacertPath, CertFile: certPath, KeyFile: keyPath, ExclusiveRootPools: true, }) if err != nil { return errors.Wrap(err, "failed to create tls config") } transport.TLSClientConfig = config return nil } } // WithTLSClientConfigFromEnv configures the client's TLS settings with the // settings in the DOCKER_CERT_PATH ([EnvOverrideCertPath]) and DOCKER_TLS_VERIFY // ([EnvTLSVerify]) environment variables. If DOCKER_CERT_PATH is not set or empty, // TLS configuration is not modified. // // WithTLSClientConfigFromEnv uses the following environment variables: // // - DOCKER_CERT_PATH ([EnvOverrideCertPath]) to specify the directory from // which to load the TLS certificates ("ca.pem", "cert.pem", "key.pem"). // - DOCKER_TLS_VERIFY ([EnvTLSVerify]) to enable or disable TLS verification // (off by default). func WithTLSClientConfigFromEnv() Opt { return func(c *Client) error { dockerCertPath := os.Getenv(EnvOverrideCertPath) if dockerCertPath == "" { return nil } tlsc, err := tlsconfig.Client(tlsconfig.Options{ CAFile: filepath.Join(dockerCertPath, "ca.pem"), CertFile: filepath.Join(dockerCertPath, "cert.pem"), KeyFile: filepath.Join(dockerCertPath, "key.pem"), InsecureSkipVerify: os.Getenv(EnvTLSVerify) == "", }) if err != nil { return err } c.client = &http.Client{ Transport: &http.Transport{TLSClientConfig: tlsc}, CheckRedirect: CheckRedirect, } return nil } } // WithVersion overrides the client version with the specified one. If an empty // version is provided, the value is ignored to allow version negotiation // (see [WithAPIVersionNegotiation]). func WithVersion(version string) Opt { return func(c *Client) error { if v := strings.TrimPrefix(version, "v"); v != "" { c.version = v c.manualOverride = true } return nil } } // WithVersionFromEnv overrides the client version with the version specified in // the DOCKER_API_VERSION ([EnvOverrideAPIVersion]) environment variable. // If DOCKER_API_VERSION is not set, or set to an empty value, the version // is not modified. func WithVersionFromEnv() Opt { return func(c *Client) error { return WithVersion(os.Getenv(EnvOverrideAPIVersion))(c) } } // WithAPIVersionNegotiation enables automatic API version negotiation for the client. // With this option enabled, the client automatically negotiates the API version // to use when making requests. API version negotiation is performed on the first // request; subsequent requests do not re-negotiate. func WithAPIVersionNegotiation() Opt { return func(c *Client) error { c.negotiateVersion = true return nil } } // WithTraceProvider sets the trace provider for the client. // If this is not set then the global trace provider will be used. func WithTraceProvider(provider trace.TracerProvider) Opt { return WithTraceOptions(otelhttp.WithTracerProvider(provider)) } // WithTraceOptions sets tracing span options for the client. func WithTraceOptions(opts ...otelhttp.Option) Opt { return func(c *Client) error { c.traceOpts = append(c.traceOpts, opts...) return nil } }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/checkpoint.go
vendor/github.com/docker/docker/client/checkpoint.go
package client import ( "context" "github.com/docker/docker/api/types/checkpoint" ) // CheckpointAPIClient defines API client methods for the checkpoints. // // Experimental: checkpoint and restore is still an experimental feature, // and only available if the daemon is running with experimental features // enabled. type CheckpointAPIClient interface { CheckpointCreate(ctx context.Context, container string, options checkpoint.CreateOptions) error CheckpointDelete(ctx context.Context, container string, options checkpoint.DeleteOptions) error CheckpointList(ctx context.Context, container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/config_list.go
vendor/github.com/docker/docker/client/config_list.go
package client import ( "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" ) // ConfigList returns the list of configs. func (cli *Client) ConfigList(ctx context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) { if err := cli.NewVersionError(ctx, "1.30", "config list"); err != nil { return nil, err } query := url.Values{} if options.Filters.Len() > 0 { filterJSON, err := filters.ToJSON(options.Filters) if err != nil { return nil, err } query.Set("filters", filterJSON) } resp, err := cli.get(ctx, "/configs", query, nil) defer ensureReaderClosed(resp) if err != nil { return nil, err } var configs []swarm.Config err = json.NewDecoder(resp.Body).Decode(&configs) return configs, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_pause.go
vendor/github.com/docker/docker/client/container_pause.go
package client import "context" // ContainerPause pauses the main process of a given container without terminating it. func (cli *Client) ContainerPause(ctx context.Context, containerID string) error { containerID, err := trimID("container", containerID) if err != nil { return err } resp, err := cli.post(ctx, "/containers/"+containerID+"/pause", nil, nil, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_restart.go
vendor/github.com/docker/docker/client/container_restart.go
package client import ( "context" "net/url" "strconv" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/versions" ) // ContainerRestart stops and starts a container again. // It makes the daemon wait for the container to be up again for // a specific amount of time, given the timeout. func (cli *Client) ContainerRestart(ctx context.Context, containerID string, options container.StopOptions) error { containerID, err := trimID("container", containerID) if err != nil { return err } query := url.Values{} if options.Timeout != nil { query.Set("t", strconv.Itoa(*options.Timeout)) } if options.Signal != "" { // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // // Normally, version-negotiation (if enabled) would not happen until // the API request is made. if err := cli.checkVersion(ctx); err != nil { return err } if versions.GreaterThanOrEqualTo(cli.version, "1.42") { query.Set("signal", options.Signal) } } resp, err := cli.post(ctx, "/containers/"+containerID+"/restart", query, nil, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/secret_create.go
vendor/github.com/docker/docker/client/secret_create.go
package client import ( "context" "encoding/json" "github.com/docker/docker/api/types/swarm" ) // SecretCreate creates a new secret. func (cli *Client) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (swarm.SecretCreateResponse, error) { if err := cli.NewVersionError(ctx, "1.25", "secret create"); err != nil { return swarm.SecretCreateResponse{}, err } resp, err := cli.post(ctx, "/secrets/create", nil, secret, nil) defer ensureReaderClosed(resp) if err != nil { return swarm.SecretCreateResponse{}, err } var response swarm.SecretCreateResponse err = json.NewDecoder(resp.Body).Decode(&response) return response, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/service_inspect.go
vendor/github.com/docker/docker/client/service_inspect.go
package client import ( "bytes" "context" "encoding/json" "fmt" "io" "net/url" "github.com/docker/docker/api/types/swarm" ) // ServiceInspectWithRaw returns the service information and the raw data. func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error) { serviceID, err := trimID("service", serviceID) if err != nil { return swarm.Service{}, nil, err } query := url.Values{} query.Set("insertDefaults", fmt.Sprintf("%v", opts.InsertDefaults)) resp, err := cli.get(ctx, "/services/"+serviceID, query, nil) defer ensureReaderClosed(resp) if err != nil { return swarm.Service{}, nil, err } body, err := io.ReadAll(resp.Body) if err != nil { return swarm.Service{}, nil, err } var response swarm.Service rdr := bytes.NewReader(body) err = json.NewDecoder(rdr).Decode(&response) return response, body, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/swarm_join.go
vendor/github.com/docker/docker/client/swarm_join.go
package client import ( "context" "github.com/docker/docker/api/types/swarm" ) // SwarmJoin joins the swarm. func (cli *Client) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error { resp, err := cli.post(ctx, "/swarm/join", nil, req, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_list.go
vendor/github.com/docker/docker/client/container_list.go
package client import ( "context" "encoding/json" "net/url" "strconv" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" ) // ContainerList returns the list of containers in the docker host. func (cli *Client) ContainerList(ctx context.Context, options container.ListOptions) ([]container.Summary, error) { query := url.Values{} if options.All { query.Set("all", "1") } if options.Limit > 0 { query.Set("limit", strconv.Itoa(options.Limit)) } if options.Since != "" { query.Set("since", options.Since) } if options.Before != "" { query.Set("before", options.Before) } if options.Size { query.Set("size", "1") } if options.Filters.Len() > 0 { //nolint:staticcheck // ignore SA1019 for old code filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters) if err != nil { return nil, err } query.Set("filters", filterJSON) } resp, err := cli.get(ctx, "/containers/json", query, nil) defer ensureReaderClosed(resp) if err != nil { return nil, err } var containers []container.Summary err = json.NewDecoder(resp.Body).Decode(&containers) return containers, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_remove.go
vendor/github.com/docker/docker/client/image_remove.go
package client import ( "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/image" ) // ImageRemove removes an image from the docker host. func (cli *Client) ImageRemove(ctx context.Context, imageID string, options image.RemoveOptions) ([]image.DeleteResponse, error) { query := url.Values{} if options.Force { query.Set("force", "1") } if !options.PruneChildren { query.Set("noprune", "1") } if len(options.Platforms) > 0 { p, err := encodePlatforms(options.Platforms...) if err != nil { return nil, err } query["platforms"] = p } resp, err := cli.delete(ctx, "/images/"+imageID, query, nil) defer ensureReaderClosed(resp) if err != nil { return nil, err } var dels []image.DeleteResponse err = json.NewDecoder(resp.Body).Decode(&dels) return dels, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/version.go
vendor/github.com/docker/docker/client/version.go
package client import ( "context" "encoding/json" "github.com/docker/docker/api/types" ) // ServerVersion returns information of the docker client and server host. func (cli *Client) ServerVersion(ctx context.Context) (types.Version, error) { resp, err := cli.get(ctx, "/version", nil, nil) defer ensureReaderClosed(resp) if err != nil { return types.Version{}, err } var server types.Version err = json.NewDecoder(resp.Body).Decode(&server) return server, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/plugin_inspect.go
vendor/github.com/docker/docker/client/plugin_inspect.go
package client import ( "bytes" "context" "encoding/json" "io" "github.com/docker/docker/api/types" ) // PluginInspectWithRaw inspects an existing plugin func (cli *Client) PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) { name, err := trimID("plugin", name) if err != nil { return nil, nil, err } resp, err := cli.get(ctx, "/plugins/"+name+"/json", nil, nil) defer ensureReaderClosed(resp) if err != nil { return nil, nil, err } body, err := io.ReadAll(resp.Body) if err != nil { return nil, nil, err } var p types.Plugin rdr := bytes.NewReader(body) err = json.NewDecoder(rdr).Decode(&p) return &p, body, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/config_inspect.go
vendor/github.com/docker/docker/client/config_inspect.go
package client import ( "bytes" "context" "encoding/json" "io" "github.com/docker/docker/api/types/swarm" ) // ConfigInspectWithRaw returns the config information with raw data func (cli *Client) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) { id, err := trimID("contig", id) if err != nil { return swarm.Config{}, nil, err } if err := cli.NewVersionError(ctx, "1.30", "config inspect"); err != nil { return swarm.Config{}, nil, err } resp, err := cli.get(ctx, "/configs/"+id, nil, nil) defer ensureReaderClosed(resp) if err != nil { return swarm.Config{}, nil, err } body, err := io.ReadAll(resp.Body) if err != nil { return swarm.Config{}, nil, err } var config swarm.Config rdr := bytes.NewReader(body) err = json.NewDecoder(rdr).Decode(&config) return config, body, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/plugin_create.go
vendor/github.com/docker/docker/client/plugin_create.go
package client import ( "context" "io" "net/http" "net/url" "github.com/docker/docker/api/types" ) // PluginCreate creates a plugin func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error { headers := http.Header(make(map[string][]string)) headers.Set("Content-Type", "application/x-tar") query := url.Values{} query.Set("name", createOptions.RepoName) resp, err := cli.postRaw(ctx, "/plugins/create", query, createContext, headers) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_search.go
vendor/github.com/docker/docker/client/image_search.go
package client import ( "context" "encoding/json" "net/http" "net/url" "strconv" cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/registry" ) // ImageSearch makes the docker host search by a term in a remote registry. // The list of results is not sorted in any fashion. func (cli *Client) ImageSearch(ctx context.Context, term string, options registry.SearchOptions) ([]registry.SearchResult, error) { var results []registry.SearchResult query := url.Values{} query.Set("term", term) if options.Limit > 0 { query.Set("limit", strconv.Itoa(options.Limit)) } if options.Filters.Len() > 0 { filterJSON, err := filters.ToJSON(options.Filters) if err != nil { return results, err } query.Set("filters", filterJSON) } resp, err := cli.tryImageSearch(ctx, query, options.RegistryAuth) defer ensureReaderClosed(resp) if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil { newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx) if privilegeErr != nil { return results, privilegeErr } resp, err = cli.tryImageSearch(ctx, query, newAuthHeader) } if err != nil { return results, err } err = json.NewDecoder(resp.Body).Decode(&results) return results, err } func (cli *Client) tryImageSearch(ctx context.Context, query url.Values, registryAuth string) (*http.Response, error) { return cli.get(ctx, "/images/search", query, http.Header{ registry.AuthHeader: {registryAuth}, }) }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_pull.go
vendor/github.com/docker/docker/client/image_pull.go
package client import ( "context" "io" "net/url" "strings" cerrdefs "github.com/containerd/errdefs" "github.com/distribution/reference" "github.com/docker/docker/api/types/image" ) // ImagePull requests the docker host to pull an image from a remote registry. // It executes the privileged function if the operation is unauthorized // and it tries one more time. // It's up to the caller to handle the io.ReadCloser and close it properly. // // FIXME(vdemeester): there is currently used in a few way in docker/docker // - if not in trusted content, ref is used to pass the whole reference, and tag is empty // - if in trusted content, ref is used to pass the reference name, and tag for the digest func (cli *Client) ImagePull(ctx context.Context, refStr string, options image.PullOptions) (io.ReadCloser, error) { ref, err := reference.ParseNormalizedNamed(refStr) if err != nil { return nil, err } query := url.Values{} query.Set("fromImage", ref.Name()) if !options.All { query.Set("tag", getAPITagFromNamedRef(ref)) } if options.Platform != "" { query.Set("platform", strings.ToLower(options.Platform)) } resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth) if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil { newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx) if privilegeErr != nil { return nil, privilegeErr } resp, err = cli.tryImageCreate(ctx, query, newAuthHeader) } if err != nil { return nil, err } return resp.Body, nil } // getAPITagFromNamedRef returns a tag from the specified reference. // This function is necessary as long as the docker "server" api expects // digests to be sent as tags and makes a distinction between the name // and tag/digest part of a reference. func getAPITagFromNamedRef(ref reference.Named) string { if digested, ok := ref.(reference.Digested); ok { return digested.Digest().String() } ref = reference.TagNameOnly(ref) if tagged, ok := ref.(reference.Tagged); ok { return tagged.Tag() } return "" }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/image_history_opts.go
vendor/github.com/docker/docker/client/image_history_opts.go
package client import ( "github.com/docker/docker/api/types/image" ) // ImageHistoryOption is a type representing functional options for the image history operation. type ImageHistoryOption interface { Apply(*imageHistoryOpts) error } type imageHistoryOptionFunc func(opt *imageHistoryOpts) error func (f imageHistoryOptionFunc) Apply(o *imageHistoryOpts) error { return f(o) } type imageHistoryOpts struct { apiOptions image.HistoryOptions }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/network_remove.go
vendor/github.com/docker/docker/client/network_remove.go
package client import "context" // NetworkRemove removes an existent network from the docker host. func (cli *Client) NetworkRemove(ctx context.Context, networkID string) error { networkID, err := trimID("network", networkID) if err != nil { return err } resp, err := cli.delete(ctx, "/networks/"+networkID, nil, nil) defer ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/login.go
vendor/github.com/docker/docker/client/login.go
package client import ( "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/registry" ) // RegistryLogin authenticates the docker server with a given docker registry. // It returns unauthorizedError when the authentication fails. func (cli *Client) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) { resp, err := cli.post(ctx, "/auth", url.Values{}, auth, nil) defer ensureReaderClosed(resp) if err != nil { return registry.AuthenticateOKBody{}, err } var response registry.AuthenticateOKBody err = json.NewDecoder(resp.Body).Decode(&response) return response, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/swarm_leave.go
vendor/github.com/docker/docker/client/swarm_leave.go
package client import ( "context" "net/url" ) // SwarmLeave leaves the swarm. func (cli *Client) SwarmLeave(ctx context.Context, force bool) error { query := url.Values{} if force { query.Set("force", "1") } resp, err := cli.post(ctx, "/swarm/leave", query, nil, nil) ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/config_remove.go
vendor/github.com/docker/docker/client/config_remove.go
package client import "context" // ConfigRemove removes a config. func (cli *Client) ConfigRemove(ctx context.Context, id string) error { id, err := trimID("config", id) if err != nil { return err } if err := cli.NewVersionError(ctx, "1.30", "config remove"); err != nil { return err } resp, err := cli.delete(ctx, "/configs/"+id, nil, nil) defer ensureReaderClosed(resp) return err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false
jesseduffield/lazydocker
https://github.com/jesseduffield/lazydocker/blob/f4fc3669ca8eb67aa350a76503397192bf26f057/vendor/github.com/docker/docker/client/container_update.go
vendor/github.com/docker/docker/client/container_update.go
package client import ( "context" "encoding/json" "github.com/docker/docker/api/types/container" ) // ContainerUpdate updates the resources of a container. func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.UpdateResponse, error) { containerID, err := trimID("container", containerID) if err != nil { return container.UpdateResponse{}, err } resp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil) defer ensureReaderClosed(resp) if err != nil { return container.UpdateResponse{}, err } var response container.UpdateResponse err = json.NewDecoder(resp.Body).Decode(&response) return response, err }
go
MIT
f4fc3669ca8eb67aa350a76503397192bf26f057
2026-01-07T08:35:43.570558Z
false