internal/awscloud: use AWS.S3ObjectPresignedURL() from osbuild/images

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2025-08-06 13:46:59 +02:00 committed by Tomáš Hozza
parent a73820b4a8
commit 27bae770e9
2 changed files with 0 additions and 29 deletions

View file

@ -537,27 +537,6 @@ func (a *AWS) shareSnapshot(snapshotId string, userIds []string) error {
return nil
}
func (a *AWS) S3ObjectPresignedURL(bucket, objectKey string) (string, error) {
logrus.Infof("[AWS] 📋 Generating Presigned URL for S3 object %s/%s", bucket, objectKey)
req, err := a.s3presign.PresignGetObject(
context.Background(),
&s3.GetObjectInput{
Bucket: aws.String(bucket),
Key: aws.String(objectKey),
},
func(opts *s3.PresignOptions) {
opts.Expires = time.Duration(7 * 24 * time.Hour)
},
)
if err != nil {
return "", err
}
logrus.Info("[AWS] 🎉 S3 Presigned URL ready")
return req.URL, nil
}
func (a *AWS) Regions() ([]string, error) {
out, err := a.ec2.DescribeRegions(context.Background(), &ec2.DescribeRegionsInput{})
if err != nil {

View file

@ -9,14 +9,6 @@ import (
"github.com/osbuild/osbuild-composer/internal/common"
)
func TestS3ObjectPresignedURL(t *testing.T) {
aws := awscloud.NewForTest(nil, nil, nil, nil, &s3signmock{t, "bucket", "object-key"})
require.NotNil(t, aws)
url, err := aws.S3ObjectPresignedURL("bucket", "object-key")
require.NoError(t, err)
require.Equal(t, "https://url.real", url)
}
func TestEC2Register(t *testing.T) {
m := newEc2Mock(t)
aws := awscloud.NewForTest(m, nil, &s3mock{t, "bucket", "object-key"}, nil, nil)