s3util.go

Copyright 2022 Red Hat, Inc

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package s3util contains helper functions to provide high level interface to S3 storage.

package
s3util

Documentation in literate-programming-style is available at: https://redhatinsights.github.io/insights-operator-utils/packages/s3/s3util.html


import
(
"context"
"github.com/aws/aws-sdk-go-v2/service/s3"
)

CopyObjectAPIClient defines the interface for S3 copy operations

type
CopyObjectAPIClient
interface
{
CopyObject
(
context
.
Context
,
*
s3
.
CopyObjectInput
,
...
func
(
*
s3
.
Options
)
)
(
*
s3
.
CopyObjectOutput
,
error
)
}

DeleteObjectsAPIClient defines the interface for S3 delete operations

type
DeleteObjectsAPIClient
interface
{
DeleteObject
(
context
.
Context
,
*
s3
.
DeleteObjectInput
,
...
func
(
*
s3
.
Options
)
)
(
*
s3
.
DeleteObjectOutput
,
error
)
DeleteObjects
(
context
.
Context
,
*
s3
.
DeleteObjectsInput
,
...
func
(
*
s3
.
Options
)
)
(
*
s3
.
DeleteObjectsOutput
,
error
)
}

GetObjectAPIClient defines the interface for S3 get object operations

type
GetObjectAPIClient
interface
{
GetObject
(
context
.
Context
,
*
s3
.
GetObjectInput
,
...
func
(
*
s3
.
Options
)
)
(
*
s3
.
GetObjectOutput
,
error
)
}

HeadObjectAPIClient defines the interface for S3 head object operations

type
HeadObjectAPIClient
interface
{
HeadObject
(
context
.
Context
,
*
s3
.
HeadObjectInput
,
...
func
(
*
s3
.
Options
)
)
(
*
s3
.
HeadObjectOutput
,
error
)
}

ListObjectsV2APIClient defines the interface for S3 list objects v2 operations

type
ListObjectsV2APIClient
interface
{
ListObjectsV2
(
context
.
Context
,
*
s3
.
ListObjectsV2Input
,
...
func
(
*
s3
.
Options
)
)
(
*
s3
.
ListObjectsV2Output
,
error
)
}

PutObjectAPIClient defines the interface for S3 put object operations

type
PutObjectAPIClient
interface
{
PutObject
(
context
.
Context
,
*
s3
.
PutObjectInput
,
...
func
(
*
s3
.
Options
)
)
(
*
s3
.
PutObjectOutput
,
error
)
}