Allow using key-value data
This commit is contained in:
@@ -58,6 +58,7 @@ type Build struct {
|
||||
LabelsAuto bool // Docker build auto labels
|
||||
Labels cli.StringSlice // Docker build labels
|
||||
Platforms cli.StringSlice // Docker build target platforms
|
||||
ArgsRaw string // Docker build args (as JSON)
|
||||
Args cli.StringSlice // Docker build args
|
||||
ArgsEnv cli.StringSlice // Docker build args from env
|
||||
Target string // Docker build target
|
||||
@@ -87,6 +88,26 @@ func (l Login) anonymous() bool {
|
||||
return l.Username == "" || l.Password == ""
|
||||
}
|
||||
|
||||
// Parse the provided build args into b.Args
|
||||
func (b Build) BuildArgs() {
|
||||
if len(b.ArgsRaw) > 0 {
|
||||
buildArgsRaw := map[string]string{}
|
||||
err := json.Unmarshal([]byte(b.ArgsRaw), &buildArgsRaw)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to parse build args: %s", err)
|
||||
}
|
||||
|
||||
for key, value := range buildArgsRaw {
|
||||
b.Args = *cli.NewStringSlice(
|
||||
append(
|
||||
b.Args.Value(),
|
||||
fmt.Sprintf("%s=%s", key, value),
|
||||
)...,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Init initialise plugin settings
|
||||
func (p *Plugin) InitSettings() error {
|
||||
if p.settings.LoginsRaw != "" {
|
||||
@@ -227,6 +248,8 @@ func (p *Plugin) writeBuildkitConfig() error {
|
||||
|
||||
// Execute provides the implementation of the plugin.
|
||||
func (p *Plugin) Execute() error {
|
||||
p.settings.Build.BuildArgs()
|
||||
|
||||
// start the Docker daemon server
|
||||
if !p.settings.Daemon.Disabled {
|
||||
// If no custom DNS value set start internal DNS server
|
||||
|
||||
Reference in New Issue
Block a user