feat(storage): Add support for content-types (GCS only)

Extends storage.Persist to accept a Content-Type argument, which in
the GCS backend is persisted with the object to ensure that the object
is served back with this content-type.

This is not yet implemented for the filesystem backend, where the
parameter is simply ignored.

This should help in the case of clients which expect the returned
objects to have content-types set when, for example, fetching layers
by digest.
This commit is contained in:
Vincent Ambo 2020-10-29 16:13:53 +01:00 committed by Vincent Ambo
parent 8a5c446bab
commit cc35bf0fc3
7 changed files with 34 additions and 13 deletions

View file

@ -420,7 +420,7 @@ func (b *byteCounter) Write(p []byte) (n int, err error) {
// image manifest.
func uploadHashLayer(ctx context.Context, s *State, key string, lw layerWriter) (*manifest.Entry, error) {
path := "staging/" + key
sha256sum, size, err := s.Storage.Persist(ctx, path, func(sw io.Writer) (string, int64, error) {
sha256sum, size, err := s.Storage.Persist(ctx, path, manifest.LayerType, func(sw io.Writer) (string, int64, error) {
// Sets up a "multiwriter" that simultaneously runs both hash
// algorithms and uploads to the storage backend.
shasum := sha256.New()