1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-26 18:20:59 +00:00

feat: added info log when container image platform mismatched (#826)

Refs https://github.com/nektos/act/pull/3225

---

* added info log when container image platform mismatched

* inline image architecture comparison into ImageExistsLocally function as per review request

(cherry picked from commit 77d31c96a9486553908fdeb1c3053015238d5a0a)

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- features
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/826): <!--number 826 --><!--line 0 --><!--description ZmVhdDogYWRkZWQgaW5mbyBsb2cgd2hlbiBjb250YWluZXIgaW1hZ2UgcGxhdGZvcm0gbWlzbWF0Y2hlZA==-->feat: added info log when container image platform mismatched<!--description-->
<!--end release-notes-assistant-->

Co-authored-by: Ryan Fleet <rmfleet@gmail.com>
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/826
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-08-07 13:51:55 +00:00 committed by earl-warren
parent e22d12ae53
commit 5f1224ba5f
No known key found for this signature in database
GPG key ID: F128CBE6AB3A7201

View file

@ -6,6 +6,7 @@ import (
"context" "context"
"fmt" "fmt"
"code.forgejo.org/forgejo/runner/v9/act/common"
cerrdefs "github.com/containerd/errdefs" cerrdefs "github.com/containerd/errdefs"
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
) )
@ -26,10 +27,15 @@ func ImageExistsLocally(ctx context.Context, imageName, platform string) (bool,
return false, err return false, err
} }
if platform == "" || platform == "any" || fmt.Sprintf("%s/%s", inspectImage.Os, inspectImage.Architecture) == platform { imagePlatform := fmt.Sprintf("%s/%s", inspectImage.Os, inspectImage.Architecture)
if platform == "" || platform == "any" || imagePlatform == platform {
return true, nil 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 return false, nil
} }