crossplane-function-sdk-python 0.1.0__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- crossplane/function/__version__.py +1 -1
- crossplane/function/proto/v1beta1/run_function.proto +58 -1
- crossplane/function/proto/v1beta1/run_function_pb2.py +61 -28
- crossplane/function/proto/v1beta1/run_function_pb2.pyi +96 -13
- crossplane/function/resource.py +21 -0
- crossplane/function/runtime.py +3 -1
- {crossplane_function_sdk_python-0.1.0.dist-info → crossplane_function_sdk_python-0.3.0.dist-info}/METADATA +15 -7
- crossplane_function_sdk_python-0.3.0.dist-info/RECORD +13 -0
- {crossplane_function_sdk_python-0.1.0.dist-info → crossplane_function_sdk_python-0.3.0.dist-info}/WHEEL +1 -1
- crossplane_function_sdk_python-0.1.0.dist-info/RECORD +0 -13
- {crossplane_function_sdk_python-0.1.0.dist-info → crossplane_function_sdk_python-0.3.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -61,6 +61,37 @@ message RunFunctionRequest {
|
|
|
61
61
|
// and that context will be passed to subsequent Functions. Crossplane
|
|
62
62
|
// discards all context returned by the last Function in the pipeline.
|
|
63
63
|
optional google.protobuf.Struct context = 5;
|
|
64
|
+
|
|
65
|
+
// Optional extra resources that the Function required.
|
|
66
|
+
// Note that extra resources is a map to Resources, plural.
|
|
67
|
+
// The map key corresponds to the key in a RunFunctionResponse's
|
|
68
|
+
// extra_resources field. If a Function requested extra resources that
|
|
69
|
+
// did not exist, Crossplane sets the map key to an empty Resources message to
|
|
70
|
+
// indicate that it attempted to satisfy the request.
|
|
71
|
+
map<string, Resources> extra_resources = 6;
|
|
72
|
+
|
|
73
|
+
// Optional credentials that this Function may use to communicate with an
|
|
74
|
+
// external system.
|
|
75
|
+
map <string, Credentials> credentials = 7;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Credentials that a Function may use to communicate with an external system.
|
|
79
|
+
message Credentials {
|
|
80
|
+
// Source of the credentials.
|
|
81
|
+
oneof source {
|
|
82
|
+
// Credential data loaded by Crossplane, for example from a Secret.
|
|
83
|
+
CredentialData credential_data = 1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// CredentialData loaded by Crossplane, for example from a Secret.
|
|
88
|
+
message CredentialData {
|
|
89
|
+
map<string, bytes> data = 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Resources represents the state of several Crossplane resources.
|
|
93
|
+
message Resources {
|
|
94
|
+
repeated Resource items = 1;
|
|
64
95
|
}
|
|
65
96
|
|
|
66
97
|
// A RunFunctionResponse contains the result of a Composition Function run.
|
|
@@ -88,6 +119,9 @@ message RunFunctionResponse {
|
|
|
88
119
|
// Optional context to be passed to the next Function in the pipeline as part
|
|
89
120
|
// of the RunFunctionRequest. Dropped on the last function in the pipeline.
|
|
90
121
|
optional google.protobuf.Struct context = 4;
|
|
122
|
+
|
|
123
|
+
// Requirements that must be satisfied for this Function to run successfully.
|
|
124
|
+
Requirements requirements = 5;
|
|
91
125
|
}
|
|
92
126
|
|
|
93
127
|
// RequestMeta contains metadata pertaining to a RunFunctionRequest.
|
|
@@ -97,6 +131,29 @@ message RequestMeta {
|
|
|
97
131
|
string tag = 1;
|
|
98
132
|
}
|
|
99
133
|
|
|
134
|
+
// Requirements that must be satisfied for a Function to run successfully.
|
|
135
|
+
message Requirements {
|
|
136
|
+
// Extra resources that this Function requires.
|
|
137
|
+
// The map key uniquely identifies the group of resources.
|
|
138
|
+
map<string, ResourceSelector> extra_resources = 1;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// ResourceSelector selects a group of resources, either by name or by label.
|
|
142
|
+
message ResourceSelector {
|
|
143
|
+
string api_version = 1;
|
|
144
|
+
string kind = 2;
|
|
145
|
+
|
|
146
|
+
oneof match {
|
|
147
|
+
string match_name = 3;
|
|
148
|
+
MatchLabels match_labels = 4;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// MatchLabels defines a set of labels to match resources against.
|
|
153
|
+
message MatchLabels {
|
|
154
|
+
map<string, string> labels = 1;
|
|
155
|
+
}
|
|
156
|
+
|
|
100
157
|
// ResponseMeta contains metadata pertaining to a RunFunctionResponse.
|
|
101
158
|
message ResponseMeta {
|
|
102
159
|
// An opaque string identifying the content of the request. Must match the
|
|
@@ -199,4 +256,4 @@ enum Severity {
|
|
|
199
256
|
// Normal results are emitted as normal events and debug logs associated
|
|
200
257
|
// with the composite resource.
|
|
201
258
|
SEVERITY_NORMAL = 3;
|
|
202
|
-
}
|
|
259
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# source: crossplane/function/proto/v1beta1/run_function.proto
|
|
4
|
+
# Protobuf Python Version: 4.25.1
|
|
4
5
|
"""Generated protocol buffer code."""
|
|
5
6
|
from google.protobuf import descriptor as _descriptor
|
|
6
7
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -15,39 +16,71 @@ from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2
|
|
|
15
16
|
from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n4crossplane/function/proto/v1beta1/run_function.proto\x12\x1e\x61piextensions.fn.proto.v1beta1\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1egoogle/protobuf/duration.proto\"\
|
|
19
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n4crossplane/function/proto/v1beta1/run_function.proto\x12\x1e\x61piextensions.fn.proto.v1beta1\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1egoogle/protobuf/duration.proto\"\xb0\x05\n\x12RunFunctionRequest\x12\x39\n\x04meta\x18\x01 \x01(\x0b\x32+.apiextensions.fn.proto.v1beta1.RequestMeta\x12\x37\n\x08observed\x18\x02 \x01(\x0b\x32%.apiextensions.fn.proto.v1beta1.State\x12\x36\n\x07\x64\x65sired\x18\x03 \x01(\x0b\x32%.apiextensions.fn.proto.v1beta1.State\x12+\n\x05input\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructH\x00\x88\x01\x01\x12-\n\x07\x63ontext\x18\x05 \x01(\x0b\x32\x17.google.protobuf.StructH\x01\x88\x01\x01\x12_\n\x0f\x65xtra_resources\x18\x06 \x03(\x0b\x32\x46.apiextensions.fn.proto.v1beta1.RunFunctionRequest.ExtraResourcesEntry\x12X\n\x0b\x63redentials\x18\x07 \x03(\x0b\x32\x43.apiextensions.fn.proto.v1beta1.RunFunctionRequest.CredentialsEntry\x1a`\n\x13\x45xtraResourcesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x38\n\x05value\x18\x02 \x01(\x0b\x32).apiextensions.fn.proto.v1beta1.Resources:\x02\x38\x01\x1a_\n\x10\x43redentialsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12:\n\x05value\x18\x02 \x01(\x0b\x32+.apiextensions.fn.proto.v1beta1.Credentials:\x02\x38\x01\x42\x08\n\x06_inputB\n\n\x08_context\"b\n\x0b\x43redentials\x12I\n\x0f\x63redential_data\x18\x01 \x01(\x0b\x32..apiextensions.fn.proto.v1beta1.CredentialDataH\x00\x42\x08\n\x06source\"\x85\x01\n\x0e\x43redentialData\x12\x46\n\x04\x64\x61ta\x18\x01 \x03(\x0b\x32\x38.apiextensions.fn.proto.v1beta1.CredentialData.DataEntry\x1a+\n\tDataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c:\x02\x38\x01\"D\n\tResources\x12\x37\n\x05items\x18\x01 \x03(\x0b\x32(.apiextensions.fn.proto.v1beta1.Resource\"\xc1\x02\n\x13RunFunctionResponse\x12:\n\x04meta\x18\x01 \x01(\x0b\x32,.apiextensions.fn.proto.v1beta1.ResponseMeta\x12\x36\n\x07\x64\x65sired\x18\x02 \x01(\x0b\x32%.apiextensions.fn.proto.v1beta1.State\x12\x37\n\x07results\x18\x03 \x03(\x0b\x32&.apiextensions.fn.proto.v1beta1.Result\x12-\n\x07\x63ontext\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructH\x00\x88\x01\x01\x12\x42\n\x0crequirements\x18\x05 \x01(\x0b\x32,.apiextensions.fn.proto.v1beta1.RequirementsB\n\n\x08_context\"\x1a\n\x0bRequestMeta\x12\x0b\n\x03tag\x18\x01 \x01(\t\"\xd2\x01\n\x0cRequirements\x12Y\n\x0f\x65xtra_resources\x18\x01 \x03(\x0b\x32@.apiextensions.fn.proto.v1beta1.Requirements.ExtraResourcesEntry\x1ag\n\x13\x45xtraResourcesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12?\n\x05value\x18\x02 \x01(\x0b\x32\x30.apiextensions.fn.proto.v1beta1.ResourceSelector:\x02\x38\x01\"\x99\x01\n\x10ResourceSelector\x12\x13\n\x0b\x61pi_version\x18\x01 \x01(\t\x12\x0c\n\x04kind\x18\x02 \x01(\t\x12\x14\n\nmatch_name\x18\x03 \x01(\tH\x00\x12\x43\n\x0cmatch_labels\x18\x04 \x01(\x0b\x32+.apiextensions.fn.proto.v1beta1.MatchLabelsH\x00\x42\x07\n\x05match\"\x85\x01\n\x0bMatchLabels\x12G\n\x06labels\x18\x01 \x03(\x0b\x32\x37.apiextensions.fn.proto.v1beta1.MatchLabels.LabelsEntry\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"P\n\x0cResponseMeta\x12\x0b\n\x03tag\x18\x01 \x01(\t\x12+\n\x03ttl\x18\x02 \x01(\x0b\x32\x19.google.protobuf.DurationH\x00\x88\x01\x01\x42\x06\n\x04_ttl\"\xe9\x01\n\x05State\x12;\n\tcomposite\x18\x01 \x01(\x0b\x32(.apiextensions.fn.proto.v1beta1.Resource\x12G\n\tresources\x18\x02 \x03(\x0b\x32\x34.apiextensions.fn.proto.v1beta1.State.ResourcesEntry\x1aZ\n\x0eResourcesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x37\n\x05value\x18\x02 \x01(\x0b\x32(.apiextensions.fn.proto.v1beta1.Resource:\x02\x38\x01\"\x82\x02\n\x08Resource\x12)\n\x08resource\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\x12[\n\x12\x63onnection_details\x18\x02 \x03(\x0b\x32?.apiextensions.fn.proto.v1beta1.Resource.ConnectionDetailsEntry\x12\x34\n\x05ready\x18\x03 \x01(\x0e\x32%.apiextensions.fn.proto.v1beta1.Ready\x1a\x38\n\x16\x43onnectionDetailsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c:\x02\x38\x01\"U\n\x06Result\x12:\n\x08severity\x18\x01 \x01(\x0e\x32(.apiextensions.fn.proto.v1beta1.Severity\x12\x0f\n\x07message\x18\x02 \x01(\t*?\n\x05Ready\x12\x15\n\x11READY_UNSPECIFIED\x10\x00\x12\x0e\n\nREADY_TRUE\x10\x01\x12\x0f\n\x0bREADY_FALSE\x10\x02*c\n\x08Severity\x12\x18\n\x14SEVERITY_UNSPECIFIED\x10\x00\x12\x12\n\x0eSEVERITY_FATAL\x10\x01\x12\x14\n\x10SEVERITY_WARNING\x10\x02\x12\x13\n\x0fSEVERITY_NORMAL\x10\x03\x32\x91\x01\n\x15\x46unctionRunnerService\x12x\n\x0bRunFunction\x12\x32.apiextensions.fn.proto.v1beta1.RunFunctionRequest\x1a\x33.apiextensions.fn.proto.v1beta1.RunFunctionResponse\"\x00\x62\x06proto3')
|
|
19
20
|
|
|
20
21
|
_globals = globals()
|
|
21
22
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
22
23
|
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'crossplane.function.proto.v1beta1.run_function_pb2', _globals)
|
|
23
24
|
if _descriptor._USE_C_DESCRIPTORS == False:
|
|
24
25
|
DESCRIPTOR._options = None
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
_globals['
|
|
30
|
-
_globals['
|
|
31
|
-
_globals['
|
|
32
|
-
_globals['
|
|
26
|
+
_globals['_RUNFUNCTIONREQUEST_EXTRARESOURCESENTRY']._options = None
|
|
27
|
+
_globals['_RUNFUNCTIONREQUEST_EXTRARESOURCESENTRY']._serialized_options = b'8\001'
|
|
28
|
+
_globals['_RUNFUNCTIONREQUEST_CREDENTIALSENTRY']._options = None
|
|
29
|
+
_globals['_RUNFUNCTIONREQUEST_CREDENTIALSENTRY']._serialized_options = b'8\001'
|
|
30
|
+
_globals['_CREDENTIALDATA_DATAENTRY']._options = None
|
|
31
|
+
_globals['_CREDENTIALDATA_DATAENTRY']._serialized_options = b'8\001'
|
|
32
|
+
_globals['_REQUIREMENTS_EXTRARESOURCESENTRY']._options = None
|
|
33
|
+
_globals['_REQUIREMENTS_EXTRARESOURCESENTRY']._serialized_options = b'8\001'
|
|
34
|
+
_globals['_MATCHLABELS_LABELSENTRY']._options = None
|
|
35
|
+
_globals['_MATCHLABELS_LABELSENTRY']._serialized_options = b'8\001'
|
|
36
|
+
_globals['_STATE_RESOURCESENTRY']._options = None
|
|
37
|
+
_globals['_STATE_RESOURCESENTRY']._serialized_options = b'8\001'
|
|
38
|
+
_globals['_RESOURCE_CONNECTIONDETAILSENTRY']._options = None
|
|
39
|
+
_globals['_RESOURCE_CONNECTIONDETAILSENTRY']._serialized_options = b'8\001'
|
|
40
|
+
_globals['_READY']._serialized_start=2670
|
|
41
|
+
_globals['_READY']._serialized_end=2733
|
|
42
|
+
_globals['_SEVERITY']._serialized_start=2735
|
|
43
|
+
_globals['_SEVERITY']._serialized_end=2834
|
|
33
44
|
_globals['_RUNFUNCTIONREQUEST']._serialized_start=151
|
|
34
|
-
_globals['_RUNFUNCTIONREQUEST']._serialized_end=
|
|
35
|
-
_globals['
|
|
36
|
-
_globals['
|
|
37
|
-
_globals['
|
|
38
|
-
_globals['
|
|
39
|
-
_globals['
|
|
40
|
-
_globals['
|
|
41
|
-
_globals['
|
|
42
|
-
_globals['
|
|
43
|
-
_globals['
|
|
44
|
-
_globals['
|
|
45
|
-
_globals['
|
|
46
|
-
_globals['
|
|
47
|
-
_globals['
|
|
48
|
-
_globals['
|
|
49
|
-
_globals['
|
|
50
|
-
_globals['
|
|
51
|
-
_globals['
|
|
52
|
-
_globals['
|
|
45
|
+
_globals['_RUNFUNCTIONREQUEST']._serialized_end=839
|
|
46
|
+
_globals['_RUNFUNCTIONREQUEST_EXTRARESOURCESENTRY']._serialized_start=624
|
|
47
|
+
_globals['_RUNFUNCTIONREQUEST_EXTRARESOURCESENTRY']._serialized_end=720
|
|
48
|
+
_globals['_RUNFUNCTIONREQUEST_CREDENTIALSENTRY']._serialized_start=722
|
|
49
|
+
_globals['_RUNFUNCTIONREQUEST_CREDENTIALSENTRY']._serialized_end=817
|
|
50
|
+
_globals['_CREDENTIALS']._serialized_start=841
|
|
51
|
+
_globals['_CREDENTIALS']._serialized_end=939
|
|
52
|
+
_globals['_CREDENTIALDATA']._serialized_start=942
|
|
53
|
+
_globals['_CREDENTIALDATA']._serialized_end=1075
|
|
54
|
+
_globals['_CREDENTIALDATA_DATAENTRY']._serialized_start=1032
|
|
55
|
+
_globals['_CREDENTIALDATA_DATAENTRY']._serialized_end=1075
|
|
56
|
+
_globals['_RESOURCES']._serialized_start=1077
|
|
57
|
+
_globals['_RESOURCES']._serialized_end=1145
|
|
58
|
+
_globals['_RUNFUNCTIONRESPONSE']._serialized_start=1148
|
|
59
|
+
_globals['_RUNFUNCTIONRESPONSE']._serialized_end=1469
|
|
60
|
+
_globals['_REQUESTMETA']._serialized_start=1471
|
|
61
|
+
_globals['_REQUESTMETA']._serialized_end=1497
|
|
62
|
+
_globals['_REQUIREMENTS']._serialized_start=1500
|
|
63
|
+
_globals['_REQUIREMENTS']._serialized_end=1710
|
|
64
|
+
_globals['_REQUIREMENTS_EXTRARESOURCESENTRY']._serialized_start=1607
|
|
65
|
+
_globals['_REQUIREMENTS_EXTRARESOURCESENTRY']._serialized_end=1710
|
|
66
|
+
_globals['_RESOURCESELECTOR']._serialized_start=1713
|
|
67
|
+
_globals['_RESOURCESELECTOR']._serialized_end=1866
|
|
68
|
+
_globals['_MATCHLABELS']._serialized_start=1869
|
|
69
|
+
_globals['_MATCHLABELS']._serialized_end=2002
|
|
70
|
+
_globals['_MATCHLABELS_LABELSENTRY']._serialized_start=1957
|
|
71
|
+
_globals['_MATCHLABELS_LABELSENTRY']._serialized_end=2002
|
|
72
|
+
_globals['_RESPONSEMETA']._serialized_start=2004
|
|
73
|
+
_globals['_RESPONSEMETA']._serialized_end=2084
|
|
74
|
+
_globals['_STATE']._serialized_start=2087
|
|
75
|
+
_globals['_STATE']._serialized_end=2320
|
|
76
|
+
_globals['_STATE_RESOURCESENTRY']._serialized_start=2230
|
|
77
|
+
_globals['_STATE_RESOURCESENTRY']._serialized_end=2320
|
|
78
|
+
_globals['_RESOURCE']._serialized_start=2323
|
|
79
|
+
_globals['_RESOURCE']._serialized_end=2581
|
|
80
|
+
_globals['_RESOURCE_CONNECTIONDETAILSENTRY']._serialized_start=2525
|
|
81
|
+
_globals['_RESOURCE_CONNECTIONDETAILSENTRY']._serialized_end=2581
|
|
82
|
+
_globals['_RESULT']._serialized_start=2583
|
|
83
|
+
_globals['_RESULT']._serialized_end=2668
|
|
84
|
+
_globals['_FUNCTIONRUNNERSERVICE']._serialized_start=2837
|
|
85
|
+
_globals['_FUNCTIONRUNNERSERVICE']._serialized_end=2982
|
|
53
86
|
# @@protoc_insertion_point(module_scope)
|
|
@@ -9,13 +9,13 @@ from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Map
|
|
|
9
9
|
DESCRIPTOR: _descriptor.FileDescriptor
|
|
10
10
|
|
|
11
11
|
class Ready(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
|
12
|
-
__slots__ =
|
|
12
|
+
__slots__ = ()
|
|
13
13
|
READY_UNSPECIFIED: _ClassVar[Ready]
|
|
14
14
|
READY_TRUE: _ClassVar[Ready]
|
|
15
15
|
READY_FALSE: _ClassVar[Ready]
|
|
16
16
|
|
|
17
17
|
class Severity(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
|
18
|
-
__slots__ =
|
|
18
|
+
__slots__ = ()
|
|
19
19
|
SEVERITY_UNSPECIFIED: _ClassVar[Severity]
|
|
20
20
|
SEVERITY_FATAL: _ClassVar[Severity]
|
|
21
21
|
SEVERITY_WARNING: _ClassVar[Severity]
|
|
@@ -29,39 +29,122 @@ SEVERITY_WARNING: Severity
|
|
|
29
29
|
SEVERITY_NORMAL: Severity
|
|
30
30
|
|
|
31
31
|
class RunFunctionRequest(_message.Message):
|
|
32
|
-
__slots__ =
|
|
32
|
+
__slots__ = ("meta", "observed", "desired", "input", "context", "extra_resources", "credentials")
|
|
33
|
+
class ExtraResourcesEntry(_message.Message):
|
|
34
|
+
__slots__ = ("key", "value")
|
|
35
|
+
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
36
|
+
VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
37
|
+
key: str
|
|
38
|
+
value: Resources
|
|
39
|
+
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[Resources, _Mapping]] = ...) -> None: ...
|
|
40
|
+
class CredentialsEntry(_message.Message):
|
|
41
|
+
__slots__ = ("key", "value")
|
|
42
|
+
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
43
|
+
VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
44
|
+
key: str
|
|
45
|
+
value: Credentials
|
|
46
|
+
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[Credentials, _Mapping]] = ...) -> None: ...
|
|
33
47
|
META_FIELD_NUMBER: _ClassVar[int]
|
|
34
48
|
OBSERVED_FIELD_NUMBER: _ClassVar[int]
|
|
35
49
|
DESIRED_FIELD_NUMBER: _ClassVar[int]
|
|
36
50
|
INPUT_FIELD_NUMBER: _ClassVar[int]
|
|
37
51
|
CONTEXT_FIELD_NUMBER: _ClassVar[int]
|
|
52
|
+
EXTRA_RESOURCES_FIELD_NUMBER: _ClassVar[int]
|
|
53
|
+
CREDENTIALS_FIELD_NUMBER: _ClassVar[int]
|
|
38
54
|
meta: RequestMeta
|
|
39
55
|
observed: State
|
|
40
56
|
desired: State
|
|
41
57
|
input: _struct_pb2.Struct
|
|
42
58
|
context: _struct_pb2.Struct
|
|
43
|
-
|
|
59
|
+
extra_resources: _containers.MessageMap[str, Resources]
|
|
60
|
+
credentials: _containers.MessageMap[str, Credentials]
|
|
61
|
+
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]] = ...) -> None: ...
|
|
62
|
+
|
|
63
|
+
class Credentials(_message.Message):
|
|
64
|
+
__slots__ = ("credential_data",)
|
|
65
|
+
CREDENTIAL_DATA_FIELD_NUMBER: _ClassVar[int]
|
|
66
|
+
credential_data: CredentialData
|
|
67
|
+
def __init__(self, credential_data: _Optional[_Union[CredentialData, _Mapping]] = ...) -> None: ...
|
|
68
|
+
|
|
69
|
+
class CredentialData(_message.Message):
|
|
70
|
+
__slots__ = ("data",)
|
|
71
|
+
class DataEntry(_message.Message):
|
|
72
|
+
__slots__ = ("key", "value")
|
|
73
|
+
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
74
|
+
VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
75
|
+
key: str
|
|
76
|
+
value: bytes
|
|
77
|
+
def __init__(self, key: _Optional[str] = ..., value: _Optional[bytes] = ...) -> None: ...
|
|
78
|
+
DATA_FIELD_NUMBER: _ClassVar[int]
|
|
79
|
+
data: _containers.ScalarMap[str, bytes]
|
|
80
|
+
def __init__(self, data: _Optional[_Mapping[str, bytes]] = ...) -> None: ...
|
|
81
|
+
|
|
82
|
+
class Resources(_message.Message):
|
|
83
|
+
__slots__ = ("items",)
|
|
84
|
+
ITEMS_FIELD_NUMBER: _ClassVar[int]
|
|
85
|
+
items: _containers.RepeatedCompositeFieldContainer[Resource]
|
|
86
|
+
def __init__(self, items: _Optional[_Iterable[_Union[Resource, _Mapping]]] = ...) -> None: ...
|
|
44
87
|
|
|
45
88
|
class RunFunctionResponse(_message.Message):
|
|
46
|
-
__slots__ =
|
|
89
|
+
__slots__ = ("meta", "desired", "results", "context", "requirements")
|
|
47
90
|
META_FIELD_NUMBER: _ClassVar[int]
|
|
48
91
|
DESIRED_FIELD_NUMBER: _ClassVar[int]
|
|
49
92
|
RESULTS_FIELD_NUMBER: _ClassVar[int]
|
|
50
93
|
CONTEXT_FIELD_NUMBER: _ClassVar[int]
|
|
94
|
+
REQUIREMENTS_FIELD_NUMBER: _ClassVar[int]
|
|
51
95
|
meta: ResponseMeta
|
|
52
96
|
desired: State
|
|
53
97
|
results: _containers.RepeatedCompositeFieldContainer[Result]
|
|
54
98
|
context: _struct_pb2.Struct
|
|
55
|
-
|
|
99
|
+
requirements: Requirements
|
|
100
|
+
def __init__(self, meta: _Optional[_Union[ResponseMeta, _Mapping]] = ..., desired: _Optional[_Union[State, _Mapping]] = ..., results: _Optional[_Iterable[_Union[Result, _Mapping]]] = ..., context: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., requirements: _Optional[_Union[Requirements, _Mapping]] = ...) -> None: ...
|
|
56
101
|
|
|
57
102
|
class RequestMeta(_message.Message):
|
|
58
|
-
__slots__ =
|
|
103
|
+
__slots__ = ("tag",)
|
|
59
104
|
TAG_FIELD_NUMBER: _ClassVar[int]
|
|
60
105
|
tag: str
|
|
61
106
|
def __init__(self, tag: _Optional[str] = ...) -> None: ...
|
|
62
107
|
|
|
108
|
+
class Requirements(_message.Message):
|
|
109
|
+
__slots__ = ("extra_resources",)
|
|
110
|
+
class ExtraResourcesEntry(_message.Message):
|
|
111
|
+
__slots__ = ("key", "value")
|
|
112
|
+
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
113
|
+
VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
114
|
+
key: str
|
|
115
|
+
value: ResourceSelector
|
|
116
|
+
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[ResourceSelector, _Mapping]] = ...) -> None: ...
|
|
117
|
+
EXTRA_RESOURCES_FIELD_NUMBER: _ClassVar[int]
|
|
118
|
+
extra_resources: _containers.MessageMap[str, ResourceSelector]
|
|
119
|
+
def __init__(self, extra_resources: _Optional[_Mapping[str, ResourceSelector]] = ...) -> None: ...
|
|
120
|
+
|
|
121
|
+
class ResourceSelector(_message.Message):
|
|
122
|
+
__slots__ = ("api_version", "kind", "match_name", "match_labels")
|
|
123
|
+
API_VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
124
|
+
KIND_FIELD_NUMBER: _ClassVar[int]
|
|
125
|
+
MATCH_NAME_FIELD_NUMBER: _ClassVar[int]
|
|
126
|
+
MATCH_LABELS_FIELD_NUMBER: _ClassVar[int]
|
|
127
|
+
api_version: str
|
|
128
|
+
kind: str
|
|
129
|
+
match_name: str
|
|
130
|
+
match_labels: MatchLabels
|
|
131
|
+
def __init__(self, api_version: _Optional[str] = ..., kind: _Optional[str] = ..., match_name: _Optional[str] = ..., match_labels: _Optional[_Union[MatchLabels, _Mapping]] = ...) -> None: ...
|
|
132
|
+
|
|
133
|
+
class MatchLabels(_message.Message):
|
|
134
|
+
__slots__ = ("labels",)
|
|
135
|
+
class LabelsEntry(_message.Message):
|
|
136
|
+
__slots__ = ("key", "value")
|
|
137
|
+
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
138
|
+
VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
139
|
+
key: str
|
|
140
|
+
value: str
|
|
141
|
+
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
|
|
142
|
+
LABELS_FIELD_NUMBER: _ClassVar[int]
|
|
143
|
+
labels: _containers.ScalarMap[str, str]
|
|
144
|
+
def __init__(self, labels: _Optional[_Mapping[str, str]] = ...) -> None: ...
|
|
145
|
+
|
|
63
146
|
class ResponseMeta(_message.Message):
|
|
64
|
-
__slots__ =
|
|
147
|
+
__slots__ = ("tag", "ttl")
|
|
65
148
|
TAG_FIELD_NUMBER: _ClassVar[int]
|
|
66
149
|
TTL_FIELD_NUMBER: _ClassVar[int]
|
|
67
150
|
tag: str
|
|
@@ -69,9 +152,9 @@ class ResponseMeta(_message.Message):
|
|
|
69
152
|
def __init__(self, tag: _Optional[str] = ..., ttl: _Optional[_Union[_duration_pb2.Duration, _Mapping]] = ...) -> None: ...
|
|
70
153
|
|
|
71
154
|
class State(_message.Message):
|
|
72
|
-
__slots__ =
|
|
155
|
+
__slots__ = ("composite", "resources")
|
|
73
156
|
class ResourcesEntry(_message.Message):
|
|
74
|
-
__slots__ =
|
|
157
|
+
__slots__ = ("key", "value")
|
|
75
158
|
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
76
159
|
VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
77
160
|
key: str
|
|
@@ -84,9 +167,9 @@ class State(_message.Message):
|
|
|
84
167
|
def __init__(self, composite: _Optional[_Union[Resource, _Mapping]] = ..., resources: _Optional[_Mapping[str, Resource]] = ...) -> None: ...
|
|
85
168
|
|
|
86
169
|
class Resource(_message.Message):
|
|
87
|
-
__slots__ =
|
|
170
|
+
__slots__ = ("resource", "connection_details", "ready")
|
|
88
171
|
class ConnectionDetailsEntry(_message.Message):
|
|
89
|
-
__slots__ =
|
|
172
|
+
__slots__ = ("key", "value")
|
|
90
173
|
KEY_FIELD_NUMBER: _ClassVar[int]
|
|
91
174
|
VALUE_FIELD_NUMBER: _ClassVar[int]
|
|
92
175
|
key: str
|
|
@@ -101,7 +184,7 @@ class Resource(_message.Message):
|
|
|
101
184
|
def __init__(self, resource: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., connection_details: _Optional[_Mapping[str, bytes]] = ..., ready: _Optional[_Union[Ready, str]] = ...) -> None: ...
|
|
102
185
|
|
|
103
186
|
class Result(_message.Message):
|
|
104
|
-
__slots__ =
|
|
187
|
+
__slots__ = ("severity", "message")
|
|
105
188
|
SEVERITY_FIELD_NUMBER: _ClassVar[int]
|
|
106
189
|
MESSAGE_FIELD_NUMBER: _ClassVar[int]
|
|
107
190
|
severity: Severity
|
crossplane/function/resource.py
CHANGED
|
@@ -106,3 +106,24 @@ def get_condition(resource: structpb.Struct, typ: str) -> Condition:
|
|
|
106
106
|
return condition
|
|
107
107
|
|
|
108
108
|
return unknown
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@dataclasses.dataclass
|
|
112
|
+
class Credentials:
|
|
113
|
+
"""Credentials."""
|
|
114
|
+
|
|
115
|
+
type: str
|
|
116
|
+
data: dict
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def get_credentials(req: structpb.Struct, name: str) -> Credentials:
|
|
120
|
+
"""Get the supplied credentials."""
|
|
121
|
+
empty = Credentials(type="data", data={})
|
|
122
|
+
if "credentials" not in req:
|
|
123
|
+
return empty
|
|
124
|
+
if name not in req["credentials"]:
|
|
125
|
+
return empty
|
|
126
|
+
return Credentials(
|
|
127
|
+
type=req["credentials"][name]["type"],
|
|
128
|
+
data=struct_to_dict(req["credentials"][name]["data"]),
|
|
129
|
+
)
|
crossplane/function/runtime.py
CHANGED
|
@@ -82,6 +82,9 @@ def serve(
|
|
|
82
82
|
If insecure is true requests will be served insecurely, even if credentials
|
|
83
83
|
are supplied.
|
|
84
84
|
"""
|
|
85
|
+
# Define the loop before the server so everything uses the same loop.
|
|
86
|
+
loop = asyncio.get_event_loop()
|
|
87
|
+
|
|
85
88
|
server = grpc.aio.server()
|
|
86
89
|
|
|
87
90
|
grpcv1beta1.add_FunctionRunnerServiceServicer_to_server(function, server)
|
|
@@ -104,7 +107,6 @@ def serve(
|
|
|
104
107
|
await server.start()
|
|
105
108
|
await server.wait_for_termination()
|
|
106
109
|
|
|
107
|
-
loop = asyncio.get_event_loop()
|
|
108
110
|
try:
|
|
109
111
|
loop.run_until_complete(start())
|
|
110
112
|
finally:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: crossplane-function-sdk-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: The Python SDK for Crossplane composition functions
|
|
5
5
|
Project-URL: Documentation, https://github.com/crossplane/function-sdk-python#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/crossplane/function-sdk-python/issues
|
|
@@ -14,11 +14,12 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
14
14
|
Requires-Python: >=3.11
|
|
15
15
|
Requires-Dist: grpcio-reflection==1.*
|
|
16
16
|
Requires-Dist: grpcio==1.*
|
|
17
|
-
Requires-Dist: structlog==
|
|
17
|
+
Requires-Dist: structlog==24.*
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
|
|
20
20
|
# function-sdk-python
|
|
21
|
-
[](https://github.com/crossplane/function-sdk-python/actions/workflows/ci.yml) 
|
|
21
|
+
[](https://github.com/crossplane/function-sdk-python/actions/workflows/ci.yml) [](https://github.com/crossplane/function-sdk-python/releases) [](https://pypi.org/project/crossplane-function-sdk-python/)
|
|
22
|
+
|
|
22
23
|
|
|
23
24
|
The [Python][python] SDK for writing [composition functions][functions].
|
|
24
25
|
|
|
@@ -28,14 +29,18 @@ guidelines] as Crossplane.
|
|
|
28
29
|
|
|
29
30
|
To learn how to use this SDK:
|
|
30
31
|
|
|
32
|
+
* [Follow the guide to writing a composition function in Python][function guide]
|
|
31
33
|
* [Learn about how composition functions work][functions]
|
|
32
|
-
* [
|
|
34
|
+
* [Read the package documentation][package docs]
|
|
33
35
|
|
|
34
36
|
The `RunFunctionRequest` and `RunFunctionResponse` types provided by this SDK
|
|
35
37
|
are generated from a proto3 protocol buffer schema. Their fields behave
|
|
36
38
|
similarly to built-in Python types like lists and dictionaries, but there are
|
|
37
|
-
some differences. Read the generated code documentation to
|
|
38
|
-
with the the differences.
|
|
39
|
+
some differences. Read the [generated code documentation][python-protobuf] to
|
|
40
|
+
familiarize yourself with the the differences.
|
|
41
|
+
|
|
42
|
+
If you just want to jump in and get started, consider using the
|
|
43
|
+
[function-template-python] template repository.
|
|
39
44
|
|
|
40
45
|
## Contributing
|
|
41
46
|
|
|
@@ -61,5 +66,8 @@ hatch build
|
|
|
61
66
|
[python]: https://python.org
|
|
62
67
|
[functions]: https://docs.crossplane.io/latest/concepts/composition-functions
|
|
63
68
|
[python-protobuf]: https://protobuf.dev/reference/python/python-generated/
|
|
69
|
+
[function-template-python]: https://github.com/crossplane/function-template-python
|
|
70
|
+
[function guide]: https://docs.crossplane.io/knowledge-base/guides/write-a-composition-function-in-python
|
|
71
|
+
[package docs]: https://crossplane.github.io/function-sdk-python
|
|
64
72
|
[contributing guidelines]: https://github.com/crossplane/crossplane/tree/master/contributing
|
|
65
73
|
[hatch]: https://github.com/pypa/hatch
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
crossplane/function/__version__.py,sha256=tqA7NsKI87Qs9KuV6_27-GU8EBOe0-jcyYictk-vtqM,704
|
|
2
|
+
crossplane/function/logging.py,sha256=Zawqq36FBzjkVg4bJ3VGK12-so7N8yAMoSPrhdwpBSA,2503
|
|
3
|
+
crossplane/function/resource.py,sha256=41u-aZ6TZB0cBMMU8JABPR0PSqevLJLh_rWvXOkbn1c,3759
|
|
4
|
+
crossplane/function/response.py,sha256=fYJcPz5ZVN06hbNWXzy0tBTOMHNYQvj3m9JjWb2qRU8,2429
|
|
5
|
+
crossplane/function/runtime.py,sha256=7-fWdxK__vbEjy6jQTnoYxtCa_bax50-qJXZP5Fz3nM,3505
|
|
6
|
+
crossplane/function/proto/v1beta1/run_function.proto,sha256=hDZgaavZ_NAAZH0OBDMJjGKpUCptQeFORviIqVXO_tA,9841
|
|
7
|
+
crossplane/function/proto/v1beta1/run_function_pb2.py,sha256=wVTF4w88n6TYgmZvVHE_AcB06HtHGqmCsOxH_fW9guI,9136
|
|
8
|
+
crossplane/function/proto/v1beta1/run_function_pb2.pyi,sha256=xitztFrrlLvArYum_uaNV_WZNGjcb8FT0hdHOx6K3e0,8901
|
|
9
|
+
crossplane/function/proto/v1beta1/run_function_pb2_grpc.py,sha256=iLQTF8CHQzjZlBGJUJTWPTfNSmm3ew02zGf6OPIsxVY,3026
|
|
10
|
+
crossplane_function_sdk_python-0.3.0.dist-info/METADATA,sha256=JmN799wI7T6k3oxFWoPAS46ywnfEKDLsTnsJEvI7U48,3160
|
|
11
|
+
crossplane_function_sdk_python-0.3.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
12
|
+
crossplane_function_sdk_python-0.3.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
13
|
+
crossplane_function_sdk_python-0.3.0.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
crossplane/function/__version__.py,sha256=WSXqJJ_BxokLA53mrcW73RxV0JfgGyb-2r2658HHVjw,704
|
|
2
|
-
crossplane/function/logging.py,sha256=Zawqq36FBzjkVg4bJ3VGK12-so7N8yAMoSPrhdwpBSA,2503
|
|
3
|
-
crossplane/function/resource.py,sha256=DJhangADTadAcjemKFSirTZcmeCraCzp9XeD_fdyDKw,3251
|
|
4
|
-
crossplane/function/response.py,sha256=fYJcPz5ZVN06hbNWXzy0tBTOMHNYQvj3m9JjWb2qRU8,2429
|
|
5
|
-
crossplane/function/runtime.py,sha256=Nh-nn9bAkfOoXepTTzhNs5nMH8a7JaMfSE2dP5-0E7U,3430
|
|
6
|
-
crossplane/function/proto/v1beta1/run_function.proto,sha256=3PRKNtZnVII9IfuH9vTVBw8i-_xMIQLQquEvU5TxaH4,7996
|
|
7
|
-
crossplane/function/proto/v1beta1/run_function_pb2.py,sha256=Dg-N-BFSXEwUKViUjK7M5_1mElAp7l34Kjhu1hfGUX0,5125
|
|
8
|
-
crossplane/function/proto/v1beta1/run_function_pb2.pyi,sha256=V9r_wwTfVZ_3F3ICJEq86RgKyYN1xaPCrkMQ6GC1OPk,4927
|
|
9
|
-
crossplane/function/proto/v1beta1/run_function_pb2_grpc.py,sha256=iLQTF8CHQzjZlBGJUJTWPTfNSmm3ew02zGf6OPIsxVY,3026
|
|
10
|
-
crossplane_function_sdk_python-0.1.0.dist-info/METADATA,sha256=HDOYsG0zyFELRP-kMB5B2qefsRJ_9A9PgF4us7TNRas,2518
|
|
11
|
-
crossplane_function_sdk_python-0.1.0.dist-info/WHEEL,sha256=mRYSEL3Ih6g5a_CVMIcwiF__0Ae4_gLYh01YFNwiq1k,87
|
|
12
|
-
crossplane_function_sdk_python-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
13
|
-
crossplane_function_sdk_python-0.1.0.dist-info/RECORD,,
|
|
File without changes
|