diff --git a/internal/cloud/awscloud/awscloud.go b/internal/cloud/awscloud/awscloud.go index 9376b3be0..d80acc20f 100644 --- a/internal/cloud/awscloud/awscloud.go +++ b/internal/cloud/awscloud/awscloud.go @@ -218,30 +218,6 @@ func NewForEndpointFromFile(filename, endpoint, region, caBundle string, skipSSL return newAwsFromCredsWithEndpoint(config.WithSharedCredentialsFiles([]string{filename, "default"}), region, endpoint, caBundle, skipSSLVerification, imagesAWS) } -func (a *AWS) Upload(filename, bucket, key string) (*manager.UploadOutput, error) { - file, err := os.Open(filename) - if err != nil { - return nil, err - } - - defer func() { - err := file.Close() - if err != nil { - logrus.Warnf("[AWS] ‼ Failed to close the file uploaded to S3️: %v", err) - } - }() - - logrus.Infof("[AWS] 🚀 Uploading image to S3: %s/%s", bucket, key) - return a.s3uploader.Upload( - context.Background(), - &s3.PutObjectInput{ - Bucket: aws.String(bucket), - Key: aws.String(key), - Body: file, - }, - ) -} - // Register is a function that imports a snapshot, waits for the snapshot to // fully import, tags the snapshot, cleans up the image in S3, and registers // an AMI in AWS. diff --git a/internal/cloud/awscloud/awscloud_test.go b/internal/cloud/awscloud/awscloud_test.go index 1e3bb3695..7d8bbce7d 100644 --- a/internal/cloud/awscloud/awscloud_test.go +++ b/internal/cloud/awscloud/awscloud_test.go @@ -1,8 +1,6 @@ package awscloud_test import ( - "os" - "path/filepath" "testing" "github.com/stretchr/testify/require" @@ -17,16 +15,6 @@ func TestS3MarkObjectAsPublic(t *testing.T) { require.NoError(t, aws.MarkS3ObjectAsPublic("bucket", "object-key")) } -func TestS3Upload(t *testing.T) { - tmpDir := t.TempDir() - require.NoError(t, os.WriteFile(filepath.Join(tmpDir, "file"), []byte("imanimage"), 0600)) - - aws := awscloud.NewForTest(nil, nil, nil, &s3upldrmock{t, "imanimage", "bucket", "object-key"}, nil) - require.NotNil(t, aws) - _, err := aws.Upload(filepath.Join(tmpDir, "file"), "bucket", "object-key") - require.NoError(t, err) -} - func TestS3ObjectPresignedURL(t *testing.T) { aws := awscloud.NewForTest(nil, nil, nil, nil, &s3signmock{t, "bucket", "object-key"}) require.NotNil(t, aws)