1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/pipe/docker/api.go
Carlos Alexandro Becker 1883ed4a73
refactor: preparing for other docker implementations (#2314)
* wip: podman

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* refactor: preparing for other docker implementations

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* refactor: preparing for other docker implementations

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* fix: log

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* fix: use buildx

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* test: cover

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* fix: lint

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
2021-06-26 16:36:31 -03:00

44 lines
1.1 KiB
Go

package docker
import (
"context"
"os/exec"
"github.com/apex/log"
"github.com/goreleaser/goreleaser/pkg/config"
)
// imager is something that can build and push docker images.
type imager interface {
Build(ctx context.Context, root string, images, flags []string) error
Push(ctx context.Context, image string) error
}
// manifester is something that can create and push docker manifests.
type manifester interface {
Create(ctx context.Context, manifest string, images, flags []string) error
Push(ctx context.Context, manifest string, flags []string) error
}
func newManifester(manifest config.DockerManifest) manifester {
return dockerManifester{}
}
func newImager(docker config.Docker) imager {
return dockerImager{
buildx: docker.Use == useBuildx,
}
}
// nolint: unparam
func runCommand(ctx context.Context, dir, binary string, args ...string) error {
/* #nosec */
cmd := exec.CommandContext(ctx, binary, args...)
cmd.Dir = dir
log := log.WithField("cmd", cmd.Args).WithField("cwd", cmd.Dir)
log.Debug("running")
out, err := cmd.CombinedOutput()
log.Debug(string(out))
return err
}