Skip to content

Commit

Permalink
Fix fallback imagescan architecture
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
patrickpichler committed Jul 8, 2024
1 parent d35d126 commit 1e86a09
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/imagescan/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"os"
"runtime"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 1e86a09

Please sign in to comment.