upload/azure: use the new azure/azblob API on Fedora 33+ & RHEL

Fedora 33 and rawhide got an updated version of the azblob library. Sadly, it
introduced a non-compatible API change. This commit does the same thing as
a67baf5a did for kolo/xmlrpc:

We now have two wrappers around the affected part of the API. Fedora 32 uses
the wrapper around the old API, whereas Fedora 33 and 34 (and RHEL with its
vendored deps) use the wrapper around the new API. The switch is implemented
using go build flags and spec file magic.

See a67baf5a for more thoughts.

Also, there's v0.11.1-0.20201209121048-6df5d9af221d in go.mod, why?

The maintainers of azblob probably tagged a wrong commit with v0.12.0 which
breaks go. The long v0.11.1-.* version is basically the proper v0.12.0 commit.
See https://github.com/Azure/azure-storage-blob-go/issues/236 for more
information.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2021-01-05 13:44:27 +01:00 committed by Ondřej Budai
parent 946a0b425a
commit 1b05192298
214 changed files with 25345 additions and 98843 deletions

View file

@ -82,7 +82,7 @@ func UploadImage(credentials Credentials, metadata ImageMetadata, fileName strin
}
// Create page blob URL. Page blob is required for VM images
blobURL := containerURL.NewPageBlobURL(metadata.ImageName)
blobURL := newPageBlobURL(containerURL, metadata.ImageName)
_, err = blobURL.Create(ctx, stat.Size(), 0, azblob.BlobHTTPHeaders{}, azblob.Metadata{}, azblob.BlobAccessConditions{})
if err != nil {
return fmt.Errorf("cannot create the blob URL: %v", err)

View file

@ -0,0 +1,46 @@
// +build !azblob_oldapi
//
// This file provides a wrapper around azure/azblob PageBlobURL.
//
// Version 0.12 of the azblob library changed the API of PageBlobURL.
// (see https://github.com/Azure/azure-storage-blob-go/blob/master/BreakingChanges.md)
// This means that different APIs are available in Fedora 32 and 33 (it does
// not matter for RHEL as it uses vendored libraries).
// This wrapper allows us to use both azblob's APIs using buildflags.
//
// This file is a wrapper for azblob equal or newer than 0.12.
package azure
import (
"context"
"io"
"github.com/Azure/azure-storage-blob-go/azblob"
)
type PageBlobURL struct {
impl azblob.PageBlobURL
}
func newPageBlobURL(containerURL azblob.ContainerURL, blobName string) PageBlobURL {
pageblobURL := containerURL.NewPageBlobURL(blobName)
return PageBlobURL{pageblobURL}
}
func (pb PageBlobURL) Create(ctx context.Context, size int64, sequenceNumber int64, h azblob.BlobHTTPHeaders, metadata azblob.Metadata, ac azblob.BlobAccessConditions) (*azblob.PageBlobCreateResponse, error) {
return pb.impl.Create(ctx, size, sequenceNumber, h, metadata, ac, azblob.PremiumPageBlobAccessTierNone, azblob.BlobTagsMap{}, azblob.ClientProvidedKeyOptions{})
}
func (pb PageBlobURL) SetHTTPHeaders(ctx context.Context, h azblob.BlobHTTPHeaders, ac azblob.BlobAccessConditions) (*azblob.BlobSetHTTPHeadersResponse, error) {
return pb.impl.SetHTTPHeaders(ctx, h, ac)
}
func (pb PageBlobURL) UploadPages(ctx context.Context, offset int64, body io.ReadSeeker, ac azblob.PageBlobAccessConditions, transactionalMD5 []byte) (*azblob.PageBlobUploadPagesResponse, error) {
return pb.impl.UploadPages(ctx, offset, body, ac, transactionalMD5, azblob.ClientProvidedKeyOptions{})
}
func (pb PageBlobURL) GetProperties(ctx context.Context, ac azblob.BlobAccessConditions) (*azblob.BlobGetPropertiesResponse, error) {
return pb.impl.GetProperties(ctx, ac, azblob.ClientProvidedKeyOptions{})
}

View file

@ -0,0 +1,46 @@
// +build azblob_oldapi
//
// This file provides a wrapper around azure/azblob PageBlobURL.
//
// Version 0.12 of the azblob library changed the API of PageBlobURL.
// (see https://github.com/Azure/azure-storage-blob-go/blob/master/BreakingChanges.md)
// This means that different APIs are available in Fedora 32 and 33 (it does
// not matter for RHEL as it uses vendored libraries).
// This wrapper allows us to use both azblob's APIs using buildflags.
//
// This file is a wrapper for azblob older than 0.12.
package azure
import (
"context"
"io"
"github.com/Azure/azure-storage-blob-go/azblob"
)
type PageBlobURL struct {
impl azblob.PageBlobURL
}
func newPageBlobURL(containerURL azblob.ContainerURL, blobName string) PageBlobURL {
pageblobURL := containerURL.NewPageBlobURL(blobName)
return PageBlobURL{pageblobURL}
}
func (pb PageBlobURL) Create(ctx context.Context, size int64, sequenceNumber int64, h azblob.BlobHTTPHeaders, metadata azblob.Metadata, ac azblob.BlobAccessConditions) (*azblob.PageBlobCreateResponse, error) {
return pb.impl.Create(ctx, size, sequenceNumber, h, metadata, ac)
}
func (pb PageBlobURL) SetHTTPHeaders(ctx context.Context, h azblob.BlobHTTPHeaders, ac azblob.BlobAccessConditions) (*azblob.BlobSetHTTPHeadersResponse, error) {
return pb.impl.SetHTTPHeaders(ctx, h, ac)
}
func (pb PageBlobURL) UploadPages(ctx context.Context, offset int64, body io.ReadSeeker, ac azblob.PageBlobAccessConditions, transactionalMD5 []byte) (*azblob.PageBlobUploadPagesResponse, error) {
return pb.impl.UploadPages(ctx, offset, body, ac, transactionalMD5)
}
func (pb PageBlobURL) GetProperties(ctx context.Context, ac azblob.BlobAccessConditions) (*azblob.BlobGetPropertiesResponse, error) {
return pb.impl.GetProperties(ctx, ac)
}