/
githubmirror
/
act
Обзор
Документация
Войти
/
githubmirror
/
act
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
pkg/container/docker_images.go
66 строк
2 KB
Casey Lee
build(deps): bump GitHub Actions to fix Node.js 20 deprecation (#6036)
24 мар 2026, 18:06
Не верифицирован
24 мар 2026, 18:06
10add23
Код
Авторство
О чём код?
//go:build !(WITHOUT_DOCKER || !(linux || darwin || windows || netbsd)) package container import ( "context" "fmt" cerrdefs "github.com/containerd/errdefs" "github.com/moby/moby/client" "github.com/nektos/act/pkg/common" ) // ImageExistsLocally returns a boolean indicating if an image with the // requested name, tag and architecture exists in the local docker image store func ImageExistsLocally(ctx context.Context, imageName string, platform string) (bool, error) { cli, err := GetDockerClient(ctx) if err != nil { return false, err } defer cli.Close() inspectImage, err := cli.ImageInspect(ctx, imageName) if cerrdefs.IsNotFound(err) { return false, nil } else if err != nil { return false, err } imagePlatform := fmt.Sprintf("%s/%s", inspectImage.Os, inspectImage.Architecture) if platform == "" || platform == "any" || imagePlatform == platform { return true, nil } logger := common.Logger(ctx) logger.Infof("image found but platform does not match: %s (image) != %s (platform)\n", imagePlatform, platform) return false, nil } // RemoveImage removes image from local store, the function is used to run different // container image architectures func RemoveImage(ctx context.Context, imageName string, force bool, pruneChildren bool) (bool, error) { cli, err := GetDockerClient(ctx) if err != nil { return false, err } defer cli.Close() inspectImage, err := cli.ImageInspect(ctx, imageName) if cerrdefs.IsNotFound(err) { return false, nil } else if err != nil { return false, err } if _, err = cli.ImageRemove(ctx, inspectImage.ID, client.ImageRemoveOptions{ Force: force, PruneChildren: pruneChildren, }); err != nil { return false, err } return true, nil }