docker: make docker volume accept all global options
Some checks failed
build / windows (push) Has been cancelled
build / other_os (push) Has been cancelled
build / mac_amd64 (push) Has been cancelled
build / mac_arm64 (push) Has been cancelled
build / linux (push) Has been cancelled
build / go1.24 (push) Has been cancelled
build / linux_386 (push) Has been cancelled
build / lint (push) Has been cancelled
build / android-all (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/386 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/amd64 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v6 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v7 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm64 (push) Has been cancelled
Build & Push Docker Images / Merge & Push Final Docker Image (push) Has been cancelled

Fixes #8401
This commit is contained in:
Nick Craig-Wood
2025-02-17 20:24:26 +00:00
parent c5a3e86df8
commit f499c625bc

View File

@@ -1,6 +1,7 @@
package docker
import (
"context"
"fmt"
"strings"
@@ -112,6 +113,7 @@ func (vol *Volume) applyOptions(volOpt VolOpts) error {
}
mntMap := configmap.Simple{}
vfsMap := configmap.Simple{}
globalMap := configmap.Simple{}
for key := range opt {
var ok bool
var err error
@@ -144,6 +146,13 @@ func (vol *Volume) applyOptions(volOpt VolOpts) error {
ok = true
}
}
if !ok {
// try as a global option in globalMap
if fs.ConfigOptionsInfo.Get(underscoreKey) != nil {
globalMap[underscoreKey] = vol.Options[key]
ok = true
}
}
if !ok {
// try as a backend option in fsOpt (backends use "_" instead of "-")
@@ -172,6 +181,20 @@ func (vol *Volume) applyOptions(volOpt VolOpts) error {
return fmt.Errorf("cannot parse mount options: %w", err)
}
// Parse Global options
if len(globalMap) > 0 {
ctx := context.Background()
ci := fs.GetConfig(ctx)
err = configstruct.Set(globalMap, ci)
if err != nil {
return fmt.Errorf("cannot parse global options: %w", err)
}
err = ci.Reload(ctx)
if err != nil {
return fmt.Errorf("failed to reload global options: %w", err)
}
}
// build remote string from fsName, fsType, fsOpt, fsPath
colon := ":"
comma := ","