MCPcopy Create free account
hub / github.com/NVIDIA/gpu-operator / ImagePath

Function ImagePath

internal/image/image.go:25–54  ·  view source on GitHub ↗
(repository string, image string, version string, imagePathEnvName string)

Source from the content-addressed store, hash-verified

23)
24
25func ImagePath(repository string, image string, version string, imagePathEnvName string) (string, error) {
26 // ImagePath is obtained using following priority
27 // 1. CR (i.e through repository/image/path variables in CRD)
28 var crdImagePath string
29 if repository == "" && version == "" {
30 if image != "" {
31 // this is useful for tools like kbld(carvel) which transform templates into image as path@digest
32 crdImagePath = image
33 }
34 } else {
35 // use @ if image digest is specified instead of tag
36 if strings.HasPrefix(version, "sha256:") {
37 crdImagePath = repository + "/" + image + "@" + version
38 } else {
39 crdImagePath = repository + "/" + image + ":" + version
40 }
41 }
42 if crdImagePath != "" {
43 return crdImagePath, nil
44 }
45
46 // 2. Env passed to GPU Operator Pod (eg OLM)
47 envImagePath := os.Getenv(imagePathEnvName)
48 if envImagePath != "" {
49 return envImagePath, nil
50 }
51
52 // 3. If both are not set, error out
53 return "", fmt.Errorf("empty image path provided through both CR and ENV %s", imagePathEnvName)
54}

Callers 5

getDriverSpecFunction · 0.92
GetImagePathMethod · 0.92
GetImagePathMethod · 0.92
GetImagePathMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected