mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-31 23:58:03 +08:00
bake: contexts support with x-bake
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
24
bake/bake.go
24
bake/bake.go
@@ -134,7 +134,7 @@ func ReadTargets(ctx context.Context, files []File, targets, overrides []string,
|
||||
gt = append(gt, target)
|
||||
}
|
||||
}
|
||||
g = []*Group{{Targets: dedupString(gt)}}
|
||||
g = []*Group{{Targets: dedupSlice(gt)}}
|
||||
}
|
||||
|
||||
for name, t := range m {
|
||||
@@ -146,7 +146,7 @@ func ReadTargets(ctx context.Context, files []File, targets, overrides []string,
|
||||
return m, g, nil
|
||||
}
|
||||
|
||||
func dedupString(s []string) []string {
|
||||
func dedupSlice(s []string) []string {
|
||||
if len(s) == 0 {
|
||||
return s
|
||||
}
|
||||
@@ -161,6 +161,24 @@ func dedupString(s []string) []string {
|
||||
return res
|
||||
}
|
||||
|
||||
func dedupMap(ms ...map[string]string) map[string]string {
|
||||
if len(ms) == 0 {
|
||||
return nil
|
||||
}
|
||||
res := map[string]string{}
|
||||
for _, m := range ms {
|
||||
if len(m) == 0 {
|
||||
continue
|
||||
}
|
||||
for k, v := range m {
|
||||
if _, ok := res[k]; !ok {
|
||||
res[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func ParseFiles(files []File, defaults map[string]string) (_ *Config, err error) {
|
||||
defer func() {
|
||||
err = formatHCLError(err, files)
|
||||
@@ -418,7 +436,7 @@ func (c Config) newOverrides(v []string) (map[string]map[string]Override, error)
|
||||
}
|
||||
|
||||
func (c Config) ResolveGroup(name string) []string {
|
||||
return dedupString(c.group(name, map[string][]string{}))
|
||||
return dedupSlice(c.group(name, map[string][]string{}))
|
||||
}
|
||||
|
||||
func (c Config) group(name string, visited map[string][]string) []string {
|
||||
|
Reference in New Issue
Block a user