MCPcopy
hub / github.com/nektos/act / ImageExistsLocally

Function ImageExistsLocally

pkg/container/docker_images.go:16–40  ·  view source on GitHub ↗

ImageExistsLocally returns a boolean indicating if an image with the requested name, tag and architecture exists in the local docker image store

(ctx context.Context, imageName string, platform string)

Source from the content-addressed store, hash-verified

14// ImageExistsLocally returns a boolean indicating if an image with the
15// requested name, tag and architecture exists in the local docker image store
16func ImageExistsLocally(ctx context.Context, imageName string, platform string) (bool, error) {
17 cli, err := GetDockerClient(ctx)
18 if err != nil {
19 return false, err
20 }
21 defer cli.Close()
22
23 inspectImage, err := cli.ImageInspect(ctx, imageName)
24 if cerrdefs.IsNotFound(err) {
25 return false, nil
26 } else if err != nil {
27 return false, err
28 }
29
30 imagePlatform := fmt.Sprintf("%s/%s", inspectImage.Os, inspectImage.Architecture)
31
32 if platform == "" || platform == "any" || imagePlatform == platform {
33 return true, nil
34 }
35
36 logger := common.Logger(ctx)
37 logger.Infof("image found but platform does not match: %s (image) != %s (platform)\n", imagePlatform, platform)
38
39 return false, nil
40}
41
42// RemoveImage removes image from local store, the function is used to run different
43// container image architectures

Callers 1

execAsDockerFunction · 0.92

Calls 3

LoggerFunction · 0.92
GetDockerClientFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…