1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00
goreleaser/internal/pipe/docker/api_buildpack.go
2022-03-17 07:55:17 -03:00

43 lines
1.0 KiB
Go

package docker
import (
"fmt"
"strings"
"github.com/goreleaser/goreleaser/pkg/context"
)
// deprected: should not be used anymore.
type buildPackImager struct{}
func (i buildPackImager) Push(ctx *context.Context, image string, flags []string) error {
return dockerImager{}.Push(ctx, image, flags)
}
func (i buildPackImager) Build(ctx *context.Context, root string, images, flags []string) error {
if err := runCommand(ctx, "", "pack", i.buildCommand(images, flags)...); err != nil {
return fmt.Errorf("failed to build %s: %w", images[0], err)
}
return nil
}
func (i buildPackImager) buildCommand(images, flags []string) []string {
base := []string{"build", images[0]}
for j := 1; j < len(images); j++ {
base = append(base, "-t", images[j])
}
builderConfigured := false
for _, flag := range flags {
if strings.HasPrefix(flag, "-B") || strings.HasPrefix(flag, "--builder") {
builderConfigured = true
}
}
if !builderConfigured {
flags = append(flags, "--builder=gcr.io/buildpacks/builder:v1")
}
return append(base, flags...)
}