spec: drop hacks for Fedora 32
There are not needed anymore, yay! Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
5ae6203d65
commit
385648223d
7 changed files with 14 additions and 182 deletions
|
|
@ -98,8 +98,8 @@ func (c StorageClient) UploadPageBlob(metadata BlobMetadata, fileName string, th
|
|||
}
|
||||
|
||||
// Create page blob URL. Page blob is required for VM images
|
||||
blobURL := newPageBlobURL(containerURL, metadata.BlobName)
|
||||
_, err = blobURL.Create(ctx, stat.Size(), 0, azblob.BlobHTTPHeaders{}, azblob.Metadata{}, azblob.BlobAccessConditions{})
|
||||
blobURL := containerURL.NewPageBlobURL(metadata.BlobName)
|
||||
_, err = blobURL.Create(ctx, stat.Size(), 0, azblob.BlobHTTPHeaders{}, azblob.Metadata{}, azblob.BlobAccessConditions{}, azblob.PremiumPageBlobAccessTierNone, azblob.BlobTagsMap{}, azblob.ClientProvidedKeyOptions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot create the blob URL: %v", err)
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ func (c StorageClient) UploadPageBlob(metadata BlobMetadata, fileName string, th
|
|||
semaphore <- 1
|
||||
go func(counter int64, buffer []byte, n int) {
|
||||
defer wg.Done()
|
||||
_, err = blobURL.UploadPages(ctx, counter*azblob.PageBlobMaxUploadPagesBytes, bytes.NewReader(buffer[:n]), azblob.PageBlobAccessConditions{}, nil)
|
||||
_, err = blobURL.UploadPages(ctx, counter*azblob.PageBlobMaxUploadPagesBytes, bytes.NewReader(buffer[:n]), azblob.PageBlobAccessConditions{}, nil, azblob.ClientProvidedKeyOptions{})
|
||||
if err != nil {
|
||||
err = fmt.Errorf("uploading a page failed: %v", err)
|
||||
// Send the error to the error channel in a non-blocking way. If there is already an error, just discard this one
|
||||
|
|
@ -160,7 +160,7 @@ func (c StorageClient) UploadPageBlob(metadata BlobMetadata, fileName string, th
|
|||
default:
|
||||
}
|
||||
// Check properties, specifically MD5 sum of the blob
|
||||
props, err := blobURL.GetProperties(ctx, azblob.BlobAccessConditions{})
|
||||
props, err := blobURL.GetProperties(ctx, azblob.BlobAccessConditions{}, azblob.ClientProvidedKeyOptions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting the properties of the new blob failed: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
// +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{})
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
// +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)
|
||||
}
|
||||
|
|
@ -14,8 +14,9 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/kolo/xmlrpc"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/ubccr/kerby/khttp"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
type Koji struct {
|
||||
|
|
@ -314,9 +315,15 @@ func (k *Koji) uploadChunk(chunk []byte, filepath, filename string, offset uint6
|
|||
HexDigest string `xmlrpc:"hexdigest"`
|
||||
}
|
||||
|
||||
err = processXMLRPCResponse(body, &reply)
|
||||
resp := xmlrpc.Response(body)
|
||||
|
||||
if resp.Err() != nil {
|
||||
return fmt.Errorf("xmlrpc server returned an error: %v", resp.Err())
|
||||
}
|
||||
|
||||
err = resp.Unmarshal(&reply)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("cannot unmarshal the xmlrpc response: %v", err)
|
||||
}
|
||||
|
||||
if reply.Size != len(chunk) {
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
// +build kolo_xmlrpc_oldapi
|
||||
//
|
||||
// This file provides a wrapper around kolo/xmlrpc response handling.
|
||||
//
|
||||
// Commit e3ad6d89 of the xmlrpc library changed the API of response handling.
|
||||
// This means that different APIs are available in Fedora 32 and 33 (it does
|
||||
// not matter for RHEL as uses vendored libraries).
|
||||
// This wrapper allows us to use both xmlrpc's APIs using buildflags.
|
||||
//
|
||||
// This file is a wrapper for xmlrpc older than e3ad6d89.
|
||||
|
||||
package koji
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kolo/xmlrpc"
|
||||
)
|
||||
|
||||
// processXMLRPCResponse is a wrapper around kolo/xmlrpc
|
||||
func processXMLRPCResponse(body []byte, reply interface{}) error {
|
||||
resp := xmlrpc.NewResponse(body)
|
||||
if resp.Failed() {
|
||||
return fmt.Errorf("xmlrpc server returned an error: %v", resp.Err())
|
||||
}
|
||||
|
||||
err := resp.Unmarshal(reply)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot unmarshal the xmlrpc response: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
// +build !kolo_xmlrpc_oldapi
|
||||
//
|
||||
// This file provides a wrapper around kolo/xmlrpc response handling.
|
||||
//
|
||||
// Commit e3ad6d89 of the xmlrpc library changed the API of response handling.
|
||||
// This means that different APIs are available in Fedora 32 and 33 (it does
|
||||
// not matter for RHEL as uses vendored libraries).
|
||||
// This wrapper allows us to use both xmlrpc's APIs using buildflags.
|
||||
//
|
||||
// This file is a wrapper for xmlrpc equal or newer than e3ad6d89.
|
||||
|
||||
package koji
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kolo/xmlrpc"
|
||||
)
|
||||
|
||||
// processXMLRPCResponse is a wrapper around kolo/xmlrpc
|
||||
func processXMLRPCResponse(body []byte, reply interface{}) error {
|
||||
resp := xmlrpc.Response(body)
|
||||
|
||||
if resp.Err() != nil {
|
||||
return fmt.Errorf("xmlrpc server returned an error: %v", resp.Err())
|
||||
}
|
||||
|
||||
err := resp.Unmarshal(reply)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot unmarshal the xmlrpc response: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -94,22 +94,6 @@ Obsoletes: osbuild-composer-koji <= 23
|
|||
%goprep
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} && 0%{?fedora} <= 32
|
||||
# Fedora 32 and older ships different kolo/xmlrpc and azure/azblob APIs. We
|
||||
# cannot specify build tags in gobuild macro because the macro itself
|
||||
# specifies build tags and -tags argument cannot be used more than once.
|
||||
# Therefore, this ugly hack with build tags switcharoo is required.
|
||||
# Remove when F32 is EOL.
|
||||
|
||||
# Remove the build constraint from the wrappers of the old APIs
|
||||
sed -i "s$// +build kolo_xmlrpc_oldapi$// +build !kolo_xmlrpc_oldapi$" internal/upload/koji/xmlrpc-response-oldapi.go
|
||||
sed -i "s$// +build azblob_oldapi$// +build !azblob_oldapi$" internal/upload/azure/page_blob_url_oldapi.go
|
||||
|
||||
# Add a build constraint to the wrappers of the new APIs
|
||||
sed -i "s$// +build !kolo_xmlrpc_oldapi$// +build kolo_xmlrpc_oldapi$" internal/upload/koji/xmlrpc-response.go
|
||||
sed -i "s$// +build !azblob_oldapi$// +build azblob_oldapi$" internal/upload/azure/page_blob_url.go
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} >= 34
|
||||
# Fedora 34 and newer ships a newer version of github.com/getkin/kin-openapi
|
||||
# package which has a different API than the older ones. Let's make the auto-
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue