internal/awscloud: use AWS.MarkS3ObjectAsPublic() from osbuild/images
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
13ba870fc6
commit
a73820b4a8
2 changed files with 0 additions and 24 deletions
|
|
@ -17,7 +17,6 @@ import (
|
||||||
"github.com/aws/aws-sdk-go-v2/service/ec2"
|
"github.com/aws/aws-sdk-go-v2/service/ec2"
|
||||||
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
|
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||||
s3types "github.com/aws/aws-sdk-go-v2/service/s3/types"
|
|
||||||
images_awscloud "github.com/osbuild/images/pkg/cloud/awscloud"
|
images_awscloud "github.com/osbuild/images/pkg/cloud/awscloud"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
@ -559,23 +558,6 @@ func (a *AWS) S3ObjectPresignedURL(bucket, objectKey string) (string, error) {
|
||||||
return req.URL, nil
|
return req.URL, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AWS) MarkS3ObjectAsPublic(bucket, objectKey string) error {
|
|
||||||
logrus.Infof("[AWS] 👐 Making S3 object public %s/%s", bucket, objectKey)
|
|
||||||
_, err := a.s3.PutObjectAcl(
|
|
||||||
context.Background(),
|
|
||||||
&s3.PutObjectAclInput{
|
|
||||||
Bucket: aws.String(bucket),
|
|
||||||
Key: aws.String(objectKey),
|
|
||||||
ACL: s3types.ObjectCannedACL(s3types.ObjectCannedACLPublicRead),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
logrus.Info("[AWS] ✔️ Making S3 object public successful")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *AWS) Regions() ([]string, error) {
|
func (a *AWS) Regions() ([]string, error) {
|
||||||
out, err := a.ec2.DescribeRegions(context.Background(), &ec2.DescribeRegionsInput{})
|
out, err := a.ec2.DescribeRegions(context.Background(), &ec2.DescribeRegionsInput{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,6 @@ import (
|
||||||
"github.com/osbuild/osbuild-composer/internal/common"
|
"github.com/osbuild/osbuild-composer/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestS3MarkObjectAsPublic(t *testing.T) {
|
|
||||||
aws := awscloud.NewForTest(nil, nil, &s3mock{t, "bucket", "object-key"}, nil, nil)
|
|
||||||
require.NotNil(t, aws)
|
|
||||||
require.NoError(t, aws.MarkS3ObjectAsPublic("bucket", "object-key"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestS3ObjectPresignedURL(t *testing.T) {
|
func TestS3ObjectPresignedURL(t *testing.T) {
|
||||||
aws := awscloud.NewForTest(nil, nil, nil, nil, &s3signmock{t, "bucket", "object-key"})
|
aws := awscloud.NewForTest(nil, nil, nil, nil, &s3signmock{t, "bucket", "object-key"})
|
||||||
require.NotNil(t, aws)
|
require.NotNil(t, aws)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue