Skip to content

Commit 64fdbcb

Browse files
authored
Merge pull request #89 from chainguard-dev/create-pull-request/patch
Export mono/sdk: refs/heads/main
2 parents 9ec2a5a + 919d117 commit 64fdbcb

File tree

8 files changed

+615
-543
lines changed

8 files changed

+615
-543
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
${{ runner.os }}-go-
3636
3737
- name: Set up Go
38-
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
38+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
3939
with:
4040
go-version-file: './go.mod'
4141
check-latest: true

.github/workflows/verify.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
fetch-depth: 0
3131

3232
- name: Set up Go
33-
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
33+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
3434
with:
3535
go-version-file: './src/github.com/${{ github.repository }}/go.mod'
3636
check-latest: true

proto/capabilities/capabilities.pb.go

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

proto/capabilities/capabilities.proto

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ enum Capability {
9898

9999
// Registry
100100

101-
// TODO(jason): Remove these coarse-grained capabilities after they're removed from the roles.
102-
CAP_REGISTRY_PULL = 1601 [(name) = "registry.pull", (bit) = 40, deprecated = true]; // Can read tags, blobs, manifests.
103-
CAP_REGISTRY_PUSH = 1602 [(name) = "registry.push", (bit) = 41, deprecated = true]; // Can create and update tags, blobs, manifests.
101+
reserved 1601; // CAP_REGISTRY_PULL
102+
reserved 1602; // CAP_REGISTRY_PUSH
104103

105104
CAP_REPO_CREATE = 1603 [(name) = "repo.create", (bit) = 56];
106105
CAP_REPO_UPDATE = 1604 [(name) = "repo.update", (bit) = 57];

proto/platform/registry/v1/registry.platform.pb.go

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

proto/platform/registry/v1/registry.platform.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,8 @@ message ImageConfigRequest {
619619
string digest = 2;
620620
// The architecture to get config for.
621621
string arch = 3;
622+
// Fetch config from registry.
623+
bool registry = 4;
622624
}
623625

624626
message RawSbomRequest {

proto/platform/registry/v1/test/entitlements.go

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,49 @@ package test
77

88
import (
99
"context"
10+
"fmt"
1011

1112
registry "chainguard.dev/sdk/proto/platform/registry/v1"
13+
"github.com/google/go-cmp/cmp"
1214
"google.golang.org/grpc"
13-
"google.golang.org/grpc/codes"
14-
"google.golang.org/grpc/status"
15+
"google.golang.org/protobuf/testing/protocmp"
1516
)
1617

1718
var _ registry.EntitlementsClient = (*MockEntitlementsClient)(nil)
1819

19-
type MockEntitlementsClient struct{}
20+
type MockEntitlementsClient struct {
21+
registry.EntitlementsClient
2022

21-
func (*MockEntitlementsClient) ListEntitlements(context.Context, *registry.EntitlementFilter, ...grpc.CallOption) (*registry.EntitlementList, error) {
22-
return nil, status.Error(codes.Unimplemented, "not implemented")
23+
OnListEntitlements []ListOnEntitlements
24+
OnListEntitlementImages []ListOnEntitlementImages
2325
}
2426

25-
func (*MockEntitlementsClient) ListEntitlementImages(context.Context, *registry.EntitlementImagesFilter, ...grpc.CallOption) (*registry.EntitlementImagesList, error) {
26-
return nil, status.Error(codes.Unimplemented, "not implemented")
27+
type ListOnEntitlements struct {
28+
Given *registry.EntitlementFilter
29+
List *registry.EntitlementList
30+
Error error
31+
}
32+
33+
type ListOnEntitlementImages struct {
34+
Given *registry.EntitlementImagesFilter
35+
List *registry.EntitlementImagesList
36+
Error error
37+
}
38+
39+
func (m *MockEntitlementsClient) ListEntitlements(_ context.Context, given *registry.EntitlementFilter, _ ...grpc.CallOption) (*registry.EntitlementList, error) {
40+
for _, o := range m.OnListEntitlements {
41+
if cmp.Equal(o.Given, given, protocmp.Transform()) {
42+
return o.List, o.Error
43+
}
44+
}
45+
return nil, fmt.Errorf("mock not found for %v", given)
46+
}
47+
48+
func (m *MockEntitlementsClient) ListEntitlementImages(_ context.Context, given *registry.EntitlementImagesFilter, _ ...grpc.CallOption) (*registry.EntitlementImagesList, error) {
49+
for _, o := range m.OnListEntitlementImages {
50+
if cmp.Equal(o.Given, given, protocmp.Transform()) {
51+
return o.List, o.Error
52+
}
53+
}
54+
return nil, fmt.Errorf("mock not found for %v", given)
2755
}

proto/platform/registry/v1/test/registry.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ type MockRegistryClient struct {
6969
OnGetRawSbom []RawSbomOnGet
7070
OnGetPackageVersionMetadata []PackageVersionMetadataOnGet
7171
OnListBuildReports []BuildReportsOnList
72+
OnGetRepoCountBySource []RepoCountBySourceOnGet
73+
OnGetArchs []ArchsOnGet
74+
OnGetSize []SizeOnGet
7275
}
7376

7477
type ReposOnCreate struct {
@@ -165,6 +168,24 @@ type BuildReportsOnList struct {
165168
Error error
166169
}
167170

171+
type RepoCountBySourceOnGet struct {
172+
Given *registry.GetRepoCountBySourceRequest
173+
Get *registry.RepoCount
174+
Error error
175+
}
176+
177+
type ArchsOnGet struct {
178+
Given *registry.ArchRequest
179+
Get *registry.Archs
180+
Error error
181+
}
182+
183+
type SizeOnGet struct {
184+
Given *registry.SizeRequest
185+
Get *registry.Size
186+
Error error
187+
}
188+
168189
func (m MockRegistryClient) CreateRepo(_ context.Context, given *registry.CreateRepoRequest, _ ...grpc.CallOption) (*registry.Repo, error) {
169190
for _, o := range m.OnCreateRepos {
170191
if cmp.Equal(o.Given, given, protocmp.Transform()) {
@@ -308,3 +329,30 @@ func (m MockRegistryClient) ListBuildReports(_ context.Context, given *registry.
308329
}
309330
return nil, fmt.Errorf("mock not found for %v", given)
310331
}
332+
333+
func (m MockRegistryClient) GetRepoCountBySource(_ context.Context, given *registry.GetRepoCountBySourceRequest, _ ...grpc.CallOption) (*registry.RepoCount, error) {
334+
for _, o := range m.OnGetRepoCountBySource {
335+
if cmp.Equal(o.Given, given, protocmp.Transform()) {
336+
return o.Get, o.Error
337+
}
338+
}
339+
return nil, fmt.Errorf("mock not found for %v", given)
340+
}
341+
342+
func (m MockRegistryClient) GetArchs(_ context.Context, given *registry.ArchRequest, _ ...grpc.CallOption) (*registry.Archs, error) {
343+
for _, o := range m.OnGetArchs {
344+
if cmp.Equal(o.Given, given, protocmp.Transform()) {
345+
return o.Get, o.Error
346+
}
347+
}
348+
return nil, fmt.Errorf("mock not found for %v", given)
349+
}
350+
351+
func (m MockRegistryClient) GetSize(_ context.Context, given *registry.SizeRequest, _ ...grpc.CallOption) (*registry.Size, error) {
352+
for _, o := range m.OnGetSize {
353+
if cmp.Equal(o.Given, given, protocmp.Transform()) {
354+
return o.Get, o.Error
355+
}
356+
}
357+
return nil, fmt.Errorf("mock not found for %v", given)
358+
}

0 commit comments

Comments
 (0)