fix: ban podman 4.3 for pack build (#1563)

Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
Matej Vasek 2023-02-20 18:16:25 +01:00 committed by GitHub
parent 6d4565158b
commit 138d1e46c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
"runtime"
"strings"
"github.com/Masterminds/semver"
pack "github.com/buildpacks/pack/pkg/client"
"github.com/buildpacks/pack/pkg/logging"
"github.com/docker/docker/client"
@ -144,6 +145,10 @@ func (b *Builder) Build(ctx context.Context, f fn.Function) (err error) {
defer cli.Close()
opts.DockerHost = dockerHost
if ok, _ := isPodmanV43(ctx, cli); ok {
return fmt.Errorf("podman 4.3 is not supported, use podman 4.2 or 4.4")
}
// Client with a logger which is enabled if in Verbose mode and a dockerClient that supports SSH docker daemon connection.
if impl, err = pack.NewClient(pack.WithLogger(b.logger), pack.WithDockerClient(cli)); err != nil {
return fmt.Errorf("cannot create pack client: %w", err)
@ -164,6 +169,24 @@ func (b *Builder) Build(ctx context.Context, f fn.Function) (err error) {
return
}
func isPodmanV43(ctx context.Context, cli client.CommonAPIClient) (b bool, err error) {
version, err := cli.ServerVersion(ctx)
if err != nil {
return
}
for _, component := range version.Components {
if component.Name == "Podman Engine" {
v := semver.MustParse(version.Version)
if v.Major() == 4 && v.Minor() == 3 {
return true, nil
}
break
}
}
return
}
// TrustBuilder determines whether the builder image should be trusted
// based on a set of trusted builder image registry prefixes.
func TrustBuilder(b string) bool {