Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion crossplane/function/proto/v1/run_function.proto
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ message RunFunctionRequest {
// satisfy the request. This field is only populated when the function uses
// resources in its requirements.
map<string, Resources> required_resources = 8;

// Optional schemas that the function specified in its requirements. The map
// key corresponds to the key in a RunFunctionResponse's requirements.schemas
// field. If a function requested a schema that could not be found, Crossplane
// sets the map key to an empty Schema message to indicate that it attempted
// to satisfy the request.
map<string, Schema> required_schemas = 9;
}

// Credentials that a function may use to communicate with an external system.
Expand Down Expand Up @@ -169,6 +176,27 @@ message Requirements {
// Resources that this function requires. The map key uniquely identifies the
// group of resources.
map<string, ResourceSelector> resources = 2;

// Schemas that this function requires. The map key uniquely identifies the
// schema request.
map<string, SchemaSelector> schemas = 3;
}

// SchemaSelector identifies a resource kind whose OpenAPI schema is requested.
message SchemaSelector {
// API version of the resource kind, e.g. "example.org/v1".
string api_version = 1;

// Kind of resource, e.g. "MyResource".
string kind = 2;
}

// Schema represents the OpenAPI schema for a resource kind.
message Schema {
// The OpenAPI v3 schema of the resource kind as unstructured JSON.
// For CRDs this is the spec.versions[].schema.openAPIV3Schema field.
// Empty if Crossplane could not find a schema for the requested kind.
optional google.protobuf.Struct openapi_v3 = 1;
}

// ResourceSelector selects a group of resources, either by name or by label.
Expand Down Expand Up @@ -367,4 +395,4 @@ enum Status {
STATUS_CONDITION_TRUE = 2;

STATUS_CONDITION_FALSE = 3;
}
}
124 changes: 68 additions & 56 deletions crossplane/function/proto/v1/run_function_pb2.py

Large diffs are not rendered by default.

40 changes: 36 additions & 4 deletions crossplane/function/proto/v1/run_function_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ STATUS_CONDITION_TRUE: Status
STATUS_CONDITION_FALSE: Status

class RunFunctionRequest(_message.Message):
__slots__ = ("meta", "observed", "desired", "input", "context", "extra_resources", "credentials", "required_resources")
__slots__ = ("meta", "observed", "desired", "input", "context", "extra_resources", "credentials", "required_resources", "required_schemas")
class ExtraResourcesEntry(_message.Message):
__slots__ = ("key", "value")
KEY_FIELD_NUMBER: _ClassVar[int]
Expand All @@ -74,6 +74,13 @@ class RunFunctionRequest(_message.Message):
key: str
value: Resources
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[Resources, _Mapping]] = ...) -> None: ...
class RequiredSchemasEntry(_message.Message):
__slots__ = ("key", "value")
KEY_FIELD_NUMBER: _ClassVar[int]
VALUE_FIELD_NUMBER: _ClassVar[int]
key: str
value: Schema
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[Schema, _Mapping]] = ...) -> None: ...
META_FIELD_NUMBER: _ClassVar[int]
OBSERVED_FIELD_NUMBER: _ClassVar[int]
DESIRED_FIELD_NUMBER: _ClassVar[int]
Expand All @@ -82,6 +89,7 @@ class RunFunctionRequest(_message.Message):
EXTRA_RESOURCES_FIELD_NUMBER: _ClassVar[int]
CREDENTIALS_FIELD_NUMBER: _ClassVar[int]
REQUIRED_RESOURCES_FIELD_NUMBER: _ClassVar[int]
REQUIRED_SCHEMAS_FIELD_NUMBER: _ClassVar[int]
meta: RequestMeta
observed: State
desired: State
Expand All @@ -90,7 +98,8 @@ class RunFunctionRequest(_message.Message):
extra_resources: _containers.MessageMap[str, Resources]
credentials: _containers.MessageMap[str, Credentials]
required_resources: _containers.MessageMap[str, Resources]
def __init__(self, meta: _Optional[_Union[RequestMeta, _Mapping]] = ..., observed: _Optional[_Union[State, _Mapping]] = ..., desired: _Optional[_Union[State, _Mapping]] = ..., input: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., context: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., extra_resources: _Optional[_Mapping[str, Resources]] = ..., credentials: _Optional[_Mapping[str, Credentials]] = ..., required_resources: _Optional[_Mapping[str, Resources]] = ...) -> None: ...
required_schemas: _containers.MessageMap[str, Schema]
def __init__(self, meta: _Optional[_Union[RequestMeta, _Mapping]] = ..., observed: _Optional[_Union[State, _Mapping]] = ..., desired: _Optional[_Union[State, _Mapping]] = ..., input: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., context: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., extra_resources: _Optional[_Mapping[str, Resources]] = ..., credentials: _Optional[_Mapping[str, Credentials]] = ..., required_resources: _Optional[_Mapping[str, Resources]] = ..., required_schemas: _Optional[_Mapping[str, Schema]] = ...) -> None: ...

class Credentials(_message.Message):
__slots__ = ("credential_data",)
Expand Down Expand Up @@ -142,7 +151,7 @@ class RequestMeta(_message.Message):
def __init__(self, tag: _Optional[str] = ...) -> None: ...

class Requirements(_message.Message):
__slots__ = ("extra_resources", "resources")
__slots__ = ("extra_resources", "resources", "schemas")
class ExtraResourcesEntry(_message.Message):
__slots__ = ("key", "value")
KEY_FIELD_NUMBER: _ClassVar[int]
Expand All @@ -157,11 +166,34 @@ class Requirements(_message.Message):
key: str
value: ResourceSelector
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[ResourceSelector, _Mapping]] = ...) -> None: ...
class SchemasEntry(_message.Message):
__slots__ = ("key", "value")
KEY_FIELD_NUMBER: _ClassVar[int]
VALUE_FIELD_NUMBER: _ClassVar[int]
key: str
value: SchemaSelector
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[SchemaSelector, _Mapping]] = ...) -> None: ...
EXTRA_RESOURCES_FIELD_NUMBER: _ClassVar[int]
RESOURCES_FIELD_NUMBER: _ClassVar[int]
SCHEMAS_FIELD_NUMBER: _ClassVar[int]
extra_resources: _containers.MessageMap[str, ResourceSelector]
resources: _containers.MessageMap[str, ResourceSelector]
def __init__(self, extra_resources: _Optional[_Mapping[str, ResourceSelector]] = ..., resources: _Optional[_Mapping[str, ResourceSelector]] = ...) -> None: ...
schemas: _containers.MessageMap[str, SchemaSelector]
def __init__(self, extra_resources: _Optional[_Mapping[str, ResourceSelector]] = ..., resources: _Optional[_Mapping[str, ResourceSelector]] = ..., schemas: _Optional[_Mapping[str, SchemaSelector]] = ...) -> None: ...

class SchemaSelector(_message.Message):
__slots__ = ("api_version", "kind")
API_VERSION_FIELD_NUMBER: _ClassVar[int]
KIND_FIELD_NUMBER: _ClassVar[int]
api_version: str
kind: str
def __init__(self, api_version: _Optional[str] = ..., kind: _Optional[str] = ...) -> None: ...

class Schema(_message.Message):
__slots__ = ("openapi_v3",)
OPENAPI_V3_FIELD_NUMBER: _ClassVar[int]
openapi_v3: _struct_pb2.Struct
def __init__(self, openapi_v3: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ...) -> None: ...

class ResourceSelector(_message.Message):
__slots__ = ("api_version", "kind", "match_name", "match_labels", "namespace")
Expand Down
28 changes: 28 additions & 0 deletions crossplane/function/proto/v1beta1/run_function.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ message RunFunctionRequest {
// satisfy the request. This field is only populated when the function uses
// resources in its requirements.
map<string, Resources> required_resources = 8;

// Optional schemas that the function specified in its requirements. The map
// key corresponds to the key in a RunFunctionResponse's requirements.schemas
// field. If a function requested a schema that could not be found, Crossplane
// sets the map key to an empty Schema message to indicate that it attempted
// to satisfy the request.
map<string, Schema> required_schemas = 9;
}

// Credentials that a function may use to communicate with an external system.
Expand Down Expand Up @@ -171,6 +178,27 @@ message Requirements {
// Resources that this function requires. The map key uniquely identifies the
// group of resources.
map<string, ResourceSelector> resources = 2;

// Schemas that this function requires. The map key uniquely identifies the
// schema request.
map<string, SchemaSelector> schemas = 3;
}

// SchemaSelector identifies a resource kind whose OpenAPI schema is requested.
message SchemaSelector {
// API version of the resource kind, e.g. "example.org/v1".
string api_version = 1;

// Kind of resource, e.g. "MyResource".
string kind = 2;
}

// Schema represents the OpenAPI schema for a resource kind.
message Schema {
// The OpenAPI v3 schema of the resource kind as unstructured JSON.
// For CRDs this is the spec.versions[].schema.openAPIV3Schema field.
// Empty if Crossplane could not find a schema for the requested kind.
optional google.protobuf.Struct openapi_v3 = 1;
}

// ResourceSelector selects a group of resources, either by name or by label.
Expand Down
Loading