mirror of
https://github.com/containers/podman.git
synced 2025-09-22 12:14:26 +08:00
vendor c/common
Also update the e2e pull test to account for the changes when pulling from the dir transport. Images pulled via the dir transport are not tagged anymore; the path is not a reliable source. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
38
vendor/github.com/containers/common/libimage/normalize.go
generated
vendored
38
vendor/github.com/containers/common/libimage/normalize.go
generated
vendored
@ -1,13 +1,51 @@
|
||||
package libimage
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containers/image/v5/docker/reference"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// NormalizePlatform normalizes (according to the OCI spec) the specified os,
|
||||
// arch and variant. If left empty, the individual item will not be normalized.
|
||||
func NormalizePlatform(rawOS, rawArch, rawVariant string) (os, arch, variant string) {
|
||||
os, arch, variant = rawOS, rawArch, rawVariant
|
||||
if os == "" {
|
||||
os = runtime.GOOS
|
||||
}
|
||||
if arch == "" {
|
||||
arch = runtime.GOARCH
|
||||
}
|
||||
rawPlatform := os + "/" + arch
|
||||
if variant != "" {
|
||||
rawPlatform += "/" + variant
|
||||
}
|
||||
|
||||
normalizedPlatform, err := platforms.Parse(rawPlatform)
|
||||
if err != nil {
|
||||
logrus.Debugf("Error normalizing platform: %v", err)
|
||||
return rawOS, rawArch, rawVariant
|
||||
}
|
||||
logrus.Debugf("Normalized platform %s to %s", rawPlatform, normalizedPlatform)
|
||||
os = rawOS
|
||||
if rawOS != "" {
|
||||
os = normalizedPlatform.OS
|
||||
}
|
||||
arch = rawArch
|
||||
if rawArch != "" {
|
||||
arch = normalizedPlatform.Architecture
|
||||
}
|
||||
variant = rawVariant
|
||||
if rawVariant != "" {
|
||||
variant = normalizedPlatform.Variant
|
||||
}
|
||||
return os, arch, variant
|
||||
}
|
||||
|
||||
// NormalizeName normalizes the provided name according to the conventions by
|
||||
// Podman and Buildah. If tag and digest are missing, the "latest" tag will be
|
||||
// used. If it's a short name, it will be prefixed with "localhost/".
|
||||
|
Reference in New Issue
Block a user