MCPcopy Create free account
hub / github.com/containers/common / NormalizePlatform

Function NormalizePlatform

libimage/normalize.go:15–47  ·  view source on GitHub ↗

NormalizePlatform normalizes (according to the OCI spec) the specified os, arch and variant. If left empty, the individual item will not be normalized.

(rawOS, rawArch, rawVariant string)

Source from the content-addressed store, hash-verified

13// NormalizePlatform normalizes (according to the OCI spec) the specified os,
14// arch and variant. If left empty, the individual item will not be normalized.
15func NormalizePlatform(rawOS, rawArch, rawVariant string) (os, arch, variant string) {
16 os, arch, variant = rawOS, rawArch, rawVariant
17 if os == "" {
18 os = runtime.GOOS
19 }
20 if arch == "" {
21 arch = runtime.GOARCH
22 }
23 rawPlatform := os + "/" + arch
24 if variant != "" {
25 rawPlatform += "/" + variant
26 }
27
28 normalizedPlatform, err := platforms.Parse(rawPlatform)
29 if err != nil {
30 logrus.Debugf("Error normalizing platform: %v", err)
31 return rawOS, rawArch, rawVariant
32 }
33 logrus.Debugf("Normalized platform %s to %s", rawPlatform, normalizedPlatform)
34 os = rawOS
35 if rawOS != "" {
36 os = normalizedPlatform.OS
37 }
38 arch = rawArch
39 if rawArch != "" {
40 arch = normalizedPlatform.Architecture
41 }
42 variant = rawVariant
43 if rawVariant != "" {
44 variant = normalizedPlatform.Variant
45 }
46 return os, arch, variant
47}
48
49// NormalizeName normalizes the provided name according to the conventions by
50// Podman and Buildah. If tag and digest are missing, the "latest" tag will be

Callers 3

newCopierMethod · 0.85
LookupImageMethod · 0.85
TestNormalizePlatformFunction · 0.85

Calls 1

ParseMethod · 0.45

Tested by 1

TestNormalizePlatformFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…