Skip to content

Commit 4b1d3d5

Browse files
committed
Merge branch 'main' into feat/service-accounts
2 parents 85b416b + 3257f06 commit 4b1d3d5

File tree

50 files changed

+751
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+751
-108
lines changed

artifacthub/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include ../Makefile
44

55
APP_NAME=artifacthub
66
APP_ENV=prod
7-
INTERNAL_API_BRANCH=master
7+
INTERNAL_API_BRANCH?=master
88

99
pb.gen:
1010
rm -rf tmp && mkdir -p tmp

artifacthub/pkg/api/descriptors/artifacthub/artifacthub.pb.go

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

artifacthub/pkg/api/descriptors/artifacts/artifacts.v1.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

artifacthub/pkg/api/private/privateapi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func ListTransferPath(ctx context.Context, client storage.Client, artifact *mode
121121
return err
122122
}
123123

124-
result = append(result, &artifacthub.ListItem{Name: item.Path, IsDirectory: item.IsDirectory})
124+
result = append(result, &artifacthub.ListItem{Name: item.Path, IsDirectory: item.IsDirectory, Size: item.Size})
125125
}
126126

127127
return nil

artifacthub/pkg/server/private/privateserver_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ func Test__ListPath(t *testing.T) {
303303
response, err := server.ListPath(context.TODO(), request)
304304
assert.Nil(t, err)
305305
assert.Equal(t, []*artifacthub.ListItem{
306-
{Name: "artifacts/projects/first/file1.txt", IsDirectory: false},
307-
{Name: "artifacts/projects/first/dir/", IsDirectory: true},
306+
{Name: "artifacts/projects/first/file1.txt", IsDirectory: false, Size: 5},
307+
{Name: "artifacts/projects/first/dir/", IsDirectory: true, Size: 0},
308308
}, response.Items)
309309
})
310310

@@ -318,9 +318,9 @@ func Test__ListPath(t *testing.T) {
318318
response, err := server.ListPath(context.TODO(), request)
319319
assert.Nil(t, err)
320320
assert.Equal(t, []*artifacthub.ListItem{
321-
{Name: "artifacts/projects/first/dir/subfile1.txt", IsDirectory: false},
322-
{Name: "artifacts/projects/first/dir/subfile2.txt", IsDirectory: false},
323-
{Name: "artifacts/projects/first/file1.txt", IsDirectory: false},
321+
{Name: "artifacts/projects/first/dir/subfile1.txt", IsDirectory: false, Size: 5},
322+
{Name: "artifacts/projects/first/dir/subfile2.txt", IsDirectory: false, Size: 5},
323+
{Name: "artifacts/projects/first/file1.txt", IsDirectory: false, Size: 5},
324324
}, response.Items)
325325
})
326326
})

artifacthub/pkg/storage/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type PathItem struct {
5555
Path string
5656
IsDirectory bool
5757
Age *time.Duration
58+
Size int64
5859
}
5960

6061
type PathIterator interface {

artifacthub/pkg/storage/gcs_bucket.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func (b *GcsBucket) DeleteObjects(paths []string) error {
207207

208208
func (b *GcsBucket) ListPath(options ListOptions) (PathIterator, error) {
209209
query := gcsstorage.Query{Prefix: pathutil.EndsInSlash(options.Path)}
210-
err := query.SetAttrSelection([]string{"Name", "Created"})
210+
err := query.SetAttrSelection([]string{"Name", "Created", "Size"})
211211
if err != nil {
212212
return nil, err
213213
}
@@ -226,7 +226,7 @@ func (b *GcsBucket) ListPath(options ListOptions) (PathIterator, error) {
226226

227227
func (b *GcsBucket) ListObjectsWithPagination(options ListOptions) (ObjectPager, error) {
228228
query := gcsstorage.Query{Prefix: pathutil.EndsInSlash(options.Path)}
229-
err := query.SetAttrSelection([]string{"Name", "Created"})
229+
err := query.SetAttrSelection([]string{"Name", "Created", "Size"})
230230
if err != nil {
231231
return nil, err
232232
}

artifacthub/pkg/storage/gcs_object_iterator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (i *GcsPathIterator) Next() (*PathItem, error) {
3333
Path: attrs.Prefix,
3434
IsDirectory: true,
3535
Age: nil,
36+
Size: 0, // Directories don't have a size
3637
}, nil
3738
}
3839

@@ -41,6 +42,7 @@ func (i *GcsPathIterator) Next() (*PathItem, error) {
4142
Path: attrs.Name,
4243
IsDirectory: false,
4344
Age: &age,
45+
Size: attrs.Size,
4446
}, nil
4547
}
4648

artifacthub/pkg/storage/inmemstorage.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (b *InMemoryBucket) Size() int {
6060

6161
func (b *InMemoryBucket) Add(path string, age time.Time) error {
6262
newAge := time.Since(age)
63-
b.Objects = append(b.Objects, &PathItem{Path: "artifacts" + path, Age: &newAge})
63+
b.Objects = append(b.Objects, &PathItem{Path: "artifacts" + path, Age: &newAge, Size: 1024}) // Default size for testing
6464

6565
return nil
6666
}
@@ -191,5 +191,11 @@ func (b *InMemoryBucket) SetCORS(ctx context.Context) error {
191191
}
192192

193193
func (b *InMemoryBucket) CreateObject(ctx context.Context, name string, content []byte) error {
194+
b.Objects = append(b.Objects, &PathItem{
195+
Path: name,
196+
IsDirectory: false,
197+
Age: nil,
198+
Size: int64(len(content)),
199+
})
194200
return nil
195201
}

artifacthub/pkg/storage/s3_object_iterator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func (i *S3PathIterator) nextAndIncrement() *PathItem {
8282
Path: i.removePathPrefix(*next.Key),
8383
IsDirectory: false,
8484
Age: &age,
85+
Size: *next.Size,
8586
}
8687
}
8788

@@ -92,6 +93,7 @@ func (i *S3PathIterator) nextAndIncrement() *PathItem {
9293
Path: i.removePathPrefix(*nextPrefix.Prefix),
9394
IsDirectory: true,
9495
Age: nil,
96+
Size: 0, // Directories don't have a size
9597
}
9698
}
9799

0 commit comments

Comments
 (0)