client: create option-structs for all client-methods
Various methods of the client do not use an options-struct; this means that
adding, removing, or changing an argument results in a breaking change in
the function's signature.
While first steps are made towards using functional options, we should take
the intermediate step of creating option-structs for all methods; option-
structs allow adding new fields without breaking backward compatibility.
This effort won't be a waste of effort if we move to functional options, as
the option structs can be reused as part of that implementation.
Example:
Taking a random example of a client function that needs updating; the
client.ContainersPrune method accepts a single filters.Args option
as argument:
ContainersPrune (ctx context .Context , pruneFilters filters .Args ) (container .PruneReport , error )
We should change this to use a struct containing the current option(s), similar
to (e.g.) client.NetworkListOptions ;
// NetworkListOptions holds parameters to filter the list of networks with.
type NetworkListOptions struct {
Filters filters.Args
}
While it may currently be overkill for a single option, it will allow expanding
options, or deprecating options without breaking compatibility (we should still
try to get rid of the filters options though, but that's separate topic )
Checklist
checkpoint_create.go
checkpoint_delete.go
checkpoint_list.go
build_cancel.go
build_prune.go
config_create.go
config_inspect.go
config_list.go
config_remove.go
config_update.go
container_attach.go
container_commit.go
container_copy.go
ContainerStatPath(ctx context.Context, containerID, path string) (container.PathStat, error) client/container_copy: Wrap options and result struct #51328
CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, options CopyToContainerOptions) error client/container_copy: Wrap options and result struct #51328
CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, container.PathStat, error) client/container_copy: Wrap options and result struct #51328
container_create.go
container_diff.go
container_exec.go
ContainerExecCreate(ctx context.Context, containerID string, options ExecCreateOptions) (container.ExecCreateResponse, error) github.com/client/container_exec: Wrap options and result #51262
ContainerExecStart(ctx context.Context, execID string, config ExecStartOptions) error github.com/client/container_exec: Wrap options and result #51262
ContainerExecAttach(ctx context.Context, execID string, config ExecAttachOptions) (HijackedResponse, error) github.com/client/container_exec: Wrap options and result #51262
ContainerExecInspect(ctx context.Context, execID string) (ExecInspect, error) github.com/client/container_exec: Wrap options and result #51262
container_export.go @austinvazquez - client: refactor ContainerExport to wrap options/result structs #51316
container_inspect.go client: merge ContainerInspectWithRaw with ContainerInspect #51290
container_kill.go
container_list.go @austinvazquez - client: refactor ContainerList to wrap result #51314
container_logs.go @austinvazquez - client: refactor ContainerLogs to wrap result #51317
container_pause.go
container_prune.go
container_remove.go
container_rename.go @austinvazquez - client: refactor ContainerRename to wrap options/result structs #51315
container_resize.go
container_restart.go
container_start.go
container_stats.go client: ContainerStats: add option, output-structs, remove ContainerStatsOneShot #51293
container_stop.go
container_top.go @austinvazquez - client: refactor ContainerTop to wrap options and results #51313
container_unpause.go
container_update.go
container_wait.go @austinvazquez - client: refactor ContainerWait to use client defined options/results structs #51312
distribution_inspect.go
image_build.go
image_create.go
image_history.go
image_import.go
image_inspect.go
image_list.go
image_load.go
image_prune.go
image_pull.go
image_push.go
image_remove.go
image_save.go
image_search.go
image_tag.go
login.go - @austinvazquez client: refactor Events, Info, RegistryLogin #51320
network_connect.go @austinvazquez - client: refactor NetworkConnect, NetworkDisconnect, NetworkRemove #51325
network_create.go @austinvazquez - client: refactor create network api implementation to define options/result struct #51269
network_disconnect.go @austinvazquez - client: refactor NetworkConnect, NetworkDisconnect, NetworkRemove #51325
network_inspect.go client: NetworkInspect, NetworkList: wrap output structs, and remove NetworkInspectWithRaw #51245
network_list.go client: NetworkInspect, NetworkList: wrap output structs, and remove NetworkInspectWithRaw #51245
network_prune.go
network_remove.go @austinvazquez - client: refactor NetworkConnect, NetworkDisconnect, NetworkRemove #51325
node_inspect.go
node_list.go
node_remove.go
node_update.go
ping.go - api/types: move Ping and swarm.Status to client #51258
plugin_create.go @austinvazquez - client: refactor plugin api client functions to define options/result… #51256
plugin_disable.go @austinvazquez - client: refactor plugin api client functions to define options/result… #51256
plugin_enable.go @austinvazquez - client: refactor plugin api client functions to define options/result… #51256
plugin_inspect.go client: PluginInspectWithRaw: refactor and rename to PluginInspect #51254
plugin_install.go @austinvazquez - client: refactor plugin api client functions to define options/result… #51256
plugin_list.go
plugin_push.go @austinvazquez - client: refactor plugin api client functions to define options/result… #51256
plugin_remove.go @austinvazquez - client: refactor plugin api client functions to define options/result… #51256
plugin_set.go @austinvazquez - client: refactor plugin api client functions to define options/result… #51256
plugin_upgrade.go @austinvazquez - client: refactor plugin api client functions to define options/result… #51256
secret_create.go client/secrets: Wrap results and options #51251
secret_inspect.go client/secrets: Wrap results and options #51251
secret_list.go client/secrets: Wrap results and options #51251
secret_remove.go client/secrets: Wrap results and options #51251
secret_update.go client/secrets: Wrap results and options #51251
service_create.go @austinvazquez - client: refactor service api client functions for defined options/res… #51252
service_inspect.go @austinvazquez - client: refactor service api client functions for defined options/res… #51252
service_list.go @austinvazquez - client: refactor service api client functions for defined options/res… #51252 , client: rename ServiceListResult.Services to ServiceListResult.Items #51273
service_logs.go @austinvazquez - client: refactor service api client functions for defined options/res… #51252
service_remove.go @austinvazquez - client: refactor service api client functions for defined options/res… #51252
service_update.go @austinvazquez - client: refactor service api client functions for defined options/res… #51252
swarm_get_unlock_key.go @austinvazquez - client: refactor swarm api functions to wrap params/responses #51244
swarm_init.go @austinvazquez - client: refactor swarm api functions to wrap params/responses #51244
swarm_inspect.go @austinvazquez - client: refactor swarm api functions to wrap params/responses #51244
swarm_join.go @austinvazquez - client: refactor swarm api functions to wrap params/responses #51244
swarm_leave.go @austinvazquez - client: refactor swarm api functions to wrap params/responses #51244
swarm_unlock.go @austinvazquez - client: refactor swarm api functions to wrap params/responses #51244
swarm_update.go @austinvazquez - client: refactor swarm api functions to wrap params/responses #51244
system_disk_usage.go @austinvazquez - api/types/system: deprecate DiskUsage.* fields and add type specific fields #51235
system_events.go @austinvazquez - client: refactor Events, Info, RegistryLogin #51320
system_info.go @austinvazquez - client: refactor Events, Info, RegistryLogin #51320
task_inspect.go @austinvazquez - client: refactor task responses #51234
task_list.go @austinvazquez - client: refactor task responses #51234
task_logs.go @austinvazquez - client: refactor task responses #51234
version.go @austinvazquez - client: refactor ServerVersion to return ServerVersionResult #51233
volume_create.go
volume_inspect.go
volume_list.go
volume_prune.go
volume_remove.go
volume_update.go #51206
client: create option-structs for all client-methods
Various methods of the client do not use an options-struct; this means that
adding, removing, or changing an argument results in a breaking change in
the function's signature.
While first steps are made towards using functional options, we should take
the intermediate step of creating option-structs for all methods; option-
structs allow adding new fields without breaking backward compatibility.
This effort won't be a waste of effort if we move to functional options, as
the option structs can be reused as part of that implementation.
Example:
Taking a random example of a client function that needs updating; the
client.ContainersPrunemethod accepts a singlefilters.Argsoptionas argument:
We should change this to use a struct containing the current option(s), similar
to (e.g.)
client.NetworkListOptions;While it may currently be overkill for a single option, it will allow expanding
options, or deprecating options without breaking compatibility (we should still
try to get rid of the
filtersoptions though, but that's separate topic)Checklist
CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) errorCheckpointDelete(ctx context.Context, containerID string, options CheckpointDeleteOptions) errorCheckpointList(ctx context.Context, container string, options CheckpointListOptions) ([]checkpoint.Summary, error)client/checkpoint_list: Wrap result in a struct #51050BuildCancel(ctx context.Context, id string) errorclient/build_*: Add options struct, wrap result #51076BuildCachePrune(ctx context.Context, opts BuildCachePruneOptions) (*build.CachePruneReport, error)client/build_*: Add options struct, wrap result #51076ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (swarm.ConfigCreateResponse, error)client/config: Wrap results and options #51078ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error)client/config: Wrap results and options #51078ConfigList(ctx context.Context, options ConfigListOptions) ([]swarm.Config, error)client/config: Wrap results and options #51078ConfigRemove(ctx context.Context, id string) errorclient/config: Wrap results and options #51078ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) errorclient/config: Wrap results and options #51078ContainerAttach(ctx context.Context, containerID string, options ContainerAttachOptions) (HijackedResponse, error)client_(attach,commit,create,diff): Wrap result and options #51278ContainerCommit(ctx context.Context, containerID string, options ContainerCommitOptions) (container.CommitResponse, error)client_(attach,commit,create,diff): Wrap result and options #51278ContainerStatPath(ctx context.Context, containerID, path string) (container.PathStat, error)client/container_copy: Wrap options and result struct #51328CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, options CopyToContainerOptions) errorclient/container_copy: Wrap options and result struct #51328CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, container.PathStat, error)client/container_copy: Wrap options and result struct #51328ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)client_(attach,commit,create,diff): Wrap result and options #51278ContainerDiff(ctx context.Context, containerID string) ([]container.FilesystemChange, error)client_(attach,commit,create,diff): Wrap result and options #51278ContainerExecCreate(ctx context.Context, containerID string, options ExecCreateOptions) (container.ExecCreateResponse, error)github.com/client/container_exec: Wrap options and result #51262ContainerExecStart(ctx context.Context, execID string, config ExecStartOptions) errorgithub.com/client/container_exec: Wrap options and result #51262ContainerExecAttach(ctx context.Context, execID string, config ExecAttachOptions) (HijackedResponse, error)github.com/client/container_exec: Wrap options and result #51262ContainerExecInspect(ctx context.Context, execID string) (ExecInspect, error)github.com/client/container_exec: Wrap options and result #51262ContainerExportto wrap options/result structs #51316ContainerExport(ctx context.Context, containerID string) (io.ReadCloser, error)ContainerInspect(ctx context.Context, containerID string) (container.InspectResponse, error)ContainerInspectWithRaw(ctx context.Context, containerID string, getSize bool) (container.InspectResponse, []byte, error)ContainerKill(ctx context.Context, containerID, signal string) errorclient: add option and output structs for various container methods #51308ContainerListto wrap result #51314ContainerList(ctx context.Context, options ContainerListOptions) ([]container.Summary, error)ContainerLogsto wrap result #51317ContainerLogs(ctx context.Context, containerID string, options ContainerLogsOptions) (io.ReadCloser, error)ContainerPause(ctx context.Context, containerID string) errorclient: add option and output structs for various container methods #51308ContainersPrune(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error)client: rewrite prune functions to use option structs and result #51200ContainerRemove(ctx context.Context, containerID string, options ContainerRemoveOptions) errorclient: add option and output structs for various container methods #51308ContainerRenameto wrap options/result structs #51315ContainerRename(ctx context.Context, containerID, newContainerName string) errorContainerResize(ctx context.Context, containerID string, options ContainerResizeOptions) errorclient: add option and output structs for various container methods #51308ContainerExecResize(ctx context.Context, execID string, options ContainerResizeOptions) errorgithub.com/client/container_exec: Wrap options and result #51262ContainerRestart(ctx context.Context, containerID string, options ContainerStopOptions) errorclient: add option and output structs for various container methods #51308ContainerStart(ctx context.Context, containerID string, options ContainerStartOptions) errorclient: add option and output structs for various container methods #51308ContainerStats(ctx context.Context, containerID string, stream bool) (StatsResponseReader, error)ContainerStatsOneShot(ctx context.Context, containerID string) (StatsResponseReader, error)ContainerStop(ctx context.Context, containerID string, options ContainerStopOptions) errorclient: add option and output structs for various container methods #51308ContainerTopto wrap options and results #51313ContainerTop(ctx context.Context, containerID string, arguments []string) (container.TopResponse, error)ContainerUnpause(ctx context.Context, containerID string) errorclient: add option and output structs for various container methods #51308ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.UpdateResponse, error)client/container_update: Wrap options and result #51326ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)DistributionInspect(ctx context.Context, imageRef, encodedRegistryAuth string) (registry.DistributionInspect, error)client/distribution_inspect: Wrap options and result #51264ImageBuild(ctx context.Context, buildContext io.Reader, options ImageBuildOptions) (ImageBuildResponse, error)client/image: Wrap result and options in structs #51227ImageCreate(ctx context.Context, parentReference string, options ImageCreateOptions) (io.ReadCloser, error)client/image: Wrap result and options in structs #51227ImageHistory(ctx context.Context, imageID string, historyOpts ...ImageHistoryOption) ([]image.HistoryResponseItem, error)client/image_(inspect,history,load,save): Wrap return values #51236ImageImport(ctx context.Context, source ImageImportSource, ref string, options ImageImportOptions) (io.ReadCloser, error)client/image: Wrap result and options in structs #51227ImageInspect(ctx context.Context, imageID string, inspectOpts ...ImageInspectOption) (image.InspectResponse, error)client/image_(inspect,history,load,save): Wrap return values #51236ImageList(ctx context.Context, options ImageListOptions) ([]image.Summary, error)client/image: Wrap result and options in structs #51227ImageLoad(ctx context.Context, input io.Reader, loadOpts ...ImageLoadOption) (LoadResponse, error)client/image_(inspect,history,load,save): Wrap return values #51236ImagesPrune(ctx context.Context, pruneFilters filters.Args) (image.PruneReport, error)client: rewrite prune functions to use option structs and result #51200ImagePull(ctx context.Context, refStr string, options ImagePullOptions) (io.ReadCloser, error)introduce ImagePullResponse with helper method to manage JSONMessage stream decoding #50935ImagePush(ctx context.Context, image string, options ImagePushOptions) (io.ReadCloser, error)introduce ImagePushResponse #51148ImageRemove(ctx context.Context, imageID string, options ImageRemoveOptions) ([]image.DeleteResponse, error)client/image: Wrap result and options in structs #51227ImageSave(ctx context.Context, imageIDs []string, saveOpts ...ImageSaveOption) (io.ReadCloser, error)client/image_(inspect,history,load,save): Wrap return values #51236ImageSearch(ctx context.Context, term string, options ImageSearchOptions) ([]registry.SearchResult, error)client/image: Wrap result and options in structs #51227ImageTag(ctx context.Context, source, target string) errorclient/image: Wrap result and options in structs #51227RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) errorNetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (network.CreateResponse, error)NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) errorNetworkInspect(ctx context.Context, networkID string, options NetworkInspectOptions) (network.Inspect, error)NetworkInspectWithRaw(ctx context.Context, networkID string, options NetworkInspectOptions) (network.Inspect, []byte, error)NetworkList(ctx context.Context, options NetworkListOptions) ([]network.Summary, error)NetworksPrune(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error)client: rewrite prune functions to use option structs and result #51200NetworkRemove(ctx context.Context, networkID string) errorNodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)client/node: Wrap options and output #51260NodeList(ctx context.Context, options NodeListOptions) ([]swarm.Node, error)client/node: Wrap options and output #51260NodeRemove(ctx context.Context, nodeID string, options NodeRemoveOptions) errorclient/node: Wrap options and output #51260NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) errorclient/node: Wrap options and output #51260Ping(ctx context.Context) (types.Ping, error)PluginCreate(ctx context.Context, createContext io.Reader, createOptions PluginCreateOptions) errorPluginDisable(ctx context.Context, name string, options PluginDisableOptions) errorPluginEnable(ctx context.Context, name string, options PluginEnableOptions) errorPluginInspectWithRaw(ctx context.Context, name string) (*plugin.Plugin, []byte, error)PluginInstall(ctx context.Context, name string, options PluginInstallOptions) (_ io.ReadCloser, retErr error)PluginList(ctx context.Context, filter filters.Args) (plugin.ListResponse, error)client: Client.PluginList: add options-struct #51207PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error)PluginRemove(ctx context.Context, name string, options PluginRemoveOptions) errorPluginSet(ctx context.Context, name string, args []string) errorPluginUpgrade(ctx context.Context, name string, options PluginInstallOptions) (io.ReadCloser, error)SecretCreate(ctx context.Context, secret swarm.SecretSpec) (swarm.SecretCreateResponse, error)SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error)SecretList(ctx context.Context, options SecretListOptions) ([]swarm.Secret, error)SecretRemove(ctx context.Context, id string) errorSecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) errorServiceCreate(ctx context.Context, service swarm.ServiceSpec, options ServiceCreateOptions) (swarm.ServiceCreateResponse, error)ServiceInspectWithRaw(ctx context.Context, serviceID string, opts ServiceInspectOptions) (swarm.Service, []byte, error)ServiceListResult.ServicestoServiceListResult.Items#51273ServiceList(ctx context.Context, options ServiceListOptions) ([]swarm.Service, error)ServiceLogs(ctx context.Context, serviceID string, options ContainerLogsOptions) (io.ReadCloser, error)ServiceRemove(ctx context.Context, serviceID string) errorServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error)SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)SwarmInspect(ctx context.Context) (swarm.Swarm, error)SwarmJoin(ctx context.Context, req swarm.JoinRequest) errorSwarmLeave(ctx context.Context, force bool) errorSwarmUnlock(ctx context.Context, req swarm.UnlockRequest) errorSwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags SwarmUpdateFlags) errorDiskUsage.*fields and add type specific fields #51235DiskUsage(ctx context.Context, options DiskUsageOptions) (system.DiskUsage, error)Events(ctx context.Context, options EventsListOptions) (<-chan events.Message, <-chan error)Info(ctx context.Context) (system.Info, error)TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)TaskList(ctx context.Context, options TaskListOptions) ([]swarm.Task, error)TaskLogs(ctx context.Context, taskID string, options ContainerLogsOptions) (io.ReadCloser, error)ServerVersion(ctx context.Context) (types.Version, error)VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)api/types/volume: moveCreateOptionstoclient.VolumeCreateOptions#51211VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error)client/volume: refactor volume options and responses #51210VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error)client/volume: refactor volume options and responses #51210 client: remove VolumeInspectWithRaw, merge with VolumeInspect #51247VolumeList(ctx context.Context, options VolumeListOptions) (volume.ListResponse, error)client/volume: refactor volume options and responses #51210VolumesPrune(ctx context.Context, pruneFilters filters.Args) (volume.PruneReport, error)client: rewrite prune functions to use option structs and result #51200VolumeRemove(ctx context.Context, volumeID string, force bool) errorclient/volume: refactor volume options and responses #51210VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error