Use OCI upload implementation from osbuild/images (HMS-9027)
Delete the OCI upload implementation from osbuild-composer and use the one from osbuild/images. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
00a466f7c6
commit
bce2bbf9e1
6 changed files with 23 additions and 24 deletions
|
|
@ -7,7 +7,7 @@ import (
|
|||
"math/big"
|
||||
"os"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/oci"
|
||||
"github.com/osbuild/images/pkg/upload/oci"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,25 +16,23 @@ import (
|
|||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/osbuild/images/pkg/arch"
|
||||
"github.com/osbuild/images/pkg/container"
|
||||
"github.com/osbuild/images/pkg/distro"
|
||||
"github.com/osbuild/images/pkg/osbuild"
|
||||
"github.com/osbuild/images/pkg/sbom"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/oci"
|
||||
|
||||
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
|
||||
"github.com/osbuild/images/pkg/arch"
|
||||
"github.com/osbuild/images/pkg/cloud/azure"
|
||||
"github.com/osbuild/images/pkg/container"
|
||||
"github.com/osbuild/images/pkg/distro"
|
||||
"github.com/osbuild/images/pkg/osbuild"
|
||||
"github.com/osbuild/images/pkg/platform"
|
||||
"github.com/osbuild/images/pkg/sbom"
|
||||
"github.com/osbuild/images/pkg/upload/koji"
|
||||
"github.com/osbuild/images/pkg/upload/oci"
|
||||
"github.com/osbuild/images/pkg/upload/vmware"
|
||||
"github.com/osbuild/osbuild-composer/internal/cloud/awscloud"
|
||||
"github.com/osbuild/osbuild-composer/internal/cloud/gcp"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuildexecutor"
|
||||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ import (
|
|||
"github.com/osbuild/images/pkg/dnfjson"
|
||||
"github.com/osbuild/images/pkg/olog"
|
||||
"github.com/osbuild/images/pkg/upload/koji"
|
||||
"github.com/osbuild/images/pkg/upload/oci"
|
||||
"github.com/osbuild/osbuild-composer/internal/cloud/awscloud"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/oci"
|
||||
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||
)
|
||||
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -34,7 +34,6 @@ require (
|
|||
github.com/oapi-codegen/oapi-codegen/v2 v2.5.0
|
||||
github.com/oapi-codegen/runtime v1.1.2
|
||||
github.com/openshift-online/ocm-sdk-go v0.1.473
|
||||
github.com/oracle/oci-go-sdk/v54 v54.0.0
|
||||
github.com/osbuild/blueprint v1.12.0
|
||||
github.com/osbuild/images v0.175.0
|
||||
github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240814102216-0239db53236d
|
||||
|
|
@ -176,6 +175,7 @@ require (
|
|||
github.com/opencontainers/image-spec v1.1.1 // indirect
|
||||
github.com/opencontainers/runtime-spec v1.2.1 // indirect
|
||||
github.com/opencontainers/selinux v1.12.0 // indirect
|
||||
github.com/oracle/oci-go-sdk/v54 v54.0.0 // indirect
|
||||
github.com/perimeterx/marshmallow v1.1.5 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package oci
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
|
@ -14,6 +13,7 @@ import (
|
|||
"github.com/oracle/oci-go-sdk/v54/objectstorage"
|
||||
"github.com/oracle/oci-go-sdk/v54/objectstorage/transfer"
|
||||
"github.com/oracle/oci-go-sdk/v54/workrequests"
|
||||
"github.com/osbuild/images/pkg/olog"
|
||||
)
|
||||
|
||||
type Uploader interface {
|
||||
|
|
@ -43,7 +43,7 @@ func (c Client) CreateImage(objectName, bucketName, namespace, compartmentID, im
|
|||
// clean up the object even if we fail
|
||||
defer func() {
|
||||
if err := c.deleteObjectFromBucket(objectName, bucketName, namespace); err != nil {
|
||||
log.Printf("failed to clean up the object '%s' from bucket '%s'", objectName, bucketName)
|
||||
olog.Printf("failed to clean up the object '%s' from bucket '%s'", objectName, bucketName)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
@ -92,9 +92,9 @@ func (c Client) uploadToBucket(objectName string, bucketName string, namespace s
|
|||
ObjectName: common.String(objectName),
|
||||
CallBack: func(multiPartUploadPart transfer.MultiPartUploadPart) {
|
||||
if multiPartUploadPart.Err != nil {
|
||||
log.Printf("upload failure: %s\n", multiPartUploadPart.Err)
|
||||
olog.Printf("upload failure: %s\n", multiPartUploadPart.Err)
|
||||
}
|
||||
log.Printf("multipart upload stats: parts %d, total-parts %d\n",
|
||||
olog.Printf("multipart upload stats: parts %d, total-parts %d\n",
|
||||
multiPartUploadPart.PartNum,
|
||||
multiPartUploadPart.TotalParts)
|
||||
},
|
||||
|
|
@ -146,7 +146,7 @@ func (c Client) createImage(objectName, bucketName, namespace, compartmentID, im
|
|||
return "", fmt.Errorf("failed to create an image from storage object: %w", err)
|
||||
}
|
||||
|
||||
log.Printf("waiting for the work request to complete, this may take a while. Work request ID: %s\n", *createImageResponse.OpcWorkRequestId)
|
||||
olog.Printf("waiting for the work request to complete, this may take a while. Work request ID: %s\n", *createImageResponse.OpcWorkRequestId)
|
||||
for {
|
||||
r, err := c.workRequestsClient.GetWorkRequest(context.Background(), workrequests.GetWorkRequestRequest{
|
||||
WorkRequestId: createImageResponse.OpcWorkRequestId,
|
||||
|
|
@ -164,7 +164,7 @@ func (c Client) createImage(objectName, bucketName, namespace, compartmentID, im
|
|||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
log.Printf("work request complete, creating the compute image capability schema based on a global one")
|
||||
olog.Printf("work request complete, creating the compute image capability schema based on a global one")
|
||||
listGlobalCS := core.ListComputeGlobalImageCapabilitySchemasRequest{
|
||||
Limit: common.Int(1),
|
||||
}
|
||||
|
|
@ -238,11 +238,11 @@ func (c Client) createImage(objectName, bucketName, namespace, compartmentID, im
|
|||
}
|
||||
|
||||
type ClientParams struct {
|
||||
User string `toml:"user"`
|
||||
Region string `toml:"region"`
|
||||
Tenancy string `toml:"tenancy"`
|
||||
PrivateKey string `toml:"private_key"`
|
||||
Fingerprint string `toml:"fingerprint"`
|
||||
User string
|
||||
Region string
|
||||
Tenancy string
|
||||
PrivateKey string
|
||||
Fingerprint string
|
||||
}
|
||||
|
||||
type ociClient struct {
|
||||
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
|
|
@ -1017,6 +1017,7 @@ github.com/osbuild/images/pkg/runner
|
|||
github.com/osbuild/images/pkg/sbom
|
||||
github.com/osbuild/images/pkg/shutil
|
||||
github.com/osbuild/images/pkg/upload/koji
|
||||
github.com/osbuild/images/pkg/upload/oci
|
||||
github.com/osbuild/images/pkg/upload/vmware
|
||||
# github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240814102216-0239db53236d
|
||||
## explicit; go 1.21
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue