-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attestations: merge attestation refs into result refs map
This patch reworks the attestations code to place its refs into the correponding Result.Refs map, to allow for easier conversions between gateway boundaries. This ensures that almost all conversions (notably, except the tranformation to protobuf), can be performed in a single line, similar to how Metadata is copied. Additionally, this prevents multiple different Attestation types, and allows a single one defined in a common package. To acheive this, instead of including a Ref type directly in each Attestation, we include a key to a ref, which can be looked up in the Result's Ref map. This key must be uniquely generated when attestations are added - note that we cannot use the same Ref ID as seen in the protobuf structure (which would be nice) as the gateway forwarder does not convert to protobuf and simply applies the forwarding in-memory, so we need a uniquely generated id. To distinguish between these IDs and past/present/future contents of the ref map, we use the "attestation:" prefix, which would allow for future extension in a similar way. (Note: as written, the gateway protobuf for the in-toto attestation is modified to contain a ref-key instead of a ref directly. This isn't a requirement, and we could easily preserve compatibility at the protobuf level by performing a transformation in the helper functions in frontend/gateway/pb/attestation.go.) Aside from the change in types and conversion logic, the only major changes are in the creation of attestations and the export of attestations. For the creation of attestations, we need to change the AddAttestation function into an InTotoAttestationAttestation, so as to allow passing a Ref alongside, which allows for encapsulation of the prefix logic, and would allow us to possibly change the transport mechanism for attestations in the future. For the export of attestations, we simply introduce a layer of indirection to lookup the attestation in the refs map. A caveat of this approach is that the behavior of the Refs map will change. This will require frontends to detect the presence of specific caps in the buildkit backend (not added yet in this patch), to ensure that attestations are only attached if they are supported, otherwise the local/tar exporters will behave unexpectedly. Signed-off-by: Justin Chadwell <[email protected]>
- Loading branch information
Showing
17 changed files
with
358 additions
and
524 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.