Skip to content

Commit

Permalink
chore(signing): Fix jq command for modifying policy.json
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftydinar authored Dec 1, 2024
1 parent c065b14 commit ab654c9
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions modules/signing/signing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ fi

POLICY_FILE="$CONTAINER_DIR/policy.json"

yq -i -o=j '.transports.docker |=
{"'"$IMAGE_REGISTRY"'/'"$IMAGE_NAME"'": [
{
"type": "sigstoreSigned",
"keyPath": "/etc/pki/containers/'"$IMAGE_NAME_FILE"'.pub",
"signedIdentity": {
"type": "matchRepository"
}
jq --arg image_registry "$IMAGE_REGISTRY" \
--arg image_name "$IMAGE_NAME" \
--arg image_name_file "$IMAGE_NAME_FILE" \
'.transports.docker |=
{ ($image_registry + "/" + $image_name): [
{
"type": "sigstoreSigned",
"keyPath": ("/etc/pki/containers/" + $image_name_file + ".pub"),
"signedIdentity": {
"type": "matchRepository"
}
]
}
+ .' "$POLICY_FILE"
}
] } + .' "$POLICY_FILE" > /tmp/tmp-policy.json && mv /tmp/tmp-policy.json "$POLICY_FILE"

mv "$MODULE_DIRECTORY/signing/registry-config.yaml" "$CONTAINER_DIR/registries.d/$IMAGE_NAME_FILE.yaml"
sed -i "s ghcr.io/IMAGENAME $IMAGE_REGISTRY g" "$CONTAINER_DIR/registries.d/$IMAGE_NAME_FILE.yaml"

0 comments on commit ab654c9

Please sign in to comment.