From 83c47c8adc4411614c0ed588dcecaf12ec8c7f04 Mon Sep 17 00:00:00 2001 From: Mike Cutalo Date: Thu, 25 Mar 2021 12:54:59 -0700 Subject: [PATCH] core: introduce core protos (#1171) --- api/core/envoy/v1/envoy.proto | 10 ++ backend/api/core/envoy/v1/envoy.pb.go | 152 ++++++++++++++++++ .../api/core/envoy/v1/envoy.pb.validate.go | 103 ++++++++++++ frontend/api/src/index.d.ts | 60 +++++++ frontend/api/src/index.js | 136 ++++++++++++++++ 5 files changed, 461 insertions(+) create mode 100644 api/core/envoy/v1/envoy.proto create mode 100644 backend/api/core/envoy/v1/envoy.pb.go create mode 100644 backend/api/core/envoy/v1/envoy.pb.validate.go diff --git a/api/core/envoy/v1/envoy.proto b/api/core/envoy/v1/envoy.proto new file mode 100644 index 0000000000..3a1d2680ca --- /dev/null +++ b/api/core/envoy/v1/envoy.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package clutch.core.envoy.v1; + +option go_package = "github.com/lyft/clutch/backend/api/core/envoy/v1;envoyv1"; + +// Represents a single Envoy Cluster +message Cluster { + string name = 1; +} diff --git a/backend/api/core/envoy/v1/envoy.pb.go b/backend/api/core/envoy/v1/envoy.pb.go new file mode 100644 index 0000000000..87b91b6661 --- /dev/null +++ b/backend/api/core/envoy/v1/envoy.pb.go @@ -0,0 +1,152 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.14.0 +// source: core/envoy/v1/envoy.proto + +package envoyv1 + +import ( + proto "github.com/golang/protobuf/proto" + 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) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +// Represents a single Envoy Cluster +type Cluster struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *Cluster) Reset() { + *x = Cluster{} + if protoimpl.UnsafeEnabled { + mi := &file_core_envoy_v1_envoy_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Cluster) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Cluster) ProtoMessage() {} + +func (x *Cluster) ProtoReflect() protoreflect.Message { + mi := &file_core_envoy_v1_envoy_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 Cluster.ProtoReflect.Descriptor instead. +func (*Cluster) Descriptor() ([]byte, []int) { + return file_core_envoy_v1_envoy_proto_rawDescGZIP(), []int{0} +} + +func (x *Cluster) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +var File_core_envoy_v1_envoy_proto protoreflect.FileDescriptor + +var file_core_envoy_v1_envoy_proto_rawDesc = []byte{ + 0x0a, 0x19, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2f, 0x76, 0x31, 0x2f, + 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x63, 0x6c, 0x75, + 0x74, 0x63, 0x68, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x76, + 0x31, 0x22, 0x1d, 0x0a, 0x07, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, + 0x79, 0x66, 0x74, 0x2f, 0x63, 0x6c, 0x75, 0x74, 0x63, 0x68, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, + 0x6e, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x65, 0x6e, 0x76, 0x6f, + 0x79, 0x2f, 0x76, 0x31, 0x3b, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_core_envoy_v1_envoy_proto_rawDescOnce sync.Once + file_core_envoy_v1_envoy_proto_rawDescData = file_core_envoy_v1_envoy_proto_rawDesc +) + +func file_core_envoy_v1_envoy_proto_rawDescGZIP() []byte { + file_core_envoy_v1_envoy_proto_rawDescOnce.Do(func() { + file_core_envoy_v1_envoy_proto_rawDescData = protoimpl.X.CompressGZIP(file_core_envoy_v1_envoy_proto_rawDescData) + }) + return file_core_envoy_v1_envoy_proto_rawDescData +} + +var file_core_envoy_v1_envoy_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_core_envoy_v1_envoy_proto_goTypes = []interface{}{ + (*Cluster)(nil), // 0: clutch.core.envoy.v1.Cluster +} +var file_core_envoy_v1_envoy_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_core_envoy_v1_envoy_proto_init() } +func file_core_envoy_v1_envoy_proto_init() { + if File_core_envoy_v1_envoy_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_core_envoy_v1_envoy_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Cluster); 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_core_envoy_v1_envoy_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_core_envoy_v1_envoy_proto_goTypes, + DependencyIndexes: file_core_envoy_v1_envoy_proto_depIdxs, + MessageInfos: file_core_envoy_v1_envoy_proto_msgTypes, + }.Build() + File_core_envoy_v1_envoy_proto = out.File + file_core_envoy_v1_envoy_proto_rawDesc = nil + file_core_envoy_v1_envoy_proto_goTypes = nil + file_core_envoy_v1_envoy_proto_depIdxs = nil +} diff --git a/backend/api/core/envoy/v1/envoy.pb.validate.go b/backend/api/core/envoy/v1/envoy.pb.validate.go new file mode 100644 index 0000000000..7a5c456bd1 --- /dev/null +++ b/backend/api/core/envoy/v1/envoy.pb.validate.go @@ -0,0 +1,103 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: core/envoy/v1/envoy.proto + +package envoyv1 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "strings" + "time" + "unicode/utf8" + + "github.com/golang/protobuf/ptypes" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = ptypes.DynamicAny{} +) + +// define the regex for a UUID once up-front +var _envoy_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") + +// Validate checks the field values on Cluster with the rules defined in the +// proto definition for this message. If any rules are violated, an error is returned. +func (m *Cluster) Validate() error { + if m == nil { + return nil + } + + // no validation rules for Name + + return nil +} + +// ClusterValidationError is the validation error returned by Cluster.Validate +// if the designated constraints aren't met. +type ClusterValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ClusterValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ClusterValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ClusterValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ClusterValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ClusterValidationError) ErrorName() string { return "ClusterValidationError" } + +// Error satisfies the builtin error interface +func (e ClusterValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCluster.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ClusterValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ClusterValidationError{} diff --git a/frontend/api/src/index.d.ts b/frontend/api/src/index.d.ts index 5e5393699d..fb432e9e0c 100644 --- a/frontend/api/src/index.d.ts +++ b/frontend/api/src/index.d.ts @@ -8177,6 +8177,66 @@ export namespace clutch { } } + /** Namespace core. */ + namespace core { + + /** Namespace envoy. */ + namespace envoy { + + /** Namespace v1. */ + namespace v1 { + + /** Properties of a Cluster. */ + interface ICluster { + + /** Cluster name */ + name?: (string|null); + } + + /** Represents a Cluster. */ + class Cluster implements ICluster { + + /** + * Constructs a new Cluster. + * @param [properties] Properties to set + */ + constructor(properties?: clutch.core.envoy.v1.ICluster); + + /** Cluster name. */ + public name: string; + + /** + * Verifies a Cluster message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Cluster message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Cluster + */ + public static fromObject(object: { [k: string]: any }): clutch.core.envoy.v1.Cluster; + + /** + * Creates a plain object from a Cluster message. Also converts values to other types if specified. + * @param message Cluster + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: clutch.core.envoy.v1.Cluster, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Cluster to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + } + } + /** Namespace envoytriage. */ namespace envoytriage { diff --git a/frontend/api/src/index.js b/frontend/api/src/index.js index b154c8bbf8..eafc1bb90d 100644 --- a/frontend/api/src/index.js +++ b/frontend/api/src/index.js @@ -19734,6 +19734,142 @@ export const clutch = $root.clutch = (() => { return sourcecontrol; })(); + clutch.core = (function() { + + /** + * Namespace core. + * @memberof clutch + * @namespace + */ + const core = {}; + + core.envoy = (function() { + + /** + * Namespace envoy. + * @memberof clutch.core + * @namespace + */ + const envoy = {}; + + envoy.v1 = (function() { + + /** + * Namespace v1. + * @memberof clutch.core.envoy + * @namespace + */ + const v1 = {}; + + v1.Cluster = (function() { + + /** + * Properties of a Cluster. + * @memberof clutch.core.envoy.v1 + * @interface ICluster + * @property {string|null} [name] Cluster name + */ + + /** + * Constructs a new Cluster. + * @memberof clutch.core.envoy.v1 + * @classdesc Represents a Cluster. + * @implements ICluster + * @constructor + * @param {clutch.core.envoy.v1.ICluster=} [properties] Properties to set + */ + function Cluster(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Cluster name. + * @member {string} name + * @memberof clutch.core.envoy.v1.Cluster + * @instance + */ + Cluster.prototype.name = ""; + + /** + * Verifies a Cluster message. + * @function verify + * @memberof clutch.core.envoy.v1.Cluster + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Cluster.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a Cluster message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof clutch.core.envoy.v1.Cluster + * @static + * @param {Object.} object Plain object + * @returns {clutch.core.envoy.v1.Cluster} Cluster + */ + Cluster.fromObject = function fromObject(object) { + if (object instanceof $root.clutch.core.envoy.v1.Cluster) + return object; + let message = new $root.clutch.core.envoy.v1.Cluster(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a Cluster message. Also converts values to other types if specified. + * @function toObject + * @memberof clutch.core.envoy.v1.Cluster + * @static + * @param {clutch.core.envoy.v1.Cluster} message Cluster + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Cluster.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this Cluster to JSON. + * @function toJSON + * @memberof clutch.core.envoy.v1.Cluster + * @instance + * @returns {Object.} JSON object + */ + Cluster.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Cluster; + })(); + + return v1; + })(); + + return envoy; + })(); + + return core; + })(); + clutch.envoytriage = (function() { /**