api: rename volumes.CreateOptions to volumes.CreateRequest

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
Austin Vazquez
2025-10-20 08:07:56 -05:00
parent a2fd724453
commit 42ba5466c7
16 changed files with 33 additions and 33 deletions

View File

@@ -2184,11 +2184,11 @@ definitions:
is set to `-1` if the reference-count is not available. is set to `-1` if the reference-count is not available.
x-nullable: false x-nullable: false
VolumeCreateOptions: VolumeCreateRequest:
description: "Volume configuration" description: "Volume configuration"
type: "object" type: "object"
title: "VolumeConfig" title: "VolumeConfig"
x-go-name: "CreateOptions" x-go-name: "CreateRequest"
properties: properties:
Name: Name:
description: | description: |
@@ -10855,7 +10855,7 @@ paths:
required: true required: true
description: "Volume configuration" description: "Volume configuration"
schema: schema:
$ref: "#/definitions/VolumeCreateOptions" $ref: "#/definitions/VolumeCreateRequest"
tags: ["Volume"] tags: ["Volume"]
/volumes/{name}: /volumes/{name}:

View File

@@ -2184,11 +2184,11 @@ definitions:
is set to `-1` if the reference-count is not available. is set to `-1` if the reference-count is not available.
x-nullable: false x-nullable: false
VolumeCreateOptions: VolumeCreateRequest:
description: "Volume configuration" description: "Volume configuration"
type: "object" type: "object"
title: "VolumeConfig" title: "VolumeConfig"
x-go-name: "CreateOptions" x-go-name: "CreateRequest"
properties: properties:
Name: Name:
description: | description: |
@@ -10855,7 +10855,7 @@ paths:
required: true required: true
description: "Volume configuration" description: "Volume configuration"
schema: schema:
$ref: "#/definitions/VolumeCreateOptions" $ref: "#/definitions/VolumeCreateRequest"
tags: ["Volume"] tags: ["Volume"]
/volumes/{name}: /volumes/{name}:

View File

@@ -5,12 +5,12 @@ package volume
// This file was generated by the swagger tool. // This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command // Editing this file might prove futile when you re-run the swagger generate command
// CreateOptions VolumeConfig // CreateRequest VolumeConfig
// //
// # Volume configuration // # Volume configuration
// //
// swagger:model CreateOptions // swagger:model CreateRequest
type CreateOptions struct { type CreateRequest struct {
// cluster volume spec // cluster volume spec
ClusterVolumeSpec *ClusterVolumeSpec `json:"ClusterVolumeSpec,omitempty"` ClusterVolumeSpec *ClusterVolumeSpec `json:"ClusterVolumeSpec,omitempty"`

View File

@@ -23,7 +23,7 @@ type VolumeCreateResult struct {
// VolumeCreate creates a volume in the docker host. // VolumeCreate creates a volume in the docker host.
func (cli *Client) VolumeCreate(ctx context.Context, options VolumeCreateOptions) (VolumeCreateResult, error) { func (cli *Client) VolumeCreate(ctx context.Context, options VolumeCreateOptions) (VolumeCreateResult, error) {
createRequest := volume.CreateOptions{ createRequest := volume.CreateRequest{
Name: options.Name, Name: options.Name,
Driver: options.Driver, Driver: options.Driver,
DriverOpts: options.DriverOpts, DriverOpts: options.DriverOpts,

View File

@@ -134,7 +134,7 @@ func volumeSpecToGRPC(spec volumetypes.ClusterVolumeSpec) *swarmapi.VolumeSpec {
// VolumeCreateToGRPC takes a VolumeCreateBody and outputs the matching // VolumeCreateToGRPC takes a VolumeCreateBody and outputs the matching
// swarmapi VolumeSpec. // swarmapi VolumeSpec.
func VolumeCreateToGRPC(volume *volumetypes.CreateOptions) *swarmapi.VolumeSpec { func VolumeCreateToGRPC(volume *volumetypes.CreateRequest) *swarmapi.VolumeSpec {
var swarmSpec *swarmapi.VolumeSpec var swarmSpec *swarmapi.VolumeSpec
if volume != nil && volume.ClusterVolumeSpec != nil { if volume != nil && volume.ClusterVolumeSpec != nil {
swarmSpec = volumeSpecToGRPC(*volume.ClusterVolumeSpec) swarmSpec = volumeSpecToGRPC(*volume.ClusterVolumeSpec)

View File

@@ -123,7 +123,7 @@ func TestAccessModeFromGRPC(t *testing.T) {
// TestVolumeCreateToGRPC tests that a docker-typed VolumeCreateBody is // TestVolumeCreateToGRPC tests that a docker-typed VolumeCreateBody is
// correctly converted to a swarm-typed VolumeSpec. // correctly converted to a swarm-typed VolumeSpec.
func TestVolumeCreateToGRPC(t *testing.T) { func TestVolumeCreateToGRPC(t *testing.T) {
volume := &volumetypes.CreateOptions{ volume := &volumetypes.CreateRequest{
Driver: "plug1", Driver: "plug1",
DriverOpts: map[string]string{"options": "yeah"}, DriverOpts: map[string]string{"options": "yeah"},
Labels: map[string]string{"labeled": "yeah"}, Labels: map[string]string{"labeled": "yeah"},

View File

@@ -474,7 +474,7 @@ func (c *containerConfig) hostConfig(deps exec.VolumeGetter) *container.HostConf
} }
// This handles the case of volumes that are defined inside a service Mount // This handles the case of volumes that are defined inside a service Mount
func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volume.CreateOptions { func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volume.CreateRequest {
var ( var (
driverName string driverName string
driverOpts map[string]string driverOpts map[string]string
@@ -488,7 +488,7 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volume.CreateOp
} }
if mount.VolumeOptions != nil { if mount.VolumeOptions != nil {
return &volume.CreateOptions{ return &volume.CreateRequest{
Name: mount.Source, Name: mount.Source,
Driver: driverName, Driver: driverName,
DriverOpts: driverOpts, DriverOpts: driverOpts,

View File

@@ -59,7 +59,7 @@ func (c *Cluster) GetVolumes(options volumebackend.ListOptions) ([]*volumetypes.
// CreateVolume creates a new cluster volume in the swarm cluster. // CreateVolume creates a new cluster volume in the swarm cluster.
// //
// Returns the volume ID if creation is successful, or an error if not. // Returns the volume ID if creation is successful, or an error if not.
func (c *Cluster) CreateVolume(v volumetypes.CreateOptions) (*volumetypes.Volume, error) { func (c *Cluster) CreateVolume(v volumetypes.CreateRequest) (*volumetypes.Volume, error) {
var resp *swarmapi.CreateVolumeResponse var resp *swarmapi.CreateVolumeResponse
if err := c.lockedManagerAction(context.TODO(), func(ctx context.Context, state nodeState) error { if err := c.lockedManagerAction(context.TODO(), func(ctx context.Context, state nodeState) error {
volumeSpec := convert.VolumeCreateToGRPC(&v) volumeSpec := convert.VolumeCreateToGRPC(&v)

View File

@@ -26,7 +26,7 @@ type Backend interface {
type ClusterBackend interface { type ClusterBackend interface {
GetVolume(nameOrID string) (volume.Volume, error) GetVolume(nameOrID string) (volume.Volume, error)
GetVolumes(options volumebackend.ListOptions) ([]*volume.Volume, error) GetVolumes(options volumebackend.ListOptions) ([]*volume.Volume, error)
CreateVolume(volume volume.CreateOptions) (*volume.Volume, error) CreateVolume(volume volume.CreateRequest) (*volume.Volume, error)
RemoveVolume(nameOrID string, force bool) error RemoveVolume(nameOrID string, force bool) error
UpdateVolume(nameOrID string, version uint64, volume volumebackend.UpdateOptions) error UpdateVolume(nameOrID string, version uint64, volume volumebackend.UpdateOptions) error
IsManager() bool IsManager() bool

View File

@@ -94,7 +94,7 @@ func (v *volumeRouter) postVolumesCreate(ctx context.Context, w http.ResponseWri
return err return err
} }
var req volume.CreateOptions var req volume.CreateRequest
if err := httputils.ReadJSON(r, &req); err != nil { if err := httputils.ReadJSON(r, &req); err != nil {
return err return err
} }

View File

@@ -187,7 +187,7 @@ func TestCreateRegularVolume(t *testing.T) {
cluster: c, cluster: c,
} }
volumeCreate := volume.CreateOptions{ volumeCreate := volume.CreateRequest{
Name: "vol1", Name: "vol1",
Driver: "foodriver", Driver: "foodriver",
} }
@@ -224,7 +224,7 @@ func TestCreateSwarmVolumeNoSwarm(t *testing.T) {
cluster: c, cluster: c,
} }
volumeCreate := volume.CreateOptions{ volumeCreate := volume.CreateRequest{
ClusterVolumeSpec: &volume.ClusterVolumeSpec{}, ClusterVolumeSpec: &volume.ClusterVolumeSpec{},
Name: "volCluster", Name: "volCluster",
Driver: "someCSI", Driver: "someCSI",
@@ -253,7 +253,7 @@ func TestCreateSwarmVolumeNotManager(t *testing.T) {
cluster: c, cluster: c,
} }
volumeCreate := volume.CreateOptions{ volumeCreate := volume.CreateRequest{
ClusterVolumeSpec: &volume.ClusterVolumeSpec{}, ClusterVolumeSpec: &volume.ClusterVolumeSpec{},
Name: "volCluster", Name: "volCluster",
Driver: "someCSI", Driver: "someCSI",
@@ -285,7 +285,7 @@ func TestCreateVolumeCluster(t *testing.T) {
cluster: c, cluster: c,
} }
volumeCreate := volume.CreateOptions{ volumeCreate := volume.CreateRequest{
ClusterVolumeSpec: &volume.ClusterVolumeSpec{}, ClusterVolumeSpec: &volume.ClusterVolumeSpec{},
Name: "volCluster", Name: "volCluster",
Driver: "someCSI", Driver: "someCSI",
@@ -692,7 +692,7 @@ func (c *fakeClusterBackend) GetVolumes(_ volumebackend.ListOptions) ([]*volume.
return volumes, nil return volumes, nil
} }
func (c *fakeClusterBackend) CreateVolume(volumeCreate volume.CreateOptions) (*volume.Volume, error) { func (c *fakeClusterBackend) CreateVolume(volumeCreate volume.CreateRequest) (*volume.Volume, error) {
if err := c.checkSwarm(); err != nil { if err := c.checkSwarm(); err != nil {
return nil, err return nil, err
} }

View File

@@ -96,7 +96,7 @@ EOT
generate_model types/volume <<- 'EOT' generate_model types/volume <<- 'EOT'
Volume Volume
VolumeCreateOptions VolumeCreateRequest
VolumeListResponse VolumeListResponse
EOT EOT

View File

@@ -585,7 +585,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) {
// Addresses https://github.com/moby/moby/issues/44422 // Addresses https://github.com/moby/moby/issues/44422
t.Run("local volume with mount options", func(t *testing.T) { t.Run("local volume with mount options", func(t *testing.T) {
ctx := testutil.StartSpan(ctx, t) ctx := testutil.StartSpan(ctx, t)
res, err := c.VolumeCreate(ctx, client.VolumeCreateOptions{ created, err := c.VolumeCreate(ctx, client.VolumeCreateOptions{
Driver: "local", Driver: "local",
Name: "test-live-restore-volume-references-local", Name: "test-live-restore-volume-references-local",
DriverOpts: map[string]string{ DriverOpts: map[string]string{
@@ -594,7 +594,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) {
}, },
}) })
assert.NilError(t, err) assert.NilError(t, err)
v := res.Volume v := created.Volume
m := mount.Mount{ m := mount.Mount{
Type: mount.TypeVolume, Type: mount.TypeVolume,
Source: v.Name, Source: v.Name,

View File

@@ -32,11 +32,11 @@ func TestVolumesCreateAndList(t *testing.T) {
if testEnv.DaemonInfo.OSType == "windows" { if testEnv.DaemonInfo.OSType == "windows" {
name = strings.ToLower(name) name = strings.ToLower(name)
} }
create, err := apiClient.VolumeCreate(ctx, client.VolumeCreateOptions{ created, err := apiClient.VolumeCreate(ctx, client.VolumeCreateOptions{
Name: name, Name: name,
}) })
assert.NilError(t, err) assert.NilError(t, err)
namedV := create.Volume namedV := created.Volume
expected := volume.Volume{ expected := volume.Volume{
// Ignore timestamp of CreatedAt // Ignore timestamp of CreatedAt
@@ -161,9 +161,9 @@ func TestVolumesInspect(t *testing.T) {
apiClient := testEnv.APIClient() apiClient := testEnv.APIClient()
now := time.Now() now := time.Now()
create, err := apiClient.VolumeCreate(ctx, client.VolumeCreateOptions{}) created, err := apiClient.VolumeCreate(ctx, client.VolumeCreateOptions{})
assert.NilError(t, err) assert.NilError(t, err)
v := create.Volume v := created.Volume
inspected, err := apiClient.VolumeInspect(ctx, v.Name) inspected, err := apiClient.VolumeInspect(ctx, v.Name)
assert.NilError(t, err) assert.NilError(t, err)

View File

@@ -5,12 +5,12 @@ package volume
// This file was generated by the swagger tool. // This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command // Editing this file might prove futile when you re-run the swagger generate command
// CreateOptions VolumeConfig // CreateRequest VolumeConfig
// //
// # Volume configuration // # Volume configuration
// //
// swagger:model CreateOptions // swagger:model CreateRequest
type CreateOptions struct { type CreateRequest struct {
// cluster volume spec // cluster volume spec
ClusterVolumeSpec *ClusterVolumeSpec `json:"ClusterVolumeSpec,omitempty"` ClusterVolumeSpec *ClusterVolumeSpec `json:"ClusterVolumeSpec,omitempty"`

View File

@@ -23,7 +23,7 @@ type VolumeCreateResult struct {
// VolumeCreate creates a volume in the docker host. // VolumeCreate creates a volume in the docker host.
func (cli *Client) VolumeCreate(ctx context.Context, options VolumeCreateOptions) (VolumeCreateResult, error) { func (cli *Client) VolumeCreate(ctx context.Context, options VolumeCreateOptions) (VolumeCreateResult, error) {
createRequest := volume.CreateOptions{ createRequest := volume.CreateRequest{
Name: options.Name, Name: options.Name,
Driver: options.Driver, Driver: options.Driver,
DriverOpts: options.DriverOpts, DriverOpts: options.DriverOpts,