1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

Makefile: add apigen target

For auto-generating api(s).

Also, re-generate/refresh the gRPC with `make apigen` (with protoc
v3.17.3 and protoc-gen-go from github.com/golang/protobuf v1.5.2) to
sync up things.
This commit is contained in:
Markus Lehtonen 2021-06-10 09:55:22 +03:00
parent 8397e5f789
commit d12e62b1fe
3 changed files with 238 additions and 110 deletions

View file

@ -122,6 +122,9 @@ mock:
mockery --name=APIHelpers --dir=pkg/apihelper --inpkg --note="Re-generate by running 'make mock'"
mockery --name=LabelerClient --dir=pkg/labeler --inpkg --note="Re-generate by running 'make mock'"
apigen:
protoc --go_opt=paths=source_relative --go_out=plugins=grpc:. pkg/labeler/labeler.proto
gofmt:
@$(GO_FMT) -w -l $$(find . -name '*.go')

View file

@ -1,155 +1,300 @@
//
//Copyright 2019 The Kubernetes Authors.
//
//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.
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: labeler.proto
// versions:
// protoc-gen-go v1.26.0
// protoc v3.17.3
// source: pkg/labeler/labeler.proto
package labeler
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
context "golang.org/x/net/context"
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
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 SetLabelsRequest struct {
NfdVersion string `protobuf:"bytes,1,opt,name=nfd_version,json=nfdVersion" json:"nfd_version,omitempty"`
NodeName string `protobuf:"bytes,2,opt,name=node_name,json=nodeName" json:"node_name,omitempty"`
Labels map[string]string `protobuf:"bytes,3,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
NfdVersion string `protobuf:"bytes,1,opt,name=nfd_version,json=nfdVersion,proto3" json:"nfd_version,omitempty"`
NodeName string `protobuf:"bytes,2,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"`
Labels map[string]string `protobuf:"bytes,3,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *SetLabelsRequest) Reset() {
*x = SetLabelsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_pkg_labeler_labeler_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SetLabelsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (m *SetLabelsRequest) Reset() { *m = SetLabelsRequest{} }
func (m *SetLabelsRequest) String() string { return proto.CompactTextString(m) }
func (*SetLabelsRequest) ProtoMessage() {}
func (x *SetLabelsRequest) ProtoReflect() protoreflect.Message {
mi := &file_pkg_labeler_labeler_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 SetLabelsRequest.ProtoReflect.Descriptor instead.
func (*SetLabelsRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_labeler_06d914ce56652184, []int{0}
}
func (m *SetLabelsRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetLabelsRequest.Unmarshal(m, b)
}
func (m *SetLabelsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SetLabelsRequest.Marshal(b, m, deterministic)
}
func (dst *SetLabelsRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_SetLabelsRequest.Merge(dst, src)
}
func (m *SetLabelsRequest) XXX_Size() int {
return xxx_messageInfo_SetLabelsRequest.Size(m)
}
func (m *SetLabelsRequest) XXX_DiscardUnknown() {
xxx_messageInfo_SetLabelsRequest.DiscardUnknown(m)
return file_pkg_labeler_labeler_proto_rawDescGZIP(), []int{0}
}
var xxx_messageInfo_SetLabelsRequest proto.InternalMessageInfo
func (m *SetLabelsRequest) GetNfdVersion() string {
if m != nil {
return m.NfdVersion
func (x *SetLabelsRequest) GetNfdVersion() string {
if x != nil {
return x.NfdVersion
}
return ""
}
func (m *SetLabelsRequest) GetNodeName() string {
if m != nil {
return m.NodeName
func (x *SetLabelsRequest) GetNodeName() string {
if x != nil {
return x.NodeName
}
return ""
}
func (m *SetLabelsRequest) GetLabels() map[string]string {
if m != nil {
return m.Labels
func (x *SetLabelsRequest) GetLabels() map[string]string {
if x != nil {
return x.Labels
}
return nil
}
type SetLabelsReply struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *SetLabelsReply) Reset() {
*x = SetLabelsReply{}
if protoimpl.UnsafeEnabled {
mi := &file_pkg_labeler_labeler_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SetLabelsReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (m *SetLabelsReply) Reset() { *m = SetLabelsReply{} }
func (m *SetLabelsReply) String() string { return proto.CompactTextString(m) }
func (*SetLabelsReply) ProtoMessage() {}
func (x *SetLabelsReply) ProtoReflect() protoreflect.Message {
mi := &file_pkg_labeler_labeler_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 SetLabelsReply.ProtoReflect.Descriptor instead.
func (*SetLabelsReply) Descriptor() ([]byte, []int) {
return fileDescriptor_labeler_06d914ce56652184, []int{1}
}
func (m *SetLabelsReply) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetLabelsReply.Unmarshal(m, b)
}
func (m *SetLabelsReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SetLabelsReply.Marshal(b, m, deterministic)
}
func (dst *SetLabelsReply) XXX_Merge(src proto.Message) {
xxx_messageInfo_SetLabelsReply.Merge(dst, src)
}
func (m *SetLabelsReply) XXX_Size() int {
return xxx_messageInfo_SetLabelsReply.Size(m)
}
func (m *SetLabelsReply) XXX_DiscardUnknown() {
xxx_messageInfo_SetLabelsReply.DiscardUnknown(m)
return file_pkg_labeler_labeler_proto_rawDescGZIP(), []int{1}
}
var xxx_messageInfo_SetLabelsReply proto.InternalMessageInfo
var File_pkg_labeler_labeler_proto protoreflect.FileDescriptor
func init() {
proto.RegisterType((*SetLabelsRequest)(nil), "labeler.SetLabelsRequest")
proto.RegisterMapType((map[string]string)(nil), "labeler.SetLabelsRequest.LabelsEntry")
proto.RegisterType((*SetLabelsReply)(nil), "labeler.SetLabelsReply")
var file_pkg_labeler_labeler_proto_rawDesc = []byte{
0x0a, 0x19, 0x70, 0x6b, 0x67, 0x2f, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x65, 0x72, 0x2f, 0x6c, 0x61,
0x62, 0x65, 0x6c, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6c, 0x61, 0x62,
0x65, 0x6c, 0x65, 0x72, 0x22, 0xca, 0x01, 0x0a, 0x10, 0x53, 0x65, 0x74, 0x4c, 0x61, 0x62, 0x65,
0x6c, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6e, 0x66, 0x64,
0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
0x6e, 0x66, 0x64, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f,
0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e,
0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3d, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c,
0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x65,
0x72, 0x2e, 0x53, 0x65, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06,
0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38,
0x01, 0x22, 0x10, 0x0a, 0x0e, 0x53, 0x65, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x52, 0x65,
0x70, 0x6c, 0x79, 0x32, 0x4c, 0x0a, 0x07, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x65, 0x72, 0x12, 0x41,
0x0a, 0x09, 0x53, 0x65, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x19, 0x2e, 0x6c, 0x61,
0x62, 0x65, 0x6c, 0x65, 0x72, 0x2e, 0x53, 0x65, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x65, 0x72,
0x2e, 0x53, 0x65, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22,
0x00, 0x42, 0x30, 0x5a, 0x2e, 0x73, 0x69, 0x67, 0x73, 0x2e, 0x6b, 0x38, 0x73, 0x2e, 0x69, 0x6f,
0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2d, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2d, 0x64, 0x69,
0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x6c, 0x61, 0x62, 0x65,
0x6c, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_pkg_labeler_labeler_proto_rawDescOnce sync.Once
file_pkg_labeler_labeler_proto_rawDescData = file_pkg_labeler_labeler_proto_rawDesc
)
func file_pkg_labeler_labeler_proto_rawDescGZIP() []byte {
file_pkg_labeler_labeler_proto_rawDescOnce.Do(func() {
file_pkg_labeler_labeler_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_labeler_labeler_proto_rawDescData)
})
return file_pkg_labeler_labeler_proto_rawDescData
}
var file_pkg_labeler_labeler_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_pkg_labeler_labeler_proto_goTypes = []interface{}{
(*SetLabelsRequest)(nil), // 0: labeler.SetLabelsRequest
(*SetLabelsReply)(nil), // 1: labeler.SetLabelsReply
nil, // 2: labeler.SetLabelsRequest.LabelsEntry
}
var file_pkg_labeler_labeler_proto_depIdxs = []int32{
2, // 0: labeler.SetLabelsRequest.labels:type_name -> labeler.SetLabelsRequest.LabelsEntry
0, // 1: labeler.Labeler.SetLabels:input_type -> labeler.SetLabelsRequest
1, // 2: labeler.Labeler.SetLabels:output_type -> labeler.SetLabelsReply
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_pkg_labeler_labeler_proto_init() }
func file_pkg_labeler_labeler_proto_init() {
if File_pkg_labeler_labeler_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_pkg_labeler_labeler_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SetLabelsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pkg_labeler_labeler_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SetLabelsReply); 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_pkg_labeler_labeler_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_pkg_labeler_labeler_proto_goTypes,
DependencyIndexes: file_pkg_labeler_labeler_proto_depIdxs,
MessageInfos: file_pkg_labeler_labeler_proto_msgTypes,
}.Build()
File_pkg_labeler_labeler_proto = out.File
file_pkg_labeler_labeler_proto_rawDesc = nil
file_pkg_labeler_labeler_proto_goTypes = nil
file_pkg_labeler_labeler_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// Client API for Labeler service
const _ = grpc.SupportPackageIsVersion6
// LabelerClient is the client API for Labeler service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type LabelerClient interface {
SetLabels(ctx context.Context, in *SetLabelsRequest, opts ...grpc.CallOption) (*SetLabelsReply, error)
}
type labelerClient struct {
cc *grpc.ClientConn
cc grpc.ClientConnInterface
}
func NewLabelerClient(cc *grpc.ClientConn) LabelerClient {
func NewLabelerClient(cc grpc.ClientConnInterface) LabelerClient {
return &labelerClient{cc}
}
func (c *labelerClient) SetLabels(ctx context.Context, in *SetLabelsRequest, opts ...grpc.CallOption) (*SetLabelsReply, error) {
out := new(SetLabelsReply)
err := grpc.Invoke(ctx, "/labeler.Labeler/SetLabels", in, out, c.cc, opts...)
err := c.cc.Invoke(ctx, "/labeler.Labeler/SetLabels", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Labeler service
// LabelerServer is the server API for Labeler service.
type LabelerServer interface {
SetLabels(context.Context, *SetLabelsRequest) (*SetLabelsReply, error)
}
// UnimplementedLabelerServer can be embedded to have forward compatible implementations.
type UnimplementedLabelerServer struct {
}
func (*UnimplementedLabelerServer) SetLabels(context.Context, *SetLabelsRequest) (*SetLabelsReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method SetLabels not implemented")
}
func RegisterLabelerServer(s *grpc.Server, srv LabelerServer) {
s.RegisterService(&_Labeler_serviceDesc, srv)
}
@ -182,25 +327,5 @@ var _Labeler_serviceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "labeler.proto",
}
func init() { proto.RegisterFile("labeler.proto", fileDescriptor_labeler_06d914ce56652184) }
var fileDescriptor_labeler_06d914ce56652184 = []byte{
// 220 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcd, 0x49, 0x4c, 0x4a,
0xcd, 0x49, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x87, 0x72, 0x95, 0x4e, 0x31,
0x72, 0x09, 0x04, 0xa7, 0x96, 0xf8, 0x80, 0xb8, 0xc5, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25,
0x42, 0xf2, 0x5c, 0xdc, 0x79, 0x69, 0x29, 0xf1, 0x65, 0xa9, 0x45, 0xc5, 0x99, 0xf9, 0x79, 0x12,
0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x5c, 0x79, 0x69, 0x29, 0x61, 0x10, 0x11, 0x21, 0x69, 0x2e,
0xce, 0xbc, 0xfc, 0x94, 0xd4, 0xf8, 0xbc, 0xc4, 0xdc, 0x54, 0x09, 0x26, 0xb0, 0x34, 0x07, 0x48,
0xc0, 0x2f, 0x31, 0x37, 0x55, 0xc8, 0x96, 0x8b, 0x0d, 0x6c, 0x7a, 0xb1, 0x04, 0xb3, 0x02, 0xb3,
0x06, 0xb7, 0x91, 0xaa, 0x1e, 0xcc, 0x6e, 0x74, 0x8b, 0xf4, 0x20, 0x3c, 0xd7, 0xbc, 0x92, 0xa2,
0xca, 0x20, 0xa8, 0x26, 0x29, 0x4b, 0x2e, 0x6e, 0x24, 0x61, 0x21, 0x01, 0x2e, 0xe6, 0xec, 0xd4,
0x4a, 0xa8, 0x1b, 0x40, 0x4c, 0x21, 0x11, 0x2e, 0xd6, 0xb2, 0xc4, 0x9c, 0x52, 0x98, 0xc5, 0x10,
0x8e, 0x15, 0x93, 0x05, 0xa3, 0x92, 0x00, 0x17, 0x1f, 0x92, 0x15, 0x05, 0x39, 0x95, 0x46, 0x3e,
0x5c, 0xec, 0x3e, 0x10, 0xcb, 0x85, 0x1c, 0xb9, 0x38, 0xe1, 0x92, 0x42, 0x92, 0x38, 0xdd, 0x24,
0x25, 0x8e, 0x4d, 0xaa, 0x20, 0xa7, 0x52, 0x89, 0x21, 0x89, 0x0d, 0x1c, 0x78, 0xc6, 0x80, 0x00,
0x00, 0x00, 0xff, 0xff, 0x2f, 0x68, 0x0f, 0x06, 0x4d, 0x01, 0x00, 0x00,
Metadata: "pkg/labeler/labeler.proto",
}

View file

@ -16,7 +16,7 @@ limitations under the License.
syntax = "proto3";
//option go_package = "labeler";
option go_package = "sigs.k8s.io/node-feature-discovery/pkg/labeler";
package labeler;