Skip to content

Commit

Permalink
bindings: volumes uses entities/types
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Jan 25, 2024
1 parent df6cc85 commit 668d517
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
14 changes: 7 additions & 7 deletions pkg/bindings/volumes/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions pkg/domain/entities/types/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 1 addition & 14 deletions pkg/domain/entities/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 668d517

Please sign in to comment.