Path: blob/main/components/content-service/pkg/storage/noop.go
2501 views
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package storage56import (7"context"89"github.com/gitpod-io/gitpod/content-service/pkg/archive"10)1112var _ DirectAccess = &DirectNoopStorage{}1314// DirectNoopStorage stores nothing, does nothing15type DirectNoopStorage struct{}1617// Init does nothing18func (rs *DirectNoopStorage) Init(ctx context.Context, owner, workspace, instance string) error {19return nil20}2122// EnsureExists does nothing23func (rs *DirectNoopStorage) EnsureExists(ctx context.Context) error {24return nil25}2627// Download always returns false and does nothing28func (rs *DirectNoopStorage) Download(ctx context.Context, destination string, name string, mappings []archive.IDMapping) (bool, error) {29return false, nil30}3132// DownloadSnapshot always returns false and does nothing33func (rs *DirectNoopStorage) DownloadSnapshot(ctx context.Context, destination string, name string, mappings []archive.IDMapping) (bool, error) {34return false, nil35}3637// ListObjects returns all objects found with the given prefix. Returns an empty list if the bucket does not exuist (yet).38func (rs *DirectNoopStorage) ListObjects(ctx context.Context, prefix string) (objects []string, err error) {39return nil, nil40}4142// Qualify just returns the name43func (rs *DirectNoopStorage) Qualify(name string) string {44return name45}4647// UploadInstance takes all files from a local location and uploads it to the per-instance remote storage48func (rs *DirectNoopStorage) UploadInstance(ctx context.Context, source string, name string, opts ...UploadOption) (bucket, object string, err error) {49return "", "", nil50}5152// Upload does nothing53func (rs *DirectNoopStorage) Upload(ctx context.Context, source string, name string, opts ...UploadOption) (string, string, error) {54return "", "", nil55}5657// Bucket returns an empty string58func (rs *DirectNoopStorage) Bucket(string) string {59return ""60}6162// BackupObject returns a backup's object name that a direct downloader would download63func (rs *DirectNoopStorage) BackupObject(name string) string {64return ""65}6667// SnapshotObject returns a snapshot's object name that a direct downloer would download68func (rs *DirectNoopStorage) SnapshotObject(name string) string {69return ""70}7172// PresignedNoopStorage does nothing73type PresignedNoopStorage struct{}7475func (*PresignedNoopStorage) EnsureExists(ctx context.Context, ownerID string) (err error) {76return nil77}7879func (*PresignedNoopStorage) DiskUsage(ctx context.Context, bucket string, prefix string) (size int64, err error) {80return 0, nil81}8283// SignDownload returns ErrNotFound84func (*PresignedNoopStorage) SignDownload(ctx context.Context, bucket, obj string, options *SignedURLOptions) (info *DownloadInfo, err error) {85return nil, ErrNotFound86}8788// SignUpload describes an object for upload89func (s *PresignedNoopStorage) SignUpload(ctx context.Context, bucket, obj string, options *SignedURLOptions) (info *UploadInfo, err error) {90return nil, ErrNotFound91}9293// DeleteObject deletes objects in the given bucket specified by the given query94func (s *PresignedNoopStorage) DeleteObject(ctx context.Context, bucket string, query *DeleteObjectQuery) error {95return nil96}9798// DeleteBucket deletes a bucket99func (s *PresignedNoopStorage) DeleteBucket(ctx context.Context, userID, bucket string) error {100return nil101}102103// Bucket returns an empty string104func (*PresignedNoopStorage) Bucket(string) string {105return ""106}107108// BlobObject returns a blob's object name109func (*PresignedNoopStorage) BlobObject(userID, name string) (string, error) {110return "", nil111}112113// ObjectHash gets a hash value114func (*PresignedNoopStorage) ObjectHash(ctx context.Context, bucket string, obj string) (string, error) {115return "", nil116}117118func (p *PresignedNoopStorage) ObjectExists(ctx context.Context, bucket, obj string) (bool, error) {119return false, nil120}121122// BackupObject returns a backup's object name that a direct downloader would download123func (*PresignedNoopStorage) BackupObject(ownerID string, workspaceID string, name string) string {124return ""125}126127// InstanceObject returns a instance's object name that a direct downloader would download128func (*PresignedNoopStorage) InstanceObject(ownerID string, workspaceID string, instanceID string, name string) string {129return ""130}131132133