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

     1  package minio
     2  
     3  import (
     4  	"context"
     5  	"io"
     6  
     7  	"github.com/kubeshop/testkube/pkg/api/v1/testkube"
     8  	"github.com/kubeshop/testkube/pkg/storage"
     9  )
    10  
    11  type ArtifactClient struct {
    12  	client storage.Client
    13  }
    14  
    15  // NewMinIOArtifactClient returns new MinIO client
    16  func NewMinIOArtifactClient(client storage.Client) *ArtifactClient {
    17  	return &ArtifactClient{client: client}
    18  }
    19  
    20  // ListFiles lists available files in the bucket from the config
    21  func (c *ArtifactClient) ListFiles(ctx context.Context, executionId, testName, testSuiteName, testWorkflowName string) ([]testkube.Artifact, error) {
    22  	return c.client.ListFiles(ctx, executionId)
    23  }
    24  
    25  // DownloadFile downloads file from bucket from the config
    26  func (c *ArtifactClient) DownloadFile(ctx context.Context, file, executionId, testName, testSuiteName, testWorkflowName string) (io.Reader, error) {
    27  	return c.client.DownloadFile(ctx, executionId, file)
    28  }
    29  
    30  // DownloadArrchive downloads archive from bucket from the config
    31  func (c *ArtifactClient) DownloadArchive(ctx context.Context, executionId string, masks []string) (io.Reader, error) {
    32  	return c.client.DownloadArchive(ctx, executionId, masks)
    33  }
    34  
    35  // UploadFile saves a file to be copied into a running execution
    36  func (c *ArtifactClient) UploadFile(ctx context.Context, bucketFolder, filePath string, reader io.Reader, objectSize int64) error {
    37  	return c.client.UploadFile(ctx, bucketFolder, filePath, reader, objectSize)
    38  }
    39  
    40  // PlaceFiles saves the content of the buckets to the filesystem
    41  func (c *ArtifactClient) PlaceFiles(ctx context.Context, bucketFolders []string, prefix string) error {
    42  	return c.client.PlaceFiles(ctx, bucketFolders, prefix)
    43  }
    44  
    45  func (c *ArtifactClient) GetValidBucketName(parentType string, parentName string) string {
    46  	return c.client.GetValidBucketName(parentType, parentName)
    47  }
    48  
    49  var _ storage.ArtifactsStorage = (*ArtifactClient)(nil)