This commit is contained in:
CrazyMax
2023-06-13 16:56:37 +02:00
committed by GitHub
12 changed files with 846 additions and 540 deletions

View File

@@ -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
}