extractImages reads from the bundled Dockerfile to extract the default docker image references.
()
| 107 | // extractImages reads from the bundled Dockerfile to extract the default docker |
| 108 | // image references. |
| 109 | func extractImages() (map[string]Image, error) { |
| 110 | images := make(map[string]Image) |
| 111 | for _, dockerfile := range []string{baseDockerfile, uvDockerfile} { |
| 112 | lines := strings.Split(dockerfile, "\n") |
| 113 | |
| 114 | for _, line := range lines { |
| 115 | if matches := fromLineRegex.FindStringSubmatch(strings.TrimSpace(line)); matches != nil { |
| 116 | ref := matches[1] |
| 117 | name := matches[2] |
| 118 | |
| 119 | image, err := NewImage(ref) |
| 120 | if err != nil { |
| 121 | return nil, fmt.Errorf("parsing %q image ref: %w", name, err) |
| 122 | } |
| 123 | |
| 124 | images[name] = image |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | for _, name := range baseImageNames { |
| 130 | if _, found := images[name]; !found { |
| 131 | return nil, fmt.Errorf("unable to find %q image ref", name) |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | return images, nil |
| 136 | } |
no test coverage detected