From 668d517af98e1e01c3c54dccef8d406f5db242b4 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 25 Jan 2024 15:37:55 +0100 Subject: [PATCH] bindings: volumes uses entities/types Signed-off-by: Giuseppe Scrivano --- pkg/bindings/volumes/volumes.go | 14 +++++++------- pkg/domain/entities/types/volumes.go | 16 ++++++++++++++++ pkg/domain/entities/volumes.go | 15 +-------------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/pkg/bindings/volumes/volumes.go b/pkg/bindings/volumes/volumes.go index 290eab219a..f52ac46405 100644 --- a/pkg/bindings/volumes/volumes.go +++ b/pkg/bindings/volumes/volumes.go @@ -6,15 +6,15 @@ import ( "strings" "github.com/containers/podman/v4/pkg/bindings" - "github.com/containers/podman/v4/pkg/domain/entities" "github.com/containers/podman/v4/pkg/domain/entities/reports" + entitiesTypes "github.com/containers/podman/v4/pkg/domain/entities/types" jsoniter "github.com/json-iterator/go" ) // Create creates a volume given its configuration. -func Create(ctx context.Context, config entities.VolumeCreateOptions, options *CreateOptions) (*entities.VolumeConfigResponse, error) { +func Create(ctx context.Context, config entitiesTypes.VolumeCreateOptions, options *CreateOptions) (*entitiesTypes.VolumeConfigResponse, error) { var ( - v entities.VolumeConfigResponse + v entitiesTypes.VolumeConfigResponse ) if options == nil { options = new(CreateOptions) @@ -39,9 +39,9 @@ func Create(ctx context.Context, config entities.VolumeCreateOptions, options *C } // Inspect returns low-level information about a volume. -func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) (*entities.VolumeConfigResponse, error) { +func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) (*entitiesTypes.VolumeConfigResponse, error) { var ( - inspect entities.VolumeConfigResponse + inspect entitiesTypes.VolumeConfigResponse ) if options == nil { options = new(InspectOptions) @@ -62,9 +62,9 @@ func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) (*en // List returns the configurations for existing volumes in the form of a slice. Optionally, filters // can be used to refine the list of volumes. -func List(ctx context.Context, options *ListOptions) ([]*entities.VolumeListReport, error) { +func List(ctx context.Context, options *ListOptions) ([]*entitiesTypes.VolumeListReport, error) { var ( - vols []*entities.VolumeListReport + vols []*entitiesTypes.VolumeListReport ) conn, err := bindings.GetClient(ctx) if err != nil { diff --git a/pkg/domain/entities/types/volumes.go b/pkg/domain/entities/types/volumes.go index 033121a1a4..e5c89edef1 100644 --- a/pkg/domain/entities/types/volumes.go +++ b/pkg/domain/entities/types/volumes.go @@ -4,6 +4,22 @@ import ( "github.com/containers/podman/v4/libpod/define" ) +// swagger:model +type VolumeCreateOptions struct { + // New volume's name. Can be left blank + Name string `schema:"name"` + // Volume driver to use + Driver string `schema:"driver"` + // User-defined key/value metadata. Provided for compatibility + Label map[string]string `schema:"label"` + // User-defined key/value metadata. Preferred field, will override Label + Labels map[string]string `schema:"labels"` + // Mapping of driver options and values. + Options map[string]string `schema:"opts"` + // Ignore existing volumes + IgnoreIfExists bool `schema:"ignoreIfExist"` +} + type VolumeRmReport struct { Err error Id string //nolint:revive,stylecheck diff --git a/pkg/domain/entities/volumes.go b/pkg/domain/entities/volumes.go index 484a24cf57..ab68fcf97e 100644 --- a/pkg/domain/entities/volumes.go +++ b/pkg/domain/entities/volumes.go @@ -8,20 +8,7 @@ import ( // VolumeCreateOptions provides details for creating volumes // swagger:model -type VolumeCreateOptions struct { - // New volume's name. Can be left blank - Name string `schema:"name"` - // Volume driver to use - Driver string `schema:"driver"` - // User-defined key/value metadata. Provided for compatibility - Label map[string]string `schema:"label"` - // User-defined key/value metadata. Preferred field, will override Label - Labels map[string]string `schema:"labels"` - // Mapping of driver options and values. - Options map[string]string `schema:"opts"` - // Ignore existing volumes - IgnoreIfExists bool `schema:"ignoreIfExist"` -} +type VolumeCreateOptions = types.VolumeCreateOptions type VolumeConfigResponse = types.VolumeConfigResponse