blob: 0783af4410f985d8151ded5e699b4045a25417c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// +build ABISupport
package abi
import (
"context"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/containers/libpod/pkg/domain/infra/abi/parse"
)
func (ic *ContainerEngine) VolumeCreate(ctx context.Context, opts entities.VolumeCreateOptions) (*entities.IdOrNameResponse, error) {
var (
volumeOptions []libpod.VolumeCreateOption
)
if len(opts.Name) > 0 {
volumeOptions = append(volumeOptions, libpod.WithVolumeName(opts.Name))
}
if len(opts.Driver) > 0 {
volumeOptions = append(volumeOptions, libpod.WithVolumeDriver(opts.Driver))
}
if len(opts.Label) > 0 {
volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(opts.Label))
}
if len(opts.Options) > 0 {
parsedOptions, err := parse.ParseVolumeOptions(opts.Options)
if err != nil {
return nil, err
}
volumeOptions = append(volumeOptions, parsedOptions...)
}
vol, err := ic.Libpod.NewVolume(ctx, volumeOptions...)
if err != nil {
return nil, err
}
return &entities.IdOrNameResponse{IdOrName: vol.Name()}, nil
}
|