mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: singularize prune methods
All methods are singular; while pruning will impact multiple items, it's more consistent to use singular for all operations. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -72,7 +72,7 @@ type ContainerAPIClient interface {
|
||||
ContainerWait(ctx context.Context, container string, options ContainerWaitOptions) ContainerWaitResult
|
||||
CopyFromContainer(ctx context.Context, container string, options CopyFromContainerOptions) (CopyFromContainerResult, error)
|
||||
CopyToContainer(ctx context.Context, container string, options CopyToContainerOptions) (CopyToContainerResult, error)
|
||||
ContainersPrune(ctx context.Context, opts ContainerPruneOptions) (ContainerPruneResult, error)
|
||||
ContainerPrune(ctx context.Context, opts ContainerPruneOptions) (ContainerPruneResult, error)
|
||||
}
|
||||
|
||||
type ExecAPIClient interface {
|
||||
@@ -101,7 +101,7 @@ type ImageAPIClient interface {
|
||||
ImageRemove(ctx context.Context, image string, options ImageRemoveOptions) (ImageRemoveResult, error)
|
||||
ImageSearch(ctx context.Context, term string, options ImageSearchOptions) (ImageSearchResult, error)
|
||||
ImageTag(ctx context.Context, options ImageTagOptions) (ImageTagResult, error)
|
||||
ImagesPrune(ctx context.Context, opts ImagePruneOptions) (ImagePruneResult, error)
|
||||
ImagePrune(ctx context.Context, opts ImagePruneOptions) (ImagePruneResult, error)
|
||||
|
||||
ImageInspect(ctx context.Context, image string, _ ...ImageInspectOption) (ImageInspectResult, error)
|
||||
ImageHistory(ctx context.Context, image string, _ ...ImageHistoryOption) (ImageHistoryResult, error)
|
||||
@@ -117,7 +117,7 @@ type NetworkAPIClient interface {
|
||||
NetworkInspect(ctx context.Context, network string, options NetworkInspectOptions) (NetworkInspectResult, error)
|
||||
NetworkList(ctx context.Context, options NetworkListOptions) (NetworkListResult, error)
|
||||
NetworkRemove(ctx context.Context, network string, options NetworkRemoveOptions) (NetworkRemoveResult, error)
|
||||
NetworksPrune(ctx context.Context, opts NetworkPruneOptions) (NetworkPruneResult, error)
|
||||
NetworkPrune(ctx context.Context, opts NetworkPruneOptions) (NetworkPruneResult, error)
|
||||
}
|
||||
|
||||
// NodeAPIClient defines API client methods for the nodes
|
||||
@@ -181,7 +181,7 @@ type VolumeAPIClient interface {
|
||||
VolumeInspect(ctx context.Context, volumeID string, options VolumeInspectOptions) (VolumeInspectResult, error)
|
||||
VolumeList(ctx context.Context, options VolumeListOptions) (VolumeListResult, error)
|
||||
VolumeRemove(ctx context.Context, volumeID string, options VolumeRemoveOptions) (VolumeRemoveResult, error)
|
||||
VolumesPrune(ctx context.Context, options VolumePruneOptions) (VolumePruneResult, error)
|
||||
VolumePrune(ctx context.Context, options VolumePruneOptions) (VolumePruneResult, error)
|
||||
VolumeUpdate(ctx context.Context, volumeID string, options VolumeUpdateOptions) (VolumeUpdateResult, error)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ type ContainerPruneOptions struct {
|
||||
Filters Filters
|
||||
}
|
||||
|
||||
// ContainerPruneResult holds the result from the [Client.ContainersPrune] method.
|
||||
// ContainerPruneResult holds the result from the [Client.ContainerPrune] method.
|
||||
type ContainerPruneResult struct {
|
||||
Report container.PruneReport
|
||||
}
|
||||
|
||||
// ContainersPrune requests the daemon to delete unused data
|
||||
func (cli *Client) ContainersPrune(ctx context.Context, opts ContainerPruneOptions) (ContainerPruneResult, error) {
|
||||
// ContainerPrune requests the daemon to delete unused data
|
||||
func (cli *Client) ContainerPrune(ctx context.Context, opts ContainerPruneOptions) (ContainerPruneResult, error) {
|
||||
query := url.Values{}
|
||||
opts.Filters.updateURLValues(query)
|
||||
|
||||
|
||||
@@ -11,15 +11,15 @@ import (
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
||||
func TestContainersPruneError(t *testing.T) {
|
||||
func TestContainerPruneError(t *testing.T) {
|
||||
client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = client.ContainersPrune(context.Background(), ContainerPruneOptions{})
|
||||
_, err = client.ContainerPrune(context.Background(), ContainerPruneOptions{})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
}
|
||||
|
||||
func TestContainersPrune(t *testing.T) {
|
||||
func TestContainerPrune(t *testing.T) {
|
||||
const expectedURL = "/containers/prune"
|
||||
|
||||
listCases := []struct {
|
||||
@@ -89,7 +89,7 @@ func TestContainersPrune(t *testing.T) {
|
||||
}))
|
||||
assert.NilError(t, err)
|
||||
|
||||
req, err := client.ContainersPrune(context.Background(), ContainerPruneOptions{Filters: listCase.filters})
|
||||
req, err := client.ContainerPrune(context.Background(), ContainerPruneOptions{Filters: listCase.filters})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Len(req.Report.ContainersDeleted, 2))
|
||||
assert.Check(t, is.Equal(uint64(9999), req.Report.SpaceReclaimed))
|
||||
|
||||
@@ -14,13 +14,13 @@ type ImagePruneOptions struct {
|
||||
Filters Filters
|
||||
}
|
||||
|
||||
// ImagePruneResult holds the result from the [Client.ImagesPrune] method.
|
||||
// ImagePruneResult holds the result from the [Client.ImagePrune] method.
|
||||
type ImagePruneResult struct {
|
||||
Report image.PruneReport
|
||||
}
|
||||
|
||||
// ImagesPrune requests the daemon to delete unused data
|
||||
func (cli *Client) ImagesPrune(ctx context.Context, opts ImagePruneOptions) (ImagePruneResult, error) {
|
||||
// ImagePrune requests the daemon to delete unused data
|
||||
func (cli *Client) ImagePrune(ctx context.Context, opts ImagePruneOptions) (ImagePruneResult, error) {
|
||||
query := url.Values{}
|
||||
opts.Filters.updateURLValues(query)
|
||||
|
||||
|
||||
@@ -12,15 +12,15 @@ import (
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
||||
func TestImagesPruneError(t *testing.T) {
|
||||
func TestImagePruneError(t *testing.T) {
|
||||
client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = client.ImagesPrune(context.Background(), ImagePruneOptions{})
|
||||
_, err = client.ImagePrune(context.Background(), ImagePruneOptions{})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
}
|
||||
|
||||
func TestImagesPrune(t *testing.T) {
|
||||
func TestImagePrune(t *testing.T) {
|
||||
const expectedURL = "/images/prune"
|
||||
|
||||
listCases := []struct {
|
||||
@@ -83,7 +83,7 @@ func TestImagesPrune(t *testing.T) {
|
||||
}))
|
||||
assert.NilError(t, err)
|
||||
|
||||
res, err := client.ImagesPrune(context.Background(), ImagePruneOptions{Filters: listCase.filters})
|
||||
res, err := client.ImagePrune(context.Background(), ImagePruneOptions{Filters: listCase.filters})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Len(res.Report.ImagesDeleted, 2))
|
||||
assert.Check(t, is.Equal(uint64(9999), res.Report.SpaceReclaimed))
|
||||
|
||||
@@ -14,13 +14,13 @@ type NetworkPruneOptions struct {
|
||||
Filters Filters
|
||||
}
|
||||
|
||||
// NetworkPruneResult holds the result from the [Client.NetworksPrune] method.
|
||||
// NetworkPruneResult holds the result from the [Client.NetworkPrune] method.
|
||||
type NetworkPruneResult struct {
|
||||
Report network.PruneReport
|
||||
}
|
||||
|
||||
// NetworksPrune requests the daemon to delete unused networks
|
||||
func (cli *Client) NetworksPrune(ctx context.Context, opts NetworkPruneOptions) (NetworkPruneResult, error) {
|
||||
// NetworkPrune requests the daemon to delete unused networks
|
||||
func (cli *Client) NetworkPrune(ctx context.Context, opts NetworkPruneOptions) (NetworkPruneResult, error) {
|
||||
query := url.Values{}
|
||||
opts.Filters.updateURLValues(query)
|
||||
|
||||
|
||||
@@ -11,17 +11,17 @@ import (
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
||||
func TestNetworksPruneError(t *testing.T) {
|
||||
func TestNetworkPruneError(t *testing.T) {
|
||||
client, err := New(
|
||||
WithMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = client.NetworksPrune(context.Background(), NetworkPruneOptions{})
|
||||
_, err = client.NetworkPrune(context.Background(), NetworkPruneOptions{})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
}
|
||||
|
||||
func TestNetworksPrune(t *testing.T) {
|
||||
func TestNetworkPrune(t *testing.T) {
|
||||
const expectedURL = "/networks/prune"
|
||||
|
||||
listCases := []struct {
|
||||
@@ -82,7 +82,7 @@ func TestNetworksPrune(t *testing.T) {
|
||||
)
|
||||
assert.NilError(t, err)
|
||||
|
||||
res, err := client.NetworksPrune(context.Background(), NetworkPruneOptions{Filters: listCase.filters})
|
||||
res, err := client.NetworkPrune(context.Background(), NetworkPruneOptions{Filters: listCase.filters})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Len(res.Report.NetworksDeleted, 2))
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ type VolumePruneOptions struct {
|
||||
Filters Filters
|
||||
}
|
||||
|
||||
// VolumePruneResult holds the result from the [Client.VolumesPrune] method.
|
||||
// VolumePruneResult holds the result from the [Client.VolumePrune] method.
|
||||
type VolumePruneResult struct {
|
||||
Report volume.PruneReport
|
||||
}
|
||||
|
||||
// VolumesPrune requests the daemon to delete unused data
|
||||
func (cli *Client) VolumesPrune(ctx context.Context, options VolumePruneOptions) (VolumePruneResult, error) {
|
||||
// VolumePrune requests the daemon to delete unused data
|
||||
func (cli *Client) VolumePrune(ctx context.Context, options VolumePruneOptions) (VolumePruneResult, error) {
|
||||
if options.All {
|
||||
if _, ok := options.Filters["all"]; ok {
|
||||
return VolumePruneResult{}, errdefs.ErrInvalidArgument.WithMessage(`conflicting options: cannot specify both "all" and "all" filter`)
|
||||
|
||||
@@ -79,7 +79,7 @@ func TestVolumePrune(t *testing.T) {
|
||||
}))
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = client.VolumesPrune(t.Context(), tc.opts)
|
||||
_, err = client.VolumePrune(t.Context(), tc.opts)
|
||||
if tc.expectedError != "" {
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidArgument))
|
||||
assert.Check(t, is.Error(err, tc.expectedError))
|
||||
|
||||
Reference in New Issue
Block a user