Skip to content

Commit a411a39

Browse files
committed
api/types: move ConfigCreateResponse, ConfigListOptions to types/swarm
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 23117af commit a411a39

13 files changed

Lines changed: 51 additions & 44 deletions

File tree

api/server/router/swarm/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type Backend interface {
3535
RemoveSecret(idOrName string) error
3636
GetSecret(id string) (swarm.Secret, error)
3737
UpdateSecret(idOrName string, version uint64, spec swarm.SecretSpec) error
38-
GetConfigs(opts types.ConfigListOptions) ([]swarm.Config, error)
38+
GetConfigs(opts swarm.ConfigListOptions) ([]swarm.Config, error)
3939
CreateConfig(s swarm.ConfigSpec) (string, error)
4040
RemoveConfig(id string) error
4141
GetConfig(id string) (swarm.Config, error)

api/server/router/swarm/cluster_routes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ func (sr *swarmRouter) getConfigs(ctx context.Context, w http.ResponseWriter, r
487487
return err
488488
}
489489

490-
configs, err := sr.backend.GetConfigs(basictypes.ConfigListOptions{Filters: filters})
490+
configs, err := sr.backend.GetConfigs(types.ConfigListOptions{Filters: filters})
491491
if err != nil {
492492
return err
493493
}
@@ -511,7 +511,7 @@ func (sr *swarmRouter) createConfig(ctx context.Context, w http.ResponseWriter,
511511
return err
512512
}
513513

514-
return httputils.WriteJSON(w, http.StatusCreated, &basictypes.ConfigCreateResponse{
514+
return httputils.WriteJSON(w, http.StatusCreated, &types.ConfigCreateResponse{
515515
ID: id,
516516
})
517517
}

api/types/swarm/config.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package swarm // import "github.com/docker/docker/api/types/swarm"
22

3-
import "os"
3+
import (
4+
"os"
5+
6+
"github.com/docker/docker/api/types/filters"
7+
)
48

59
// Config represents a config.
610
type Config struct {
@@ -44,3 +48,15 @@ type ConfigReference struct {
4448
ConfigID string
4549
ConfigName string
4650
}
51+
52+
// ConfigCreateResponse contains the information returned to a client
53+
// on the creation of a new config.
54+
type ConfigCreateResponse struct {
55+
// ID is the id of the created config.
56+
ID string
57+
}
58+
59+
// ConfigListOptions holds parameters to list configs
60+
type ConfigListOptions struct {
61+
Filters filters.Args
62+
}

api/types/types.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package types // import "github.com/docker/docker/api/types"
33
import (
44
"github.com/docker/docker/api/types/build"
55
"github.com/docker/docker/api/types/container"
6-
"github.com/docker/docker/api/types/filters"
76
"github.com/docker/docker/api/types/image"
87
"github.com/docker/docker/api/types/swarm"
98
"github.com/docker/docker/api/types/volume"
@@ -94,18 +93,6 @@ type DiskUsage struct {
9493
BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40.
9594
}
9695

97-
// ConfigCreateResponse contains the information returned to a client
98-
// on the creation of a new config.
99-
type ConfigCreateResponse struct {
100-
// ID is the id of the created config.
101-
ID string
102-
}
103-
104-
// ConfigListOptions holds parameters to list configs
105-
type ConfigListOptions struct {
106-
Filters filters.Args
107-
}
108-
10996
// PushResult contains the tag, manifest digest, and manifest size from the
11097
// push. It's used to signal this information to the trust code in the client
11198
// so it can sign the manifest if necessary.

api/types/types_deprecated.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ type SecretCreateResponse = swarm.SecretCreateResponse
127127
// Deprecated: use [swarm.SecretListOptions].
128128
type SecretListOptions = swarm.SecretListOptions
129129

130+
// ConfigCreateResponse contains the information returned to a client
131+
// on the creation of a new config.
132+
//
133+
// Deprecated: use [swarm.ConfigCreateResponse].
134+
type ConfigCreateResponse = swarm.ConfigCreateResponse
135+
136+
// ConfigListOptions holds parameters to list configs
137+
//
138+
// Deprecated: use [swarm.ConfigListOptions].
139+
type ConfigListOptions = swarm.ConfigListOptions
140+
130141
// BuildCache contains information about a build cache record.
131142
//
132143
// Deprecated: deprecated in API 1.49. Use [build.CacheRecord] instead.

client/client_interfaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ type SecretAPIClient interface {
229229

230230
// ConfigAPIClient defines API client methods for configs
231231
type ConfigAPIClient interface {
232-
ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error)
233-
ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error)
232+
ConfigList(ctx context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error)
233+
ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (swarm.ConfigCreateResponse, error)
234234
ConfigRemove(ctx context.Context, id string) error
235235
ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error)
236236
ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error

client/config_create.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import (
44
"context"
55
"encoding/json"
66

7-
"github.com/docker/docker/api/types"
87
"github.com/docker/docker/api/types/swarm"
98
)
109

1110
// ConfigCreate creates a new config.
12-
func (cli *Client) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
13-
var response types.ConfigCreateResponse
11+
func (cli *Client) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (swarm.ConfigCreateResponse, error) {
12+
var response swarm.ConfigCreateResponse
1413
if err := cli.NewVersionError(ctx, "1.30", "config create"); err != nil {
1514
return response, err
1615
}

client/config_create_test.go

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

13-
"github.com/docker/docker/api/types"
1413
"github.com/docker/docker/api/types/swarm"
1514
"github.com/docker/docker/errdefs"
1615
"gotest.tools/v3/assert"
@@ -46,7 +45,7 @@ func TestConfigCreate(t *testing.T) {
4645
if req.Method != http.MethodPost {
4746
return nil, fmt.Errorf("expected POST method, got %s", req.Method)
4847
}
49-
b, err := json.Marshal(types.ConfigCreateResponse{
48+
b, err := json.Marshal(swarm.ConfigCreateResponse{
5049
ID: "test_config",
5150
})
5251
if err != nil {

client/config_list.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import (
55
"encoding/json"
66
"net/url"
77

8-
"github.com/docker/docker/api/types"
98
"github.com/docker/docker/api/types/filters"
109
"github.com/docker/docker/api/types/swarm"
1110
)
1211

1312
// ConfigList returns the list of configs.
14-
func (cli *Client) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
13+
func (cli *Client) ConfigList(ctx context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
1514
if err := cli.NewVersionError(ctx, "1.30", "config list"); err != nil {
1615
return nil, err
1716
}

client/config_list_test.go

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

13-
"github.com/docker/docker/api/types"
1413
"github.com/docker/docker/api/types/filters"
1514
"github.com/docker/docker/api/types/swarm"
1615
"github.com/docker/docker/errdefs"
@@ -23,7 +22,7 @@ func TestConfigListUnsupported(t *testing.T) {
2322
version: "1.29",
2423
client: &http.Client{},
2524
}
26-
_, err := client.ConfigList(context.Background(), types.ConfigListOptions{})
25+
_, err := client.ConfigList(context.Background(), swarm.ConfigListOptions{})
2726
assert.Check(t, is.Error(err, `"config list" requires API version 1.30, but the Docker daemon API version is 1.29`))
2827
}
2928

@@ -33,25 +32,25 @@ func TestConfigListError(t *testing.T) {
3332
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
3433
}
3534

36-
_, err := client.ConfigList(context.Background(), types.ConfigListOptions{})
35+
_, err := client.ConfigList(context.Background(), swarm.ConfigListOptions{})
3736
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
3837
}
3938

4039
func TestConfigList(t *testing.T) {
4140
expectedURL := "/v1.30/configs"
4241

4342
listCases := []struct {
44-
options types.ConfigListOptions
43+
options swarm.ConfigListOptions
4544
expectedQueryParams map[string]string
4645
}{
4746
{
48-
options: types.ConfigListOptions{},
47+
options: swarm.ConfigListOptions{},
4948
expectedQueryParams: map[string]string{
5049
"filters": "",
5150
},
5251
},
5352
{
54-
options: types.ConfigListOptions{
53+
options: swarm.ConfigListOptions{
5554
Filters: filters.NewArgs(
5655
filters.Arg("label", "label1"),
5756
filters.Arg("label", "label2"),

0 commit comments

Comments
 (0)