Skip to content

Commit 5f1224b

Browse files
earl-warrenrmfleet
authored andcommitted
feat: added info log when container image platform mismatched (#826)
Refs nektos/act#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 <[email protected]> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/826 Reviewed-by: Mathieu Fenniak <[email protected]> Co-authored-by: Earl Warren <[email protected]> Co-committed-by: Earl Warren <[email protected]>
1 parent e22d12a commit 5f1224b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

act/container/docker_images.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"fmt"
88

9+
"code.forgejo.org/forgejo/runner/v9/act/common"
910
cerrdefs "github.com/containerd/errdefs"
1011
"github.com/docker/docker/api/types/image"
1112
)
@@ -26,10 +27,15 @@ func ImageExistsLocally(ctx context.Context, imageName, platform string) (bool,
2627
return false, err
2728
}
2829

29-
if platform == "" || platform == "any" || fmt.Sprintf("%s/%s", inspectImage.Os, inspectImage.Architecture) == platform {
30+
imagePlatform := fmt.Sprintf("%s/%s", inspectImage.Os, inspectImage.Architecture)
31+
32+
if platform == "" || platform == "any" || imagePlatform == platform {
3033
return true, nil
3134
}
3235

36+
logger := common.Logger(ctx)
37+
logger.Infof("image found but platform does not match: %s (image) != %s (platform)\n", imagePlatform, platform)
38+
3339
return false, nil
3440
}
3541

0 commit comments

Comments
 (0)