controller: refactor build inputs to external struct
This patch continues the move to attempt to merge the build.Options struct into the controllerapi.Options message. To do this, we extract all the input parameters into a dedicated message (adding the missing ones, except for the InStream parameter which will require some additional fiddling around). We also rework the NamedContexts to allow containing States (by transmitting them as DefinitionOps), and adding a Linked field to the common options. Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
committed by
CrazyMax
parent
ea06685c11
commit
3c3e4a6d5f
@@ -3,15 +3,16 @@ package buildflags
|
||||
import (
|
||||
"strings"
|
||||
|
||||
controllerapi "github.com/docker/buildx/controller/pb"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func ParseContextNames(values []string) (map[string]string, error) {
|
||||
func ParseContextNames(values []string) (map[string]*controllerapi.NamedContext, error) {
|
||||
if len(values) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
result := make(map[string]string, len(values))
|
||||
result := make(map[string]*controllerapi.NamedContext, len(values))
|
||||
for _, value := range values {
|
||||
kv := strings.SplitN(value, "=", 2)
|
||||
if len(kv) != 2 {
|
||||
@@ -22,7 +23,7 @@ func ParseContextNames(values []string) (map[string]string, error) {
|
||||
return nil, errors.Wrapf(err, "invalid context name %s", kv[0])
|
||||
}
|
||||
name := strings.TrimSuffix(reference.FamiliarString(named), ":latest")
|
||||
result[name] = kv[1]
|
||||
result[name] = &controllerapi.NamedContext{Path: kv[1]}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user