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.
|
2023-11-20 11:38:50 -05:00
|
|
|
func Volume(builders ...func(vol *volume.Volume)) *volume.Volume {
|
2022-04-29 13:26:50 -04:00
|
|
|
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
|
2023-11-20 11:38:50 -05:00
|
|
|
func VolumeLabels(labels map[string]string) func(vol *volume.Volume) {
|
|
|
|
return func(vol *volume.Volume) {
|
|
|
|
vol.Labels = labels
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// VolumeName sets the volume labels
|
2023-11-20 11:38:50 -05:00
|
|
|
func VolumeName(name string) func(vol *volume.Volume) {
|
|
|
|
return func(vol *volume.Volume) {
|
|
|
|
vol.Name = name
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// VolumeDriver sets the volume driver
|
2023-11-20 11:38:50 -05:00
|
|
|
func VolumeDriver(name string) func(vol *volume.Volume) {
|
|
|
|
return func(vol *volume.Volume) {
|
|
|
|
vol.Driver = name
|
2017-02-27 12:39:35 -05:00
|
|
|
}
|
|
|
|
}
|