From aab5a8c21b454be22c6e94bb423dfa25a53bdeea Mon Sep 17 00:00:00 2001 From: Michael Nelson Date: Tue, 15 Aug 2023 12:20:23 +1000 Subject: [PATCH] Adds generated go client for oci-catalog that we'll use from syncer. (#6618) ### Description of the change Follows on from #6595, updates the proto service files according to buf's lint, and generates the go client for use in the asset-syncer. Note: I added a separate `buf.yaml` and `buf.gen.yaml` for the oci-catalog service as buf doesn't let you refer to a proto outside of the `buf.yaml` root, so the other option would have been to move our existing `buf.yaml` and `buf.generate` into the Kubeapps root directory. I don't mind either way, but it made more sense to me for the oci-catalog service to have its own so that it is independent (it may be useful outside of Kubeapps, theoretically). ### Benefits The next PR can use the client without being cluttered by the extra diff. ### Applicable issues - ref: #6263 --------- Signed-off-by: Michael Nelson --- Makefile | 11 +- cmd/oci-catalog/buf.gen.yaml | 14 + cmd/oci-catalog/buf.lock | 2 + cmd/oci-catalog/buf.yaml | 15 + cmd/oci-catalog/build.rs | 2 +- .../gen/catalog/v1alpha1/ocicatalog.pb.go | 526 ++++++++++++++++++ .../catalog/v1alpha1/ocicatalog_grpc.pb.go | 203 +++++++ .../v1alpha1}/ocicatalog.proto | 25 +- cmd/oci-catalog/src/main.rs | 16 +- cmd/oci-catalog/src/providers/dockerhub.rs | 33 +- cmd/oci-catalog/src/providers/mod.rs | 14 +- .../reference/developer/release-process.md | 9 +- 12 files changed, 825 insertions(+), 45 deletions(-) create mode 100644 cmd/oci-catalog/buf.gen.yaml create mode 100644 cmd/oci-catalog/buf.lock create mode 100644 cmd/oci-catalog/buf.yaml create mode 100644 cmd/oci-catalog/gen/catalog/v1alpha1/ocicatalog.pb.go create mode 100644 cmd/oci-catalog/gen/catalog/v1alpha1/ocicatalog_grpc.pb.go rename cmd/oci-catalog/proto/{ => ocicatalog/v1alpha1}/ocicatalog.proto (69%) diff --git a/Makefile b/Makefile index f484815b7db..d5a4fc607cd 100644 --- a/Makefile +++ b/Makefile @@ -70,4 +70,13 @@ lint: ./script/linters/yaml-linter.sh ./script/linters/golang-linter.sh -.PHONY: default all test-all test test-dashboard fmt vet lint install-tools +buf-generate: + cd cmd/kubeapps-apis && buf generate + cd cmd/oci-catalog && buf generate + cd dashboard && yarn prettier + +buf-mod-update: + buf mod update cmd/kubeapps-apis + buf mod update cmd/oci-catalog + +.PHONY: default all buf-generate buf-mod-update test-all test test-dashboard fmt vet lint install-tools diff --git a/cmd/oci-catalog/buf.gen.yaml b/cmd/oci-catalog/buf.gen.yaml new file mode 100644 index 00000000000..6e208f4389b --- /dev/null +++ b/cmd/oci-catalog/buf.gen.yaml @@ -0,0 +1,14 @@ +# Copyright 2021-2023 the Kubeapps contributors. +# SPDX-License-Identifier: Apache-2.0 + +--- +version: v1beta1 +plugins: + - name: go + out: gen + opt: + - module=github.com/vmware-tanzu/kubeapps/cmd/oci-catalog/gen + - name: go-grpc + out: gen + opt: + - module=github.com/vmware-tanzu/kubeapps/cmd/oci-catalog/gen diff --git a/cmd/oci-catalog/buf.lock b/cmd/oci-catalog/buf.lock new file mode 100644 index 00000000000..c91b5810c29 --- /dev/null +++ b/cmd/oci-catalog/buf.lock @@ -0,0 +1,2 @@ +# Generated by buf. DO NOT EDIT. +version: v1 diff --git a/cmd/oci-catalog/buf.yaml b/cmd/oci-catalog/buf.yaml new file mode 100644 index 00000000000..a31f3c3cf07 --- /dev/null +++ b/cmd/oci-catalog/buf.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 the Kubeapps contributors. +# SPDX-License-Identifier: Apache-2.0 + +--- +version: v1beta1 +name: "buf.build/kubeapps/oci-catalog" +build: + roots: + - proto +lint: + use: + - DEFAULT + ignore_only: + RPC_RESPONSE_STANDARD_NAME: + - ocicatalog/v1alpha1/ocicatalog.proto diff --git a/cmd/oci-catalog/build.rs b/cmd/oci-catalog/build.rs index c5d9f3e0457..05fa7c98d1d 100644 --- a/cmd/oci-catalog/build.rs +++ b/cmd/oci-catalog/build.rs @@ -4,7 +4,7 @@ use std::env; fn main() -> Result<(), Box> { - tonic_build::compile_protos("proto/ocicatalog.proto")?; + tonic_build::compile_protos("proto/ocicatalog/v1alpha1/ocicatalog.proto")?; // If the binary is built with the ENV var "OCI_CATALOG_VERSION", // the value will be available at buildime. Otherwise, it becomes "devel" diff --git a/cmd/oci-catalog/gen/catalog/v1alpha1/ocicatalog.pb.go b/cmd/oci-catalog/gen/catalog/v1alpha1/ocicatalog.pb.go new file mode 100644 index 00000000000..1f43ecb3666 --- /dev/null +++ b/cmd/oci-catalog/gen/catalog/v1alpha1/ocicatalog.pb.go @@ -0,0 +1,526 @@ +// Copyright 2023 the Kubeapps contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc (unknown) +// source: ocicatalog/v1alpha1/ocicatalog.proto + +package v1alpha1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// RegistryProvider +// +// Optionally specify the registry provider when known. +type RegistryProvider int32 + +const ( + RegistryProvider_REGISTRY_PROVIDER_UNSPECIFIED RegistryProvider = 0 + RegistryProvider_REGISTRY_PROVIDER_DOCKER_HUB RegistryProvider = 1 + RegistryProvider_REGISTRY_PROVIDER_HARBOR RegistryProvider = 2 +) + +// Enum value maps for RegistryProvider. +var ( + RegistryProvider_name = map[int32]string{ + 0: "REGISTRY_PROVIDER_UNSPECIFIED", + 1: "REGISTRY_PROVIDER_DOCKER_HUB", + 2: "REGISTRY_PROVIDER_HARBOR", + } + RegistryProvider_value = map[string]int32{ + "REGISTRY_PROVIDER_UNSPECIFIED": 0, + "REGISTRY_PROVIDER_DOCKER_HUB": 1, + "REGISTRY_PROVIDER_HARBOR": 2, + } +) + +func (x RegistryProvider) Enum() *RegistryProvider { + p := new(RegistryProvider) + *p = x + return p +} + +func (x RegistryProvider) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (RegistryProvider) Descriptor() protoreflect.EnumDescriptor { + return file_ocicatalog_v1alpha1_ocicatalog_proto_enumTypes[0].Descriptor() +} + +func (RegistryProvider) Type() protoreflect.EnumType { + return &file_ocicatalog_v1alpha1_ocicatalog_proto_enumTypes[0] +} + +func (x RegistryProvider) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use RegistryProvider.Descriptor instead. +func (RegistryProvider) EnumDescriptor() ([]byte, []int) { + return file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescGZIP(), []int{0} +} + +// ListRepositoriesForRegistryRequest +// +// Request for listing repositories of a registry or a namespaced registry. +type ListRepositoriesForRegistryRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The OCI registry for which the repositories should be listed. + Registry string `protobuf:"bytes,1,opt,name=registry,proto3" json:"registry,omitempty"` + // An optional namespace within which to list repositories. + Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` + // An optional list of content types to filter. + ContentTypes []string `protobuf:"bytes,3,rep,name=content_types,json=contentTypes,proto3" json:"content_types,omitempty"` + // Perhaps switch to be a one-of, so when testing, can pass a token + // directly? Though wouldn't want this to be used or available in prod. + KubernetesSecret string `protobuf:"bytes,4,opt,name=kubernetes_secret,json=kubernetesSecret,proto3" json:"kubernetes_secret,omitempty"` + // In self-hosted registry examples, such as a self-hosted Harbor registry, + // there will be no information in the URL that can be used to determine + // the provider (and hence, which strategy / API to use). The optional + // registry_provider field can be used to explicitly identify the provider. + RegistryProvider RegistryProvider `protobuf:"varint,5,opt,name=registry_provider,json=registryProvider,proto3,enum=ocicatalog.v1alpha1.RegistryProvider" json:"registry_provider,omitempty"` +} + +func (x *ListRepositoriesForRegistryRequest) Reset() { + *x = ListRepositoriesForRegistryRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListRepositoriesForRegistryRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRepositoriesForRegistryRequest) ProtoMessage() {} + +func (x *ListRepositoriesForRegistryRequest) ProtoReflect() protoreflect.Message { + mi := &file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRepositoriesForRegistryRequest.ProtoReflect.Descriptor instead. +func (*ListRepositoriesForRegistryRequest) Descriptor() ([]byte, []int) { + return file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescGZIP(), []int{0} +} + +func (x *ListRepositoriesForRegistryRequest) GetRegistry() string { + if x != nil { + return x.Registry + } + return "" +} + +func (x *ListRepositoriesForRegistryRequest) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +func (x *ListRepositoriesForRegistryRequest) GetContentTypes() []string { + if x != nil { + return x.ContentTypes + } + return nil +} + +func (x *ListRepositoriesForRegistryRequest) GetKubernetesSecret() string { + if x != nil { + return x.KubernetesSecret + } + return "" +} + +func (x *ListRepositoriesForRegistryRequest) GetRegistryProvider() RegistryProvider { + if x != nil { + return x.RegistryProvider + } + return RegistryProvider_REGISTRY_PROVIDER_UNSPECIFIED +} + +// Repository +// +// Uniquely identifies an OCI repository. +type Repository struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Registry string `protobuf:"bytes,1,opt,name=registry,proto3" json:"registry,omitempty"` + Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *Repository) Reset() { + *x = Repository{} + if protoimpl.UnsafeEnabled { + mi := &file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Repository) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Repository) ProtoMessage() {} + +func (x *Repository) ProtoReflect() protoreflect.Message { + mi := &file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Repository.ProtoReflect.Descriptor instead. +func (*Repository) Descriptor() ([]byte, []int) { + return file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescGZIP(), []int{1} +} + +func (x *Repository) GetRegistry() string { + if x != nil { + return x.Registry + } + return "" +} + +func (x *Repository) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +func (x *Repository) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// ListTagsForRepositoryRequest +// +// Identifies the repository for which tags are to be listed. Can be +// extended in the future with other options. +type ListTagsForRepositoryRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Repository *Repository `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` + RegistryProvider RegistryProvider `protobuf:"varint,2,opt,name=registry_provider,json=registryProvider,proto3,enum=ocicatalog.v1alpha1.RegistryProvider" json:"registry_provider,omitempty"` +} + +func (x *ListTagsForRepositoryRequest) Reset() { + *x = ListTagsForRepositoryRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListTagsForRepositoryRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListTagsForRepositoryRequest) ProtoMessage() {} + +func (x *ListTagsForRepositoryRequest) ProtoReflect() protoreflect.Message { + mi := &file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListTagsForRepositoryRequest.ProtoReflect.Descriptor instead. +func (*ListTagsForRepositoryRequest) Descriptor() ([]byte, []int) { + return file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescGZIP(), []int{2} +} + +func (x *ListTagsForRepositoryRequest) GetRepository() *Repository { + if x != nil { + return x.Repository + } + return nil +} + +func (x *ListTagsForRepositoryRequest) GetRegistryProvider() RegistryProvider { + if x != nil { + return x.RegistryProvider + } + return RegistryProvider_REGISTRY_PROVIDER_UNSPECIFIED +} + +// Tag +// +// Simple tag for a repository. +type Tag struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *Tag) Reset() { + *x = Tag{} + if protoimpl.UnsafeEnabled { + mi := &file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Tag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Tag) ProtoMessage() {} + +func (x *Tag) ProtoReflect() protoreflect.Message { + mi := &file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Tag.ProtoReflect.Descriptor instead. +func (*Tag) Descriptor() ([]byte, []int) { + return file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescGZIP(), []int{3} +} + +func (x *Tag) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +var File_ocicatalog_v1alpha1_ocicatalog_proto protoreflect.FileDescriptor + +var file_ocicatalog_v1alpha1_ocicatalog_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x6f, 0x63, 0x69, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x2f, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6f, 0x63, 0x69, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x6f, 0x63, 0x69, 0x63, 0x61, 0x74, 0x61, 0x6c, + 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x22, 0x84, 0x02, 0x0a, 0x22, + 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, + 0x46, 0x6f, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x1c, + 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x23, 0x0a, 0x0d, + 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, + 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x5f, + 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x6b, 0x75, + 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x52, + 0x0a, 0x11, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x25, 0x2e, 0x6f, 0x63, 0x69, 0x63, + 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, + 0x52, 0x10, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, + 0x65, 0x72, 0x22, 0x5a, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, + 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x09, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xb3, + 0x01, 0x0a, 0x1c, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x46, 0x6f, 0x72, 0x52, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x3f, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x63, 0x69, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x6f, 0x72, 0x79, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, + 0x12, 0x52, 0x0a, 0x11, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x5f, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x25, 0x2e, 0x6f, 0x63, + 0x69, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, + 0x65, 0x72, 0x52, 0x10, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x76, + 0x69, 0x64, 0x65, 0x72, 0x22, 0x19, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x2a, + 0x75, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x1d, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x52, 0x59, 0x5f, + 0x50, 0x52, 0x4f, 0x56, 0x49, 0x44, 0x45, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, + 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x20, 0x0a, 0x1c, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, + 0x52, 0x59, 0x5f, 0x50, 0x52, 0x4f, 0x56, 0x49, 0x44, 0x45, 0x52, 0x5f, 0x44, 0x4f, 0x43, 0x4b, + 0x45, 0x52, 0x5f, 0x48, 0x55, 0x42, 0x10, 0x01, 0x12, 0x1c, 0x0a, 0x18, 0x52, 0x45, 0x47, 0x49, + 0x53, 0x54, 0x52, 0x59, 0x5f, 0x50, 0x52, 0x4f, 0x56, 0x49, 0x44, 0x45, 0x52, 0x5f, 0x48, 0x41, + 0x52, 0x42, 0x4f, 0x52, 0x10, 0x02, 0x32, 0xf6, 0x01, 0x0a, 0x11, 0x4f, 0x43, 0x49, 0x43, 0x61, + 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x79, 0x0a, 0x1b, + 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, + 0x46, 0x6f, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x37, 0x2e, 0x6f, 0x63, + 0x69, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x69, + 0x65, 0x73, 0x46, 0x6f, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x6f, 0x63, 0x69, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, + 0x67, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x30, 0x01, 0x12, 0x66, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x54, + 0x61, 0x67, 0x73, 0x46, 0x6f, 0x72, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, + 0x12, 0x31, 0x2e, 0x6f, 0x63, 0x69, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x46, + 0x6f, 0x72, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x6f, 0x63, 0x69, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x54, 0x61, 0x67, 0x30, 0x01, 0x42, + 0x47, 0x5a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x6d, + 0x77, 0x61, 0x72, 0x65, 0x2d, 0x74, 0x61, 0x6e, 0x7a, 0x75, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x61, + 0x70, 0x70, 0x73, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x6f, 0x63, 0x69, 0x2d, 0x63, 0x61, 0x74, 0x61, + 0x6c, 0x6f, 0x67, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x2f, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescOnce sync.Once + file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescData = file_ocicatalog_v1alpha1_ocicatalog_proto_rawDesc +) + +func file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescGZIP() []byte { + file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescOnce.Do(func() { + file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescData = protoimpl.X.CompressGZIP(file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescData) + }) + return file_ocicatalog_v1alpha1_ocicatalog_proto_rawDescData +} + +var file_ocicatalog_v1alpha1_ocicatalog_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_ocicatalog_v1alpha1_ocicatalog_proto_goTypes = []interface{}{ + (RegistryProvider)(0), // 0: ocicatalog.v1alpha1.RegistryProvider + (*ListRepositoriesForRegistryRequest)(nil), // 1: ocicatalog.v1alpha1.ListRepositoriesForRegistryRequest + (*Repository)(nil), // 2: ocicatalog.v1alpha1.Repository + (*ListTagsForRepositoryRequest)(nil), // 3: ocicatalog.v1alpha1.ListTagsForRepositoryRequest + (*Tag)(nil), // 4: ocicatalog.v1alpha1.Tag +} +var file_ocicatalog_v1alpha1_ocicatalog_proto_depIdxs = []int32{ + 0, // 0: ocicatalog.v1alpha1.ListRepositoriesForRegistryRequest.registry_provider:type_name -> ocicatalog.v1alpha1.RegistryProvider + 2, // 1: ocicatalog.v1alpha1.ListTagsForRepositoryRequest.repository:type_name -> ocicatalog.v1alpha1.Repository + 0, // 2: ocicatalog.v1alpha1.ListTagsForRepositoryRequest.registry_provider:type_name -> ocicatalog.v1alpha1.RegistryProvider + 1, // 3: ocicatalog.v1alpha1.OCICatalogService.ListRepositoriesForRegistry:input_type -> ocicatalog.v1alpha1.ListRepositoriesForRegistryRequest + 3, // 4: ocicatalog.v1alpha1.OCICatalogService.ListTagsForRepository:input_type -> ocicatalog.v1alpha1.ListTagsForRepositoryRequest + 2, // 5: ocicatalog.v1alpha1.OCICatalogService.ListRepositoriesForRegistry:output_type -> ocicatalog.v1alpha1.Repository + 4, // 6: ocicatalog.v1alpha1.OCICatalogService.ListTagsForRepository:output_type -> ocicatalog.v1alpha1.Tag + 5, // [5:7] is the sub-list for method output_type + 3, // [3:5] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_ocicatalog_v1alpha1_ocicatalog_proto_init() } +func file_ocicatalog_v1alpha1_ocicatalog_proto_init() { + if File_ocicatalog_v1alpha1_ocicatalog_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRepositoriesForRegistryRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Repository); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListTagsForRepositoryRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Tag); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_ocicatalog_v1alpha1_ocicatalog_proto_rawDesc, + NumEnums: 1, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_ocicatalog_v1alpha1_ocicatalog_proto_goTypes, + DependencyIndexes: file_ocicatalog_v1alpha1_ocicatalog_proto_depIdxs, + EnumInfos: file_ocicatalog_v1alpha1_ocicatalog_proto_enumTypes, + MessageInfos: file_ocicatalog_v1alpha1_ocicatalog_proto_msgTypes, + }.Build() + File_ocicatalog_v1alpha1_ocicatalog_proto = out.File + file_ocicatalog_v1alpha1_ocicatalog_proto_rawDesc = nil + file_ocicatalog_v1alpha1_ocicatalog_proto_goTypes = nil + file_ocicatalog_v1alpha1_ocicatalog_proto_depIdxs = nil +} diff --git a/cmd/oci-catalog/gen/catalog/v1alpha1/ocicatalog_grpc.pb.go b/cmd/oci-catalog/gen/catalog/v1alpha1/ocicatalog_grpc.pb.go new file mode 100644 index 00000000000..7383edd50ab --- /dev/null +++ b/cmd/oci-catalog/gen/catalog/v1alpha1/ocicatalog_grpc.pb.go @@ -0,0 +1,203 @@ +// Copyright 2023 the Kubeapps contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: ocicatalog/v1alpha1/ocicatalog.proto + +package v1alpha1 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + OCICatalogService_ListRepositoriesForRegistry_FullMethodName = "/ocicatalog.v1alpha1.OCICatalogService/ListRepositoriesForRegistry" + OCICatalogService_ListTagsForRepository_FullMethodName = "/ocicatalog.v1alpha1.OCICatalogService/ListTagsForRepository" +) + +// OCICatalogServiceClient is the client API for OCICatalogService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type OCICatalogServiceClient interface { + ListRepositoriesForRegistry(ctx context.Context, in *ListRepositoriesForRegistryRequest, opts ...grpc.CallOption) (OCICatalogService_ListRepositoriesForRegistryClient, error) + ListTagsForRepository(ctx context.Context, in *ListTagsForRepositoryRequest, opts ...grpc.CallOption) (OCICatalogService_ListTagsForRepositoryClient, error) +} + +type oCICatalogServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewOCICatalogServiceClient(cc grpc.ClientConnInterface) OCICatalogServiceClient { + return &oCICatalogServiceClient{cc} +} + +func (c *oCICatalogServiceClient) ListRepositoriesForRegistry(ctx context.Context, in *ListRepositoriesForRegistryRequest, opts ...grpc.CallOption) (OCICatalogService_ListRepositoriesForRegistryClient, error) { + stream, err := c.cc.NewStream(ctx, &OCICatalogService_ServiceDesc.Streams[0], OCICatalogService_ListRepositoriesForRegistry_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &oCICatalogServiceListRepositoriesForRegistryClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type OCICatalogService_ListRepositoriesForRegistryClient interface { + Recv() (*Repository, error) + grpc.ClientStream +} + +type oCICatalogServiceListRepositoriesForRegistryClient struct { + grpc.ClientStream +} + +func (x *oCICatalogServiceListRepositoriesForRegistryClient) Recv() (*Repository, error) { + m := new(Repository) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *oCICatalogServiceClient) ListTagsForRepository(ctx context.Context, in *ListTagsForRepositoryRequest, opts ...grpc.CallOption) (OCICatalogService_ListTagsForRepositoryClient, error) { + stream, err := c.cc.NewStream(ctx, &OCICatalogService_ServiceDesc.Streams[1], OCICatalogService_ListTagsForRepository_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &oCICatalogServiceListTagsForRepositoryClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type OCICatalogService_ListTagsForRepositoryClient interface { + Recv() (*Tag, error) + grpc.ClientStream +} + +type oCICatalogServiceListTagsForRepositoryClient struct { + grpc.ClientStream +} + +func (x *oCICatalogServiceListTagsForRepositoryClient) Recv() (*Tag, error) { + m := new(Tag) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// OCICatalogServiceServer is the server API for OCICatalogService service. +// All implementations must embed UnimplementedOCICatalogServiceServer +// for forward compatibility +type OCICatalogServiceServer interface { + ListRepositoriesForRegistry(*ListRepositoriesForRegistryRequest, OCICatalogService_ListRepositoriesForRegistryServer) error + ListTagsForRepository(*ListTagsForRepositoryRequest, OCICatalogService_ListTagsForRepositoryServer) error + mustEmbedUnimplementedOCICatalogServiceServer() +} + +// UnimplementedOCICatalogServiceServer must be embedded to have forward compatible implementations. +type UnimplementedOCICatalogServiceServer struct { +} + +func (UnimplementedOCICatalogServiceServer) ListRepositoriesForRegistry(*ListRepositoriesForRegistryRequest, OCICatalogService_ListRepositoriesForRegistryServer) error { + return status.Errorf(codes.Unimplemented, "method ListRepositoriesForRegistry not implemented") +} +func (UnimplementedOCICatalogServiceServer) ListTagsForRepository(*ListTagsForRepositoryRequest, OCICatalogService_ListTagsForRepositoryServer) error { + return status.Errorf(codes.Unimplemented, "method ListTagsForRepository not implemented") +} +func (UnimplementedOCICatalogServiceServer) mustEmbedUnimplementedOCICatalogServiceServer() {} + +// UnsafeOCICatalogServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to OCICatalogServiceServer will +// result in compilation errors. +type UnsafeOCICatalogServiceServer interface { + mustEmbedUnimplementedOCICatalogServiceServer() +} + +func RegisterOCICatalogServiceServer(s grpc.ServiceRegistrar, srv OCICatalogServiceServer) { + s.RegisterService(&OCICatalogService_ServiceDesc, srv) +} + +func _OCICatalogService_ListRepositoriesForRegistry_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ListRepositoriesForRegistryRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(OCICatalogServiceServer).ListRepositoriesForRegistry(m, &oCICatalogServiceListRepositoriesForRegistryServer{stream}) +} + +type OCICatalogService_ListRepositoriesForRegistryServer interface { + Send(*Repository) error + grpc.ServerStream +} + +type oCICatalogServiceListRepositoriesForRegistryServer struct { + grpc.ServerStream +} + +func (x *oCICatalogServiceListRepositoriesForRegistryServer) Send(m *Repository) error { + return x.ServerStream.SendMsg(m) +} + +func _OCICatalogService_ListTagsForRepository_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ListTagsForRepositoryRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(OCICatalogServiceServer).ListTagsForRepository(m, &oCICatalogServiceListTagsForRepositoryServer{stream}) +} + +type OCICatalogService_ListTagsForRepositoryServer interface { + Send(*Tag) error + grpc.ServerStream +} + +type oCICatalogServiceListTagsForRepositoryServer struct { + grpc.ServerStream +} + +func (x *oCICatalogServiceListTagsForRepositoryServer) Send(m *Tag) error { + return x.ServerStream.SendMsg(m) +} + +// OCICatalogService_ServiceDesc is the grpc.ServiceDesc for OCICatalogService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var OCICatalogService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "ocicatalog.v1alpha1.OCICatalogService", + HandlerType: (*OCICatalogServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "ListRepositoriesForRegistry", + Handler: _OCICatalogService_ListRepositoriesForRegistry_Handler, + ServerStreams: true, + }, + { + StreamName: "ListTagsForRepository", + Handler: _OCICatalogService_ListTagsForRepository_Handler, + ServerStreams: true, + }, + }, + Metadata: "ocicatalog/v1alpha1/ocicatalog.proto", +} diff --git a/cmd/oci-catalog/proto/ocicatalog.proto b/cmd/oci-catalog/proto/ocicatalog/v1alpha1/ocicatalog.proto similarity index 69% rename from cmd/oci-catalog/proto/ocicatalog.proto rename to cmd/oci-catalog/proto/ocicatalog/v1alpha1/ocicatalog.proto index 7c8d294d1a2..b4be280c584 100644 --- a/cmd/oci-catalog/proto/ocicatalog.proto +++ b/cmd/oci-catalog/proto/ocicatalog/v1alpha1/ocicatalog.proto @@ -2,28 +2,29 @@ // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; -package ocicatalog; +package ocicatalog.v1alpha1; +option go_package = "github.com/vmware-tanzu/kubeapps/cmd/oci-catalog/gen/catalog/v1alpha1"; -// The OCICatalog service defines the two RPCs for listing repositories and listing tags +// The OCICatalogService defines the two RPCs for listing repositories and listing tags // for a repository. -service OCICatalog { - rpc ListRepositoriesForRegistry(ListRepositoriesRequest) returns (stream Repository); - rpc ListTagsForRepository(ListTagsRequest) returns (stream Tag); +service OCICatalogService { + rpc ListRepositoriesForRegistry(ListRepositoriesForRegistryRequest) returns (stream Repository); + rpc ListTagsForRepository(ListTagsForRepositoryRequest) returns (stream Tag); } // RegistryProvider // // Optionally specify the registry provider when known. enum RegistryProvider { - UNKNOWN = 0; - DOCKER_HUB = 1; - HARBOR = 2; + REGISTRY_PROVIDER_UNSPECIFIED = 0; + REGISTRY_PROVIDER_DOCKER_HUB = 1; + REGISTRY_PROVIDER_HARBOR = 2; } -// ListRepositoriesRequest +// ListRepositoriesForRegistryRequest // // Request for listing repositories of a registry or a namespaced registry. -message ListRepositoriesRequest { +message ListRepositoriesForRegistryRequest { // The OCI registry for which the repositories should be listed. string registry = 1; @@ -53,11 +54,11 @@ message Repository { string name = 3; } -// ListTagsRequest +// ListTagsForRepositoryRequest // // Identifies the repository for which tags are to be listed. Can be // extended in the future with other options. -message ListTagsRequest { +message ListTagsForRepositoryRequest { Repository repository = 1; RegistryProvider registry_provider = 2; diff --git a/cmd/oci-catalog/src/main.rs b/cmd/oci-catalog/src/main.rs index e82d2a43c81..9783349b621 100644 --- a/cmd/oci-catalog/src/main.rs +++ b/cmd/oci-catalog/src/main.rs @@ -10,10 +10,12 @@ use tonic::{transport::Server, Request, Response, Status}; // Ensure that the compiled proto API is available within a module // before importing the required items. pub mod oci_catalog { - tonic::include_proto!("ocicatalog"); + tonic::include_proto!("ocicatalog.v1alpha1"); } -use oci_catalog::oci_catalog_server::{OciCatalog, OciCatalogServer}; -use oci_catalog::{ListRepositoriesRequest, ListTagsRequest, Repository, Tag}; +use oci_catalog::oci_catalog_service_server::{OciCatalogService, OciCatalogServiceServer}; +use oci_catalog::{ + ListRepositoriesForRegistryRequest, ListTagsForRepositoryRequest, Repository, Tag, +}; mod cli; mod providers; @@ -22,13 +24,13 @@ mod providers; pub struct KubeappsOCICatalog {} #[tonic::async_trait] -impl OciCatalog for KubeappsOCICatalog { +impl OciCatalogService for KubeappsOCICatalog { type ListRepositoriesForRegistryStream = ReceiverStream>; type ListTagsForRepositoryStream = ReceiverStream>; async fn list_repositories_for_registry( &self, - request: Request, + request: Request, ) -> Result, Status> { // The provider for request strategy provides the registry-specific // implementation. @@ -53,7 +55,7 @@ impl OciCatalog for KubeappsOCICatalog { async fn list_tags_for_repository( &self, - request: Request, + request: Request, ) -> Result, Status> { // The provider for request strategy provides the registry-specific // implementation. @@ -87,7 +89,7 @@ async fn main() -> Result<(), Box> { // for an example setup. let server = Server::builder() - .add_service(OciCatalogServer::new(kubeapps_oci_catalog)) + .add_service(OciCatalogServiceServer::new(kubeapps_oci_catalog)) .add_service(health_service) .serve(addr); log::info!("listening for gRPC requests at {}", addr); diff --git a/cmd/oci-catalog/src/providers/dockerhub.rs b/cmd/oci-catalog/src/providers/dockerhub.rs index 80bfc082ec9..63391dd055c 100644 --- a/cmd/oci-catalog/src/providers/dockerhub.rs +++ b/cmd/oci-catalog/src/providers/dockerhub.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use super::OCICatalogSender; -use super::{ListRepositoriesRequest, ListTagsRequest, Repository, Tag}; +use super::{ListRepositoriesForRegistryRequest, ListTagsForRepositoryRequest, Repository, Tag}; use log; use reqwest::{StatusCode, Url}; use serde::{Deserialize, Serialize}; @@ -58,7 +58,7 @@ impl OCICatalogSender for DockerHubAPI { async fn send_repositories( &self, tx: mpsc::Sender>, - request: &ListRepositoriesRequest, + request: &ListRepositoriesForRegistryRequest, ) { let mut url = url_for_request_repositories(request); @@ -123,7 +123,11 @@ impl OCICatalogSender for DockerHubAPI { } } - async fn send_tags(&self, tx: mpsc::Sender>, request: &ListTagsRequest) { + async fn send_tags( + &self, + tx: mpsc::Sender>, + request: &ListTagsForRepositoryRequest, + ) { let mut url = match url_for_request_tags(request) { Ok(u) => u, Err(e) => { @@ -188,7 +192,7 @@ impl OCICatalogSender for DockerHubAPI { } } -fn url_for_request_repositories(request: &ListRepositoriesRequest) -> Url { +fn url_for_request_repositories(request: &ListRepositoriesForRegistryRequest) -> Url { let mut url = reqwest::Url::parse(DOCKERHUB_URI).unwrap(); if !request.namespace.is_empty() { @@ -211,7 +215,7 @@ fn url_for_request_repositories(request: &ListRepositoriesRequest) -> Url { url } -fn url_for_request_tags(request: &ListTagsRequest) -> Result { +fn url_for_request_tags(request: &ListTagsForRepositoryRequest) -> Result { let mut url = reqwest::Url::parse(DOCKERHUB_URI).unwrap(); let repo = match request.repository.clone() { @@ -241,36 +245,39 @@ mod tests { use rstest::rstest; #[rstest] - #[case::without_namespace(ListRepositoriesRequest{ + #[case::without_namespace(ListRepositoriesForRegistryRequest{ registry: "registry-1.dockerhub.io".to_string(), ..Default::default() }, "https://hub.docker.com/v2/repositories/?page_size=100&ordering=name")] - #[case::with_namespace(ListRepositoriesRequest{ + #[case::with_namespace(ListRepositoriesForRegistryRequest{ registry: "registry-1.dockerhub.io".to_string(), namespace: "bitnamicharts".to_string(), ..Default::default() }, "https://hub.docker.com/v2/namespaces/bitnamicharts/repositories/?page_size=100&ordering=name")] - #[case::with_content_type(ListRepositoriesRequest{ + #[case::with_content_type(ListRepositoriesForRegistryRequest{ registry: "registry-1.dockerhub.io".to_string(), namespace: "bitnamicharts".to_string(), content_types: vec!["helm".to_string()], ..Default::default() }, "https://hub.docker.com/v2/namespaces/bitnamicharts/repositories/?page_size=100&ordering=name&content_types=helm")] - #[case::with_multiple_content_types(ListRepositoriesRequest{ + #[case::with_multiple_content_types(ListRepositoriesForRegistryRequest{ registry: "registry-1.dockerhub.io".to_string(), namespace: "bitnamicharts".to_string(), content_types: vec!["helm".to_string(), "image".to_string()], ..Default::default() }, "https://hub.docker.com/v2/namespaces/bitnamicharts/repositories/?page_size=100&ordering=name&content_types=helm&content_types=image")] - fn test_url_for_request(#[case] request: ListRepositoriesRequest, #[case] expected_url: Url) { + fn test_url_for_request( + #[case] request: ListRepositoriesForRegistryRequest, + #[case] expected_url: Url, + ) { assert_eq!(url_for_request_repositories(&request), expected_url); } #[rstest] - #[case::without_repository(ListTagsRequest{ + #[case::without_repository(ListTagsForRepositoryRequest{ ..Default::default() }, Err(Status::invalid_argument("bang")))] - #[case::with_repository(ListTagsRequest{ + #[case::with_repository(ListTagsForRepositoryRequest{ repository: Some(Repository{ namespace: "bitnamicharts".to_string(), name: "apache".to_string(), @@ -279,7 +286,7 @@ mod tests { ..Default::default() }, Ok(reqwest::Url::parse("https://hub.docker.com/v2/repositories/bitnamicharts/apache/tags?page_size=100").unwrap()))] fn test_url_for_request_tags( - #[case] request: ListTagsRequest, + #[case] request: ListTagsForRepositoryRequest, #[case] expected_result: Result, ) { match expected_result { diff --git a/cmd/oci-catalog/src/providers/mod.rs b/cmd/oci-catalog/src/providers/mod.rs index 4546379c4fa..0bfbceb6c12 100644 --- a/cmd/oci-catalog/src/providers/mod.rs +++ b/cmd/oci-catalog/src/providers/mod.rs @@ -3,7 +3,7 @@ use crate::oci_catalog::RegistryProvider; -use super::{ListRepositoriesRequest, ListTagsRequest, Repository, Tag}; +use super::{ListRepositoriesForRegistryRequest, ListTagsForRepositoryRequest, Repository, Tag}; use tokio::sync::mpsc; use tonic::Status; @@ -20,12 +20,16 @@ pub trait OCICatalogSender { async fn send_repositories( &self, tx: mpsc::Sender>, - request: &ListRepositoriesRequest, + request: &ListRepositoriesForRegistryRequest, ); /// send_tags requests tags for a repository of a provider and sends /// them down a channel for our API to return. - async fn send_tags(&self, tx: mpsc::Sender>, request: &ListTagsRequest); + async fn send_tags( + &self, + tx: mpsc::Sender>, + request: &ListTagsForRepositoryRequest, + ); // The id simply gives a way in tests to determine which provider // has been selected. @@ -61,12 +65,12 @@ mod tests { )] #[case::without_provider_but_matching_url( "https://registry-x.docker.io", - RegistryProvider::Unknown, + RegistryProvider::Unspecified, dockerhub::PROVIDER_NAME )] #[case::without_provider_or_matching_registry( "https://registry-x.dockers.io", - RegistryProvider::Unknown, + RegistryProvider::Unspecified, "" )] fn test_provider_for_request( diff --git a/site/content/docs/latest/reference/developer/release-process.md b/site/content/docs/latest/reference/developer/release-process.md index ed753103f6d..425b4774666 100644 --- a/site/content/docs/latest/reference/developer/release-process.md +++ b/site/content/docs/latest/reference/developer/release-process.md @@ -84,17 +84,14 @@ As per the introduction of the new Kubeapps APIs service, it is based upon autom ```bash # You need to have the latest buf binary installed, if not, go to https://docs.buf.build/installation/ -buf mod update cmd/kubeapps-apis/ +make buf-mod-update ``` -- Next, the autogenerated code ought to be regenerated. Note that some frontend code files might not comply with the `prettier` rules, therefore, triggering the linter may be required. +- Next, the autogenerated code ought to be regenerated. ```bash # You need to have the latest buf binary installed, if not, go to https://docs.buf.build/installation/ -cd cmd/kubeapps-apis -make generate - -npx prettier --write ../../dashboard/src/ +make buf-generate ``` As part of this process, the [autogenerated API documentation](https://github.com/vmware-tanzu/kubeapps/blob/main/cmd/kubeapps-apis/docs/kubeapps-apis.swagger.json)