Skip to content

Commit

Permalink
Merge pull request #218 from depot/support-x-bake-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie authored Oct 30, 2023
2 parents 891546a + 5610286 commit e3c6c4c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ import (
"github.com/compose-spec/compose-go/types"
compose "github.com/compose-spec/compose-go/types"
"github.com/docker/buildx/bake"
"gopkg.in/yaml.v2"
)

type xbake struct {
Tags []string `yaml:"tags,omitempty"`
}

// TODO: largely copied from buildx/bake/bake.go. Refactor in buildx fork.
func TargetTags(files []bake.File) (map[string][]string, error) {
if len(files) == 0 {
Expand Down Expand Up @@ -72,6 +77,16 @@ func TargetTags(files []bake.File) (map[string][]string, error) {
if len(srv.Build.Tags) > 0 {
targetTags[target] = srv.Build.Tags
} else {
if bakeExtension, ok := srv.Build.Extensions["x-bake"]; ok {
var xb xbake
yb, _ := yaml.Marshal(bakeExtension)
err := yaml.Unmarshal(yb, &xb)
if err == nil && len(xb.Tags) > 0 {
targetTags[target] = xb.Tags
continue
}
}

imageNames := []string{getImageNameOrDefault(srv, projectName)}
targetTags[target] = imageNames
}
Expand Down

0 comments on commit e3c6c4c

Please sign in to comment.