From 1e86a09f958db609f4cf3118ea4468434df78551 Mon Sep 17 00:00:00 2001 From: Patrick Pichler Date: Mon, 8 Jul 2024 16:55:04 +0200 Subject: [PATCH] Fix fallback imagescan architecture The containerd host config is not always configured, causing a potential panic. Instead, the value of `runtime.GOARCH` is now used as the fallback value for image architecture. --- cmd/imagescan/collector/collector.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/imagescan/collector/collector.go b/cmd/imagescan/collector/collector.go index 6f52fbbb..5f6b8534 100644 --- a/cmd/imagescan/collector/collector.go +++ b/cmd/imagescan/collector/collector.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "os" + "runtime" "sort" "strings" "time" @@ -99,7 +100,7 @@ func (c *Collector) Collect(ctx context.Context) error { // There are rare cases where the Architecture of an image is not set (even though this doesn't appear to be // neither OCI nor docker image spec conform). This is not a 100% solution, but should be good enough. if strings.TrimSpace(arch) == "" { - arch = c.hostFsConfig.Platform.Architecture + arch = runtime.GOARCH } metadata := &castaipb.ImageMetadata{