feat: translation support
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
See #483
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package convert // https://github.com/docker/cli/blob/master/cli/compose/convert/volume.go
|
||||
|
||||
import (
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
composetypes "github.com/docker/cli/cli/compose/types"
|
||||
"github.com/docker/docker/api/types/mount"
|
||||
"github.com/pkg/errors"
|
||||
@ -40,10 +41,10 @@ func handleVolumeToMount(
|
||||
result := createMountFromVolume(volume)
|
||||
|
||||
if volume.Tmpfs != nil {
|
||||
return mount.Mount{}, errors.New("tmpfs options are incompatible with type volume")
|
||||
return mount.Mount{}, errors.New(i18n.G("tmpfs options are incompatible with type volume"))
|
||||
}
|
||||
if volume.Bind != nil {
|
||||
return mount.Mount{}, errors.New("bind options are incompatible with type volume")
|
||||
return mount.Mount{}, errors.New(i18n.G("bind options are incompatible with type volume"))
|
||||
}
|
||||
// Anonymous volumes
|
||||
if volume.Source == "" {
|
||||
@ -52,7 +53,7 @@ func handleVolumeToMount(
|
||||
|
||||
stackVolume, exists := stackVolumes[volume.Source]
|
||||
if !exists {
|
||||
return mount.Mount{}, errors.Errorf("undefined volume %q", volume.Source)
|
||||
return mount.Mount{}, errors.New(i18n.G("undefined volume %q", volume.Source))
|
||||
}
|
||||
|
||||
result.Source = namespace.Scope(volume.Source)
|
||||
@ -86,13 +87,13 @@ func handleBindToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, er
|
||||
result := createMountFromVolume(volume)
|
||||
|
||||
if volume.Source == "" {
|
||||
return mount.Mount{}, errors.New("invalid bind source, source cannot be empty")
|
||||
return mount.Mount{}, errors.New(i18n.G("invalid bind source, source cannot be empty"))
|
||||
}
|
||||
if volume.Volume != nil {
|
||||
return mount.Mount{}, errors.New("volume options are incompatible with type bind")
|
||||
return mount.Mount{}, errors.New(i18n.G("volume options are incompatible with type bind"))
|
||||
}
|
||||
if volume.Tmpfs != nil {
|
||||
return mount.Mount{}, errors.New("tmpfs options are incompatible with type bind")
|
||||
return mount.Mount{}, errors.New(i18n.G("tmpfs options are incompatible with type bind"))
|
||||
}
|
||||
if volume.Bind != nil {
|
||||
result.BindOptions = &mount.BindOptions{
|
||||
@ -106,13 +107,13 @@ func handleTmpfsToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, e
|
||||
result := createMountFromVolume(volume)
|
||||
|
||||
if volume.Source != "" {
|
||||
return mount.Mount{}, errors.New("invalid tmpfs source, source must be empty")
|
||||
return mount.Mount{}, errors.New(i18n.G("invalid tmpfs source, source must be empty"))
|
||||
}
|
||||
if volume.Bind != nil {
|
||||
return mount.Mount{}, errors.New("bind options are incompatible with type tmpfs")
|
||||
return mount.Mount{}, errors.New(i18n.G("bind options are incompatible with type tmpfs"))
|
||||
}
|
||||
if volume.Volume != nil {
|
||||
return mount.Mount{}, errors.New("volume options are incompatible with type tmpfs")
|
||||
return mount.Mount{}, errors.New(i18n.G("volume options are incompatible with type tmpfs"))
|
||||
}
|
||||
if volume.Tmpfs != nil {
|
||||
result.TmpfsOptions = &mount.TmpfsOptions{
|
||||
@ -126,13 +127,13 @@ func handleNpipeToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, e
|
||||
result := createMountFromVolume(volume)
|
||||
|
||||
if volume.Source == "" {
|
||||
return mount.Mount{}, errors.New("invalid npipe source, source cannot be empty")
|
||||
return mount.Mount{}, errors.New(i18n.G("invalid npipe source, source cannot be empty"))
|
||||
}
|
||||
if volume.Volume != nil {
|
||||
return mount.Mount{}, errors.New("volume options are incompatible with type npipe")
|
||||
return mount.Mount{}, errors.New(i18n.G("volume options are incompatible with type npipe"))
|
||||
}
|
||||
if volume.Tmpfs != nil {
|
||||
return mount.Mount{}, errors.New("tmpfs options are incompatible with type npipe")
|
||||
return mount.Mount{}, errors.New(i18n.G("tmpfs options are incompatible with type npipe"))
|
||||
}
|
||||
if volume.Bind != nil {
|
||||
result.BindOptions = &mount.BindOptions{
|
||||
@ -158,5 +159,5 @@ func convertVolumeToMount(
|
||||
case "npipe":
|
||||
return handleNpipeToMount(volume)
|
||||
}
|
||||
return mount.Mount{}, errors.New("volume type must be volume, bind, tmpfs or npipe")
|
||||
return mount.Mount{}, errors.New(i18n.G("volume type must be volume, bind, tmpfs or npipe"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user