MCPcopy Index your code
hub / github.com/devspace-sh/devspace / GetStrippedDockerImageName

Function GetStrippedDockerImageName

pkg/util/dockerfile/get.go:16–42  ·  view source on GitHub ↗

GetStrippedDockerImageName returns a tag stripped image name and checks if it's a valid image name

(imageName string)

Source from the content-addressed store, hash-verified

14
15// GetStrippedDockerImageName returns a tag stripped image name and checks if it's a valid image name
16func GetStrippedDockerImageName(imageName string) (string, string, error) {
17 imageName = strings.TrimSpace(imageName)
18
19 // Check if we can parse the name
20 ref, err := reference.ParseNormalizedNamed(imageName)
21 if err != nil {
22 return "", "", err
23 }
24
25 // Check if there was a tag
26 tag := ""
27 if refTagged, ok := ref.(reference.NamedTagged); ok {
28 tag = refTagged.Tag()
29 }
30
31 repoInfo, err := dockerregistry.ParseRepositoryInfo(ref)
32 if err != nil {
33 return "", "", err
34 }
35
36 if repoInfo.Index.Official {
37 // strip docker.io and library from image
38 return strings.TrimPrefix(strings.TrimPrefix(reference.TrimNamed(ref).Name(), repoInfo.Index.Name+"/library/"), repoInfo.Index.Name+"/"), tag, nil
39 }
40
41 return reference.TrimNamed(ref).Name(), tag, nil
42}
43
44// GetPorts retrieves all the exported ports from a dockerfile
45func GetPorts(filename string) ([]int, error) {

Callers 6

addPullSecretConfigMethod · 0.92
CompareImageNamesFunction · 0.92
adjustConfigFunction · 0.92
validateImagesFunction · 0.92
resolveImageFunction · 0.92
initDevspaceMethod · 0.92

Calls 1

NameMethod · 0.65

Tested by

no test coverage detected