grafeas / kritis

Deploy-time Policy Enforcer for Kubernetes applications
https://github.com/grafeas/kritis/blob/master/docs/binary-authorization.md
Apache License 2.0
696 stars 133 forks source link

Add UploadAttestationOccurrence() method in metadata client interface #557

Closed ooq closed 4 years ago

ooq commented 4 years ago

Add UploadAttestationOccurrence() method in metadata client interface and all its implementations.

A helper method CreateOccurrenceFromAttestation() and its tests are added in the process to deduplicate code.

The existing CreateAttestationOccurrence() will now use UploadAttestationOccurrence() to upload attestation after creating it. In the long term, we consider deleting CreateAttestationOccurrence() altogether because attestation creation should be the caller's responsibility instead of the metadata client.

UploadAttestationOccurrence() also supports both GenericSignedAttestation and PgpSignedAttestation, while CreateAttestationOccurrence() only supports the latter.

Testing for UploadAttestationOccurrence() is covered by existing CreateAttestationOccurrence() tests, because CreateAttestationOccurrence() is the only caller of UploadAttestationOccurrence() as for now.