Skip to content

Commit

Permalink
Merge pull request #74 from atomist-skills/check-without-context
Browse files Browse the repository at this point in the history
check public images by querying without context
  • Loading branch information
chrispatrick committed Mar 7, 2024
2 parents 93c9635 + e17e92e commit 96f03e3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions policy/policy_handler/mocks/base_image_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package mocks

import (
"context"
"fmt"

"github.com/atomist-skills/go-skill"
"github.com/atomist-skills/go-skill/policy/data"
Expand Down Expand Up @@ -93,7 +92,18 @@ func mockBaseImageDetails(ctx context.Context, req skill.RequestContext, sb *typ
}

if queryResponse.ImageDetailsByDigest == nil {
return ImageDetailsByDigestResponse{}, fmt.Errorf("no base images found for digest %s", baseImageDigest)
// if base image is not found in skill context org, then try with no org in case it is public

queryVariables["context"] = map[string]interface{}{}
_, err := ds.Query(ctx, imageDetailsByDigestQueryName, imageDetailsByDigestQuery, queryVariables, &queryResponse)
if err != nil {
return ImageDetailsByDigestResponse{}, err
}

if queryResponse.ImageDetailsByDigest == nil {
req.Log.Info("Base image could not be found")
return ImageDetailsByDigestResponse{}, nil
}
}

baseImage := queryResponse.ImageDetailsByDigest
Expand Down

0 comments on commit 96f03e3

Please sign in to comment.