2017-02-27 12:39:35 -05:00
|
|
|
package builders
|
|
|
|
|
2022-04-29 13:26:50 -04:00
|
|
|
import "github.com/docker/docker/api/types/volume"
|
2017-02-27 12:39:35 -05:00
|
|
|
|
|
|
|
// Volume creates a volume with default values.
|
2018-02-15 11:58:17 -05:00
|
|
|
// Any number of volume function builder can be passed to augment it.
|
2022-04-29 13:26:50 -04:00
|
|
|
func Volume(builders ...func(volume *volume.Volume)) *volume.Volume {
|
|
|
|
vol := &volume.Volume{
|
2017-02-27 12:39:35 -05:00
|
|
|
Name: "volume",
|
|
|
|
Driver: "local",
|
|
|
|
Mountpoint: "/data/volume",
|
|
|
|
Scope: "local",
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, builder := range builders {
|
2022-04-29 13:26:50 -04:00
|
|
|
builder(vol)
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
|
2022-04-29 13:26:50 -04:00
|
|
|
return vol
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// VolumeLabels sets the volume labels
|
2022-04-29 13:26:50 -04:00
|
|
|
func VolumeLabels(labels map[string]string) func(volume *volume.Volume) {
|
|
|
|
return func(volume *volume.Volume) {
|
2017-02-27 12:39:35 -05:00
|
|
|
volume.Labels = labels
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// VolumeName sets the volume labels
|
2022-04-29 13:26:50 -04:00
|
|
|
func VolumeName(name string) func(volume *volume.Volume) {
|
|
|
|
return func(volume *volume.Volume) {
|
2017-02-27 12:39:35 -05:00
|
|
|
volume.Name = name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// VolumeDriver sets the volume driver
|
2022-04-29 13:26:50 -04:00
|
|
|
func VolumeDriver(name string) func(volume *volume.Volume) {
|
|
|
|
return func(volume *volume.Volume) {
|
2017-02-27 12:39:35 -05:00
|
|
|
volume.Driver = name
|
|
|
|
}
|
|
|
|
}
|