Skip to content

Commit

Permalink
Add missing check
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume J. Charmes <[email protected]>
  • Loading branch information
creack committed Jul 27, 2018
1 parent 99ffb74 commit f0365ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion assets/in
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ username=$(jq -r '.source.username // ""' < $payload)
password=$(jq -r '.source.password // ""' < $payload)
repository="$(jq -r '.source.repository // ""' < $payload)"
tag="$(jq -r '.source.tag // "latest"' < $payload)"
digest="$(jq -r '.source.digest // ""' < $payload)"
ca_certs=$(jq -r '.source.ca_certs // []' < $payload)
client_certs=$(jq -r '.source.client_certs // []' < $payload)
max_concurrent_downloads=$(jq -r '.source.max_concurrent_downloads // 3' < $payload)
Expand All @@ -45,7 +46,8 @@ else
registry=
fi

digest="$(jq -r '.version.digest' < $payload)"
# If the source digest is set, it takes precedence.
[ -z "$digest" ] && digest="$(jq -r '.version.digest' < $payload)"

rootfs="$(jq -r '.params.rootfs // false' < $payload)"
skip_download="$(jq -r '.params.skip_download // false' < $payload)"
Expand Down
6 changes: 6 additions & 0 deletions cmd/check/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ func main() {

// If we have a source digest, use it, otherwise, use the tag.
if request.Source.Digest != "" {
// Override the Version value if any.
request.Version.Digest = request.Source.Digest
namedref, err = reference.WithDigest(baseNamedRef, digest.Digest(request.Source.Digest))
fatalIf("failed to construct digested reference", err)
} else {
Expand Down Expand Up @@ -121,6 +123,10 @@ func main() {
response = append(response, Version{latestDigest})
}

if request.Source.Digest != "" && len(response) == 0 {
fatalIf("digest not found", fmt.Errorf("%q", request.Source.Digest))
}

json.NewEncoder(os.Stdout).Encode(response)
}

Expand Down

0 comments on commit f0365ad

Please sign in to comment.