diff --git a/proto/v1/run_function.pb.go b/proto/v1/run_function.pb.go new file mode 100644 index 0000000..d046708 --- /dev/null +++ b/proto/v1/run_function.pb.go @@ -0,0 +1,1839 @@ +// +//Copyright 2022 The Crossplane 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. +// versions: +// protoc-gen-go v1.33.0 +// protoc (unknown) +// source: v1/run_function.proto + +package v1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + durationpb "google.golang.org/protobuf/types/known/durationpb" + structpb "google.golang.org/protobuf/types/known/structpb" + 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) +) + +// Ready indicates whether a composed resource should be considered ready. +type Ready int32 + +const ( + Ready_READY_UNSPECIFIED Ready = 0 + // True means the composed resource has been observed to be ready. + Ready_READY_TRUE Ready = 1 + // False means the composed resource has not been observed to be ready. + Ready_READY_FALSE Ready = 2 +) + +// Enum value maps for Ready. +var ( + Ready_name = map[int32]string{ + 0: "READY_UNSPECIFIED", + 1: "READY_TRUE", + 2: "READY_FALSE", + } + Ready_value = map[string]int32{ + "READY_UNSPECIFIED": 0, + "READY_TRUE": 1, + "READY_FALSE": 2, + } +) + +func (x Ready) Enum() *Ready { + p := new(Ready) + *p = x + return p +} + +func (x Ready) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Ready) Descriptor() protoreflect.EnumDescriptor { + return file_v1_run_function_proto_enumTypes[0].Descriptor() +} + +func (Ready) Type() protoreflect.EnumType { + return &file_v1_run_function_proto_enumTypes[0] +} + +func (x Ready) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Ready.Descriptor instead. +func (Ready) EnumDescriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{0} +} + +// Severity of Function results. +type Severity int32 + +const ( + Severity_SEVERITY_UNSPECIFIED Severity = 0 + // Fatal results are fatal; subsequent Composition Functions may run, but + // the Composition Function pipeline run will be considered a failure and + // the first fatal result will be returned as an error. + Severity_SEVERITY_FATAL Severity = 1 + // Warning results are non-fatal; the entire Composition will run to + // completion but warning events and debug logs associated with the + // composite resource will be emitted. + Severity_SEVERITY_WARNING Severity = 2 + // Normal results are emitted as normal events and debug logs associated + // with the composite resource. + Severity_SEVERITY_NORMAL Severity = 3 +) + +// Enum value maps for Severity. +var ( + Severity_name = map[int32]string{ + 0: "SEVERITY_UNSPECIFIED", + 1: "SEVERITY_FATAL", + 2: "SEVERITY_WARNING", + 3: "SEVERITY_NORMAL", + } + Severity_value = map[string]int32{ + "SEVERITY_UNSPECIFIED": 0, + "SEVERITY_FATAL": 1, + "SEVERITY_WARNING": 2, + "SEVERITY_NORMAL": 3, + } +) + +func (x Severity) Enum() *Severity { + p := new(Severity) + *p = x + return p +} + +func (x Severity) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Severity) Descriptor() protoreflect.EnumDescriptor { + return file_v1_run_function_proto_enumTypes[1].Descriptor() +} + +func (Severity) Type() protoreflect.EnumType { + return &file_v1_run_function_proto_enumTypes[1] +} + +func (x Severity) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Severity.Descriptor instead. +func (Severity) EnumDescriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{1} +} + +// Target of Function results and conditions. +type Target int32 + +const ( + // If the target is unspecified, the result targets the composite resource. + Target_TARGET_UNSPECIFIED Target = 0 + // Target the composite resource. Results that target the composite resource + // should include detailed, advanced information. + Target_TARGET_COMPOSITE Target = 1 + // Target the composite and the claim. Results that target the composite and + // the claim should include only end-user friendly information. + Target_TARGET_COMPOSITE_AND_CLAIM Target = 2 +) + +// Enum value maps for Target. +var ( + Target_name = map[int32]string{ + 0: "TARGET_UNSPECIFIED", + 1: "TARGET_COMPOSITE", + 2: "TARGET_COMPOSITE_AND_CLAIM", + } + Target_value = map[string]int32{ + "TARGET_UNSPECIFIED": 0, + "TARGET_COMPOSITE": 1, + "TARGET_COMPOSITE_AND_CLAIM": 2, + } +) + +func (x Target) Enum() *Target { + p := new(Target) + *p = x + return p +} + +func (x Target) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Target) Descriptor() protoreflect.EnumDescriptor { + return file_v1_run_function_proto_enumTypes[2].Descriptor() +} + +func (Target) Type() protoreflect.EnumType { + return &file_v1_run_function_proto_enumTypes[2] +} + +func (x Target) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Target.Descriptor instead. +func (Target) EnumDescriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{2} +} + +type Status int32 + +const ( + Status_STATUS_CONDITION_UNSPECIFIED Status = 0 + Status_STATUS_CONDITION_UNKNOWN Status = 1 + Status_STATUS_CONDITION_TRUE Status = 2 + Status_STATUS_CONDITION_FALSE Status = 3 +) + +// Enum value maps for Status. +var ( + Status_name = map[int32]string{ + 0: "STATUS_CONDITION_UNSPECIFIED", + 1: "STATUS_CONDITION_UNKNOWN", + 2: "STATUS_CONDITION_TRUE", + 3: "STATUS_CONDITION_FALSE", + } + Status_value = map[string]int32{ + "STATUS_CONDITION_UNSPECIFIED": 0, + "STATUS_CONDITION_UNKNOWN": 1, + "STATUS_CONDITION_TRUE": 2, + "STATUS_CONDITION_FALSE": 3, + } +) + +func (x Status) Enum() *Status { + p := new(Status) + *p = x + return p +} + +func (x Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Status) Descriptor() protoreflect.EnumDescriptor { + return file_v1_run_function_proto_enumTypes[3].Descriptor() +} + +func (Status) Type() protoreflect.EnumType { + return &file_v1_run_function_proto_enumTypes[3] +} + +func (x Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Status.Descriptor instead. +func (Status) EnumDescriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{3} +} + +// A RunFunctionRequest requests that the Composition Function be run. +type RunFunctionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Metadata pertaining to this request. + Meta *RequestMeta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta,omitempty"` + // The observed state prior to invocation of a Function pipeline. State passed + // to each Function is fresh as of the time the pipeline was invoked, not as + // of the time each Function was invoked. + Observed *State `protobuf:"bytes,2,opt,name=observed,proto3" json:"observed,omitempty"` + // Desired state according to a Function pipeline. The state passed to a + // particular Function may have been accumulated by previous Functions in the + // pipeline. + // + // Note that the desired state must be a partial object with only the fields + // that this function (and its predecessors in the pipeline) wants to have + // set in the object. Copying a non-partial observed state to desired is most + // likely not what you want to do. Leaving out fields that had been returned + // as desired before will result in them being deleted from the objects in the + // cluster. + Desired *State `protobuf:"bytes,3,opt,name=desired,proto3" json:"desired,omitempty"` + // Optional input specific to this Function invocation. A JSON representation + // of the 'input' block of the relevant entry in a Composition's pipeline. + Input *structpb.Struct `protobuf:"bytes,4,opt,name=input,proto3,oneof" json:"input,omitempty"` + // Optional context. Crossplane may pass arbitary contextual information to a + // Function. A Function may also return context in its RunFunctionResponse, + // and that context will be passed to subsequent Functions. Crossplane + // discards all context returned by the last Function in the pipeline. + Context *structpb.Struct `protobuf:"bytes,5,opt,name=context,proto3,oneof" json:"context,omitempty"` + // Optional extra resources that the Function required. + // Note that extra resources is a map to Resources, plural. + // The map key corresponds to the key in a RunFunctionResponse's + // extra_resources field. If a Function requested extra resources that + // did not exist, Crossplane sets the map key to an empty Resources message to + // indicate that it attempted to satisfy the request. + ExtraResources map[string]*Resources `protobuf:"bytes,6,rep,name=extra_resources,json=extraResources,proto3" json:"extra_resources,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // Optional credentials that this Function may use to communicate with an + // external system. + Credentials map[string]*Credentials `protobuf:"bytes,7,rep,name=credentials,proto3" json:"credentials,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *RunFunctionRequest) Reset() { + *x = RunFunctionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RunFunctionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RunFunctionRequest) ProtoMessage() {} + +func (x *RunFunctionRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_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 RunFunctionRequest.ProtoReflect.Descriptor instead. +func (*RunFunctionRequest) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{0} +} + +func (x *RunFunctionRequest) GetMeta() *RequestMeta { + if x != nil { + return x.Meta + } + return nil +} + +func (x *RunFunctionRequest) GetObserved() *State { + if x != nil { + return x.Observed + } + return nil +} + +func (x *RunFunctionRequest) GetDesired() *State { + if x != nil { + return x.Desired + } + return nil +} + +func (x *RunFunctionRequest) GetInput() *structpb.Struct { + if x != nil { + return x.Input + } + return nil +} + +func (x *RunFunctionRequest) GetContext() *structpb.Struct { + if x != nil { + return x.Context + } + return nil +} + +func (x *RunFunctionRequest) GetExtraResources() map[string]*Resources { + if x != nil { + return x.ExtraResources + } + return nil +} + +func (x *RunFunctionRequest) GetCredentials() map[string]*Credentials { + if x != nil { + return x.Credentials + } + return nil +} + +// Credentials that a Function may use to communicate with an external system. +type Credentials struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Source of the credentials. + // + // Types that are assignable to Source: + // + // *Credentials_CredentialData + Source isCredentials_Source `protobuf_oneof:"source"` +} + +func (x *Credentials) Reset() { + *x = Credentials{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Credentials) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Credentials) ProtoMessage() {} + +func (x *Credentials) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_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 Credentials.ProtoReflect.Descriptor instead. +func (*Credentials) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{1} +} + +func (m *Credentials) GetSource() isCredentials_Source { + if m != nil { + return m.Source + } + return nil +} + +func (x *Credentials) GetCredentialData() *CredentialData { + if x, ok := x.GetSource().(*Credentials_CredentialData); ok { + return x.CredentialData + } + return nil +} + +type isCredentials_Source interface { + isCredentials_Source() +} + +type Credentials_CredentialData struct { + // Credential data loaded by Crossplane, for example from a Secret. + CredentialData *CredentialData `protobuf:"bytes,1,opt,name=credential_data,json=credentialData,proto3,oneof"` +} + +func (*Credentials_CredentialData) isCredentials_Source() {} + +// CredentialData loaded by Crossplane, for example from a Secret. +type CredentialData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data map[string][]byte `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *CredentialData) Reset() { + *x = CredentialData{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CredentialData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CredentialData) ProtoMessage() {} + +func (x *CredentialData) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_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 CredentialData.ProtoReflect.Descriptor instead. +func (*CredentialData) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{2} +} + +func (x *CredentialData) GetData() map[string][]byte { + if x != nil { + return x.Data + } + return nil +} + +// Resources represents the state of several Crossplane resources. +type Resources struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items []*Resource `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *Resources) Reset() { + *x = Resources{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Resources) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resources) ProtoMessage() {} + +func (x *Resources) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_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 Resources.ProtoReflect.Descriptor instead. +func (*Resources) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{3} +} + +func (x *Resources) GetItems() []*Resource { + if x != nil { + return x.Items + } + return nil +} + +// A RunFunctionResponse contains the result of a Composition Function run. +type RunFunctionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Metadata pertaining to this response. + Meta *ResponseMeta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta,omitempty"` + // Desired state according to a Function pipeline. Functions may add desired + // state, and may mutate or delete any part of the desired state they are + // concerned with. A Function must pass through any part of the desired state + // that it is not concerned with. + // + // Note that the desired state must be a partial object with only the fields + // that this function (and its predecessors in the pipeline) wants to have + // set in the object. Copying a non-partial observed state to desired is most + // likely not what you want to do. Leaving out fields that had been returned + // as desired before will result in them being deleted from the objects in the + // cluster. + Desired *State `protobuf:"bytes,2,opt,name=desired,proto3" json:"desired,omitempty"` + // Results of the Function run. Results are used for observability purposes. + Results []*Result `protobuf:"bytes,3,rep,name=results,proto3" json:"results,omitempty"` + // Optional context to be passed to the next Function in the pipeline as part + // of the RunFunctionRequest. Dropped on the last function in the pipeline. + Context *structpb.Struct `protobuf:"bytes,4,opt,name=context,proto3,oneof" json:"context,omitempty"` + // Requirements that must be satisfied for this Function to run successfully. + Requirements *Requirements `protobuf:"bytes,5,opt,name=requirements,proto3" json:"requirements,omitempty"` + // Status conditions to be applied to the composite resource. Conditions may also + // optionally be applied to the composite resource's associated claim. + Conditions []*Condition `protobuf:"bytes,6,rep,name=conditions,proto3" json:"conditions,omitempty"` +} + +func (x *RunFunctionResponse) Reset() { + *x = RunFunctionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RunFunctionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RunFunctionResponse) ProtoMessage() {} + +func (x *RunFunctionResponse) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_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 RunFunctionResponse.ProtoReflect.Descriptor instead. +func (*RunFunctionResponse) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{4} +} + +func (x *RunFunctionResponse) GetMeta() *ResponseMeta { + if x != nil { + return x.Meta + } + return nil +} + +func (x *RunFunctionResponse) GetDesired() *State { + if x != nil { + return x.Desired + } + return nil +} + +func (x *RunFunctionResponse) GetResults() []*Result { + if x != nil { + return x.Results + } + return nil +} + +func (x *RunFunctionResponse) GetContext() *structpb.Struct { + if x != nil { + return x.Context + } + return nil +} + +func (x *RunFunctionResponse) GetRequirements() *Requirements { + if x != nil { + return x.Requirements + } + return nil +} + +func (x *RunFunctionResponse) GetConditions() []*Condition { + if x != nil { + return x.Conditions + } + return nil +} + +// RequestMeta contains metadata pertaining to a RunFunctionRequest. +type RequestMeta struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // An opaque string identifying the content of the request. Two identical + // requests should have the same tag. + Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` +} + +func (x *RequestMeta) Reset() { + *x = RequestMeta{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequestMeta) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestMeta) ProtoMessage() {} + +func (x *RequestMeta) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_proto_msgTypes[5] + 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 RequestMeta.ProtoReflect.Descriptor instead. +func (*RequestMeta) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{5} +} + +func (x *RequestMeta) GetTag() string { + if x != nil { + return x.Tag + } + return "" +} + +// Requirements that must be satisfied for a Function to run successfully. +type Requirements struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Extra resources that this Function requires. + // The map key uniquely identifies the group of resources. + ExtraResources map[string]*ResourceSelector `protobuf:"bytes,1,rep,name=extra_resources,json=extraResources,proto3" json:"extra_resources,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Requirements) Reset() { + *x = Requirements{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Requirements) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Requirements) ProtoMessage() {} + +func (x *Requirements) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_proto_msgTypes[6] + 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 Requirements.ProtoReflect.Descriptor instead. +func (*Requirements) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{6} +} + +func (x *Requirements) GetExtraResources() map[string]*ResourceSelector { + if x != nil { + return x.ExtraResources + } + return nil +} + +// ResourceSelector selects a group of resources, either by name or by label. +type ResourceSelector struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // API version of resources to select. + ApiVersion string `protobuf:"bytes,1,opt,name=api_version,json=apiVersion,proto3" json:"api_version,omitempty"` + // Kind of resources to select. + Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"` + // Resources to match. + // + // Types that are assignable to Match: + // + // *ResourceSelector_MatchName + // *ResourceSelector_MatchLabels + Match isResourceSelector_Match `protobuf_oneof:"match"` +} + +func (x *ResourceSelector) Reset() { + *x = ResourceSelector{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResourceSelector) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResourceSelector) ProtoMessage() {} + +func (x *ResourceSelector) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_proto_msgTypes[7] + 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 ResourceSelector.ProtoReflect.Descriptor instead. +func (*ResourceSelector) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{7} +} + +func (x *ResourceSelector) GetApiVersion() string { + if x != nil { + return x.ApiVersion + } + return "" +} + +func (x *ResourceSelector) GetKind() string { + if x != nil { + return x.Kind + } + return "" +} + +func (m *ResourceSelector) GetMatch() isResourceSelector_Match { + if m != nil { + return m.Match + } + return nil +} + +func (x *ResourceSelector) GetMatchName() string { + if x, ok := x.GetMatch().(*ResourceSelector_MatchName); ok { + return x.MatchName + } + return "" +} + +func (x *ResourceSelector) GetMatchLabels() *MatchLabels { + if x, ok := x.GetMatch().(*ResourceSelector_MatchLabels); ok { + return x.MatchLabels + } + return nil +} + +type isResourceSelector_Match interface { + isResourceSelector_Match() +} + +type ResourceSelector_MatchName struct { + // Match the resource with this name. + MatchName string `protobuf:"bytes,3,opt,name=match_name,json=matchName,proto3,oneof"` +} + +type ResourceSelector_MatchLabels struct { + // Match all resources with these labels. + MatchLabels *MatchLabels `protobuf:"bytes,4,opt,name=match_labels,json=matchLabels,proto3,oneof"` +} + +func (*ResourceSelector_MatchName) isResourceSelector_Match() {} + +func (*ResourceSelector_MatchLabels) isResourceSelector_Match() {} + +// MatchLabels defines a set of labels to match resources against. +type MatchLabels struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Labels map[string]string `protobuf:"bytes,1,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 *MatchLabels) Reset() { + *x = MatchLabels{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MatchLabels) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MatchLabels) ProtoMessage() {} + +func (x *MatchLabels) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_proto_msgTypes[8] + 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 MatchLabels.ProtoReflect.Descriptor instead. +func (*MatchLabels) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{8} +} + +func (x *MatchLabels) GetLabels() map[string]string { + if x != nil { + return x.Labels + } + return nil +} + +// ResponseMeta contains metadata pertaining to a RunFunctionResponse. +type ResponseMeta struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // An opaque string identifying the content of the request. Must match the + // meta.tag of the corresponding RunFunctionRequest. + Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` + // Time-to-live of this response. Deterministic Functions with no side-effects + // (e.g. simple templating Functions) may specify a TTL. Crossplane may choose + // to cache responses until the TTL expires. + Ttl *durationpb.Duration `protobuf:"bytes,2,opt,name=ttl,proto3,oneof" json:"ttl,omitempty"` +} + +func (x *ResponseMeta) Reset() { + *x = ResponseMeta{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResponseMeta) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResponseMeta) ProtoMessage() {} + +func (x *ResponseMeta) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_proto_msgTypes[9] + 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 ResponseMeta.ProtoReflect.Descriptor instead. +func (*ResponseMeta) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{9} +} + +func (x *ResponseMeta) GetTag() string { + if x != nil { + return x.Tag + } + return "" +} + +func (x *ResponseMeta) GetTtl() *durationpb.Duration { + if x != nil { + return x.Ttl + } + return nil +} + +// State of the composite resource (XR) and any composed resources. +type State struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The state of the composite resource (XR). + Composite *Resource `protobuf:"bytes,1,opt,name=composite,proto3" json:"composite,omitempty"` + // The state of any composed resources. + Resources map[string]*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *State) Reset() { + *x = State{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *State) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*State) ProtoMessage() {} + +func (x *State) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_proto_msgTypes[10] + 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 State.ProtoReflect.Descriptor instead. +func (*State) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{10} +} + +func (x *State) GetComposite() *Resource { + if x != nil { + return x.Composite + } + return nil +} + +func (x *State) GetResources() map[string]*Resource { + if x != nil { + return x.Resources + } + return nil +} + +// A Resource represents the state of a composite or composed resource. +type Resource struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The JSON representation of the resource. + // + // - Crossplane will set this field in a RunFunctionRequest to the entire + // observed state of a resource - including its metadata, spec, and status. + // + // - A Function should set this field in a RunFunctionRequest to communicate + // the desired state of a composite or composed resource. + // + // - A Function may only specify the desired status of a composite resource - + // not its metadata or spec. A Function should not return desired metadata + // or spec for a composite resource. This will be ignored. + // + // - A Function may not specify the desired status of a composed resource - + // only its metadata and spec. A Function should not return desired status + // for a composed resource. This will be ignored. + Resource *structpb.Struct `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + // The resource's connection details. + // + // - Crossplane will set this field in a RunFunctionRequest to communicate the + // the observed connection details of a composite or composed resource. + // + // - A Function should set this field in a RunFunctionResponse to indicate the + // desired connection details of the composite resource. + // + // - A Function should not set this field in a RunFunctionResponse to indicate + // the desired connection details of a composed resource. This will be + // ignored. + ConnectionDetails map[string][]byte `protobuf:"bytes,2,rep,name=connection_details,json=connectionDetails,proto3" json:"connection_details,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // Ready indicates whether the resource should be considered ready. + // + // * Crossplane will never set this field in a RunFunctionRequest. + // + // - A Function should set this field to READY_TRUE in a RunFunctionResponse + // to indicate that a desired composed resource is ready. + // + // - A Function should not set this field in a RunFunctionResponse to indicate + // that the desired composite resource is ready. This will be ignored. + Ready Ready `protobuf:"varint,3,opt,name=ready,proto3,enum=apiextensions.fn.proto.v1.Ready" json:"ready,omitempty"` +} + +func (x *Resource) Reset() { + *x = Resource{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Resource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resource) ProtoMessage() {} + +func (x *Resource) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_proto_msgTypes[11] + 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 Resource.ProtoReflect.Descriptor instead. +func (*Resource) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{11} +} + +func (x *Resource) GetResource() *structpb.Struct { + if x != nil { + return x.Resource + } + return nil +} + +func (x *Resource) GetConnectionDetails() map[string][]byte { + if x != nil { + return x.ConnectionDetails + } + return nil +} + +func (x *Resource) GetReady() Ready { + if x != nil { + return x.Ready + } + return Ready_READY_UNSPECIFIED +} + +// A Result of running a Function. +type Result struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Severity of this result. + Severity Severity `protobuf:"varint,1,opt,name=severity,proto3,enum=apiextensions.fn.proto.v1.Severity" json:"severity,omitempty"` + // Human-readable details about the result. + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + // Optional PascalCase, machine-readable reason for this result. If omitted, + // the value will be ComposeResources. + Reason *string `protobuf:"bytes,3,opt,name=reason,proto3,oneof" json:"reason,omitempty"` + // The resources this result targets. + Target *Target `protobuf:"varint,4,opt,name=target,proto3,enum=apiextensions.fn.proto.v1.Target,oneof" json:"target,omitempty"` +} + +func (x *Result) Reset() { + *x = Result{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Result) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Result) ProtoMessage() {} + +func (x *Result) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_proto_msgTypes[12] + 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 Result.ProtoReflect.Descriptor instead. +func (*Result) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{12} +} + +func (x *Result) GetSeverity() Severity { + if x != nil { + return x.Severity + } + return Severity_SEVERITY_UNSPECIFIED +} + +func (x *Result) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *Result) GetReason() string { + if x != nil && x.Reason != nil { + return *x.Reason + } + return "" +} + +func (x *Result) GetTarget() Target { + if x != nil && x.Target != nil { + return *x.Target + } + return Target_TARGET_UNSPECIFIED +} + +// Status condition to be applied to the composite resource. Condition may also +// optionally be applied to the composite resource's associated claim. For +// detailed information on proper usage of status conditions, please see +// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties. +type Condition struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Type of condition in PascalCase. + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + // Status of the condition. + Status Status `protobuf:"varint,2,opt,name=status,proto3,enum=apiextensions.fn.proto.v1.Status" json:"status,omitempty"` + // Reason contains a programmatic identifier indicating the reason for the + // condition's last transition. Producers of specific condition types may + // define expected values and meanings for this field, and whether the values + // are considered a guaranteed API. The value should be a PascalCase string. + // This field may not be empty. + Reason string `protobuf:"bytes,3,opt,name=reason,proto3" json:"reason,omitempty"` + // Message is a human readable message indicating details about the + // transition. This may be an empty string. + Message *string `protobuf:"bytes,4,opt,name=message,proto3,oneof" json:"message,omitempty"` + // The resources this condition targets. + Target *Target `protobuf:"varint,5,opt,name=target,proto3,enum=apiextensions.fn.proto.v1.Target,oneof" json:"target,omitempty"` +} + +func (x *Condition) Reset() { + *x = Condition{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_run_function_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Condition) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Condition) ProtoMessage() {} + +func (x *Condition) ProtoReflect() protoreflect.Message { + mi := &file_v1_run_function_proto_msgTypes[13] + 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 Condition.ProtoReflect.Descriptor instead. +func (*Condition) Descriptor() ([]byte, []int) { + return file_v1_run_function_proto_rawDescGZIP(), []int{13} +} + +func (x *Condition) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Condition) GetStatus() Status { + if x != nil { + return x.Status + } + return Status_STATUS_CONDITION_UNSPECIFIED +} + +func (x *Condition) GetReason() string { + if x != nil { + return x.Reason + } + return "" +} + +func (x *Condition) GetMessage() string { + if x != nil && x.Message != nil { + return *x.Message + } + return "" +} + +func (x *Condition) GetTarget() Target { + if x != nil && x.Target != nil { + return *x.Target + } + return Target_TARGET_UNSPECIFIED +} + +var File_v1_run_function_proto protoreflect.FileDescriptor + +var file_v1_run_function_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x76, 0x31, 0x2f, 0x72, 0x75, 0x6e, 0x5f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x19, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0xeb, 0x05, 0x0a, 0x12, 0x52, 0x75, 0x6e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3a, 0x0a, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, + 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x04, 0x6d, + 0x65, 0x74, 0x61, 0x12, 0x3c, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, + 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x64, 0x12, 0x3a, 0x0a, 0x07, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x52, 0x07, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x12, 0x32, 0x0a, + 0x05, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, + 0x74, 0x72, 0x75, 0x63, 0x74, 0x48, 0x00, 0x52, 0x05, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x88, 0x01, + 0x01, 0x12, 0x36, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x48, 0x01, 0x52, 0x07, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x88, 0x01, 0x01, 0x12, 0x6a, 0x0a, 0x0f, 0x65, 0x78, 0x74, + 0x72, 0x61, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, + 0x75, 0x6e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x2e, 0x45, 0x78, 0x74, 0x72, 0x61, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x65, 0x78, 0x74, 0x72, 0x61, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x60, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x61, 0x6c, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x61, 0x70, 0x69, + 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x75, 0x6e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x1a, 0x67, 0x0a, 0x13, 0x45, 0x78, 0x74, 0x72, 0x61, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 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, 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, + 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x1a, 0x66, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 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, 0x3c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x69, 0x6e, 0x70, + 0x75, 0x74, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x6d, + 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, 0x54, 0x0a, + 0x0f, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, + 0x61, 0x48, 0x00, 0x52, 0x0e, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x44, + 0x61, 0x74, 0x61, 0x42, 0x08, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x92, 0x01, + 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, + 0x12, 0x47, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x33, + 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, + 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x37, 0x0a, 0x09, 0x44, 0x61, 0x74, + 0x61, 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, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x22, 0x46, 0x0a, 0x09, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, + 0x39, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, + 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, + 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0xa2, 0x03, 0x0a, 0x13, 0x52, + 0x75, 0x6e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x27, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, + 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x12, + 0x3a, 0x0a, 0x07, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, + 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x07, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x12, 0x3b, 0x0a, 0x07, 0x72, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x61, + 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, + 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x36, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, + 0x65, 0x78, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, + 0x63, 0x74, 0x48, 0x00, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x88, 0x01, 0x01, + 0x12, 0x4b, 0x0a, 0x0c, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x76, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, + 0x0c, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x44, 0x0a, + 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, + 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, + 0x1f, 0x0a, 0x0b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x10, + 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, + 0x22, 0xe4, 0x01, 0x0a, 0x0c, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x12, 0x64, 0x0a, 0x0f, 0x65, 0x78, 0x74, 0x72, 0x61, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3b, 0x2e, 0x61, 0x70, 0x69, + 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x2e, 0x45, 0x78, 0x74, 0x72, 0x61, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x65, 0x78, 0x74, 0x72, 0x61, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x6e, 0x0a, 0x13, 0x45, 0x78, 0x74, 0x72, 0x61, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 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, 0x41, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, + 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xbe, 0x01, 0x0a, 0x10, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1f, 0x0a, 0x0b, + 0x61, 0x70, 0x69, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x61, 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, + 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, + 0x64, 0x12, 0x1f, 0x0a, 0x0a, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x09, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0c, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6c, 0x61, 0x62, 0x65, + 0x6c, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, + 0x48, 0x00, 0x52, 0x0b, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x42, + 0x07, 0x0a, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x22, 0x94, 0x01, 0x0a, 0x0b, 0x4d, 0x61, 0x74, + 0x63, 0x68, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x4a, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, + 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, + 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, + 0x5a, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x12, + 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, + 0x67, 0x12, 0x30, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x03, 0x74, 0x74, 0x6c, + 0x88, 0x01, 0x01, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x74, 0x74, 0x6c, 0x22, 0xfc, 0x01, 0x0a, 0x05, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x41, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x63, + 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 0x12, 0x4d, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x61, 0x70, + 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x61, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 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, 0x39, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x70, 0x69, + 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xa8, 0x02, 0x0a, 0x08, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, + 0x63, 0x74, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x69, 0x0a, 0x12, + 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, + 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x43, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x52, 0x11, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x36, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x76, 0x31, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x79, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x1a, + 0x44, 0x0a, 0x16, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x74, + 0x61, 0x69, 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, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xd6, 0x01, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x12, 0x3f, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x53, + 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, + 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1b, 0x0a, 0x06, 0x72, + 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x06, 0x72, + 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x3e, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x01, 0x52, 0x06, 0x74, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x88, 0x01, 0x01, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x72, 0x65, 0x61, + 0x73, 0x6f, 0x6e, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xe8, + 0x01, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x39, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x21, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, + 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, + 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, + 0x73, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x88, + 0x01, 0x01, 0x12, 0x3e, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x01, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x88, + 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x09, + 0x0a, 0x07, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2a, 0x3f, 0x0a, 0x05, 0x52, 0x65, 0x61, + 0x64, 0x79, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x45, 0x41, 0x44, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x52, 0x45, 0x41, + 0x44, 0x59, 0x5f, 0x54, 0x52, 0x55, 0x45, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x52, 0x45, 0x41, + 0x44, 0x59, 0x5f, 0x46, 0x41, 0x4c, 0x53, 0x45, 0x10, 0x02, 0x2a, 0x63, 0x0a, 0x08, 0x53, 0x65, + 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x14, 0x53, 0x45, 0x56, 0x45, 0x52, 0x49, + 0x54, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x45, 0x56, 0x45, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x46, 0x41, 0x54, + 0x41, 0x4c, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x45, 0x56, 0x45, 0x52, 0x49, 0x54, 0x59, + 0x5f, 0x57, 0x41, 0x52, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, + 0x56, 0x45, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x03, 0x2a, + 0x56, 0x0a, 0x06, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x12, 0x54, 0x41, 0x52, + 0x47, 0x45, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, + 0x00, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x43, 0x4f, 0x4d, 0x50, + 0x4f, 0x53, 0x49, 0x54, 0x45, 0x10, 0x01, 0x12, 0x1e, 0x0a, 0x1a, 0x54, 0x41, 0x52, 0x47, 0x45, + 0x54, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x45, 0x5f, 0x41, 0x4e, 0x44, 0x5f, + 0x43, 0x4c, 0x41, 0x49, 0x4d, 0x10, 0x02, 0x2a, 0x7f, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x20, 0x0a, 0x1c, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4f, 0x4e, 0x44, + 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4f, + 0x4e, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, + 0x01, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4f, 0x4e, 0x44, + 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x52, 0x55, 0x45, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, + 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, + 0x5f, 0x46, 0x41, 0x4c, 0x53, 0x45, 0x10, 0x03, 0x32, 0x87, 0x01, 0x0a, 0x15, 0x46, 0x75, 0x6e, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x6e, 0x0a, 0x0b, 0x52, 0x75, 0x6e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x75, + 0x6e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x2e, 0x2e, 0x61, 0x70, 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, + 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x75, 0x6e, + 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x42, 0x41, 0x5a, 0x3f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x63, 0x72, 0x6f, 0x73, 0x73, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x63, 0x72, 0x6f, 0x73, + 0x73, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x65, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x66, 0x6e, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_v1_run_function_proto_rawDescOnce sync.Once + file_v1_run_function_proto_rawDescData = file_v1_run_function_proto_rawDesc +) + +func file_v1_run_function_proto_rawDescGZIP() []byte { + file_v1_run_function_proto_rawDescOnce.Do(func() { + file_v1_run_function_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_run_function_proto_rawDescData) + }) + return file_v1_run_function_proto_rawDescData +} + +var file_v1_run_function_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_v1_run_function_proto_msgTypes = make([]protoimpl.MessageInfo, 21) +var file_v1_run_function_proto_goTypes = []interface{}{ + (Ready)(0), // 0: apiextensions.fn.proto.v1.Ready + (Severity)(0), // 1: apiextensions.fn.proto.v1.Severity + (Target)(0), // 2: apiextensions.fn.proto.v1.Target + (Status)(0), // 3: apiextensions.fn.proto.v1.Status + (*RunFunctionRequest)(nil), // 4: apiextensions.fn.proto.v1.RunFunctionRequest + (*Credentials)(nil), // 5: apiextensions.fn.proto.v1.Credentials + (*CredentialData)(nil), // 6: apiextensions.fn.proto.v1.CredentialData + (*Resources)(nil), // 7: apiextensions.fn.proto.v1.Resources + (*RunFunctionResponse)(nil), // 8: apiextensions.fn.proto.v1.RunFunctionResponse + (*RequestMeta)(nil), // 9: apiextensions.fn.proto.v1.RequestMeta + (*Requirements)(nil), // 10: apiextensions.fn.proto.v1.Requirements + (*ResourceSelector)(nil), // 11: apiextensions.fn.proto.v1.ResourceSelector + (*MatchLabels)(nil), // 12: apiextensions.fn.proto.v1.MatchLabels + (*ResponseMeta)(nil), // 13: apiextensions.fn.proto.v1.ResponseMeta + (*State)(nil), // 14: apiextensions.fn.proto.v1.State + (*Resource)(nil), // 15: apiextensions.fn.proto.v1.Resource + (*Result)(nil), // 16: apiextensions.fn.proto.v1.Result + (*Condition)(nil), // 17: apiextensions.fn.proto.v1.Condition + nil, // 18: apiextensions.fn.proto.v1.RunFunctionRequest.ExtraResourcesEntry + nil, // 19: apiextensions.fn.proto.v1.RunFunctionRequest.CredentialsEntry + nil, // 20: apiextensions.fn.proto.v1.CredentialData.DataEntry + nil, // 21: apiextensions.fn.proto.v1.Requirements.ExtraResourcesEntry + nil, // 22: apiextensions.fn.proto.v1.MatchLabels.LabelsEntry + nil, // 23: apiextensions.fn.proto.v1.State.ResourcesEntry + nil, // 24: apiextensions.fn.proto.v1.Resource.ConnectionDetailsEntry + (*structpb.Struct)(nil), // 25: google.protobuf.Struct + (*durationpb.Duration)(nil), // 26: google.protobuf.Duration +} +var file_v1_run_function_proto_depIdxs = []int32{ + 9, // 0: apiextensions.fn.proto.v1.RunFunctionRequest.meta:type_name -> apiextensions.fn.proto.v1.RequestMeta + 14, // 1: apiextensions.fn.proto.v1.RunFunctionRequest.observed:type_name -> apiextensions.fn.proto.v1.State + 14, // 2: apiextensions.fn.proto.v1.RunFunctionRequest.desired:type_name -> apiextensions.fn.proto.v1.State + 25, // 3: apiextensions.fn.proto.v1.RunFunctionRequest.input:type_name -> google.protobuf.Struct + 25, // 4: apiextensions.fn.proto.v1.RunFunctionRequest.context:type_name -> google.protobuf.Struct + 18, // 5: apiextensions.fn.proto.v1.RunFunctionRequest.extra_resources:type_name -> apiextensions.fn.proto.v1.RunFunctionRequest.ExtraResourcesEntry + 19, // 6: apiextensions.fn.proto.v1.RunFunctionRequest.credentials:type_name -> apiextensions.fn.proto.v1.RunFunctionRequest.CredentialsEntry + 6, // 7: apiextensions.fn.proto.v1.Credentials.credential_data:type_name -> apiextensions.fn.proto.v1.CredentialData + 20, // 8: apiextensions.fn.proto.v1.CredentialData.data:type_name -> apiextensions.fn.proto.v1.CredentialData.DataEntry + 15, // 9: apiextensions.fn.proto.v1.Resources.items:type_name -> apiextensions.fn.proto.v1.Resource + 13, // 10: apiextensions.fn.proto.v1.RunFunctionResponse.meta:type_name -> apiextensions.fn.proto.v1.ResponseMeta + 14, // 11: apiextensions.fn.proto.v1.RunFunctionResponse.desired:type_name -> apiextensions.fn.proto.v1.State + 16, // 12: apiextensions.fn.proto.v1.RunFunctionResponse.results:type_name -> apiextensions.fn.proto.v1.Result + 25, // 13: apiextensions.fn.proto.v1.RunFunctionResponse.context:type_name -> google.protobuf.Struct + 10, // 14: apiextensions.fn.proto.v1.RunFunctionResponse.requirements:type_name -> apiextensions.fn.proto.v1.Requirements + 17, // 15: apiextensions.fn.proto.v1.RunFunctionResponse.conditions:type_name -> apiextensions.fn.proto.v1.Condition + 21, // 16: apiextensions.fn.proto.v1.Requirements.extra_resources:type_name -> apiextensions.fn.proto.v1.Requirements.ExtraResourcesEntry + 12, // 17: apiextensions.fn.proto.v1.ResourceSelector.match_labels:type_name -> apiextensions.fn.proto.v1.MatchLabels + 22, // 18: apiextensions.fn.proto.v1.MatchLabels.labels:type_name -> apiextensions.fn.proto.v1.MatchLabels.LabelsEntry + 26, // 19: apiextensions.fn.proto.v1.ResponseMeta.ttl:type_name -> google.protobuf.Duration + 15, // 20: apiextensions.fn.proto.v1.State.composite:type_name -> apiextensions.fn.proto.v1.Resource + 23, // 21: apiextensions.fn.proto.v1.State.resources:type_name -> apiextensions.fn.proto.v1.State.ResourcesEntry + 25, // 22: apiextensions.fn.proto.v1.Resource.resource:type_name -> google.protobuf.Struct + 24, // 23: apiextensions.fn.proto.v1.Resource.connection_details:type_name -> apiextensions.fn.proto.v1.Resource.ConnectionDetailsEntry + 0, // 24: apiextensions.fn.proto.v1.Resource.ready:type_name -> apiextensions.fn.proto.v1.Ready + 1, // 25: apiextensions.fn.proto.v1.Result.severity:type_name -> apiextensions.fn.proto.v1.Severity + 2, // 26: apiextensions.fn.proto.v1.Result.target:type_name -> apiextensions.fn.proto.v1.Target + 3, // 27: apiextensions.fn.proto.v1.Condition.status:type_name -> apiextensions.fn.proto.v1.Status + 2, // 28: apiextensions.fn.proto.v1.Condition.target:type_name -> apiextensions.fn.proto.v1.Target + 7, // 29: apiextensions.fn.proto.v1.RunFunctionRequest.ExtraResourcesEntry.value:type_name -> apiextensions.fn.proto.v1.Resources + 5, // 30: apiextensions.fn.proto.v1.RunFunctionRequest.CredentialsEntry.value:type_name -> apiextensions.fn.proto.v1.Credentials + 11, // 31: apiextensions.fn.proto.v1.Requirements.ExtraResourcesEntry.value:type_name -> apiextensions.fn.proto.v1.ResourceSelector + 15, // 32: apiextensions.fn.proto.v1.State.ResourcesEntry.value:type_name -> apiextensions.fn.proto.v1.Resource + 4, // 33: apiextensions.fn.proto.v1.FunctionRunnerService.RunFunction:input_type -> apiextensions.fn.proto.v1.RunFunctionRequest + 8, // 34: apiextensions.fn.proto.v1.FunctionRunnerService.RunFunction:output_type -> apiextensions.fn.proto.v1.RunFunctionResponse + 34, // [34:35] is the sub-list for method output_type + 33, // [33:34] is the sub-list for method input_type + 33, // [33:33] is the sub-list for extension type_name + 33, // [33:33] is the sub-list for extension extendee + 0, // [0:33] is the sub-list for field type_name +} + +func init() { file_v1_run_function_proto_init() } +func file_v1_run_function_proto_init() { + if File_v1_run_function_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_v1_run_function_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RunFunctionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Credentials); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CredentialData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Resources); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RunFunctionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequestMeta); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Requirements); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResourceSelector); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MatchLabels); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResponseMeta); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*State); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Resource); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Result); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_run_function_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Condition); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_v1_run_function_proto_msgTypes[0].OneofWrappers = []interface{}{} + file_v1_run_function_proto_msgTypes[1].OneofWrappers = []interface{}{ + (*Credentials_CredentialData)(nil), + } + file_v1_run_function_proto_msgTypes[4].OneofWrappers = []interface{}{} + file_v1_run_function_proto_msgTypes[7].OneofWrappers = []interface{}{ + (*ResourceSelector_MatchName)(nil), + (*ResourceSelector_MatchLabels)(nil), + } + file_v1_run_function_proto_msgTypes[9].OneofWrappers = []interface{}{} + file_v1_run_function_proto_msgTypes[12].OneofWrappers = []interface{}{} + file_v1_run_function_proto_msgTypes[13].OneofWrappers = []interface{}{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_v1_run_function_proto_rawDesc, + NumEnums: 4, + NumMessages: 21, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_v1_run_function_proto_goTypes, + DependencyIndexes: file_v1_run_function_proto_depIdxs, + EnumInfos: file_v1_run_function_proto_enumTypes, + MessageInfos: file_v1_run_function_proto_msgTypes, + }.Build() + File_v1_run_function_proto = out.File + file_v1_run_function_proto_rawDesc = nil + file_v1_run_function_proto_goTypes = nil + file_v1_run_function_proto_depIdxs = nil +} diff --git a/proto/v1/run_function.proto b/proto/v1/run_function.proto new file mode 100644 index 0000000..b66e970 --- /dev/null +++ b/proto/v1/run_function.proto @@ -0,0 +1,326 @@ +/* +Copyright 2022 The Crossplane 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. +*/ + +syntax = "proto3"; + +import "google/protobuf/struct.proto"; +import "google/protobuf/duration.proto"; + +package apiextensions.fn.proto.v1; + +option go_package = "github.com/crossplane/crossplane/apis/apiextensions/fn/proto/v1"; + +// A FunctionRunnerService is a Composition Function. +service FunctionRunnerService { + // RunFunction runs the Composition Function. + rpc RunFunction(RunFunctionRequest) returns (RunFunctionResponse) {} +} + +// A RunFunctionRequest requests that the Composition Function be run. +message RunFunctionRequest { + // Metadata pertaining to this request. + RequestMeta meta = 1; + + // The observed state prior to invocation of a Function pipeline. State passed + // to each Function is fresh as of the time the pipeline was invoked, not as + // of the time each Function was invoked. + State observed = 2; + + // Desired state according to a Function pipeline. The state passed to a + // particular Function may have been accumulated by previous Functions in the + // pipeline. + // + // Note that the desired state must be a partial object with only the fields + // that this function (and its predecessors in the pipeline) wants to have + // set in the object. Copying a non-partial observed state to desired is most + // likely not what you want to do. Leaving out fields that had been returned + // as desired before will result in them being deleted from the objects in the + // cluster. + State desired = 3; + + // Optional input specific to this Function invocation. A JSON representation + // of the 'input' block of the relevant entry in a Composition's pipeline. + optional google.protobuf.Struct input = 4; + + // Optional context. Crossplane may pass arbitary contextual information to a + // Function. A Function may also return context in its RunFunctionResponse, + // and that context will be passed to subsequent Functions. Crossplane + // discards all context returned by the last Function in the pipeline. + optional google.protobuf.Struct context = 5; + + // Optional extra resources that the Function required. + // Note that extra resources is a map to Resources, plural. + // The map key corresponds to the key in a RunFunctionResponse's + // extra_resources field. If a Function requested extra resources that + // did not exist, Crossplane sets the map key to an empty Resources message to + // indicate that it attempted to satisfy the request. + map extra_resources = 6; + + // Optional credentials that this Function may use to communicate with an + // external system. + map credentials = 7; +} + +// Credentials that a Function may use to communicate with an external system. +message Credentials { + // Source of the credentials. + oneof source { + // Credential data loaded by Crossplane, for example from a Secret. + CredentialData credential_data = 1; + } +} + +// CredentialData loaded by Crossplane, for example from a Secret. +message CredentialData { + map data = 1; +} + +// Resources represents the state of several Crossplane resources. +message Resources { + repeated Resource items = 1; +} + +// A RunFunctionResponse contains the result of a Composition Function run. +message RunFunctionResponse { + // Metadata pertaining to this response. + ResponseMeta meta = 1; + + // Desired state according to a Function pipeline. Functions may add desired + // state, and may mutate or delete any part of the desired state they are + // concerned with. A Function must pass through any part of the desired state + // that it is not concerned with. + // + // + // Note that the desired state must be a partial object with only the fields + // that this function (and its predecessors in the pipeline) wants to have + // set in the object. Copying a non-partial observed state to desired is most + // likely not what you want to do. Leaving out fields that had been returned + // as desired before will result in them being deleted from the objects in the + // cluster. + State desired = 2; + + // Results of the Function run. Results are used for observability purposes. + repeated Result results = 3; + + // Optional context to be passed to the next Function in the pipeline as part + // of the RunFunctionRequest. Dropped on the last function in the pipeline. + optional google.protobuf.Struct context = 4; + + // Requirements that must be satisfied for this Function to run successfully. + Requirements requirements = 5; + + // Status conditions to be applied to the composite resource. Conditions may also + // optionally be applied to the composite resource's associated claim. + repeated Condition conditions = 6; +} + +// RequestMeta contains metadata pertaining to a RunFunctionRequest. +message RequestMeta { + // An opaque string identifying the content of the request. Two identical + // requests should have the same tag. + string tag = 1; +} + +// Requirements that must be satisfied for a Function to run successfully. +message Requirements { + // Extra resources that this Function requires. + // The map key uniquely identifies the group of resources. + map extra_resources = 1; +} + +// ResourceSelector selects a group of resources, either by name or by label. +message ResourceSelector { + // API version of resources to select. + string api_version = 1; + + // Kind of resources to select. + string kind = 2; + + // Resources to match. + oneof match { + // Match the resource with this name. + string match_name = 3; + + // Match all resources with these labels. + MatchLabels match_labels = 4; + } +} + +// MatchLabels defines a set of labels to match resources against. +message MatchLabels { + map labels = 1; +} + +// ResponseMeta contains metadata pertaining to a RunFunctionResponse. +message ResponseMeta { + // An opaque string identifying the content of the request. Must match the + // meta.tag of the corresponding RunFunctionRequest. + string tag = 1; + + // Time-to-live of this response. Deterministic Functions with no side-effects + // (e.g. simple templating Functions) may specify a TTL. Crossplane may choose + // to cache responses until the TTL expires. + optional google.protobuf.Duration ttl = 2; +} + +// State of the composite resource (XR) and any composed resources. +message State { + // The state of the composite resource (XR). + Resource composite = 1; + + // The state of any composed resources. + map resources = 2; +} + +// A Resource represents the state of a composite or composed resource. +message Resource { + // The JSON representation of the resource. + // + // * Crossplane will set this field in a RunFunctionRequest to the entire + // observed state of a resource - including its metadata, spec, and status. + // + // * A Function should set this field in a RunFunctionRequest to communicate + // the desired state of a composite or composed resource. + // + // * A Function may only specify the desired status of a composite resource - + // not its metadata or spec. A Function should not return desired metadata + // or spec for a composite resource. This will be ignored. + // + // * A Function may not specify the desired status of a composed resource - + // only its metadata and spec. A Function should not return desired status + // for a composed resource. This will be ignored. + google.protobuf.Struct resource = 1; + + // The resource's connection details. + // + // * Crossplane will set this field in a RunFunctionRequest to communicate the + // the observed connection details of a composite or composed resource. + // + // * A Function should set this field in a RunFunctionResponse to indicate the + // desired connection details of the composite resource. + // + // * A Function should not set this field in a RunFunctionResponse to indicate + // the desired connection details of a composed resource. This will be + // ignored. + map connection_details = 2; + + // Ready indicates whether the resource should be considered ready. + // + // * Crossplane will never set this field in a RunFunctionRequest. + // + // * A Function should set this field to READY_TRUE in a RunFunctionResponse + // to indicate that a desired composed resource is ready. + // + // * A Function should not set this field in a RunFunctionResponse to indicate + // that the desired composite resource is ready. This will be ignored. + Ready ready = 3; +} + +// Ready indicates whether a composed resource should be considered ready. +enum Ready { + READY_UNSPECIFIED = 0; + + // True means the composed resource has been observed to be ready. + READY_TRUE = 1; + + // False means the composed resource has not been observed to be ready. + READY_FALSE = 2; +} + +// A Result of running a Function. +message Result { + // Severity of this result. + Severity severity = 1; + + // Human-readable details about the result. + string message = 2; + + // Optional PascalCase, machine-readable reason for this result. If omitted, + // the value will be ComposeResources. + optional string reason = 3; + + // The resources this result targets. + optional Target target = 4; +} + +// Severity of Function results. +enum Severity { + SEVERITY_UNSPECIFIED = 0; + + // Fatal results are fatal; subsequent Composition Functions may run, but + // the Composition Function pipeline run will be considered a failure and + // the first fatal result will be returned as an error. + SEVERITY_FATAL = 1; + + // Warning results are non-fatal; the entire Composition will run to + // completion but warning events and debug logs associated with the + // composite resource will be emitted. + SEVERITY_WARNING = 2; + + // Normal results are emitted as normal events and debug logs associated + // with the composite resource. + SEVERITY_NORMAL = 3; +} + +// Target of Function results and conditions. +enum Target { + // If the target is unspecified, the result targets the composite resource. + TARGET_UNSPECIFIED = 0; + + // Target the composite resource. Results that target the composite resource + // should include detailed, advanced information. + TARGET_COMPOSITE = 1; + + // Target the composite and the claim. Results that target the composite and + // the claim should include only end-user friendly information. + TARGET_COMPOSITE_AND_CLAIM = 2; +} + +// Status condition to be applied to the composite resource. Condition may also +// optionally be applied to the composite resource's associated claim. For +// detailed information on proper usage of status conditions, please see +// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties. +message Condition { + // Type of condition in PascalCase. + string type = 1; + + // Status of the condition. + Status status = 2; + + // Reason contains a programmatic identifier indicating the reason for the + // condition's last transition. Producers of specific condition types may + // define expected values and meanings for this field, and whether the values + // are considered a guaranteed API. The value should be a PascalCase string. + // This field may not be empty. + string reason = 3; + + // Message is a human readable message indicating details about the + // transition. This may be an empty string. + optional string message = 4; + + // The resources this condition targets. + optional Target target = 5; +} + +enum Status { + STATUS_CONDITION_UNSPECIFIED = 0; + + STATUS_CONDITION_UNKNOWN = 1; + + STATUS_CONDITION_TRUE = 2; + + STATUS_CONDITION_FALSE = 3; +} diff --git a/proto/v1/run_function_grpc.pb.go b/proto/v1/run_function_grpc.pb.go new file mode 100644 index 0000000..c6b61af --- /dev/null +++ b/proto/v1/run_function_grpc.pb.go @@ -0,0 +1,126 @@ +// +//Copyright 2022 The Crossplane 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-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: v1/run_function.proto + +package v1 + +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 ( + FunctionRunnerService_RunFunction_FullMethodName = "/apiextensions.fn.proto.v1.FunctionRunnerService/RunFunction" +) + +// FunctionRunnerServiceClient is the client API for FunctionRunnerService 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 FunctionRunnerServiceClient interface { + // RunFunction runs the Composition Function. + RunFunction(ctx context.Context, in *RunFunctionRequest, opts ...grpc.CallOption) (*RunFunctionResponse, error) +} + +type functionRunnerServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewFunctionRunnerServiceClient(cc grpc.ClientConnInterface) FunctionRunnerServiceClient { + return &functionRunnerServiceClient{cc} +} + +func (c *functionRunnerServiceClient) RunFunction(ctx context.Context, in *RunFunctionRequest, opts ...grpc.CallOption) (*RunFunctionResponse, error) { + out := new(RunFunctionResponse) + err := c.cc.Invoke(ctx, FunctionRunnerService_RunFunction_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// FunctionRunnerServiceServer is the server API for FunctionRunnerService service. +// All implementations must embed UnimplementedFunctionRunnerServiceServer +// for forward compatibility +type FunctionRunnerServiceServer interface { + // RunFunction runs the Composition Function. + RunFunction(context.Context, *RunFunctionRequest) (*RunFunctionResponse, error) + mustEmbedUnimplementedFunctionRunnerServiceServer() +} + +// UnimplementedFunctionRunnerServiceServer must be embedded to have forward compatible implementations. +type UnimplementedFunctionRunnerServiceServer struct { +} + +func (UnimplementedFunctionRunnerServiceServer) RunFunction(context.Context, *RunFunctionRequest) (*RunFunctionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RunFunction not implemented") +} +func (UnimplementedFunctionRunnerServiceServer) mustEmbedUnimplementedFunctionRunnerServiceServer() {} + +// UnsafeFunctionRunnerServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to FunctionRunnerServiceServer will +// result in compilation errors. +type UnsafeFunctionRunnerServiceServer interface { + mustEmbedUnimplementedFunctionRunnerServiceServer() +} + +func RegisterFunctionRunnerServiceServer(s grpc.ServiceRegistrar, srv FunctionRunnerServiceServer) { + s.RegisterService(&FunctionRunnerService_ServiceDesc, srv) +} + +func _FunctionRunnerService_RunFunction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RunFunctionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FunctionRunnerServiceServer).RunFunction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FunctionRunnerService_RunFunction_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FunctionRunnerServiceServer).RunFunction(ctx, req.(*RunFunctionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// FunctionRunnerService_ServiceDesc is the grpc.ServiceDesc for FunctionRunnerService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var FunctionRunnerService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "apiextensions.fn.proto.v1.FunctionRunnerService", + HandlerType: (*FunctionRunnerServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RunFunction", + Handler: _FunctionRunnerService_RunFunction_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "v1/run_function.proto", +} diff --git a/proto/v1beta1/run_function.pb.go b/proto/v1beta1/run_function.pb.go index 3320e6b..d971b65 100644 --- a/proto/v1beta1/run_function.pb.go +++ b/proto/v1beta1/run_function.pb.go @@ -19,9 +19,7 @@ // protoc (unknown) // source: v1beta1/run_function.proto -// Note that the authoritative Composition Functions protobuf definition lives -// at the below URL. Each SDK maintains and manually syncs its own copy. -// https://github.com/crossplane/crossplane/tree/master/apis/apiextensions/fn/proto +// Generated from apiextensions/fn/proto/v1/run_function.proto by ../hack/duplicate_proto_type.sh. DO NOT EDIT. package v1beta1 @@ -154,7 +152,7 @@ func (Severity) EnumDescriptor() ([]byte, []int) { return file_v1beta1_run_function_proto_rawDescGZIP(), []int{1} } -// Target of Function results. +// Target of Function results and conditions. type Target int32 const ( @@ -579,8 +577,8 @@ type RunFunctionResponse struct { Context *structpb.Struct `protobuf:"bytes,4,opt,name=context,proto3,oneof" json:"context,omitempty"` // Requirements that must be satisfied for this Function to run successfully. Requirements *Requirements `protobuf:"bytes,5,opt,name=requirements,proto3" json:"requirements,omitempty"` - // Status Conditions to be applied to the Composite Resource and sometimes the - // Claim. + // Status conditions to be applied to the composite resource. Conditions may also + // optionally be applied to the composite resource's associated claim. Conditions []*Condition `protobuf:"bytes,6,rep,name=conditions,proto3" json:"conditions,omitempty"` } @@ -1138,7 +1136,8 @@ type Result struct { Severity Severity `protobuf:"varint,1,opt,name=severity,proto3,enum=apiextensions.fn.proto.v1beta1.Severity" json:"severity,omitempty"` // Human-readable details about the result. Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - // Optional PascalCase, machine-readable reason for this result. + // Optional PascalCase, machine-readable reason for this result. If omitted, + // the value will be ComposeResources. Reason *string `protobuf:"bytes,3,opt,name=reason,proto3,oneof" json:"reason,omitempty"` // The resources this result targets. Target *Target `protobuf:"varint,4,opt,name=target,proto3,enum=apiextensions.fn.proto.v1beta1.Target,oneof" json:"target,omitempty"` @@ -1204,22 +1203,23 @@ func (x *Result) GetTarget() Target { return Target_TARGET_UNSPECIFIED } -// A Status Condition to be applied to the Composite Resource and sometimes the -// Claim. For detailed information on proper usage of Conditions, please see +// Status condition to be applied to the composite resource. Condition may also +// optionally be applied to the composite resource's associated claim. For +// detailed information on proper usage of status conditions, please see // https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties. type Condition struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Type of condition in CamelCase or in foo.example.com/CamelCase. + // Type of condition in PascalCase. Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // Status of the condition. Status Status `protobuf:"varint,2,opt,name=status,proto3,enum=apiextensions.fn.proto.v1beta1.Status" json:"status,omitempty"` // Reason contains a programmatic identifier indicating the reason for the // condition's last transition. Producers of specific condition types may // define expected values and meanings for this field, and whether the values - // are considered a guaranteed API. The value should be a CamelCase string. + // are considered a guaranteed API. The value should be a PascalCase string. // This field may not be empty. Reason string `protobuf:"bytes,3,opt,name=reason,proto3" json:"reason,omitempty"` // Message is a human readable message indicating details about the @@ -1549,11 +1549,12 @@ var file_v1beta1_run_function_proto_rawDesc = []byte{ 0x69, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x66, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x75, 0x6e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x42, 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x72, 0x6f, 0x73, 0x73, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x66, 0x75, 0x6e, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x2d, 0x73, 0x64, 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x22, 0x00, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x63, 0x72, 0x6f, 0x73, 0x73, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x63, 0x72, 0x6f, 0x73, + 0x73, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x65, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x66, 0x6e, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/proto/v1beta1/run_function.proto b/proto/v1beta1/run_function.proto index c2eb741..52ab926 100644 --- a/proto/v1beta1/run_function.proto +++ b/proto/v1beta1/run_function.proto @@ -19,12 +19,11 @@ syntax = "proto3"; import "google/protobuf/struct.proto"; import "google/protobuf/duration.proto"; -// Note that the authoritative Composition Functions protobuf definition lives -// at the below URL. Each SDK maintains and manually syncs its own copy. -// https://github.com/crossplane/crossplane/tree/master/apis/apiextensions/fn/proto +// Generated from apiextensions/fn/proto/v1/run_function.proto by ../hack/duplicate_proto_type.sh. DO NOT EDIT. + package apiextensions.fn.proto.v1beta1; -option go_package = "github.com/crossplane/function-sdk-go/proto/v1beta1"; +option go_package = "github.com/crossplane/crossplane/apis/apiextensions/fn/proto/v1beta1"; // A FunctionRunnerService is a Composition Function. service FunctionRunnerService { @@ -125,8 +124,8 @@ message RunFunctionResponse { // Requirements that must be satisfied for this Function to run successfully. Requirements requirements = 5; - // Status Conditions to be applied to the Composite Resource and sometimes the - // Claim. + // Status conditions to be applied to the composite resource. Conditions may also + // optionally be applied to the composite resource's associated claim. repeated Condition conditions = 6; } @@ -251,7 +250,8 @@ message Result { // Human-readable details about the result. string message = 2; - // Optional PascalCase, machine-readable reason for this result. + // Optional PascalCase, machine-readable reason for this result. If omitted, + // the value will be ComposeResources. optional string reason = 3; // The resources this result targets. @@ -277,7 +277,7 @@ enum Severity { SEVERITY_NORMAL = 3; } -// Target of Function results. +// Target of Function results and conditions. enum Target { // If the target is unspecified, the result targets the composite resource. TARGET_UNSPECIFIED = 0; @@ -291,11 +291,12 @@ enum Target { TARGET_COMPOSITE_AND_CLAIM = 2; } -// A Status Condition to be applied to the Composite Resource and sometimes the -// Claim. For detailed information on proper usage of Conditions, please see +// Status condition to be applied to the composite resource. Condition may also +// optionally be applied to the composite resource's associated claim. For +// detailed information on proper usage of status conditions, please see // https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties. message Condition { - // Type of condition in CamelCase or in foo.example.com/CamelCase. + // Type of condition in PascalCase. string type = 1; // Status of the condition. @@ -304,7 +305,7 @@ message Condition { // Reason contains a programmatic identifier indicating the reason for the // condition's last transition. Producers of specific condition types may // define expected values and meanings for this field, and whether the values - // are considered a guaranteed API. The value should be a CamelCase string. + // are considered a guaranteed API. The value should be a PascalCase string. // This field may not be empty. string reason = 3; diff --git a/proto/v1beta1/run_function_grpc.pb.go b/proto/v1beta1/run_function_grpc.pb.go index 179469a..ac66b7f 100644 --- a/proto/v1beta1/run_function_grpc.pb.go +++ b/proto/v1beta1/run_function_grpc.pb.go @@ -19,9 +19,7 @@ // - protoc (unknown) // source: v1beta1/run_function.proto -// Note that the authoritative Composition Functions protobuf definition lives -// at the below URL. Each SDK maintains and manually syncs its own copy. -// https://github.com/crossplane/crossplane/tree/master/apis/apiextensions/fn/proto +// Generated from apiextensions/fn/proto/v1/run_function.proto by ../hack/duplicate_proto_type.sh. DO NOT EDIT. package v1beta1 diff --git a/request/request.go b/request/request.go index 569760a..db7687d 100644 --- a/request/request.go +++ b/request/request.go @@ -23,19 +23,19 @@ import ( "k8s.io/apimachinery/pkg/runtime" "github.com/crossplane/function-sdk-go/errors" - "github.com/crossplane/function-sdk-go/proto/v1beta1" + v1 "github.com/crossplane/function-sdk-go/proto/v1" "github.com/crossplane/function-sdk-go/resource" "github.com/crossplane/function-sdk-go/resource/composed" "github.com/crossplane/function-sdk-go/resource/composite" ) // GetInput from the supplied request. Input is loaded into the supplied object. -func GetInput(req *v1beta1.RunFunctionRequest, into runtime.Object) error { +func GetInput(req *v1.RunFunctionRequest, into runtime.Object) error { return errors.Wrapf(resource.AsObject(req.GetInput(), into), "cannot get function input %T from %T", into, req) } // GetContextKey gets context from the supplied key. -func GetContextKey(req *v1beta1.RunFunctionRequest, key string) (*structpb.Value, bool) { +func GetContextKey(req *v1.RunFunctionRequest, key string) (*structpb.Value, bool) { f := req.GetContext().GetFields() if f == nil { return nil, false @@ -45,7 +45,7 @@ func GetContextKey(req *v1beta1.RunFunctionRequest, key string) (*structpb.Value } // GetObservedCompositeResource from the supplied request. -func GetObservedCompositeResource(req *v1beta1.RunFunctionRequest) (*resource.Composite, error) { +func GetObservedCompositeResource(req *v1.RunFunctionRequest) (*resource.Composite, error) { xr := &resource.Composite{ Resource: composite.New(), ConnectionDetails: req.GetObserved().GetComposite().GetConnectionDetails(), @@ -60,7 +60,7 @@ func GetObservedCompositeResource(req *v1beta1.RunFunctionRequest) (*resource.Co } // GetObservedComposedResources from the supplied request. -func GetObservedComposedResources(req *v1beta1.RunFunctionRequest) (map[resource.Name]resource.ObservedComposed, error) { +func GetObservedComposedResources(req *v1.RunFunctionRequest) (map[resource.Name]resource.ObservedComposed, error) { ocds := map[resource.Name]resource.ObservedComposed{} for name, r := range req.GetObserved().GetResources() { ocd := resource.ObservedComposed{Resource: composed.New(), ConnectionDetails: r.GetConnectionDetails()} @@ -78,7 +78,7 @@ func GetObservedComposedResources(req *v1beta1.RunFunctionRequest) (map[resource } // GetDesiredCompositeResource from the supplied request. -func GetDesiredCompositeResource(req *v1beta1.RunFunctionRequest) (*resource.Composite, error) { +func GetDesiredCompositeResource(req *v1.RunFunctionRequest) (*resource.Composite, error) { xr := &resource.Composite{ Resource: composite.New(), ConnectionDetails: req.GetDesired().GetComposite().GetConnectionDetails(), @@ -93,7 +93,7 @@ func GetDesiredCompositeResource(req *v1beta1.RunFunctionRequest) (*resource.Com } // GetDesiredComposedResources from the supplied request. -func GetDesiredComposedResources(req *v1beta1.RunFunctionRequest) (map[resource.Name]*resource.DesiredComposed, error) { +func GetDesiredComposedResources(req *v1.RunFunctionRequest) (map[resource.Name]*resource.DesiredComposed, error) { dcds := map[resource.Name]*resource.DesiredComposed{} for name, r := range req.GetDesired().GetResources() { dcd := &resource.DesiredComposed{Resource: composed.New()} @@ -101,11 +101,11 @@ func GetDesiredComposedResources(req *v1beta1.RunFunctionRequest) (map[resource. return nil, err } switch r.GetReady() { - case v1beta1.Ready_READY_UNSPECIFIED: + case v1.Ready_READY_UNSPECIFIED: dcd.Ready = resource.ReadyUnspecified - case v1beta1.Ready_READY_TRUE: + case v1.Ready_READY_TRUE: dcd.Ready = resource.ReadyTrue - case v1beta1.Ready_READY_FALSE: + case v1.Ready_READY_FALSE: dcd.Ready = resource.ReadyFalse } dcds[resource.Name(name)] = dcd @@ -114,7 +114,7 @@ func GetDesiredComposedResources(req *v1beta1.RunFunctionRequest) (map[resource. } // GetExtraResources from the supplied request. -func GetExtraResources(req *v1beta1.RunFunctionRequest) (map[string][]resource.Extra, error) { +func GetExtraResources(req *v1.RunFunctionRequest) (map[string][]resource.Extra, error) { out := make(map[string][]resource.Extra, len(req.GetExtraResources())) for name, ers := range req.GetExtraResources() { out[name] = []resource.Extra{} @@ -130,14 +130,14 @@ func GetExtraResources(req *v1beta1.RunFunctionRequest) (map[string][]resource.E } // GetCredentials from the supplied request. -func GetCredentials(req *v1beta1.RunFunctionRequest, name string) (resource.Credentials, error) { +func GetCredentials(req *v1.RunFunctionRequest, name string) (resource.Credentials, error) { cred, exists := req.GetCredentials()[name] if !exists { return resource.Credentials{}, errors.Errorf("%s: credential not found", name) } switch t := cred.GetSource().(type) { - case *v1beta1.Credentials_CredentialData: + case *v1.Credentials_CredentialData: return resource.Credentials{Type: resource.CredentialsTypeData, Data: cred.GetCredentialData().GetData()}, nil default: return resource.Credentials{}, errors.Errorf("%s: not a supported credential source", t) diff --git a/request/request_test.go b/request/request_test.go index f081899..592c401 100644 --- a/request/request_test.go +++ b/request/request_test.go @@ -23,7 +23,7 @@ import ( "github.com/google/go-cmp/cmp" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "github.com/crossplane/function-sdk-go/proto/v1beta1" + v1 "github.com/crossplane/function-sdk-go/proto/v1" "github.com/crossplane/function-sdk-go/resource" "github.com/crossplane/function-sdk-go/resource/composed" "github.com/crossplane/function-sdk-go/resource/composite" @@ -37,12 +37,12 @@ func TestGetObservedCompositeResource(t *testing.T) { cases := map[string]struct { reason string - req *v1beta1.RunFunctionRequest + req *v1.RunFunctionRequest want want }{ "NoObservedXR": { reason: "In the unlikely event the request has no observed XR we should return a usable, empty Composite.", - req: &v1beta1.RunFunctionRequest{}, + req: &v1.RunFunctionRequest{}, want: want{ oxr: &resource.Composite{ Resource: composite.New(), @@ -52,9 +52,9 @@ func TestGetObservedCompositeResource(t *testing.T) { }, "ObservedXR": { reason: "We should return the XR read from the request.", - req: &v1beta1.RunFunctionRequest{ - Observed: &v1beta1.State{ - Composite: &v1beta1.Resource{ + req: &v1.RunFunctionRequest{ + Observed: &v1.State{ + Composite: &v1.Resource{ Resource: resource.MustStructJSON(`{ "apiVersion": "test.crossplane.io/v1", "kind": "XR" @@ -103,12 +103,12 @@ func TestGetDesiredCompositeResource(t *testing.T) { cases := map[string]struct { reason string - req *v1beta1.RunFunctionRequest + req *v1.RunFunctionRequest want want }{ "NoDesiredXR": { reason: "If the request has no desired XR we should return a usable, empty Composite.", - req: &v1beta1.RunFunctionRequest{}, + req: &v1.RunFunctionRequest{}, want: want{ oxr: &resource.Composite{ Resource: composite.New(), @@ -118,9 +118,9 @@ func TestGetDesiredCompositeResource(t *testing.T) { }, "DesiredXR": { reason: "We should return the XR read from the request.", - req: &v1beta1.RunFunctionRequest{ - Desired: &v1beta1.State{ - Composite: &v1beta1.Resource{ + req: &v1.RunFunctionRequest{ + Desired: &v1.State{ + Composite: &v1.Resource{ Resource: resource.MustStructJSON(`{ "apiVersion": "test.crossplane.io/v1", "kind": "XR" @@ -169,21 +169,21 @@ func TestGetObservedComposedResources(t *testing.T) { cases := map[string]struct { reason string - req *v1beta1.RunFunctionRequest + req *v1.RunFunctionRequest want want }{ "NoObservedComposedResources": { reason: "If the request has no observed composed resources we should return an empty, non-nil map.", - req: &v1beta1.RunFunctionRequest{}, + req: &v1.RunFunctionRequest{}, want: want{ ocds: map[resource.Name]resource.ObservedComposed{}, }, }, "ObservedComposedResources": { reason: "If the request has observed composed resources we should return them.", - req: &v1beta1.RunFunctionRequest{ - Observed: &v1beta1.State{ - Resources: map[string]*v1beta1.Resource{ + req: &v1.RunFunctionRequest{ + Observed: &v1.State{ + Resources: map[string]*v1.Resource{ "observed-composed-resource": { Resource: resource.MustStructJSON(`{ "apiVersion": "test.crossplane.io/v1", @@ -236,27 +236,27 @@ func TestGetDesiredComposedResources(t *testing.T) { cases := map[string]struct { reason string - req *v1beta1.RunFunctionRequest + req *v1.RunFunctionRequest want want }{ "NoDesiredComposedResources": { reason: "If the request has no desired composed resources we should return an empty, non-nil map.", - req: &v1beta1.RunFunctionRequest{}, + req: &v1.RunFunctionRequest{}, want: want{ dcds: map[resource.Name]*resource.DesiredComposed{}, }, }, "DesiredComposedResources": { reason: "If the request has desired composed resources we should return them.", - req: &v1beta1.RunFunctionRequest{ - Desired: &v1beta1.State{ - Resources: map[string]*v1beta1.Resource{ + req: &v1.RunFunctionRequest{ + Desired: &v1.State{ + Resources: map[string]*v1.Resource{ "desired-composed-resource": { Resource: resource.MustStructJSON(`{ "apiVersion": "test.crossplane.io/v1", "kind": "Composed" }`), - Ready: v1beta1.Ready_READY_TRUE, + Ready: v1.Ready_READY_TRUE, }, }, }, diff --git a/response/condition.go b/response/condition.go index 9d604c8..34f95cb 100644 --- a/response/condition.go +++ b/response/condition.go @@ -17,41 +17,41 @@ limitations under the License. package response import ( - "github.com/crossplane/function-sdk-go/proto/v1beta1" + v1 "github.com/crossplane/function-sdk-go/proto/v1" ) // ConditionOption allows further customization of the condition. type ConditionOption struct { - condition *v1beta1.Condition + condition *v1.Condition } // ConditionTrue will create a condition with the status of true and add the // condition to the supplied RunFunctionResponse. -func ConditionTrue(rsp *v1beta1.RunFunctionResponse, typ, reason string) *ConditionOption { - return newCondition(rsp, typ, reason, v1beta1.Status_STATUS_CONDITION_TRUE) +func ConditionTrue(rsp *v1.RunFunctionResponse, typ, reason string) *ConditionOption { + return newCondition(rsp, typ, reason, v1.Status_STATUS_CONDITION_TRUE) } // ConditionFalse will create a condition with the status of false and add the // condition to the supplied RunFunctionResponse. -func ConditionFalse(rsp *v1beta1.RunFunctionResponse, typ, reason string) *ConditionOption { - return newCondition(rsp, typ, reason, v1beta1.Status_STATUS_CONDITION_FALSE) +func ConditionFalse(rsp *v1.RunFunctionResponse, typ, reason string) *ConditionOption { + return newCondition(rsp, typ, reason, v1.Status_STATUS_CONDITION_FALSE) } // ConditionUnknown will create a condition with the status of unknown and add // the condition to the supplied RunFunctionResponse. -func ConditionUnknown(rsp *v1beta1.RunFunctionResponse, typ, reason string) *ConditionOption { - return newCondition(rsp, typ, reason, v1beta1.Status_STATUS_CONDITION_UNKNOWN) +func ConditionUnknown(rsp *v1.RunFunctionResponse, typ, reason string) *ConditionOption { + return newCondition(rsp, typ, reason, v1.Status_STATUS_CONDITION_UNKNOWN) } -func newCondition(rsp *v1beta1.RunFunctionResponse, typ, reason string, s v1beta1.Status) *ConditionOption { +func newCondition(rsp *v1.RunFunctionResponse, typ, reason string, s v1.Status) *ConditionOption { if rsp.GetConditions() == nil { - rsp.Conditions = make([]*v1beta1.Condition, 0, 1) + rsp.Conditions = make([]*v1.Condition, 0, 1) } - c := &v1beta1.Condition{ + c := &v1.Condition{ Type: typ, Status: s, Reason: reason, - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), } rsp.Conditions = append(rsp.GetConditions(), c) return &ConditionOption{condition: c} @@ -59,14 +59,14 @@ func newCondition(rsp *v1beta1.RunFunctionResponse, typ, reason string, s v1beta // TargetComposite updates the condition to target the composite resource. func (c *ConditionOption) TargetComposite() *ConditionOption { - c.condition.Target = v1beta1.Target_TARGET_COMPOSITE.Enum() + c.condition.Target = v1.Target_TARGET_COMPOSITE.Enum() return c } // TargetCompositeAndClaim updates the condition to target both the composite // resource and claim. func (c *ConditionOption) TargetCompositeAndClaim() *ConditionOption { - c.condition.Target = v1beta1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum() + c.condition.Target = v1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum() return c } diff --git a/response/condition_test.go b/response/condition_test.go index 60fca7c..e76f117 100644 --- a/response/condition_test.go +++ b/response/condition_test.go @@ -23,7 +23,7 @@ import ( "google.golang.org/protobuf/testing/protocmp" "k8s.io/utils/ptr" - "github.com/crossplane/function-sdk-go/proto/v1beta1" + v1 "github.com/crossplane/function-sdk-go/proto/v1" "github.com/crossplane/function-sdk-go/response" ) @@ -41,12 +41,12 @@ const ( ) func TestCondition(t *testing.T) { - type testFn func(*v1beta1.RunFunctionResponse) + type testFn func(*v1.RunFunctionResponse) type args struct { fns []testFn } type want struct { - conditions []*v1beta1.Condition + conditions []*v1.Condition } cases := map[string]struct { reason string @@ -57,36 +57,36 @@ func TestCondition(t *testing.T) { reason: "Correctly adds conditions to the response.", args: args{ fns: []testFn{ - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.ConditionTrue(rsp, typeDatabaseReady, reasonAvailable) }, - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.ConditionFalse(rsp, typeDatabaseReady, reasonCreating) }, - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.ConditionUnknown(rsp, typeDatabaseReady, reasonPriorFailure) }, }, }, want: want{ - conditions: []*v1beta1.Condition{ + conditions: []*v1.Condition{ { Type: typeDatabaseReady, - Status: v1beta1.Status_STATUS_CONDITION_TRUE, + Status: v1.Status_STATUS_CONDITION_TRUE, Reason: reasonAvailable, - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), }, { Type: typeDatabaseReady, - Status: v1beta1.Status_STATUS_CONDITION_FALSE, + Status: v1.Status_STATUS_CONDITION_FALSE, Reason: reasonCreating, - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), }, { Type: typeDatabaseReady, - Status: v1beta1.Status_STATUS_CONDITION_UNKNOWN, + Status: v1.Status_STATUS_CONDITION_UNKNOWN, Reason: reasonPriorFailure, - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), }, }, }, @@ -95,27 +95,27 @@ func TestCondition(t *testing.T) { reason: "Correctly sets targets on condition and adds it to the response.", args: args{ fns: []testFn{ - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.ConditionTrue(rsp, typeDatabaseReady, reasonAvailable).TargetComposite() }, - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.ConditionTrue(rsp, typeDatabaseReady, reasonAvailable).TargetCompositeAndClaim() }, }, }, want: want{ - conditions: []*v1beta1.Condition{ + conditions: []*v1.Condition{ { Type: typeDatabaseReady, - Status: v1beta1.Status_STATUS_CONDITION_TRUE, + Status: v1.Status_STATUS_CONDITION_TRUE, Reason: reasonAvailable, - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), }, { Type: typeDatabaseReady, - Status: v1beta1.Status_STATUS_CONDITION_TRUE, + Status: v1.Status_STATUS_CONDITION_TRUE, Reason: reasonAvailable, - Target: v1beta1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Target: v1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), }, }, }, @@ -124,18 +124,18 @@ func TestCondition(t *testing.T) { reason: "Correctly sets message on condition and adds it to the response.", args: args{ fns: []testFn{ - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.ConditionTrue(rsp, typeDatabaseReady, reasonAvailable).WithMessage("a test message") }, }, }, want: want{ - conditions: []*v1beta1.Condition{ + conditions: []*v1.Condition{ { Type: typeDatabaseReady, - Status: v1beta1.Status_STATUS_CONDITION_TRUE, + Status: v1.Status_STATUS_CONDITION_TRUE, Reason: reasonAvailable, - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), Message: ptr.To("a test message"), }, }, @@ -145,12 +145,12 @@ func TestCondition(t *testing.T) { reason: "Can chain condition options together.", args: args{ fns: []testFn{ - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.ConditionTrue(rsp, typeDatabaseReady, reasonAvailable). WithMessage("a test message"). TargetCompositeAndClaim() }, - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.ConditionTrue(rsp, typeDatabaseReady, reasonAvailable). TargetCompositeAndClaim(). WithMessage("a test message") @@ -158,19 +158,19 @@ func TestCondition(t *testing.T) { }, }, want: want{ - conditions: []*v1beta1.Condition{ + conditions: []*v1.Condition{ { Type: typeDatabaseReady, - Status: v1beta1.Status_STATUS_CONDITION_TRUE, + Status: v1.Status_STATUS_CONDITION_TRUE, Reason: reasonAvailable, - Target: v1beta1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Target: v1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), Message: ptr.To("a test message"), }, { Type: typeDatabaseReady, - Status: v1beta1.Status_STATUS_CONDITION_TRUE, + Status: v1.Status_STATUS_CONDITION_TRUE, Reason: reasonAvailable, - Target: v1beta1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Target: v1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), Message: ptr.To("a test message"), }, }, @@ -179,7 +179,7 @@ func TestCondition(t *testing.T) { } for name, tc := range cases { t.Run(name, func(t *testing.T) { - rsp := &v1beta1.RunFunctionResponse{} + rsp := &v1.RunFunctionResponse{} for _, f := range tc.args.fns { f(rsp) } diff --git a/response/response.go b/response/response.go index 7d5913e..a4b590a 100644 --- a/response/response.go +++ b/response/response.go @@ -24,7 +24,7 @@ import ( "google.golang.org/protobuf/types/known/structpb" "github.com/crossplane/function-sdk-go/errors" - "github.com/crossplane/function-sdk-go/proto/v1beta1" + v1 "github.com/crossplane/function-sdk-go/proto/v1" "github.com/crossplane/function-sdk-go/resource" ) @@ -33,9 +33,9 @@ const DefaultTTL = 1 * time.Minute // To bootstraps a response to the supplied request. It automatically copies the // desired state from the request. -func To(req *v1beta1.RunFunctionRequest, ttl time.Duration) *v1beta1.RunFunctionResponse { - return &v1beta1.RunFunctionResponse{ - Meta: &v1beta1.ResponseMeta{ +func To(req *v1.RunFunctionRequest, ttl time.Duration) *v1.RunFunctionResponse { + return &v1.RunFunctionResponse{ + Meta: &v1.ResponseMeta{ Tag: req.GetMeta().GetTag(), Ttl: durationpb.New(ttl), }, @@ -45,7 +45,7 @@ func To(req *v1beta1.RunFunctionRequest, ttl time.Duration) *v1beta1.RunFunction } // SetContextKey sets context to the supplied key. -func SetContextKey(rsp *v1beta1.RunFunctionResponse, key string, v *structpb.Value) { +func SetContextKey(rsp *v1.RunFunctionResponse, key string, v *structpb.Value) { if rsp.GetContext().GetFields() == nil { rsp.Context = &structpb.Struct{Fields: make(map[string]*structpb.Value)} } @@ -56,12 +56,12 @@ func SetContextKey(rsp *v1beta1.RunFunctionResponse, key string, v *structpb.Val // supplied response. The caller must be sure to avoid overwriting the desired // state that may have been accumulated by previous Functions in the pipeline, // unless they intend to. -func SetDesiredCompositeResource(rsp *v1beta1.RunFunctionResponse, xr *resource.Composite) error { +func SetDesiredCompositeResource(rsp *v1.RunFunctionResponse, xr *resource.Composite) error { if rsp.GetDesired() == nil { - rsp.Desired = &v1beta1.State{} + rsp.Desired = &v1.State{} } s, err := resource.AsStruct(xr.Resource) - rsp.Desired.Composite = &v1beta1.Resource{Resource: s, ConnectionDetails: xr.ConnectionDetails} + rsp.Desired.Composite = &v1.Resource{Resource: s, ConnectionDetails: xr.ConnectionDetails} return errors.Wrapf(err, "cannot convert %T to desired composite resource", xr.Resource) } @@ -69,26 +69,26 @@ func SetDesiredCompositeResource(rsp *v1beta1.RunFunctionResponse, xr *resource. // supplied response. The caller must be sure to avoid overwriting the desired // state that may have been accumulated by previous Functions in the pipeline, // unless they intend to. -func SetDesiredComposedResources(rsp *v1beta1.RunFunctionResponse, dcds map[resource.Name]*resource.DesiredComposed) error { +func SetDesiredComposedResources(rsp *v1.RunFunctionResponse, dcds map[resource.Name]*resource.DesiredComposed) error { if rsp.GetDesired() == nil { - rsp.Desired = &v1beta1.State{} + rsp.Desired = &v1.State{} } if rsp.GetDesired().GetResources() == nil { - rsp.Desired.Resources = map[string]*v1beta1.Resource{} + rsp.Desired.Resources = map[string]*v1.Resource{} } for name, dcd := range dcds { s, err := resource.AsStruct(dcd.Resource) if err != nil { return err } - r := &v1beta1.Resource{Resource: s} + r := &v1.Resource{Resource: s} switch dcd.Ready { case resource.ReadyUnspecified: - r.Ready = v1beta1.Ready_READY_UNSPECIFIED + r.Ready = v1.Ready_READY_UNSPECIFIED case resource.ReadyFalse: - r.Ready = v1beta1.Ready_READY_FALSE + r.Ready = v1.Ready_READY_FALSE case resource.ReadyTrue: - r.Ready = v1beta1.Ready_READY_TRUE + r.Ready = v1.Ready_READY_TRUE } rsp.Desired.Resources[string(name)] = r } diff --git a/response/result.go b/response/result.go index e2cac99..7313965 100644 --- a/response/result.go +++ b/response/result.go @@ -20,48 +20,48 @@ package response import ( "fmt" - "github.com/crossplane/function-sdk-go/proto/v1beta1" + v1 "github.com/crossplane/function-sdk-go/proto/v1" ) // ResultOption allows further customization of the result. type ResultOption struct { - result *v1beta1.Result + result *v1.Result } // Fatal adds a fatal result to the supplied RunFunctionResponse. // An event will be created for the Composite Resource. // A fatal result cannot target the claim. -func Fatal(rsp *v1beta1.RunFunctionResponse, err error) { - newResult(rsp, v1beta1.Severity_SEVERITY_FATAL, err.Error()) +func Fatal(rsp *v1.RunFunctionResponse, err error) { + newResult(rsp, v1.Severity_SEVERITY_FATAL, err.Error()) } // Warning adds a warning result to the supplied RunFunctionResponse. // An event will be created for the Composite Resource. -func Warning(rsp *v1beta1.RunFunctionResponse, err error) *ResultOption { - return newResult(rsp, v1beta1.Severity_SEVERITY_WARNING, err.Error()) +func Warning(rsp *v1.RunFunctionResponse, err error) *ResultOption { + return newResult(rsp, v1.Severity_SEVERITY_WARNING, err.Error()) } // Normal adds a normal result to the supplied RunFunctionResponse. // An event will be created for the Composite Resource. -func Normal(rsp *v1beta1.RunFunctionResponse, message string) *ResultOption { - return newResult(rsp, v1beta1.Severity_SEVERITY_NORMAL, message) +func Normal(rsp *v1.RunFunctionResponse, message string) *ResultOption { + return newResult(rsp, v1.Severity_SEVERITY_NORMAL, message) } // Normalf adds a normal result to the supplied RunFunctionResponse. // An event will be created for the Composite Resource. -func Normalf(rsp *v1beta1.RunFunctionResponse, format string, a ...any) *ResultOption { +func Normalf(rsp *v1.RunFunctionResponse, format string, a ...any) *ResultOption { return Normal(rsp, fmt.Sprintf(format, a...)) } -func newResult(rsp *v1beta1.RunFunctionResponse, s v1beta1.Severity, message string) *ResultOption { +func newResult(rsp *v1.RunFunctionResponse, s v1.Severity, message string) *ResultOption { if rsp.GetResults() == nil { - rsp.Results = make([]*v1beta1.Result, 0, 1) + rsp.Results = make([]*v1.Result, 0, 1) } - r := &v1beta1.Result{ + r := &v1.Result{ Severity: s, Message: message, - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), } rsp.Results = append(rsp.GetResults(), r) @@ -71,14 +71,14 @@ func newResult(rsp *v1beta1.RunFunctionResponse, s v1beta1.Severity, message str // TargetComposite updates the result and its event to target the composite // resource. func (o *ResultOption) TargetComposite() *ResultOption { - o.result.Target = v1beta1.Target_TARGET_COMPOSITE.Enum() + o.result.Target = v1.Target_TARGET_COMPOSITE.Enum() return o } // TargetCompositeAndClaim updates the result and its event to target both the // composite resource and claim. func (o *ResultOption) TargetCompositeAndClaim() *ResultOption { - o.result.Target = v1beta1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum() + o.result.Target = v1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum() return o } diff --git a/response/result_test.go b/response/result_test.go index fed8315..49cc900 100644 --- a/response/result_test.go +++ b/response/result_test.go @@ -24,17 +24,17 @@ import ( "google.golang.org/protobuf/testing/protocmp" "k8s.io/utils/ptr" - "github.com/crossplane/function-sdk-go/proto/v1beta1" + v1 "github.com/crossplane/function-sdk-go/proto/v1" "github.com/crossplane/function-sdk-go/response" ) func TestResult(t *testing.T) { - type testFn func(*v1beta1.RunFunctionResponse) + type testFn func(*v1.RunFunctionResponse) type args struct { fns []testFn } type want struct { - results []*v1beta1.Result + results []*v1.Result } cases := map[string]struct { reason string @@ -45,41 +45,41 @@ func TestResult(t *testing.T) { reason: "Correctly adds results to the response.", args: args{ fns: []testFn{ - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.Normal(rsp, "this is a test normal result") }, - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.Normalf(rsp, "this is a test normal %s result", "formatted") }, - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.Warning(rsp, errors.New("this is a test warning result")) }, - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.Fatal(rsp, errors.New("this is a test fatal result")) }, }, }, want: want{ - results: []*v1beta1.Result{ + results: []*v1.Result{ { - Severity: v1beta1.Severity_SEVERITY_NORMAL, + Severity: v1.Severity_SEVERITY_NORMAL, Message: "this is a test normal result", - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), }, { - Severity: v1beta1.Severity_SEVERITY_NORMAL, + Severity: v1.Severity_SEVERITY_NORMAL, Message: "this is a test normal formatted result", - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), }, { - Severity: v1beta1.Severity_SEVERITY_WARNING, + Severity: v1.Severity_SEVERITY_WARNING, Message: "this is a test warning result", - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), }, { - Severity: v1beta1.Severity_SEVERITY_FATAL, + Severity: v1.Severity_SEVERITY_FATAL, Message: "this is a test fatal result", - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), }, }, }, @@ -88,25 +88,25 @@ func TestResult(t *testing.T) { reason: "Correctly sets targets on result and adds it to the response.", args: args{ fns: []testFn{ - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.Warning(rsp, errors.New("this is a test warning result targeting the composite")).TargetComposite() }, - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.Warning(rsp, errors.New("this is a test fatal result targeting both")).TargetCompositeAndClaim() }, }, }, want: want{ - results: []*v1beta1.Result{ + results: []*v1.Result{ { - Severity: v1beta1.Severity_SEVERITY_WARNING, + Severity: v1.Severity_SEVERITY_WARNING, Message: "this is a test warning result targeting the composite", - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), }, { - Severity: v1beta1.Severity_SEVERITY_WARNING, + Severity: v1.Severity_SEVERITY_WARNING, Message: "this is a test fatal result targeting both", - Target: v1beta1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Target: v1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), }, }, }, @@ -115,26 +115,26 @@ func TestResult(t *testing.T) { reason: "Correctly sets reason on result and adds it to the response.", args: args{ fns: []testFn{ - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.Normal(rsp, "this is a test normal result targeting the composite").WithReason("TestReason") }, - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.Warning(rsp, errors.New("this is a test warning result targeting the composite")).WithReason("TestReason") }, }, }, want: want{ - results: []*v1beta1.Result{ + results: []*v1.Result{ { - Severity: v1beta1.Severity_SEVERITY_NORMAL, + Severity: v1.Severity_SEVERITY_NORMAL, Message: "this is a test normal result targeting the composite", - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), Reason: ptr.To("TestReason"), }, { - Severity: v1beta1.Severity_SEVERITY_WARNING, + Severity: v1.Severity_SEVERITY_WARNING, Message: "this is a test warning result targeting the composite", - Target: v1beta1.Target_TARGET_COMPOSITE.Enum(), + Target: v1.Target_TARGET_COMPOSITE.Enum(), Reason: ptr.To("TestReason"), }, }, @@ -144,12 +144,12 @@ func TestResult(t *testing.T) { reason: "Can chain result options together.", args: args{ fns: []testFn{ - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.Normal(rsp, "this is a test normal result targeting the composite and claim"). WithReason("TestReason"). TargetCompositeAndClaim() }, - func(rsp *v1beta1.RunFunctionResponse) { + func(rsp *v1.RunFunctionResponse) { response.Warning(rsp, errors.New("this is a test warning result targeting the composite and claim")). TargetCompositeAndClaim(). WithReason("TestReason") @@ -157,17 +157,17 @@ func TestResult(t *testing.T) { }, }, want: want{ - results: []*v1beta1.Result{ + results: []*v1.Result{ { - Severity: v1beta1.Severity_SEVERITY_NORMAL, + Severity: v1.Severity_SEVERITY_NORMAL, Message: "this is a test normal result targeting the composite and claim", - Target: v1beta1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Target: v1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), Reason: ptr.To("TestReason"), }, { - Severity: v1beta1.Severity_SEVERITY_WARNING, + Severity: v1.Severity_SEVERITY_WARNING, Message: "this is a test warning result targeting the composite and claim", - Target: v1beta1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Target: v1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), Reason: ptr.To("TestReason"), }, }, @@ -176,7 +176,7 @@ func TestResult(t *testing.T) { } for name, tc := range cases { t.Run(name, func(t *testing.T) { - rsp := &v1beta1.RunFunctionResponse{} + rsp := &v1.RunFunctionResponse{} for _, f := range tc.args.fns { f(rsp) } diff --git a/sdk.go b/sdk.go index 0b20a59..9d124ef 100644 --- a/sdk.go +++ b/sdk.go @@ -18,6 +18,7 @@ limitations under the License. package function import ( + "context" "crypto/tls" "crypto/x509" "net" @@ -29,8 +30,10 @@ import ( "google.golang.org/grpc/credentials" ginsecure "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/reflection" + "google.golang.org/protobuf/proto" "github.com/crossplane/function-sdk-go/logging" + v1 "github.com/crossplane/function-sdk-go/proto/v1" "github.com/crossplane/function-sdk-go/proto/v1beta1" ) @@ -127,7 +130,7 @@ func MaxRecvMessageSize(sz int) ServeOption { // Serve the supplied Function by creating a gRPC server and listening for // RunFunctionRequests. Blocks until the server returns an error. -func Serve(fn v1beta1.FunctionRunnerServiceServer, o ...ServeOption) error { +func Serve(fn v1.FunctionRunnerServiceServer, o ...ServeOption) error { so := &ServeOptions{ Network: DefaultNetwork, Address: DefaultAddress, @@ -151,7 +154,8 @@ func Serve(fn v1beta1.FunctionRunnerServiceServer, o ...ServeOption) error { srv := grpc.NewServer(grpc.MaxRecvMsgSize(so.MaxRecvMsgSize), grpc.Creds(so.Credentials)) reflection.Register(srv) - v1beta1.RegisterFunctionRunnerServiceServer(srv, fn) + v1.RegisterFunctionRunnerServiceServer(srv, fn) + v1beta1.RegisterFunctionRunnerServiceServer(srv, ServeBeta(fn)) return errors.Wrap(srv.Serve(lis), "cannot serve mTLS gRPC connections") } @@ -159,3 +163,55 @@ func Serve(fn v1beta1.FunctionRunnerServiceServer, o ...ServeOption) error { func NewLogger(debug bool) (logging.Logger, error) { return logging.NewLogger(debug) } + +// A BetaServer is a v1beta1 FunctionRunnerServiceServer that wraps an identical +// v1 FunctionRunnerServiceServer. This requires the v1 and v1beta1 protos to be +// identical. +// +// Functions were promoted from v1beta1 to v1 in Crossplane v1.17. Crossplane +// v1.16 and earlier only sends v1beta1 RunFunctionRequests. Functions should +// use the BetaServer for backward compatibility, to support Crossplane v1.16 +// and earlier. +type BetaServer struct { + wrapped v1.FunctionRunnerServiceServer + + v1beta1.UnimplementedFunctionRunnerServiceServer +} + +// ServeBeta returns a v1beta1.FunctionRunnerServiceServer that wraps the +// suppled v1.FunctionRunnerServiceServer. +func ServeBeta(s v1.FunctionRunnerServiceServer) *BetaServer { + return &BetaServer{wrapped: s} +} + +// RunFunction calls the RunFunction method of the wrapped +// v1.FunctionRunnerServiceServer. It converts from v1beta1 to v1 and back by +// round-tripping through protobuf marshaling. +func (s *BetaServer) RunFunction(ctx context.Context, req *v1beta1.RunFunctionRequest) (*v1beta1.RunFunctionResponse, error) { + gareq := &v1.RunFunctionRequest{} + + b, err := proto.Marshal(req) + if err != nil { + return nil, errors.Wrap(err, "cannot marshal v1beta1 RunFunctionRequest to protobuf bytes") + } + + if err := proto.Unmarshal(b, gareq); err != nil { + return nil, errors.Wrap(err, "cannot unmarshal v1 RunFunctionRequest from v1beta1 protobuf bytes") + } + + garsp, err := s.wrapped.RunFunction(ctx, gareq) + if err != nil { + // This error is intentionally not wrapped. This middleware is just + // calling an underlying RunFunction. + return nil, err + } + + b, err = proto.Marshal(garsp) + if err != nil { + return nil, errors.Wrap(err, "cannot marshal v1beta1 RunFunctionResponse to protobuf bytes") + } + + rsp := &v1beta1.RunFunctionResponse{} + err = proto.Unmarshal(b, rsp) + return rsp, errors.Wrap(err, "cannot unmarshal v1 RunFunctionResponse from v1beta1 protobuf bytes") +} diff --git a/sdk_test.go b/sdk_test.go index 0c9f657..d8994e0 100644 --- a/sdk_test.go +++ b/sdk_test.go @@ -17,10 +17,17 @@ limitations under the License. package function import ( + "context" "fmt" + "testing" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/testing/protocmp" + "github.com/crossplane/function-sdk-go/errors" + v1 "github.com/crossplane/function-sdk-go/proto/v1" "github.com/crossplane/function-sdk-go/proto/v1beta1" "github.com/crossplane/function-sdk-go/request" "github.com/crossplane/function-sdk-go/resource" @@ -28,9 +35,11 @@ import ( "github.com/crossplane/function-sdk-go/response" ) -var req = &v1beta1.RunFunctionRequest{ - Observed: &v1beta1.State{ - Composite: &v1beta1.Resource{ +var _ v1beta1.FunctionRunnerServiceServer = &BetaServer{} + +var req = &v1.RunFunctionRequest{ + Observed: &v1.State{ + Composite: &v1.Resource{ Resource: resource.MustStructJSON(`{"spec":{"widgets":9001}}`), }, }, @@ -61,7 +70,7 @@ func Example() { desired["new"].Resource.SetInteger("spec.widgets", widgets) // Create a desired composed resource using structured data. - // db, _ := composed.From(&v1beta1.Instance{}) + // db, _ := composed.From(&v1.Instance{}) // desired["database"] = &resource.DesiredComposed{Resource: db} // Add a label to our new desired resource, and any other. @@ -78,3 +87,86 @@ func Example() { // Output: // {"meta":{"ttl":"60s"},"desired":{"resources":{"new":{"resource":{"apiVersion":"example.org/v1","kind":"CoolResource","metadata":{"labels":{"coolness":"high"}},"spec":{"widgets":9001}}}}}} } + +func TestBetaServer(t *testing.T) { + type args struct { + ctx context.Context + req *v1beta1.RunFunctionRequest + } + type want struct { + rsp *v1beta1.RunFunctionResponse + err error + } + + cases := map[string]struct { + reason string + wrapped v1.FunctionRunnerServiceServer + args args + want want + }{ + "RunFunctionError": { + reason: "We should return any error the wrapped server encounters", + wrapped: &MockFunctionServer{err: errors.New("boom")}, + args: args{ + req: &v1beta1.RunFunctionRequest{ + Meta: &v1beta1.RequestMeta{ + Tag: "hi", + }, + }, + }, + want: want{ + err: cmpopts.AnyError, + }, + }, + "Success": { + reason: "We should return the response the wrapped server returns", + wrapped: &MockFunctionServer{ + rsp: &v1.RunFunctionResponse{ + Meta: &v1.ResponseMeta{ + Tag: "hello", + }, + }, + }, + args: args{ + req: &v1beta1.RunFunctionRequest{ + Meta: &v1beta1.RequestMeta{ + Tag: "hi", + }, + }, + }, + want: want{ + rsp: &v1beta1.RunFunctionResponse{ + Meta: &v1beta1.ResponseMeta{ + Tag: "hello", + }, + }, + }, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + s := ServeBeta(tc.wrapped) + rsp, err := s.RunFunction(tc.args.ctx, tc.args.req) + + if diff := cmp.Diff(tc.want.rsp, rsp, protocmp.Transform()); diff != "" { + t.Errorf("\n%s\ns.RunFunction(...): -want rsp, +got rsp:\n%s", tc.reason, diff) + } + if diff := cmp.Diff(tc.want.err, err, cmpopts.EquateErrors()); diff != "" { + t.Errorf("\n%s\ns.RunFunction(...): -want err, +got err:\n%s", tc.reason, diff) + } + }) + } + +} + +type MockFunctionServer struct { + v1.UnimplementedFunctionRunnerServiceServer + + rsp *v1.RunFunctionResponse + err error +} + +func (s *MockFunctionServer) RunFunction(context.Context, *v1.RunFunctionRequest) (*v1.RunFunctionResponse, error) { + return s.rsp, s.err +}