Skip to content

Commit b688af2

Browse files
committed
api/types: move checkpoint-types to api/types/checkpoint
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 3e5b2a6 commit b688af2

16 files changed

Lines changed: 93 additions & 66 deletions
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package checkpoint // import "github.com/docker/docker/api/server/router/checkpoint"
22

3-
import "github.com/docker/docker/api/types"
3+
import "github.com/docker/docker/api/types/checkpoint"
44

55
// Backend for Checkpoint
66
type Backend interface {
7-
CheckpointCreate(container string, config types.CheckpointCreateOptions) error
8-
CheckpointDelete(container string, config types.CheckpointDeleteOptions) error
9-
CheckpointList(container string, config types.CheckpointListOptions) ([]types.Checkpoint, error)
7+
CheckpointCreate(container string, config checkpoint.CreateOptions) error
8+
CheckpointDelete(container string, config checkpoint.DeleteOptions) error
9+
CheckpointList(container string, config checkpoint.ListOptions) ([]checkpoint.Summary, error)
1010
}

api/server/router/checkpoint/checkpoint_routes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import (
55
"net/http"
66

77
"github.com/docker/docker/api/server/httputils"
8-
"github.com/docker/docker/api/types"
8+
"github.com/docker/docker/api/types/checkpoint"
99
)
1010

1111
func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
1212
if err := httputils.ParseForm(r); err != nil {
1313
return err
1414
}
1515

16-
var options types.CheckpointCreateOptions
16+
var options checkpoint.CreateOptions
1717
if err := httputils.ReadJSON(r, &options); err != nil {
1818
return err
1919
}
@@ -32,7 +32,7 @@ func (s *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.R
3232
return err
3333
}
3434

35-
checkpoints, err := s.backend.CheckpointList(vars["name"], types.CheckpointListOptions{
35+
checkpoints, err := s.backend.CheckpointList(vars["name"], checkpoint.ListOptions{
3636
CheckpointDir: r.Form.Get("dir"),
3737
})
3838
if err != nil {
@@ -47,7 +47,7 @@ func (s *checkpointRouter) deleteContainerCheckpoint(ctx context.Context, w http
4747
return err
4848
}
4949

50-
err := s.backend.CheckpointDelete(vars["name"], types.CheckpointDeleteOptions{
50+
err := s.backend.CheckpointDelete(vars["name"], checkpoint.DeleteOptions{
5151
CheckpointDir: r.Form.Get("dir"),
5252
CheckpointID: vars["checkpoint"],
5353
})

api/types/checkpoint/list.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package checkpoint
2+
3+
// Summary represents the details of a checkpoint when listing endpoints.
4+
type Summary struct {
5+
// Name is the name of the checkpoint.
6+
Name string
7+
}

api/types/checkpoint/options.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package checkpoint
2+
3+
// CreateOptions holds parameters to create a checkpoint from a container.
4+
type CreateOptions struct {
5+
CheckpointID string
6+
CheckpointDir string
7+
Exit bool
8+
}
9+
10+
// ListOptions holds parameters to list checkpoints for a container.
11+
type ListOptions struct {
12+
CheckpointDir string
13+
}
14+
15+
// DeleteOptions holds parameters to delete a checkpoint from a container.
16+
type DeleteOptions struct {
17+
CheckpointID string
18+
CheckpointDir string
19+
}

api/types/client.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,6 @@ import (
1111
units "github.com/docker/go-units"
1212
)
1313

14-
// CheckpointCreateOptions holds parameters to create a checkpoint from a container
15-
type CheckpointCreateOptions struct {
16-
CheckpointID string
17-
CheckpointDir string
18-
Exit bool
19-
}
20-
21-
// CheckpointListOptions holds parameters to list checkpoints for a container
22-
type CheckpointListOptions struct {
23-
CheckpointDir string
24-
}
25-
26-
// CheckpointDeleteOptions holds parameters to delete a checkpoint from a container
27-
type CheckpointDeleteOptions struct {
28-
CheckpointID string
29-
CheckpointDir string
30-
}
31-
3214
// ContainerAttachOptions holds parameters to attach to a container.
3315
type ContainerAttachOptions struct {
3416
Stream bool

api/types/types.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,6 @@ type NetworkInspectOptions struct {
494494
Verbose bool
495495
}
496496

497-
// Checkpoint represents the details of a checkpoint
498-
type Checkpoint struct {
499-
Name string // Name is the name of the checkpoint
500-
}
501-
502497
// DiskUsageObject represents an object type used for disk usage query filtering.
503498
type DiskUsageObject string
504499

api/types/types_deprecated.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
package types
22

3-
import "github.com/docker/docker/api/types/system"
3+
import (
4+
"github.com/docker/docker/api/types/checkpoint"
5+
"github.com/docker/docker/api/types/system"
6+
)
7+
8+
// CheckpointCreateOptions holds parameters to create a checkpoint from a container.
9+
//
10+
// Deprecated: use [checkpoint.CreateOptions].
11+
type CheckpointCreateOptions = checkpoint.CreateOptions
12+
13+
// CheckpointListOptions holds parameters to list checkpoints for a container
14+
//
15+
// Deprecated: use [checkpoint.ListOptions].
16+
type CheckpointListOptions = checkpoint.ListOptions
17+
18+
// CheckpointDeleteOptions holds parameters to delete a checkpoint from a container
19+
//
20+
// Deprecated: use [checkpoint.DeleteOptions].
21+
type CheckpointDeleteOptions = checkpoint.DeleteOptions
22+
23+
// Checkpoint represents the details of a checkpoint when listing endpoints.
24+
//
25+
// Deprecated: use [checkpoint.Summary].
26+
type Checkpoint = checkpoint.Summary
427

528
// Info contains response of Engine API:
629
// GET "/info"

client/checkpoint_create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package client // import "github.com/docker/docker/client"
33
import (
44
"context"
55

6-
"github.com/docker/docker/api/types"
6+
"github.com/docker/docker/api/types/checkpoint"
77
)
88

99
// CheckpointCreate creates a checkpoint from the given container with the given name
10-
func (cli *Client) CheckpointCreate(ctx context.Context, container string, options types.CheckpointCreateOptions) error {
10+
func (cli *Client) CheckpointCreate(ctx context.Context, container string, options checkpoint.CreateOptions) error {
1111
resp, err := cli.post(ctx, "/containers/"+container+"/checkpoints", nil, options, nil)
1212
ensureReaderClosed(resp)
1313
return err

client/checkpoint_create_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strings"
1111
"testing"
1212

13-
"github.com/docker/docker/api/types"
13+
"github.com/docker/docker/api/types/checkpoint"
1414
"github.com/docker/docker/errdefs"
1515
"gotest.tools/v3/assert"
1616
is "gotest.tools/v3/assert/cmp"
@@ -20,7 +20,7 @@ func TestCheckpointCreateError(t *testing.T) {
2020
client := &Client{
2121
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
2222
}
23-
err := client.CheckpointCreate(context.Background(), "nothing", types.CheckpointCreateOptions{
23+
err := client.CheckpointCreate(context.Background(), "nothing", checkpoint.CreateOptions{
2424
CheckpointID: "noting",
2525
Exit: true,
2626
})
@@ -43,7 +43,7 @@ func TestCheckpointCreate(t *testing.T) {
4343
return nil, fmt.Errorf("expected POST method, got %s", req.Method)
4444
}
4545

46-
createOptions := &types.CheckpointCreateOptions{}
46+
createOptions := &checkpoint.CreateOptions{}
4747
if err := json.NewDecoder(req.Body).Decode(createOptions); err != nil {
4848
return nil, err
4949
}
@@ -63,7 +63,7 @@ func TestCheckpointCreate(t *testing.T) {
6363
}),
6464
}
6565

66-
err := client.CheckpointCreate(context.Background(), expectedContainerID, types.CheckpointCreateOptions{
66+
err := client.CheckpointCreate(context.Background(), expectedContainerID, checkpoint.CreateOptions{
6767
CheckpointID: expectedCheckpointID,
6868
Exit: true,
6969
})

client/checkpoint_delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"context"
55
"net/url"
66

7-
"github.com/docker/docker/api/types"
7+
"github.com/docker/docker/api/types/checkpoint"
88
)
99

1010
// CheckpointDelete deletes the checkpoint with the given name from the given container
11-
func (cli *Client) CheckpointDelete(ctx context.Context, containerID string, options types.CheckpointDeleteOptions) error {
11+
func (cli *Client) CheckpointDelete(ctx context.Context, containerID string, options checkpoint.DeleteOptions) error {
1212
query := url.Values{}
1313
if options.CheckpointDir != "" {
1414
query.Set("dir", options.CheckpointDir)

0 commit comments

Comments
 (0)