Documentation
¶
Overview ¶
Package test provides mock implementations of Registry gRPC clients for testing.
This package offers mock clients that implement the Registry service interfaces, enabling unit testing without requiring a live Registry service connection.
Overview ¶
The test package provides the following key features:
- Mock implementations of all Registry gRPC client interfaces
- Configurable responses for each RPC method
- Request matching using protocol buffer comparison
Basic Usage ¶
Create a mock registry client and configure expected responses:
mock := &test.MockRegistryClients{
RegistryClient: test.MockRegistryClient{
OnListRepos: []test.ReposOnList{{
Given: ®istry.RepoFilter{},
List: ®istry.RepoList{
Items: []*registry.Repo{{
Id: "repo-id",
Name: "test-repo",
}},
},
}},
},
}
// Use the mock in place of a real registry client
repos, err := mock.Registry().ListRepos(ctx, ®istry.RepoFilter{})
Available Mock Clients ¶
The package provides mock implementations for all Registry services:
- MockRegistryClients: Aggregates all mock clients and implements registry.Clients
- MockRegistryClient: Repository and tag management operations
- MockVulnerabilitiesClient: Vulnerability report operations
- MockApkoClient: Apko image build and config operations
- MockEntitlementsClient: Entitlement management operations
Request Matching ¶
Mock responses are matched against incoming requests using protocol buffer comparison. Configure multiple responses for different request patterns:
mock := test.MockRegistryClient{
OnListRepos: []test.ReposOnList{{
Given: ®istry.RepoFilter{},
List: ®istry.RepoList{Items: repos},
}},
}
Error Simulation ¶
Simulate error conditions by setting the Error field:
mock := test.MockRegistryClient{
OnDeleteRepos: []test.ReposOnDelete{{
Given: ®istry.DeleteRepoRequest{Id: "protected-repo"},
Error: status.Error(codes.PermissionDenied, "cannot delete protected repo"),
}},
}
Thread Safety ¶
Mock clients are safe for concurrent read access. Configure all expected responses before using the mock in concurrent tests. Do not modify mock configurations while tests are running.
Index ¶
- type ArchsOnGet
- type BuildReportsOnList
- type BuildStatusOnGet
- type ChartOnGet
- type EntitlementCatalogImagesOnList
- type EntitlementImagesOnList
- type EntitlementSummaryOnGet
- type EntitlementsOnList
- type EolTagOnList
- type FeaturesOnGet
- type HelmOnGet
- type ImageConfigOnGet
- type ManifestMetadataOnList
- type MockApkoClient
- type MockEntitlementsClient
- func (m *MockEntitlementsClient) GetFeatures(_ context.Context, given *registry.GetFeaturesRequest, _ ...grpc.CallOption) (*registry.GetFeaturesResponse, error)
- func (m *MockEntitlementsClient) ListEntitlementCatalogImages(_ context.Context, given *registry.EntitlementImagesFilter, ...) (*registry.EntitlementImagesList, error)
- func (m *MockEntitlementsClient) ListEntitlementImages(_ context.Context, given *registry.EntitlementImagesFilter, ...) (*registry.EntitlementImagesList, error)
- func (m *MockEntitlementsClient) ListEntitlements(_ context.Context, given *registry.EntitlementFilter, _ ...grpc.CallOption) (*registry.EntitlementList, error)
- func (m *MockEntitlementsClient) Summary(_ context.Context, given *registry.EntitlementSummaryRequest, ...) (*registry.EntitlementSummaryResponse, error)
- type MockRegistryClient
- func (m MockRegistryClient) CreateRepo(_ context.Context, given *registry.CreateRepoRequest, _ ...grpc.CallOption) (*registry.Repo, error)
- func (m MockRegistryClient) CreateTag(_ context.Context, given *registry.CreateTagRequest, _ ...grpc.CallOption) (*registry.Tag, error)
- func (m MockRegistryClient) DeleteRepo(_ context.Context, given *registry.DeleteRepoRequest, _ ...grpc.CallOption) (*emptypb.Empty, error)
- func (m MockRegistryClient) DeleteTag(_ context.Context, given *registry.DeleteTagRequest, _ ...grpc.CallOption) (*emptypb.Empty, error)
- func (m MockRegistryClient) GetArchs(_ context.Context, given *registry.ArchRequest, _ ...grpc.CallOption) (*registry.Archs, error)
- func (m MockRegistryClient) GetBuildStatus(_ context.Context, given *registry.BuildReportFilter, _ ...grpc.CallOption) (*registry.BuildStatus, error)
- func (m MockRegistryClient) GetChart(_ context.Context, given *registry.GetChartRequest, _ ...grpc.CallOption) (*registry.Chart, error)
- func (m MockRegistryClient) GetHelm(_ context.Context, given *registry.HelmRequest, _ ...grpc.CallOption) (*registry.Helm, error)
- func (m MockRegistryClient) GetImageConfig(_ context.Context, given *registry.ImageConfigRequest, _ ...grpc.CallOption) (*registry.ImageConfig, error)
- func (m MockRegistryClient) GetPackageVersionMetadata(_ context.Context, given *registry.PackageVersionMetadataRequest, ...) (*registry.PackageVersionMetadata, error)
- func (m MockRegistryClient) GetRawSbom(_ context.Context, given *registry.RawSbomRequest, _ ...grpc.CallOption) (*registry.RawSbom, error)
- func (m MockRegistryClient) GetRegistrySettings(_ context.Context, given *registry.GetRegistrySettingsRequest, ...) (*registry.RegistrySettings, error)
- func (m MockRegistryClient) GetRepoCountBySource(_ context.Context, given *registry.GetRepoCountBySourceRequest, ...) (*registry.RepoCount, error)
- func (m MockRegistryClient) GetSbom(_ context.Context, given *registry.SbomRequest, _ ...grpc.CallOption) (*tenant.Sbom2, error)
- func (m MockRegistryClient) GetSize(_ context.Context, given *registry.SizeRequest, _ ...grpc.CallOption) (*registry.Size, error)
- func (m MockRegistryClient) GetSyncStatus(_ context.Context, given *registry.GetSyncStatusRequest, _ ...grpc.CallOption) (*registry.SyncStatus, error)
- func (m MockRegistryClient) GetUpdateStatus(_ context.Context, given *registry.UpdateStatusRequest, _ ...grpc.CallOption) (*registry.UpdateStatus, error)
- func (m MockRegistryClient) GetVulnReport(_ context.Context, given *registry.VulnReportRequest, _ ...grpc.CallOption) (*tenant.VulnReport, error)
- func (m MockRegistryClient) ListBuildReports(_ context.Context, given *registry.BuildReportFilter, _ ...grpc.CallOption) (*registry.BuildReportList, error)
- func (m MockRegistryClient) ListEolTags(_ context.Context, given *registry.EolTagFilter, _ ...grpc.CallOption) (*registry.EolTagList, error)
- func (m MockRegistryClient) ListManifestMetadata(_ context.Context, given *registry.ManifestMetadataFilter, ...) (*registry.ManifestMetadataList, error)
- func (m MockRegistryClient) ListRepos(_ context.Context, given *registry.RepoFilter, _ ...grpc.CallOption) (*registry.RepoList, error)
- func (m MockRegistryClient) ListSyncStatuses(_ context.Context, given *registry.ListSyncStatusesRequest, ...) (*registry.SyncStatusList, error)
- func (m MockRegistryClient) ListTagHistory(_ context.Context, given *registry.TagHistoryFilter, _ ...grpc.CallOption) (*registry.TagHistoryList, error)
- func (m MockRegistryClient) ListTags(_ context.Context, given *registry.TagFilter, _ ...grpc.CallOption) (*registry.TagList, error)
- func (m MockRegistryClient) UpdateRepo(_ context.Context, given *registry.Repo, _ ...grpc.CallOption) (*registry.Repo, error)
- func (m MockRegistryClient) UpdateTag(_ context.Context, given *registry.Tag, _ ...grpc.CallOption) (*registry.Tag, error)
- type MockRegistryClients
- func (m MockRegistryClients) Apko() registry.ApkoClient
- func (m MockRegistryClients) Close() error
- func (m MockRegistryClients) Entitlements() registry.EntitlementsClient
- func (m MockRegistryClients) Registry() registry.RegistryClient
- func (m MockRegistryClients) Vulnerabilities() registry.VulnerabilitiesClient
- type MockVulnerabilitiesClient
- func (m MockVulnerabilitiesClient) GetRawVulnReport(_ context.Context, given *registry.GetRawVulnReportRequest, ...) (*registry.RawVulnReport, error)
- func (m MockVulnerabilitiesClient) ListCumulativeVulnCountReports(_ context.Context, given *registry.VulnCountReportFilter, _ ...grpc.CallOption) (*registry.VulnCountReportList, error)
- func (m MockVulnerabilitiesClient) ListVulnCountReports(_ context.Context, given *registry.VulnCountReportFilter, _ ...grpc.CallOption) (*registry.VulnCountReportList, error)
- func (m MockVulnerabilitiesClient) ListVulnReports(_ context.Context, given *registry.VulnReportFilter, _ ...grpc.CallOption) (*registry.VulnReportList, error)
- type OnBuildImage
- type OnResolveConfig
- type PackageVersionMetadataOnGet
- type RawSbomOnGet
- type RawVulnReportOnGet
- type RegistrySettingsOnGet
- type RepoCountBySourceOnGet
- type RepoOnUpdate
- type ReposOnCreate
- type ReposOnDelete
- type ReposOnList
- type SbomOnGet
- type SizeOnGet
- type SyncStatusOnGet
- type SyncStatusOnList
- type TagHistoryOnList
- type TagOnUpdate
- type TagsOnCreate
- type TagsOnDelete
- type TagsOnList
- type UpdateStatusOnGet
- type VulnCountReportsOnList
- type VulnReportOnGet
- type VulnReportsOnList
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArchsOnGet ¶ added in v0.1.33
type ArchsOnGet struct {
Given *registry.ArchRequest
Get *registry.Archs
Error error
}
type BuildReportsOnList ¶ added in v0.1.29
type BuildReportsOnList struct {
Given *registry.BuildReportFilter
List *registry.BuildReportList
Error error
}
type BuildStatusOnGet ¶ added in v0.1.33
type BuildStatusOnGet struct {
Given *registry.BuildReportFilter
Get *registry.BuildStatus
Error error
}
type ChartOnGet ¶ added in v0.1.46
type ChartOnGet struct {
Given *registry.GetChartRequest
Get *registry.Chart
Error error
}
type EntitlementCatalogImagesOnList ¶ added in v0.1.38
type EntitlementCatalogImagesOnList struct {
Given *registry.EntitlementImagesFilter
List *registry.EntitlementImagesList
Error error
}
type EntitlementImagesOnList ¶ added in v0.1.35
type EntitlementImagesOnList struct {
Given *registry.EntitlementImagesFilter
List *registry.EntitlementImagesList
Error error
}
type EntitlementSummaryOnGet ¶ added in v0.1.35
type EntitlementSummaryOnGet struct {
Given *registry.EntitlementSummaryRequest
Get *registry.EntitlementSummaryResponse
Error error
}
type EntitlementsOnList ¶ added in v0.1.35
type EntitlementsOnList struct {
Given *registry.EntitlementFilter
List *registry.EntitlementList
Error error
}
type EolTagOnList ¶ added in v0.1.35
type EolTagOnList struct {
Given *registry.EolTagFilter
Get *registry.EolTagList
Error error
}
type FeaturesOnGet ¶ added in v0.1.35
type FeaturesOnGet struct {
Given *registry.GetFeaturesRequest
Get *registry.GetFeaturesResponse
Error error
}
type HelmOnGet ¶ added in v0.1.35
type HelmOnGet struct {
Given *registry.HelmRequest
Get *registry.Helm
Error error
}
type ImageConfigOnGet ¶ added in v0.1.20
type ImageConfigOnGet struct {
Given *registry.ImageConfigRequest
Get *registry.ImageConfig
Error error
}
type ManifestMetadataOnList ¶ added in v0.1.20
type ManifestMetadataOnList struct {
Given *registry.ManifestMetadataFilter
List *registry.ManifestMetadataList
Error error
}
type MockApkoClient ¶ added in v0.1.29
type MockApkoClient struct {
registry.ApkoClient
OnResolveConfig []OnResolveConfig
OnBuildImage []OnBuildImage
}
Example ¶
ExampleMockApkoClient demonstrates mocking Apko operations.
package main
import (
"context"
"fmt"
registry "chainguard.dev/sdk/proto/platform/registry/v1"
"chainguard.dev/sdk/proto/platform/registry/v1/test"
)
func main() {
mock := test.MockApkoClient{
OnBuildImage: []test.OnBuildImage{{
Given: ®istry.BuildImageRequest{},
Result: ®istry.BuildImageResponse{},
}},
}
result, err := mock.BuildImage(context.Background(), ®istry.BuildImageRequest{})
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Build image result: %v\n", result != nil)
}
Output: Build image result: true
func (MockApkoClient) BuildImage ¶ added in v0.1.29
func (m MockApkoClient) BuildImage(_ context.Context, given *registry.BuildImageRequest, _ ...grpc.CallOption) (*registry.BuildImageResponse, error)
func (MockApkoClient) ResolveConfig ¶ added in v0.1.29
func (m MockApkoClient) ResolveConfig(_ context.Context, given *registry.ResolveConfigRequest, _ ...grpc.CallOption) (*registry.ApkoConfig, error)
type MockEntitlementsClient ¶ added in v0.1.33
type MockEntitlementsClient struct {
registry.EntitlementsClient
OnListEntitlements []EntitlementsOnList
OnListEntitlementImages []EntitlementImagesOnList
OnListEntitlementCatalogImages []EntitlementCatalogImagesOnList
OnGetEntitlementSummary []EntitlementSummaryOnGet
OnGetFeatures []FeaturesOnGet
}
func (*MockEntitlementsClient) GetFeatures ¶ added in v0.1.35
func (m *MockEntitlementsClient) GetFeatures(_ context.Context, given *registry.GetFeaturesRequest, _ ...grpc.CallOption) (*registry.GetFeaturesResponse, error)
func (*MockEntitlementsClient) ListEntitlementCatalogImages ¶ added in v0.1.38
func (m *MockEntitlementsClient) ListEntitlementCatalogImages(_ context.Context, given *registry.EntitlementImagesFilter, _ ...grpc.CallOption) (*registry.EntitlementImagesList, error)
func (*MockEntitlementsClient) ListEntitlementImages ¶ added in v0.1.33
func (m *MockEntitlementsClient) ListEntitlementImages(_ context.Context, given *registry.EntitlementImagesFilter, _ ...grpc.CallOption) (*registry.EntitlementImagesList, error)
func (*MockEntitlementsClient) ListEntitlements ¶ added in v0.1.33
func (m *MockEntitlementsClient) ListEntitlements(_ context.Context, given *registry.EntitlementFilter, _ ...grpc.CallOption) (*registry.EntitlementList, error)
func (*MockEntitlementsClient) Summary ¶ added in v0.1.33
func (m *MockEntitlementsClient) Summary(_ context.Context, given *registry.EntitlementSummaryRequest, _ ...grpc.CallOption) (*registry.EntitlementSummaryResponse, error)
type MockRegistryClient ¶
type MockRegistryClient struct {
registry.RegistryClient
OnCreateRepos []ReposOnCreate
OnDeleteRepos []ReposOnDelete
OnListRepos []ReposOnList
OnListEolTags []EolTagOnList
OnCreateTags []TagsOnCreate
OnDeleteTags []TagsOnDelete
OnUpdateTag []TagOnUpdate
OnListTags []TagsOnList
OnUpdateRepo []RepoOnUpdate
OnListTagHistory []TagHistoryOnList
OnGetImageConfig []ImageConfigOnGet
OnGetSbom []SbomOnGet
OnGetVulnReport []VulnReportOnGet
OnListManifestMetadata []ManifestMetadataOnList
OnGetRawSbom []RawSbomOnGet
OnGetPackageVersionMetadata []PackageVersionMetadataOnGet
OnListBuildReports []BuildReportsOnList
OnGetBuildStatus []BuildStatusOnGet
OnGetUpdateStatus []UpdateStatusOnGet
OnGetRepoCountBySource []RepoCountBySourceOnGet
OnGetArchs []ArchsOnGet
OnGetSize []SizeOnGet
OnGetHelm []HelmOnGet
OnGetChart []ChartOnGet
OnGetRegistrySettings []RegistrySettingsOnGet
OnGetSyncStatus []SyncStatusOnGet
OnListSyncStatuses []SyncStatusOnList
}
func (MockRegistryClient) CreateRepo ¶
func (m MockRegistryClient) CreateRepo(_ context.Context, given *registry.CreateRepoRequest, _ ...grpc.CallOption) (*registry.Repo, error)
func (MockRegistryClient) CreateTag ¶
func (m MockRegistryClient) CreateTag(_ context.Context, given *registry.CreateTagRequest, _ ...grpc.CallOption) (*registry.Tag, error)
func (MockRegistryClient) DeleteRepo ¶
func (m MockRegistryClient) DeleteRepo(_ context.Context, given *registry.DeleteRepoRequest, _ ...grpc.CallOption) (*emptypb.Empty, error)
func (MockRegistryClient) DeleteTag ¶
func (m MockRegistryClient) DeleteTag(_ context.Context, given *registry.DeleteTagRequest, _ ...grpc.CallOption) (*emptypb.Empty, error)
func (MockRegistryClient) GetArchs ¶ added in v0.1.33
func (m MockRegistryClient) GetArchs(_ context.Context, given *registry.ArchRequest, _ ...grpc.CallOption) (*registry.Archs, error)
func (MockRegistryClient) GetBuildStatus ¶ added in v0.1.33
func (m MockRegistryClient) GetBuildStatus(_ context.Context, given *registry.BuildReportFilter, _ ...grpc.CallOption) (*registry.BuildStatus, error)
func (MockRegistryClient) GetChart ¶ added in v0.1.46
func (m MockRegistryClient) GetChart(_ context.Context, given *registry.GetChartRequest, _ ...grpc.CallOption) (*registry.Chart, error)
func (MockRegistryClient) GetHelm ¶ added in v0.1.35
func (m MockRegistryClient) GetHelm(_ context.Context, given *registry.HelmRequest, _ ...grpc.CallOption) (*registry.Helm, error)
func (MockRegistryClient) GetImageConfig ¶ added in v0.1.20
func (m MockRegistryClient) GetImageConfig(_ context.Context, given *registry.ImageConfigRequest, _ ...grpc.CallOption) (*registry.ImageConfig, error)
func (MockRegistryClient) GetPackageVersionMetadata ¶ added in v0.1.25
func (m MockRegistryClient) GetPackageVersionMetadata(_ context.Context, given *registry.PackageVersionMetadataRequest, _ ...grpc.CallOption) (*registry.PackageVersionMetadata, error)
func (MockRegistryClient) GetRawSbom ¶ added in v0.1.21
func (m MockRegistryClient) GetRawSbom(_ context.Context, given *registry.RawSbomRequest, _ ...grpc.CallOption) (*registry.RawSbom, error)
func (MockRegistryClient) GetRegistrySettings ¶ added in v0.1.45
func (m MockRegistryClient) GetRegistrySettings(_ context.Context, given *registry.GetRegistrySettingsRequest, _ ...grpc.CallOption) (*registry.RegistrySettings, error)
func (MockRegistryClient) GetRepoCountBySource ¶ added in v0.1.33
func (m MockRegistryClient) GetRepoCountBySource(_ context.Context, given *registry.GetRepoCountBySourceRequest, _ ...grpc.CallOption) (*registry.RepoCount, error)
func (MockRegistryClient) GetSbom ¶ added in v0.1.8
func (m MockRegistryClient) GetSbom(_ context.Context, given *registry.SbomRequest, _ ...grpc.CallOption) (*tenant.Sbom2, error)
func (MockRegistryClient) GetSize ¶ added in v0.1.33
func (m MockRegistryClient) GetSize(_ context.Context, given *registry.SizeRequest, _ ...grpc.CallOption) (*registry.Size, error)
func (MockRegistryClient) GetSyncStatus ¶ added in v0.1.46
func (m MockRegistryClient) GetSyncStatus(_ context.Context, given *registry.GetSyncStatusRequest, _ ...grpc.CallOption) (*registry.SyncStatus, error)
func (MockRegistryClient) GetUpdateStatus ¶ added in v0.1.33
func (m MockRegistryClient) GetUpdateStatus(_ context.Context, given *registry.UpdateStatusRequest, _ ...grpc.CallOption) (*registry.UpdateStatus, error)
func (MockRegistryClient) GetVulnReport ¶ added in v0.1.12
func (m MockRegistryClient) GetVulnReport(_ context.Context, given *registry.VulnReportRequest, _ ...grpc.CallOption) (*tenant.VulnReport, error)
func (MockRegistryClient) ListBuildReports ¶ added in v0.1.29
func (m MockRegistryClient) ListBuildReports(_ context.Context, given *registry.BuildReportFilter, _ ...grpc.CallOption) (*registry.BuildReportList, error)
func (MockRegistryClient) ListEolTags ¶ added in v0.1.35
func (m MockRegistryClient) ListEolTags(_ context.Context, given *registry.EolTagFilter, _ ...grpc.CallOption) (*registry.EolTagList, error)
func (MockRegistryClient) ListManifestMetadata ¶ added in v0.1.20
func (m MockRegistryClient) ListManifestMetadata(_ context.Context, given *registry.ManifestMetadataFilter, _ ...grpc.CallOption) (*registry.ManifestMetadataList, error)
func (MockRegistryClient) ListRepos ¶
func (m MockRegistryClient) ListRepos(_ context.Context, given *registry.RepoFilter, _ ...grpc.CallOption) (*registry.RepoList, error)
func (MockRegistryClient) ListSyncStatuses ¶ added in v0.1.51
func (m MockRegistryClient) ListSyncStatuses(_ context.Context, given *registry.ListSyncStatusesRequest, _ ...grpc.CallOption) (*registry.SyncStatusList, error)
func (MockRegistryClient) ListTagHistory ¶
func (m MockRegistryClient) ListTagHistory(_ context.Context, given *registry.TagHistoryFilter, _ ...grpc.CallOption) (*registry.TagHistoryList, error)
func (MockRegistryClient) ListTags ¶
func (m MockRegistryClient) ListTags(_ context.Context, given *registry.TagFilter, _ ...grpc.CallOption) (*registry.TagList, error)
func (MockRegistryClient) UpdateRepo ¶
func (m MockRegistryClient) UpdateRepo(_ context.Context, given *registry.Repo, _ ...grpc.CallOption) (*registry.Repo, error)
type MockRegistryClients ¶
type MockRegistryClients struct {
OnClose error
RegistryClient MockRegistryClient
VulnerabilitiesClient MockVulnerabilitiesClient
ApkoClient MockApkoClient
EntitlementsClient MockEntitlementsClient
}
Example ¶
ExampleMockRegistryClients demonstrates creating a complete mock registry client.
package main
import (
"context"
"fmt"
registry "chainguard.dev/sdk/proto/platform/registry/v1"
"chainguard.dev/sdk/proto/platform/registry/v1/test"
)
func main() {
// Create a mock registry client with configured responses.
mock := &test.MockRegistryClients{
RegistryClient: test.MockRegistryClient{
OnListRepos: []test.ReposOnList{{
Given: ®istry.RepoFilter{},
List: ®istry.RepoList{
Items: []*registry.Repo{{
Id: "repo-123",
Name: "test-repo",
}},
},
}},
},
}
// Use the mock client.
repos, err := mock.Registry().ListRepos(context.Background(), ®istry.RepoFilter{})
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Found %d repos\n", len(repos.Items))
fmt.Printf("First repo: %s\n", repos.Items[0].Name)
}
Output: Found 1 repos First repo: test-repo
Example (Close) ¶
ExampleMockRegistryClients_close demonstrates handling the Close method.
package main
import (
"fmt"
"chainguard.dev/sdk/proto/platform/registry/v1/test"
)
func main() {
mock := &test.MockRegistryClients{
OnClose: nil,
}
err := mock.Close()
if err != nil {
fmt.Printf("Close error: %v\n", err)
return
}
fmt.Println("Client closed successfully")
}
Output: Client closed successfully
func (MockRegistryClients) Apko ¶ added in v0.1.29
func (m MockRegistryClients) Apko() registry.ApkoClient
func (MockRegistryClients) Close ¶
func (m MockRegistryClients) Close() error
func (MockRegistryClients) Entitlements ¶ added in v0.1.33
func (m MockRegistryClients) Entitlements() registry.EntitlementsClient
func (MockRegistryClients) Registry ¶
func (m MockRegistryClients) Registry() registry.RegistryClient
func (MockRegistryClients) Vulnerabilities ¶ added in v0.1.27
func (m MockRegistryClients) Vulnerabilities() registry.VulnerabilitiesClient
type MockVulnerabilitiesClient ¶ added in v0.1.27
type MockVulnerabilitiesClient struct {
registry.VulnerabilitiesClient
OnListVulnReports []VulnReportsOnList
OnGetRawVulnReport []RawVulnReportOnGet
OnListVulnCountReports []VulnCountReportsOnList
OnListCumulativeVulnCountReports []VulnCountReportsOnList
}
Example ¶
ExampleMockVulnerabilitiesClient demonstrates mocking vulnerability operations.
package main
import (
"context"
"fmt"
registry "chainguard.dev/sdk/proto/platform/registry/v1"
"chainguard.dev/sdk/proto/platform/registry/v1/test"
)
func main() {
mock := test.MockVulnerabilitiesClient{
OnListVulnReports: []test.VulnReportsOnList{{
Given: ®istry.VulnReportFilter{},
List: ®istry.VulnReportList{},
}},
}
list, err := mock.ListVulnReports(context.Background(), ®istry.VulnReportFilter{})
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Vuln reports listed: %v\n", list != nil)
}
Output: Vuln reports listed: true
func (MockVulnerabilitiesClient) GetRawVulnReport ¶ added in v0.1.27
func (m MockVulnerabilitiesClient) GetRawVulnReport(_ context.Context, given *registry.GetRawVulnReportRequest, _ ...grpc.CallOption) (*registry.RawVulnReport, error)
func (MockVulnerabilitiesClient) ListCumulativeVulnCountReports ¶ added in v0.1.32
func (m MockVulnerabilitiesClient) ListCumulativeVulnCountReports(_ context.Context, given *registry.VulnCountReportFilter, _ ...grpc.CallOption) (*registry.VulnCountReportList, error)
func (MockVulnerabilitiesClient) ListVulnCountReports ¶ added in v0.1.27
func (m MockVulnerabilitiesClient) ListVulnCountReports(_ context.Context, given *registry.VulnCountReportFilter, _ ...grpc.CallOption) (*registry.VulnCountReportList, error)
func (MockVulnerabilitiesClient) ListVulnReports ¶ added in v0.1.27
func (m MockVulnerabilitiesClient) ListVulnReports(_ context.Context, given *registry.VulnReportFilter, _ ...grpc.CallOption) (*registry.VulnReportList, error)
type OnBuildImage ¶ added in v0.1.29
type OnBuildImage struct {
Given *registry.BuildImageRequest
Result *registry.BuildImageResponse
Error error
}
type OnResolveConfig ¶ added in v0.1.29
type OnResolveConfig struct {
Given *registry.ResolveConfigRequest
Result *registry.ApkoConfig
Error error
}
type PackageVersionMetadataOnGet ¶ added in v0.1.25
type PackageVersionMetadataOnGet struct {
Given *registry.PackageVersionMetadataRequest
Get *registry.PackageVersionMetadata
Error error
}
type RawSbomOnGet ¶ added in v0.1.21
type RawSbomOnGet struct {
Given *registry.RawSbomRequest //nolint:staticcheck
Get *registry.RawSbom //nolint:staticcheck
Error error
}
type RawVulnReportOnGet ¶ added in v0.1.27
type RawVulnReportOnGet struct {
Given *registry.GetRawVulnReportRequest
Get *registry.RawVulnReport
Error error
}
type RegistrySettingsOnGet ¶ added in v0.1.45
type RegistrySettingsOnGet struct {
Given *registry.GetRegistrySettingsRequest
Get *registry.RegistrySettings
Error error
}
type RepoCountBySourceOnGet ¶ added in v0.1.33
type RepoCountBySourceOnGet struct {
Given *registry.GetRepoCountBySourceRequest
Get *registry.RepoCount
Error error
}
type RepoOnUpdate ¶
type ReposOnCreate ¶
type ReposOnCreate struct {
Given *registry.CreateRepoRequest
Created *registry.Repo
Error error
}
type ReposOnDelete ¶
type ReposOnDelete struct {
Given *registry.DeleteRepoRequest
Error error
}
type ReposOnList ¶
type ReposOnList struct {
Given *registry.RepoFilter
List *registry.RepoList
Error error
}
type SbomOnGet ¶ added in v0.1.8
type SbomOnGet struct {
Given *registry.SbomRequest //nolint:staticcheck
Get *tenant.Sbom2
Error error
}
type SizeOnGet ¶ added in v0.1.33
type SizeOnGet struct {
Given *registry.SizeRequest
Get *registry.Size
Error error
}
type SyncStatusOnGet ¶ added in v0.1.46
type SyncStatusOnGet struct {
Given *registry.GetSyncStatusRequest
Get *registry.SyncStatus
Error error
}
type SyncStatusOnList ¶ added in v0.1.51
type SyncStatusOnList struct {
Given *registry.ListSyncStatusesRequest
Get *registry.SyncStatusList
Error error
}
type TagHistoryOnList ¶
type TagHistoryOnList struct {
Given *registry.TagHistoryFilter
List *registry.TagHistoryList
Error error
}
type TagOnUpdate ¶
type TagsOnCreate ¶
type TagsOnCreate struct {
Given *registry.CreateTagRequest
Created *registry.Tag
Error error
}
type TagsOnDelete ¶
type TagsOnDelete struct {
Given *registry.DeleteTagRequest
Error error
}
type TagsOnList ¶
type UpdateStatusOnGet ¶ added in v0.1.33
type UpdateStatusOnGet struct {
Given *registry.UpdateStatusRequest
Get *registry.UpdateStatus
Error error
}
type VulnCountReportsOnList ¶ added in v0.1.27
type VulnCountReportsOnList struct {
Given *registry.VulnCountReportFilter
List *registry.VulnCountReportList
Error error
}
type VulnReportOnGet ¶ added in v0.1.12
type VulnReportOnGet struct {
Given *registry.VulnReportRequest
Get *tenant.VulnReport
Error error
}
type VulnReportsOnList ¶ added in v0.1.27
type VulnReportsOnList struct {
Given *registry.VulnReportFilter
List *registry.VulnReportList
Error error
}