|
| 1 | +/* |
| 2 | +Copyright 2022 The Crossplane Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +syntax = "proto3"; |
| 18 | + |
| 19 | +import "google/protobuf/struct.proto"; |
| 20 | +import "google/protobuf/duration.proto"; |
| 21 | + |
| 22 | +package apiextensions.fn.proto.v1; |
| 23 | + |
| 24 | +option go_package = "github.com/crossplane/crossplane/apis/apiextensions/fn/proto/v1"; |
| 25 | + |
| 26 | +// A FunctionRunnerService is a Composition Function. |
| 27 | +service FunctionRunnerService { |
| 28 | + // RunFunction runs the Composition Function. |
| 29 | + rpc RunFunction(RunFunctionRequest) returns (RunFunctionResponse) {} |
| 30 | +} |
| 31 | + |
| 32 | +// A RunFunctionRequest requests that the Composition Function be run. |
| 33 | +message RunFunctionRequest { |
| 34 | + // Metadata pertaining to this request. |
| 35 | + RequestMeta meta = 1; |
| 36 | + |
| 37 | + // The observed state prior to invocation of a Function pipeline. State passed |
| 38 | + // to each Function is fresh as of the time the pipeline was invoked, not as |
| 39 | + // of the time each Function was invoked. |
| 40 | + State observed = 2; |
| 41 | + |
| 42 | + // Desired state according to a Function pipeline. The state passed to a |
| 43 | + // particular Function may have been accumulated by previous Functions in the |
| 44 | + // pipeline. |
| 45 | + // |
| 46 | + // Note that the desired state must be a partial object with only the fields |
| 47 | + // that this function (and its predecessors in the pipeline) wants to have |
| 48 | + // set in the object. Copying a non-partial observed state to desired is most |
| 49 | + // likely not what you want to do. Leaving out fields that had been returned |
| 50 | + // as desired before will result in them being deleted from the objects in the |
| 51 | + // cluster. |
| 52 | + State desired = 3; |
| 53 | + |
| 54 | + // Optional input specific to this Function invocation. A JSON representation |
| 55 | + // of the 'input' block of the relevant entry in a Composition's pipeline. |
| 56 | + optional google.protobuf.Struct input = 4; |
| 57 | + |
| 58 | + // Optional context. Crossplane may pass arbitary contextual information to a |
| 59 | + // Function. A Function may also return context in its RunFunctionResponse, |
| 60 | + // and that context will be passed to subsequent Functions. Crossplane |
| 61 | + // discards all context returned by the last Function in the pipeline. |
| 62 | + optional google.protobuf.Struct context = 5; |
| 63 | + |
| 64 | + // Optional extra resources that the Function required. |
| 65 | + // Note that extra resources is a map to Resources, plural. |
| 66 | + // The map key corresponds to the key in a RunFunctionResponse's |
| 67 | + // extra_resources field. If a Function requested extra resources that |
| 68 | + // did not exist, Crossplane sets the map key to an empty Resources message to |
| 69 | + // indicate that it attempted to satisfy the request. |
| 70 | + map<string, Resources> extra_resources = 6; |
| 71 | + |
| 72 | + // Optional credentials that this Function may use to communicate with an |
| 73 | + // external system. |
| 74 | + map <string, Credentials> credentials = 7; |
| 75 | +} |
| 76 | + |
| 77 | +// Credentials that a Function may use to communicate with an external system. |
| 78 | +message Credentials { |
| 79 | + // Source of the credentials. |
| 80 | + oneof source { |
| 81 | + // Credential data loaded by Crossplane, for example from a Secret. |
| 82 | + CredentialData credential_data = 1; |
| 83 | + } |
| 84 | +} |
| 85 | + |
| 86 | +// CredentialData loaded by Crossplane, for example from a Secret. |
| 87 | +message CredentialData { |
| 88 | + map<string, bytes> data = 1; |
| 89 | +} |
| 90 | + |
| 91 | +// Resources represents the state of several Crossplane resources. |
| 92 | +message Resources { |
| 93 | + repeated Resource items = 1; |
| 94 | +} |
| 95 | + |
| 96 | +// A RunFunctionResponse contains the result of a Composition Function run. |
| 97 | +message RunFunctionResponse { |
| 98 | + // Metadata pertaining to this response. |
| 99 | + ResponseMeta meta = 1; |
| 100 | + |
| 101 | + // Desired state according to a Function pipeline. Functions may add desired |
| 102 | + // state, and may mutate or delete any part of the desired state they are |
| 103 | + // concerned with. A Function must pass through any part of the desired state |
| 104 | + // that it is not concerned with. |
| 105 | + // |
| 106 | + // |
| 107 | + // Note that the desired state must be a partial object with only the fields |
| 108 | + // that this function (and its predecessors in the pipeline) wants to have |
| 109 | + // set in the object. Copying a non-partial observed state to desired is most |
| 110 | + // likely not what you want to do. Leaving out fields that had been returned |
| 111 | + // as desired before will result in them being deleted from the objects in the |
| 112 | + // cluster. |
| 113 | + State desired = 2; |
| 114 | + |
| 115 | + // Results of the Function run. Results are used for observability purposes. |
| 116 | + repeated Result results = 3; |
| 117 | + |
| 118 | + // Optional context to be passed to the next Function in the pipeline as part |
| 119 | + // of the RunFunctionRequest. Dropped on the last function in the pipeline. |
| 120 | + optional google.protobuf.Struct context = 4; |
| 121 | + |
| 122 | + // Requirements that must be satisfied for this Function to run successfully. |
| 123 | + Requirements requirements = 5; |
| 124 | + |
| 125 | + // Status conditions to be applied to the composite resource. Conditions may also |
| 126 | + // optionally be applied to the composite resource's associated claim. |
| 127 | + repeated Condition conditions = 6; |
| 128 | +} |
| 129 | + |
| 130 | +// RequestMeta contains metadata pertaining to a RunFunctionRequest. |
| 131 | +message RequestMeta { |
| 132 | + // An opaque string identifying the content of the request. Two identical |
| 133 | + // requests should have the same tag. |
| 134 | + string tag = 1; |
| 135 | +} |
| 136 | + |
| 137 | +// Requirements that must be satisfied for a Function to run successfully. |
| 138 | +message Requirements { |
| 139 | + // Extra resources that this Function requires. |
| 140 | + // The map key uniquely identifies the group of resources. |
| 141 | + map<string, ResourceSelector> extra_resources = 1; |
| 142 | +} |
| 143 | + |
| 144 | +// ResourceSelector selects a group of resources, either by name or by label. |
| 145 | +message ResourceSelector { |
| 146 | + // API version of resources to select. |
| 147 | + string api_version = 1; |
| 148 | + |
| 149 | + // Kind of resources to select. |
| 150 | + string kind = 2; |
| 151 | + |
| 152 | + // Resources to match. |
| 153 | + oneof match { |
| 154 | + // Match the resource with this name. |
| 155 | + string match_name = 3; |
| 156 | + |
| 157 | + // Match all resources with these labels. |
| 158 | + MatchLabels match_labels = 4; |
| 159 | + } |
| 160 | +} |
| 161 | + |
| 162 | +// MatchLabels defines a set of labels to match resources against. |
| 163 | +message MatchLabels { |
| 164 | + map<string, string> labels = 1; |
| 165 | +} |
| 166 | + |
| 167 | +// ResponseMeta contains metadata pertaining to a RunFunctionResponse. |
| 168 | +message ResponseMeta { |
| 169 | + // An opaque string identifying the content of the request. Must match the |
| 170 | + // meta.tag of the corresponding RunFunctionRequest. |
| 171 | + string tag = 1; |
| 172 | + |
| 173 | + // Time-to-live of this response. Deterministic Functions with no side-effects |
| 174 | + // (e.g. simple templating Functions) may specify a TTL. Crossplane may choose |
| 175 | + // to cache responses until the TTL expires. |
| 176 | + optional google.protobuf.Duration ttl = 2; |
| 177 | +} |
| 178 | + |
| 179 | +// State of the composite resource (XR) and any composed resources. |
| 180 | +message State { |
| 181 | + // The state of the composite resource (XR). |
| 182 | + Resource composite = 1; |
| 183 | + |
| 184 | + // The state of any composed resources. |
| 185 | + map<string, Resource> resources = 2; |
| 186 | +} |
| 187 | + |
| 188 | +// A Resource represents the state of a composite or composed resource. |
| 189 | +message Resource { |
| 190 | + // The JSON representation of the resource. |
| 191 | + // |
| 192 | + // * Crossplane will set this field in a RunFunctionRequest to the entire |
| 193 | + // observed state of a resource - including its metadata, spec, and status. |
| 194 | + // |
| 195 | + // * A Function should set this field in a RunFunctionRequest to communicate |
| 196 | + // the desired state of a composite or composed resource. |
| 197 | + // |
| 198 | + // * A Function may only specify the desired status of a composite resource - |
| 199 | + // not its metadata or spec. A Function should not return desired metadata |
| 200 | + // or spec for a composite resource. This will be ignored. |
| 201 | + // |
| 202 | + // * A Function may not specify the desired status of a composed resource - |
| 203 | + // only its metadata and spec. A Function should not return desired status |
| 204 | + // for a composed resource. This will be ignored. |
| 205 | + google.protobuf.Struct resource = 1; |
| 206 | + |
| 207 | + // The resource's connection details. |
| 208 | + // |
| 209 | + // * Crossplane will set this field in a RunFunctionRequest to communicate the |
| 210 | + // the observed connection details of a composite or composed resource. |
| 211 | + // |
| 212 | + // * A Function should set this field in a RunFunctionResponse to indicate the |
| 213 | + // desired connection details of the composite resource. |
| 214 | + // |
| 215 | + // * A Function should not set this field in a RunFunctionResponse to indicate |
| 216 | + // the desired connection details of a composed resource. This will be |
| 217 | + // ignored. |
| 218 | + map<string, bytes> connection_details = 2; |
| 219 | + |
| 220 | + // Ready indicates whether the resource should be considered ready. |
| 221 | + // |
| 222 | + // * Crossplane will never set this field in a RunFunctionRequest. |
| 223 | + // |
| 224 | + // * A Function should set this field to READY_TRUE in a RunFunctionResponse |
| 225 | + // to indicate that a desired composed resource is ready. |
| 226 | + // |
| 227 | + // * A Function should not set this field in a RunFunctionResponse to indicate |
| 228 | + // that the desired composite resource is ready. This will be ignored. |
| 229 | + Ready ready = 3; |
| 230 | +} |
| 231 | + |
| 232 | +// Ready indicates whether a composed resource should be considered ready. |
| 233 | +enum Ready { |
| 234 | + READY_UNSPECIFIED = 0; |
| 235 | + |
| 236 | + // True means the composed resource has been observed to be ready. |
| 237 | + READY_TRUE = 1; |
| 238 | + |
| 239 | + // False means the composed resource has not been observed to be ready. |
| 240 | + READY_FALSE = 2; |
| 241 | +} |
| 242 | + |
| 243 | +// A Result of running a Function. |
| 244 | +message Result { |
| 245 | + // Severity of this result. |
| 246 | + Severity severity = 1; |
| 247 | + |
| 248 | + // Human-readable details about the result. |
| 249 | + string message = 2; |
| 250 | + |
| 251 | + // Optional PascalCase, machine-readable reason for this result. If omitted, |
| 252 | + // the value will be ComposeResources. |
| 253 | + optional string reason = 3; |
| 254 | + |
| 255 | + // The resources this result targets. |
| 256 | + optional Target target = 4; |
| 257 | +} |
| 258 | + |
| 259 | +// Severity of Function results. |
| 260 | +enum Severity { |
| 261 | + SEVERITY_UNSPECIFIED = 0; |
| 262 | + |
| 263 | + // Fatal results are fatal; subsequent Composition Functions may run, but |
| 264 | + // the Composition Function pipeline run will be considered a failure and |
| 265 | + // the first fatal result will be returned as an error. |
| 266 | + SEVERITY_FATAL = 1; |
| 267 | + |
| 268 | + // Warning results are non-fatal; the entire Composition will run to |
| 269 | + // completion but warning events and debug logs associated with the |
| 270 | + // composite resource will be emitted. |
| 271 | + SEVERITY_WARNING = 2; |
| 272 | + |
| 273 | + // Normal results are emitted as normal events and debug logs associated |
| 274 | + // with the composite resource. |
| 275 | + SEVERITY_NORMAL = 3; |
| 276 | +} |
| 277 | + |
| 278 | +// Target of Function results and conditions. |
| 279 | +enum Target { |
| 280 | + // If the target is unspecified, the result targets the composite resource. |
| 281 | + TARGET_UNSPECIFIED = 0; |
| 282 | + |
| 283 | + // Target the composite resource. Results that target the composite resource |
| 284 | + // should include detailed, advanced information. |
| 285 | + TARGET_COMPOSITE = 1; |
| 286 | + |
| 287 | + // Target the composite and the claim. Results that target the composite and |
| 288 | + // the claim should include only end-user friendly information. |
| 289 | + TARGET_COMPOSITE_AND_CLAIM = 2; |
| 290 | +} |
| 291 | + |
| 292 | +// Status condition to be applied to the composite resource. Condition may also |
| 293 | +// optionally be applied to the composite resource's associated claim. For |
| 294 | +// detailed information on proper usage of status conditions, please see |
| 295 | +// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties. |
| 296 | +message Condition { |
| 297 | + // Type of condition in PascalCase. |
| 298 | + string type = 1; |
| 299 | + |
| 300 | + // Status of the condition. |
| 301 | + Status status = 2; |
| 302 | + |
| 303 | + // Reason contains a programmatic identifier indicating the reason for the |
| 304 | + // condition's last transition. Producers of specific condition types may |
| 305 | + // define expected values and meanings for this field, and whether the values |
| 306 | + // are considered a guaranteed API. The value should be a PascalCase string. |
| 307 | + // This field may not be empty. |
| 308 | + string reason = 3; |
| 309 | + |
| 310 | + // Message is a human readable message indicating details about the |
| 311 | + // transition. This may be an empty string. |
| 312 | + optional string message = 4; |
| 313 | + |
| 314 | + // The resources this condition targets. |
| 315 | + optional Target target = 5; |
| 316 | +} |
| 317 | + |
| 318 | +enum Status { |
| 319 | + STATUS_CONDITION_UNSPECIFIED = 0; |
| 320 | + |
| 321 | + STATUS_CONDITION_UNKNOWN = 1; |
| 322 | + |
| 323 | + STATUS_CONDITION_TRUE = 2; |
| 324 | + |
| 325 | + STATUS_CONDITION_FALSE = 3; |
| 326 | +} |
0 commit comments