github.com/kubeshop/testkube@v1.17.23/pkg/storage/storage.go (about)

     1  package storage
     2  
     3  import (
     4  	"context"
     5  	"io"
     6  	"time"
     7  
     8  	"github.com/minio/minio-go/v7"
     9  
    10  	"github.com/kubeshop/testkube/pkg/api/v1/testkube"
    11  )
    12  
    13  // Client is storage client abstraction
    14  //
    15  //go:generate mockgen -destination=./storage_mock.go -package=storage "github.com/kubeshop/testkube/pkg/storage" Client
    16  type Client interface {
    17  	ClientBucket
    18  	ClientImplicitBucket
    19  }
    20  
    21  // ClientImplicitBucket is storage client abstraction where bucket name is provided from config
    22  type ClientImplicitBucket interface {
    23  	IsConnectionPossible(ctx context.Context) (bool, error)
    24  	ListFiles(ctx context.Context, bucketFolder string) ([]testkube.Artifact, error)
    25  	SaveFile(ctx context.Context, bucketFolder, filePath string) error
    26  	DownloadFile(ctx context.Context, bucketFolder, file string) (*minio.Object, error)
    27  	DownloadArchive(ctx context.Context, bucketFolder string, masks []string) (io.Reader, error)
    28  	UploadFile(ctx context.Context, bucketFolder string, filePath string, reader io.Reader, objectSize int64) error
    29  	PlaceFiles(ctx context.Context, bucketFolders []string, prefix string) error
    30  	DeleteFile(ctx context.Context, bucketFolder, file string) error
    31  }
    32  
    33  // ClientBucket is storage client abstraction where you have to specify bucket name
    34  type ClientBucket interface {
    35  	CreateBucket(ctx context.Context, bucket string) error
    36  	DeleteBucket(ctx context.Context, bucket string, force bool) error
    37  	ListBuckets(ctx context.Context) ([]string, error)
    38  	DownloadFileFromBucket(ctx context.Context, bucket, bucketFolder, file string) (io.Reader, minio.ObjectInfo, error)
    39  	DownloadArchiveFromBucket(ctx context.Context, bucket, bucketFolder string, masks []string) (io.Reader, error)
    40  	UploadFileToBucket(ctx context.Context, bucket, bucketFolder, filePath string, reader io.Reader, objectSize int64) error
    41  	GetValidBucketName(parentType string, parentName string) string
    42  	DeleteFileFromBucket(ctx context.Context, bucket, bucketFolder, file string) error
    43  	PresignDownloadFileFromBucket(ctx context.Context, bucket, bucketFolder, file string, expires time.Duration) (string, error)
    44  	PresignUploadFileToBucket(ctx context.Context, bucket, bucketFolder, filePath string, expires time.Duration) (string, error)
    45  }