Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/content-service/pkg/storage/noop.go
2501 views
1
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package storage
6
7
import (
8
"context"
9
10
"github.com/gitpod-io/gitpod/content-service/pkg/archive"
11
)
12
13
var _ DirectAccess = &DirectNoopStorage{}
14
15
// DirectNoopStorage stores nothing, does nothing
16
type DirectNoopStorage struct{}
17
18
// Init does nothing
19
func (rs *DirectNoopStorage) Init(ctx context.Context, owner, workspace, instance string) error {
20
return nil
21
}
22
23
// EnsureExists does nothing
24
func (rs *DirectNoopStorage) EnsureExists(ctx context.Context) error {
25
return nil
26
}
27
28
// Download always returns false and does nothing
29
func (rs *DirectNoopStorage) Download(ctx context.Context, destination string, name string, mappings []archive.IDMapping) (bool, error) {
30
return false, nil
31
}
32
33
// DownloadSnapshot always returns false and does nothing
34
func (rs *DirectNoopStorage) DownloadSnapshot(ctx context.Context, destination string, name string, mappings []archive.IDMapping) (bool, error) {
35
return false, nil
36
}
37
38
// ListObjects returns all objects found with the given prefix. Returns an empty list if the bucket does not exuist (yet).
39
func (rs *DirectNoopStorage) ListObjects(ctx context.Context, prefix string) (objects []string, err error) {
40
return nil, nil
41
}
42
43
// Qualify just returns the name
44
func (rs *DirectNoopStorage) Qualify(name string) string {
45
return name
46
}
47
48
// UploadInstance takes all files from a local location and uploads it to the per-instance remote storage
49
func (rs *DirectNoopStorage) UploadInstance(ctx context.Context, source string, name string, opts ...UploadOption) (bucket, object string, err error) {
50
return "", "", nil
51
}
52
53
// Upload does nothing
54
func (rs *DirectNoopStorage) Upload(ctx context.Context, source string, name string, opts ...UploadOption) (string, string, error) {
55
return "", "", nil
56
}
57
58
// Bucket returns an empty string
59
func (rs *DirectNoopStorage) Bucket(string) string {
60
return ""
61
}
62
63
// BackupObject returns a backup's object name that a direct downloader would download
64
func (rs *DirectNoopStorage) BackupObject(name string) string {
65
return ""
66
}
67
68
// SnapshotObject returns a snapshot's object name that a direct downloer would download
69
func (rs *DirectNoopStorage) SnapshotObject(name string) string {
70
return ""
71
}
72
73
// PresignedNoopStorage does nothing
74
type PresignedNoopStorage struct{}
75
76
func (*PresignedNoopStorage) EnsureExists(ctx context.Context, ownerID string) (err error) {
77
return nil
78
}
79
80
func (*PresignedNoopStorage) DiskUsage(ctx context.Context, bucket string, prefix string) (size int64, err error) {
81
return 0, nil
82
}
83
84
// SignDownload returns ErrNotFound
85
func (*PresignedNoopStorage) SignDownload(ctx context.Context, bucket, obj string, options *SignedURLOptions) (info *DownloadInfo, err error) {
86
return nil, ErrNotFound
87
}
88
89
// SignUpload describes an object for upload
90
func (s *PresignedNoopStorage) SignUpload(ctx context.Context, bucket, obj string, options *SignedURLOptions) (info *UploadInfo, err error) {
91
return nil, ErrNotFound
92
}
93
94
// DeleteObject deletes objects in the given bucket specified by the given query
95
func (s *PresignedNoopStorage) DeleteObject(ctx context.Context, bucket string, query *DeleteObjectQuery) error {
96
return nil
97
}
98
99
// DeleteBucket deletes a bucket
100
func (s *PresignedNoopStorage) DeleteBucket(ctx context.Context, userID, bucket string) error {
101
return nil
102
}
103
104
// Bucket returns an empty string
105
func (*PresignedNoopStorage) Bucket(string) string {
106
return ""
107
}
108
109
// BlobObject returns a blob's object name
110
func (*PresignedNoopStorage) BlobObject(userID, name string) (string, error) {
111
return "", nil
112
}
113
114
// ObjectHash gets a hash value
115
func (*PresignedNoopStorage) ObjectHash(ctx context.Context, bucket string, obj string) (string, error) {
116
return "", nil
117
}
118
119
func (p *PresignedNoopStorage) ObjectExists(ctx context.Context, bucket, obj string) (bool, error) {
120
return false, nil
121
}
122
123
// BackupObject returns a backup's object name that a direct downloader would download
124
func (*PresignedNoopStorage) BackupObject(ownerID string, workspaceID string, name string) string {
125
return ""
126
}
127
128
// InstanceObject returns a instance's object name that a direct downloader would download
129
func (*PresignedNoopStorage) InstanceObject(ownerID string, workspaceID string, instanceID string, name string) string {
130
return ""
131
}
132
133