From 4522bc5ef382e24a54f8ad9651a08a52758df2fb Mon Sep 17 00:00:00 2001 From: gNPSI Team Date: Tue, 9 Jul 2024 10:43:15 -0700 Subject: [PATCH] no change PiperOrigin-RevId: 650682359 --- .bazelversion | 2 +- WORKSPACE => WORKSPACE.bazel | 71 ++-- common.bzl | 29 -- compile_protos.sh | 24 ++ proto/gnpsi/BUILD.bazel | 24 +- proto/gnpsi/gnpsi.pb.go | 610 ----------------------------------- proto/gnpsi/gnpsi.proto | 4 +- proto/gnpsi/gnpsi_grpc.pb.go | 132 -------- regenerate-files.sh | 21 -- 9 files changed, 52 insertions(+), 865 deletions(-) rename WORKSPACE => WORKSPACE.bazel (50%) delete mode 100644 common.bzl create mode 100755 compile_protos.sh delete mode 100755 proto/gnpsi/gnpsi.pb.go delete mode 100755 proto/gnpsi/gnpsi_grpc.pb.go delete mode 100755 regenerate-files.sh diff --git a/.bazelversion b/.bazelversion index 19b860c..c0be8a7 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.4.0 +6.4.0 \ No newline at end of file diff --git a/WORKSPACE b/WORKSPACE.bazel similarity index 50% rename from WORKSPACE rename to WORKSPACE.bazel index 5c10a60..5a853a3 100644 --- a/WORKSPACE +++ b/WORKSPACE.bazel @@ -16,22 +16,10 @@ workspace(name = "com_github_openconfig_gnpsi") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -### Bazel rules for many languages to compile PROTO into gRPC libraries -# Note: any version of this which is less than 4.3.0 requires bazel version 5.4.0 (set in .bazelversion file) -http_archive( - name = "rules_proto_grpc", - sha256 = "c0d718f4d892c524025504e67a5bfe83360b3a982e654bc71fed7514eb8ac8ad", - strip_prefix = "rules_proto_grpc-4.6.0", - urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/4.6.0.tar.gz"], -) +# -- Load Dependencies --------------------------------------------------------- +load("gnpsi_deps.bzl", "gnpsi_deps") -# googleapis has not had a release since 2016 - take the master version as of 4-jan-23 -http_archive( - name = "com_google_googleapis", - sha256 = "9fc03150d86501d7da35eefa989d5553bdd77a95cfe4373cdafe8eee92f6bfb1", - strip_prefix = "googleapis-870a5ed7e141b4faf70e2a0858854e9b5bb18612", - urls = ["https://github.com/googleapis/googleapis/archive/870a5ed7e141b4faf70e2a0858854e9b5bb18612.tar.gz"], -) +gnpsi_deps() # -- Load GRPC Dependencies ---------------------------------------------------- load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") @@ -43,50 +31,37 @@ switched_rules_by_language( go = True, ) -load( - "@rules_proto_grpc//:repositories.bzl", - "bazel_gazelle", - "io_bazel_rules_go", - "rules_proto_grpc_repos", - "rules_proto_grpc_toolchains", -) +load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") -rules_proto_grpc_toolchains() -rules_proto_grpc_repos() +grpc_deps() -load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") +load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") -rules_proto_dependencies() -rules_proto_toolchains() +grpc_extra_deps() -### Golang -io_bazel_rules_go() -load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") -go_rules_dependencies() -go_register_toolchains(go_version = "1.20") +# -- Load Protobuf ------------------------------------------------------------- -# gazelle:repo bazel_gazelle -bazel_gazelle() +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") -# -- Load Dependencies --------------------------------------------------------- -load("gnpsi_deps.bzl", "gnpsi_deps") +protobuf_deps() -gnpsi_deps() +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") -load("@rules_proto_grpc//go:repositories.bzl", rules_proto_grpc_go_repos = "go_repos") +rules_proto_dependencies() -rules_proto_grpc_go_repos() +rules_proto_toolchains() -### C++ -load("@rules_proto_grpc//cpp:repositories.bzl", rules_proto_grpc_cpp_repos = "cpp_repos") -rules_proto_grpc_cpp_repos() -load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") +### Bazel rules for many languages to compile PROTO into gRPC libraries +http_archive( + name = "rules_proto_grpc", + sha256 = "bbe4db93499f5c9414926e46f9e35016999a4e9f6e3522482d3760dc61011070", + strip_prefix = "rules_proto_grpc-4.2.0", + urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/4.2.0.tar.gz"], +) -grpc_deps() +load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains") -# Load gazelle_dependencies last, so that the newer version of org_golang_google_grpc is used. -# see https://github.com/rules-proto-grpc/rules_proto_grpc/issues/160 -load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") -gazelle_dependencies() \ No newline at end of file +rules_proto_grpc_toolchains() +rules_proto_grpc_repos() diff --git a/common.bzl b/common.bzl deleted file mode 100644 index b40ec14..0000000 --- a/common.bzl +++ /dev/null @@ -1,29 +0,0 @@ -load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler") -load("@io_bazel_rules_go//proto/wkt:well_known_types.bzl", "PROTO_RUNTIME_DEPS", "WELL_KNOWN_TYPES_APIV2") - -def use_new_compilers(): - go_proto_compiler( - name = "go_protoc_gen_go", - options = [ - "paths=source_relative", - ], - plugin = "@org_golang_google_protobuf//cmd/protoc-gen-go", - suffix = ".pb.go", - visibility = ["//visibility:public"], - deps = PROTO_RUNTIME_DEPS + WELL_KNOWN_TYPES_APIV2, - ) - go_proto_compiler( - name = "go_protoc_gen_go_grpc", - options = [ - "paths=source_relative", - ], - plugin = "@org_golang_google_grpc_cmd_protoc_gen_go_grpc//:protoc-gen-go-grpc", - suffix = "_grpc.pb.go", - visibility = ["//visibility:public"], - deps = PROTO_RUNTIME_DEPS + [ - "@org_golang_google_grpc//:go_default_library", - "@org_golang_google_grpc//codes:go_default_library", - "@org_golang_google_grpc//status:go_default_library", - ], - ) - diff --git a/compile_protos.sh b/compile_protos.sh new file mode 100755 index 0000000..ee6cf08 --- /dev/null +++ b/compile_protos.sh @@ -0,0 +1,24 @@ +# +# Copyright 2021 Google LLC All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +#!/bin/bash + + +# Cpp +PROTO_DIR="proto/gnpsi" +protoc -I $PROTO_DIR --grpc_out=$PROTO_DIR --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` $PROTO_DIR/gnpsi.proto +protoc -I $PROTO_DIR --cpp_out=$PROTO_DIR $PROTO_DIR/gnpsi.proto + diff --git a/proto/gnpsi/BUILD.bazel b/proto/gnpsi/BUILD.bazel index 3beae56..5037a59 100644 --- a/proto/gnpsi/BUILD.bazel +++ b/proto/gnpsi/BUILD.bazel @@ -12,11 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # + load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library") -load("@io_bazel_rules_go//go:def.bzl", "go_library") -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") -load("@rules_proto//proto:defs.bzl", "proto_library") -load("//:common.bzl", "use_new_compilers") + # gnpsi defines a gRPC-based network packet sampling interface implemented on # vendor network elements. It provides mechanisms for streaming packet # samples/updates from the network element. @@ -25,8 +23,6 @@ package( licenses = ["notice"], ) -use_new_compilers() - proto_library( name = "gnpsi_proto", srcs = ["gnpsi.proto"], @@ -48,19 +44,3 @@ cc_grpc_library( grpc_only = ["True"], deps = [":gnpsi_cc_proto"], ) - -go_proto_library( - name = "gnpsi_go_proto", - compilers = [ - "go_protoc_gen_go", - "go_protoc_gen_go_grpc", - ], - importpath = "github.com/openconfig/gnpsi/proto/gnpsi", - proto = ":gnpsi_proto", -) - -go_library( - name = "gnpsi", - embed = [":gnpsi_go_proto"], - importpath = "github.com/openconfig/gnpsi/proto/gnpsi", -) \ No newline at end of file diff --git a/proto/gnpsi/gnpsi.pb.go b/proto/gnpsi/gnpsi.pb.go deleted file mode 100755 index e2f1300..0000000 --- a/proto/gnpsi/gnpsi.pb.go +++ /dev/null @@ -1,610 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.30.0 -// protoc v3.21.10 -// source: proto/gnpsi/gnpsi.proto - -package gnpsi - -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) -) - -type SFlowMetadata_Version int32 - -const ( - SFlowMetadata_UNSPECIFIED SFlowMetadata_Version = 0 - SFlowMetadata_V2 SFlowMetadata_Version = 1 - SFlowMetadata_V5 SFlowMetadata_Version = 2 -) - -// Enum value maps for SFlowMetadata_Version. -var ( - SFlowMetadata_Version_name = map[int32]string{ - 0: "UNSPECIFIED", - 1: "V2", - 2: "V5", - } - SFlowMetadata_Version_value = map[string]int32{ - "UNSPECIFIED": 0, - "V2": 1, - "V5": 2, - } -) - -func (x SFlowMetadata_Version) Enum() *SFlowMetadata_Version { - p := new(SFlowMetadata_Version) - *p = x - return p -} - -func (x SFlowMetadata_Version) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SFlowMetadata_Version) Descriptor() protoreflect.EnumDescriptor { - return file_proto_gnpsi_gnpsi_proto_enumTypes[0].Descriptor() -} - -func (SFlowMetadata_Version) Type() protoreflect.EnumType { - return &file_proto_gnpsi_gnpsi_proto_enumTypes[0] -} - -func (x SFlowMetadata_Version) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use SFlowMetadata_Version.Descriptor instead. -func (SFlowMetadata_Version) EnumDescriptor() ([]byte, []int) { - return file_proto_gnpsi_gnpsi_proto_rawDescGZIP(), []int{0, 0} -} - -type NetFlowMetadata_Version int32 - -const ( - NetFlowMetadata_UNSPECIFIED NetFlowMetadata_Version = 0 - NetFlowMetadata_V1 NetFlowMetadata_Version = 1 - NetFlowMetadata_V5 NetFlowMetadata_Version = 2 - NetFlowMetadata_V7 NetFlowMetadata_Version = 3 - NetFlowMetadata_V9 NetFlowMetadata_Version = 4 -) - -// Enum value maps for NetFlowMetadata_Version. -var ( - NetFlowMetadata_Version_name = map[int32]string{ - 0: "UNSPECIFIED", - 1: "V1", - 2: "V5", - 3: "V7", - 4: "V9", - } - NetFlowMetadata_Version_value = map[string]int32{ - "UNSPECIFIED": 0, - "V1": 1, - "V5": 2, - "V7": 3, - "V9": 4, - } -) - -func (x NetFlowMetadata_Version) Enum() *NetFlowMetadata_Version { - p := new(NetFlowMetadata_Version) - *p = x - return p -} - -func (x NetFlowMetadata_Version) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (NetFlowMetadata_Version) Descriptor() protoreflect.EnumDescriptor { - return file_proto_gnpsi_gnpsi_proto_enumTypes[1].Descriptor() -} - -func (NetFlowMetadata_Version) Type() protoreflect.EnumType { - return &file_proto_gnpsi_gnpsi_proto_enumTypes[1] -} - -func (x NetFlowMetadata_Version) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use NetFlowMetadata_Version.Descriptor instead. -func (NetFlowMetadata_Version) EnumDescriptor() ([]byte, []int) { - return file_proto_gnpsi_gnpsi_proto_rawDescGZIP(), []int{1, 0} -} - -type IPFIXMetadata_Version int32 - -const ( - IPFIXMetadata_UNSPECIFIED IPFIXMetadata_Version = 0 - IPFIXMetadata_V10 IPFIXMetadata_Version = 1 -) - -// Enum value maps for IPFIXMetadata_Version. -var ( - IPFIXMetadata_Version_name = map[int32]string{ - 0: "UNSPECIFIED", - 1: "V10", - } - IPFIXMetadata_Version_value = map[string]int32{ - "UNSPECIFIED": 0, - "V10": 1, - } -) - -func (x IPFIXMetadata_Version) Enum() *IPFIXMetadata_Version { - p := new(IPFIXMetadata_Version) - *p = x - return p -} - -func (x IPFIXMetadata_Version) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (IPFIXMetadata_Version) Descriptor() protoreflect.EnumDescriptor { - return file_proto_gnpsi_gnpsi_proto_enumTypes[2].Descriptor() -} - -func (IPFIXMetadata_Version) Type() protoreflect.EnumType { - return &file_proto_gnpsi_gnpsi_proto_enumTypes[2] -} - -func (x IPFIXMetadata_Version) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use IPFIXMetadata_Version.Descriptor instead. -func (IPFIXMetadata_Version) EnumDescriptor() ([]byte, []int) { - return file_proto_gnpsi_gnpsi_proto_rawDescGZIP(), []int{2, 0} -} - -type SFlowMetadata struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Version SFlowMetadata_Version `protobuf:"varint,1,opt,name=version,proto3,enum=gnpsi.SFlowMetadata_Version" json:"version,omitempty"` -} - -func (x *SFlowMetadata) Reset() { - *x = SFlowMetadata{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_gnpsi_gnpsi_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SFlowMetadata) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SFlowMetadata) ProtoMessage() {} - -func (x *SFlowMetadata) ProtoReflect() protoreflect.Message { - mi := &file_proto_gnpsi_gnpsi_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 SFlowMetadata.ProtoReflect.Descriptor instead. -func (*SFlowMetadata) Descriptor() ([]byte, []int) { - return file_proto_gnpsi_gnpsi_proto_rawDescGZIP(), []int{0} -} - -func (x *SFlowMetadata) GetVersion() SFlowMetadata_Version { - if x != nil { - return x.Version - } - return SFlowMetadata_UNSPECIFIED -} - -type NetFlowMetadata struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Version NetFlowMetadata_Version `protobuf:"varint,1,opt,name=version,proto3,enum=gnpsi.NetFlowMetadata_Version" json:"version,omitempty"` -} - -func (x *NetFlowMetadata) Reset() { - *x = NetFlowMetadata{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_gnpsi_gnpsi_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *NetFlowMetadata) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*NetFlowMetadata) ProtoMessage() {} - -func (x *NetFlowMetadata) ProtoReflect() protoreflect.Message { - mi := &file_proto_gnpsi_gnpsi_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 NetFlowMetadata.ProtoReflect.Descriptor instead. -func (*NetFlowMetadata) Descriptor() ([]byte, []int) { - return file_proto_gnpsi_gnpsi_proto_rawDescGZIP(), []int{1} -} - -func (x *NetFlowMetadata) GetVersion() NetFlowMetadata_Version { - if x != nil { - return x.Version - } - return NetFlowMetadata_UNSPECIFIED -} - -type IPFIXMetadata struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Version IPFIXMetadata_Version `protobuf:"varint,1,opt,name=version,proto3,enum=gnpsi.IPFIXMetadata_Version" json:"version,omitempty"` -} - -func (x *IPFIXMetadata) Reset() { - *x = IPFIXMetadata{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_gnpsi_gnpsi_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *IPFIXMetadata) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*IPFIXMetadata) ProtoMessage() {} - -func (x *IPFIXMetadata) ProtoReflect() protoreflect.Message { - mi := &file_proto_gnpsi_gnpsi_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 IPFIXMetadata.ProtoReflect.Descriptor instead. -func (*IPFIXMetadata) Descriptor() ([]byte, []int) { - return file_proto_gnpsi_gnpsi_proto_rawDescGZIP(), []int{2} -} - -func (x *IPFIXMetadata) GetVersion() IPFIXMetadata_Version { - if x != nil { - return x.Version - } - return IPFIXMetadata_UNSPECIFIED -} - -type Request struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *Request) Reset() { - *x = Request{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_gnpsi_gnpsi_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Request) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Request) ProtoMessage() {} - -func (x *Request) ProtoReflect() protoreflect.Message { - mi := &file_proto_gnpsi_gnpsi_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 Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_proto_gnpsi_gnpsi_proto_rawDescGZIP(), []int{3} -} - -type Sample struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Packet []byte `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet,omitempty"` - Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - SflowMetadata *SFlowMetadata `protobuf:"bytes,101,opt,name=sflow_metadata,json=sflowMetadata,proto3" json:"sflow_metadata,omitempty"` - NetflowMetadata *NetFlowMetadata `protobuf:"bytes,102,opt,name=netflow_metadata,json=netflowMetadata,proto3" json:"netflow_metadata,omitempty"` - IpfixMetadata *IPFIXMetadata `protobuf:"bytes,103,opt,name=ipfix_metadata,json=ipfixMetadata,proto3" json:"ipfix_metadata,omitempty"` -} - -func (x *Sample) Reset() { - *x = Sample{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_gnpsi_gnpsi_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Sample) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Sample) ProtoMessage() {} - -func (x *Sample) ProtoReflect() protoreflect.Message { - mi := &file_proto_gnpsi_gnpsi_proto_msgTypes[4] - 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 Sample.ProtoReflect.Descriptor instead. -func (*Sample) Descriptor() ([]byte, []int) { - return file_proto_gnpsi_gnpsi_proto_rawDescGZIP(), []int{4} -} - -func (x *Sample) GetPacket() []byte { - if x != nil { - return x.Packet - } - return nil -} - -func (x *Sample) GetTimestamp() int64 { - if x != nil { - return x.Timestamp - } - return 0 -} - -func (x *Sample) GetSflowMetadata() *SFlowMetadata { - if x != nil { - return x.SflowMetadata - } - return nil -} - -func (x *Sample) GetNetflowMetadata() *NetFlowMetadata { - if x != nil { - return x.NetflowMetadata - } - return nil -} - -func (x *Sample) GetIpfixMetadata() *IPFIXMetadata { - if x != nil { - return x.IpfixMetadata - } - return nil -} - -var File_proto_gnpsi_gnpsi_proto protoreflect.FileDescriptor - -var file_proto_gnpsi_gnpsi_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6e, 0x70, 0x73, 0x69, 0x2f, 0x67, 0x6e, - 0x70, 0x73, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x67, 0x6e, 0x70, 0x73, 0x69, - 0x22, 0x73, 0x0a, 0x0d, 0x53, 0x46, 0x6c, 0x6f, 0x77, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x12, 0x36, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x67, 0x6e, 0x70, 0x73, 0x69, 0x2e, 0x53, 0x46, 0x6c, 0x6f, 0x77, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x2a, 0x0a, 0x07, 0x56, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x06, 0x0a, 0x02, 0x56, 0x32, 0x10, 0x01, 0x12, 0x06, 0x0a, - 0x02, 0x56, 0x35, 0x10, 0x02, 0x22, 0x87, 0x01, 0x0a, 0x0f, 0x4e, 0x65, 0x74, 0x46, 0x6c, 0x6f, - 0x77, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x38, 0x0a, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x67, 0x6e, 0x70, - 0x73, 0x69, 0x2e, 0x4e, 0x65, 0x74, 0x46, 0x6c, 0x6f, 0x77, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0f, - 0x0a, 0x0b, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, - 0x06, 0x0a, 0x02, 0x56, 0x31, 0x10, 0x01, 0x12, 0x06, 0x0a, 0x02, 0x56, 0x35, 0x10, 0x02, 0x12, - 0x06, 0x0a, 0x02, 0x56, 0x37, 0x10, 0x03, 0x12, 0x06, 0x0a, 0x02, 0x56, 0x39, 0x10, 0x04, 0x22, - 0x6c, 0x0a, 0x0d, 0x49, 0x50, 0x46, 0x49, 0x58, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x12, 0x36, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x1c, 0x2e, 0x67, 0x6e, 0x70, 0x73, 0x69, 0x2e, 0x49, 0x50, 0x46, 0x49, 0x58, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x23, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, - 0x45, 0x44, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x56, 0x31, 0x30, 0x10, 0x01, 0x22, 0x09, 0x0a, - 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xfb, 0x01, 0x0a, 0x06, 0x53, 0x61, 0x6d, - 0x70, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, - 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3b, 0x0a, 0x0e, 0x73, 0x66, 0x6c, - 0x6f, 0x77, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x65, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6e, 0x70, 0x73, 0x69, 0x2e, 0x53, 0x46, 0x6c, 0x6f, 0x77, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x0d, 0x73, 0x66, 0x6c, 0x6f, 0x77, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x41, 0x0a, 0x10, 0x6e, 0x65, 0x74, 0x66, 0x6c, 0x6f, - 0x77, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x66, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x16, 0x2e, 0x67, 0x6e, 0x70, 0x73, 0x69, 0x2e, 0x4e, 0x65, 0x74, 0x46, 0x6c, 0x6f, 0x77, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x0f, 0x6e, 0x65, 0x74, 0x66, 0x6c, 0x6f, - 0x77, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x3b, 0x0a, 0x0e, 0x69, 0x70, 0x66, - 0x69, 0x78, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x67, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6e, 0x70, 0x73, 0x69, 0x2e, 0x49, 0x50, 0x46, 0x49, 0x58, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x0d, 0x69, 0x70, 0x66, 0x69, 0x78, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x32, 0x35, 0x0a, 0x05, 0x67, 0x4e, 0x50, 0x53, 0x49, 0x12, - 0x2c, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x0e, 0x2e, 0x67, - 0x6e, 0x70, 0x73, 0x69, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x67, - 0x6e, 0x70, 0x73, 0x69, 0x2e, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x30, 0x01, 0x42, 0x29, 0x5a, - 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x67, 0x6e, 0x70, 0x73, 0x69, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2f, 0x67, 0x6e, 0x70, 0x73, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_proto_gnpsi_gnpsi_proto_rawDescOnce sync.Once - file_proto_gnpsi_gnpsi_proto_rawDescData = file_proto_gnpsi_gnpsi_proto_rawDesc -) - -func file_proto_gnpsi_gnpsi_proto_rawDescGZIP() []byte { - file_proto_gnpsi_gnpsi_proto_rawDescOnce.Do(func() { - file_proto_gnpsi_gnpsi_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_gnpsi_gnpsi_proto_rawDescData) - }) - return file_proto_gnpsi_gnpsi_proto_rawDescData -} - -var file_proto_gnpsi_gnpsi_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_proto_gnpsi_gnpsi_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_proto_gnpsi_gnpsi_proto_goTypes = []interface{}{ - (SFlowMetadata_Version)(0), // 0: gnpsi.SFlowMetadata.Version - (NetFlowMetadata_Version)(0), // 1: gnpsi.NetFlowMetadata.Version - (IPFIXMetadata_Version)(0), // 2: gnpsi.IPFIXMetadata.Version - (*SFlowMetadata)(nil), // 3: gnpsi.SFlowMetadata - (*NetFlowMetadata)(nil), // 4: gnpsi.NetFlowMetadata - (*IPFIXMetadata)(nil), // 5: gnpsi.IPFIXMetadata - (*Request)(nil), // 6: gnpsi.Request - (*Sample)(nil), // 7: gnpsi.Sample -} -var file_proto_gnpsi_gnpsi_proto_depIdxs = []int32{ - 0, // 0: gnpsi.SFlowMetadata.version:type_name -> gnpsi.SFlowMetadata.Version - 1, // 1: gnpsi.NetFlowMetadata.version:type_name -> gnpsi.NetFlowMetadata.Version - 2, // 2: gnpsi.IPFIXMetadata.version:type_name -> gnpsi.IPFIXMetadata.Version - 3, // 3: gnpsi.Sample.sflow_metadata:type_name -> gnpsi.SFlowMetadata - 4, // 4: gnpsi.Sample.netflow_metadata:type_name -> gnpsi.NetFlowMetadata - 5, // 5: gnpsi.Sample.ipfix_metadata:type_name -> gnpsi.IPFIXMetadata - 6, // 6: gnpsi.gNPSI.Subscribe:input_type -> gnpsi.Request - 7, // 7: gnpsi.gNPSI.Subscribe:output_type -> gnpsi.Sample - 7, // [7:8] is the sub-list for method output_type - 6, // [6:7] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name -} - -func init() { file_proto_gnpsi_gnpsi_proto_init() } -func file_proto_gnpsi_gnpsi_proto_init() { - if File_proto_gnpsi_gnpsi_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_proto_gnpsi_gnpsi_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SFlowMetadata); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proto_gnpsi_gnpsi_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NetFlowMetadata); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proto_gnpsi_gnpsi_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*IPFIXMetadata); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proto_gnpsi_gnpsi_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Request); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proto_gnpsi_gnpsi_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Sample); 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_proto_gnpsi_gnpsi_proto_rawDesc, - NumEnums: 3, - NumMessages: 5, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_proto_gnpsi_gnpsi_proto_goTypes, - DependencyIndexes: file_proto_gnpsi_gnpsi_proto_depIdxs, - EnumInfos: file_proto_gnpsi_gnpsi_proto_enumTypes, - MessageInfos: file_proto_gnpsi_gnpsi_proto_msgTypes, - }.Build() - File_proto_gnpsi_gnpsi_proto = out.File - file_proto_gnpsi_gnpsi_proto_rawDesc = nil - file_proto_gnpsi_gnpsi_proto_goTypes = nil - file_proto_gnpsi_gnpsi_proto_depIdxs = nil -} diff --git a/proto/gnpsi/gnpsi.proto b/proto/gnpsi/gnpsi.proto index d772436..b8f3753 100644 --- a/proto/gnpsi/gnpsi.proto +++ b/proto/gnpsi/gnpsi.proto @@ -15,6 +15,8 @@ // syntax = "proto3"; +option go_package = "github.com/openconfig/gnpsi/proto/gnpsi"; + // Package gNPSI defines a service specification for the gRPC Network Packet // Sampling Interface. This interface is defined to be a standard interface via // which a telemetry system ("client") can subscribe to sampling updates from a @@ -23,8 +25,6 @@ syntax = "proto3"; // package gnpsi; -option go_package = "github.com/openconfig/gnpsi/proto/gnpsi"; - service gNPSI { // gNPSI subscription allows client to subscribe to SFlow/NetFlow/IPFIX // updates from the device. Past updates, i.e., updates before the diff --git a/proto/gnpsi/gnpsi_grpc.pb.go b/proto/gnpsi/gnpsi_grpc.pb.go deleted file mode 100755 index faa9bb4..0000000 --- a/proto/gnpsi/gnpsi_grpc.pb.go +++ /dev/null @@ -1,132 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.10 -// source: proto/gnpsi/gnpsi.proto - -package gnpsi - -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 - -// GNPSIClient is the client API for GNPSI 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 GNPSIClient interface { - Subscribe(ctx context.Context, in *Request, opts ...grpc.CallOption) (GNPSI_SubscribeClient, error) -} - -type gNPSIClient struct { - cc grpc.ClientConnInterface -} - -func NewGNPSIClient(cc grpc.ClientConnInterface) GNPSIClient { - return &gNPSIClient{cc} -} - -func (c *gNPSIClient) Subscribe(ctx context.Context, in *Request, opts ...grpc.CallOption) (GNPSI_SubscribeClient, error) { - stream, err := c.cc.NewStream(ctx, &GNPSI_ServiceDesc.Streams[0], "/gnpsi.gNPSI/Subscribe", opts...) - if err != nil { - return nil, err - } - x := &gNPSISubscribeClient{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 GNPSI_SubscribeClient interface { - Recv() (*Sample, error) - grpc.ClientStream -} - -type gNPSISubscribeClient struct { - grpc.ClientStream -} - -func (x *gNPSISubscribeClient) Recv() (*Sample, error) { - m := new(Sample) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// GNPSIServer is the server API for GNPSI service. -// All implementations must embed UnimplementedGNPSIServer -// for forward compatibility -type GNPSIServer interface { - Subscribe(*Request, GNPSI_SubscribeServer) error - mustEmbedUnimplementedGNPSIServer() -} - -// UnimplementedGNPSIServer must be embedded to have forward compatible implementations. -type UnimplementedGNPSIServer struct { -} - -func (UnimplementedGNPSIServer) Subscribe(*Request, GNPSI_SubscribeServer) error { - return status.Errorf(codes.Unimplemented, "method Subscribe not implemented") -} -func (UnimplementedGNPSIServer) mustEmbedUnimplementedGNPSIServer() {} - -// UnsafeGNPSIServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to GNPSIServer will -// result in compilation errors. -type UnsafeGNPSIServer interface { - mustEmbedUnimplementedGNPSIServer() -} - -func RegisterGNPSIServer(s grpc.ServiceRegistrar, srv GNPSIServer) { - s.RegisterService(&GNPSI_ServiceDesc, srv) -} - -func _GNPSI_Subscribe_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(Request) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(GNPSIServer).Subscribe(m, &gNPSISubscribeServer{stream}) -} - -type GNPSI_SubscribeServer interface { - Send(*Sample) error - grpc.ServerStream -} - -type gNPSISubscribeServer struct { - grpc.ServerStream -} - -func (x *gNPSISubscribeServer) Send(m *Sample) error { - return x.ServerStream.SendMsg(m) -} - -// GNPSI_ServiceDesc is the grpc.ServiceDesc for GNPSI service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var GNPSI_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "gnpsi.gNPSI", - HandlerType: (*GNPSIServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "Subscribe", - Handler: _GNPSI_Subscribe_Handler, - ServerStreams: true, - }, - }, - Metadata: "proto/gnpsi/gnpsi.proto", -} diff --git a/regenerate-files.sh b/regenerate-files.sh deleted file mode 100755 index 36c8a1a..0000000 --- a/regenerate-files.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -euo pipefail - -BASE=$(bazel info bazel-genfiles) -GNPSI_NS='github.com/openconfig/gnpsi' - - -copy_generated() { - pkg="$1" - # Default to using package name for proto if $2 is unset - proto="$1" && [ "${2++}" ] && proto="$2" - # Bazel go_rules will create empty files containing "// +build ignore\n\npackage ignore" - # in the case where the protoc compiler doesn't generate any output. See: - # https://github.com/bazelbuild/rules_go/blob/03a8b8e90eebe699d7/go/tools/builders/protoc.go#L190 - for file in "${BASE}"/proto/"${pkg}"/"${proto}"_go_proto_/"${GNPSI_NS}"/proto/"${pkg}"/*.pb.go; do - [[ $(head -n 1 "${file}") == "// +build ignore" ]] || cp "${file}" "proto/${pkg}"/ - done -} - -bazel build //proto/gnpsi:all -copy_generated "gnpsi"