Compare commits
226 Commits
Author | SHA1 | Date |
---|---|---|
|
6e65599e58 | |
|
a5cde9d9ee | |
|
f99b12c0de | |
|
27e990f6aa | |
|
cf67e6d0fe | |
|
14b6502f33 | |
|
7a915c2df7 | |
|
3931d503fc | |
|
82e60b0596 | |
|
57df02ae00 | |
|
b1e9695250 | |
|
1f3d442276 | |
|
f0bb336ba5 | |
|
47180d9798 | |
|
869fbfeb3d | |
|
9f55079121 | |
|
ed95373a01 | |
|
0262a24330 | |
|
8895e9d9af | |
|
1e0c20eb61 | |
|
cdaf6697c5 | |
|
fcec201f01 | |
|
88d97d3cab | |
|
e2606cff9f | |
|
f295c0144b | |
|
325c37d344 | |
|
e6b771c3a6 | |
|
68cbf5f53e | |
|
c8bcded971 | |
|
e0b964055b | |
|
5c1e33baf4 | |
|
466945254d | |
|
4fb63f221e | |
|
26bdc926e8 | |
|
1e0f18263e | |
|
4ad65f2934 | |
|
aa09bd0632 | |
|
0f188bcbde | |
|
de5a11c59f | |
|
afa27a3121 | |
|
aaf3d08879 | |
|
aff844707c | |
|
fb5d6fa5ab | |
|
8525cebb57 | |
|
597f5ee437 | |
|
ce63739286 | |
|
dbc0d0176b | |
|
d3bad9135d | |
|
b6d553bdaf | |
|
cd38d99a5c | |
|
0932de3e5d | |
|
47d0d54b26 | |
|
54d6e39371 | |
|
8551576b1f | |
|
f1ae43e725 | |
|
192b1d0b7a | |
|
a82962a952 | |
|
0651813b59 | |
|
8f57f81ea1 | |
|
2c8b642afd | |
|
479335d1e3 | |
|
84cf34e482 | |
|
81df679319 | |
|
773346f3f8 | |
|
77f1f6e8dd | |
|
b8dd9ec256 | |
|
6b3e0cbcc4 | |
|
d9e26f5b03 | |
|
5139481ee5 | |
|
a8999723f4 | |
|
9ef55d251c | |
|
064ffe7458 | |
|
d4b3506ec7 | |
|
70e86c0d30 | |
|
685918f02d | |
|
9c44291da2 | |
|
36e5600356 | |
|
5cf7fffbf1 | |
|
c632b0c1ad | |
|
25e49cf3bd | |
|
7452119ba8 | |
|
870edfcd76 | |
|
fc8796d42b | |
|
569af1d6d3 | |
|
41eca588a1 | |
|
50086a69b2 | |
|
1bf5f444e4 | |
|
5a3e1536ee | |
|
6a256486e2 | |
|
fde5b7ef84 | |
|
266dd49d93 | |
|
5ceb76308d | |
|
59f8ccc62a | |
|
8057458e36 | |
|
7990ab8939 | |
|
d10f084b84 | |
|
33ee9e1c4a | |
|
df655cabec | |
|
5fe3b5c9e0 | |
|
974bdc45a6 | |
|
b57a5cc532 | |
|
e6638d23de | |
|
c359461aba | |
|
6e741032dd | |
|
ed8a958352 | |
|
3c487eb331 | |
|
c3e673d75d | |
|
362377d127 | |
|
6724d5f751 | |
|
180ecf03c9 | |
|
dc2184e615 | |
|
064e2aa9fd | |
|
dc14d6ee97 | |
|
0d5c56841d | |
|
f283740fcc | |
|
7c4fc33106 | |
|
8e4f43b297 | |
|
8f0f8b2455 | |
|
147a52d1fc | |
|
8b868813ef | |
|
6cf22d08e9 | |
|
7980096588 | |
|
05f4c59f9b | |
|
b03cbba90f | |
|
8a723bc386 | |
|
b3ca1f4350 | |
|
ff67b54871 | |
|
f197e4153b | |
|
d287926b81 | |
|
4c92b3d67b | |
|
ad29667aca | |
|
8460e7c175 | |
|
114092deec | |
|
c2c39d437c | |
|
9850b183f5 | |
|
39b1128332 | |
|
f8f842de82 | |
|
0f7d85f43d | |
|
7837143425 | |
|
8d6112205f | |
|
069cd68c28 | |
|
e19fa8bf57 | |
|
6037575281 | |
|
556607ede7 | |
|
50f301a73e | |
|
b65bce9787 | |
|
0cf78a98a6 | |
|
b79146a8c4 | |
|
f0dd3c41e3 | |
|
626c01a3c6 | |
|
ee47c2bbe3 | |
|
34f26a171f | |
|
1939eecd6b | |
|
ab8fdbf378 | |
|
b20b98b072 | |
|
7b92076473 | |
|
193d468376 | |
|
2ba56eac92 | |
|
7eaa507eb1 | |
|
95d7dc7195 | |
|
3aa74114fa | |
|
4cdd26b141 | |
|
d1c067e388 | |
|
8261272aff | |
|
d383a331a7 | |
|
73c8c299bb | |
|
be1ea67d2e | |
|
1bab07c2c9 | |
|
86e715d718 | |
|
c214b4b1ba | |
|
a24b927baf | |
|
00beeb1ba7 | |
|
c7e73d1823 | |
|
c9551c9e88 | |
|
40638f325e | |
|
8ad3d882d3 | |
|
315857ee26 | |
|
860ec281f2 | |
|
07cea82fd4 | |
|
6e8530c0f0 | |
|
aac80f59e1 | |
|
579ae97773 | |
|
268bf2a362 | |
|
202a88a29f | |
|
5d480b46cf | |
|
8df052e3eb | |
|
d5d463e542 | |
|
c6f91a93e8 | |
|
c6896415c5 | |
|
30c66c4fb7 | |
|
a4e53820c8 | |
|
3bf234c44d | |
|
5e2cede190 | |
|
97dd555f03 | |
|
24930e5d73 | |
|
068fbb01ba | |
|
6e8f78e42d | |
|
09ed73551b | |
|
c8c6afa295 | |
|
24839a25df | |
|
c056300872 | |
|
f7230fdd3e | |
|
9c282500be | |
|
4ea7a909ef | |
|
439ecb87ec | |
|
5e2643b8c2 | |
|
7f4f118925 | |
|
6f043878ac | |
|
1f49c3437c | |
|
fe8c323754 | |
|
e1851feb69 | |
|
5c354a9041 | |
|
4d1542ab2c | |
|
efe587b0b5 | |
|
73cfd7dc91 | |
|
c05a20bfbf | |
|
c1a32d1bf9 | |
|
fd28b20cb7 | |
|
f6194cc1e9 | |
|
d87d844949 | |
|
8f66ed0f63 | |
|
7ec501d193 | |
|
2c6a27627e | |
|
4569ef1018 | |
|
9190f78c9f | |
|
25f400bb45 |
|
@ -12,16 +12,30 @@ on:
|
|||
description: PyPI project version (e.g. v0.1.0)
|
||||
required: false
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages.
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow only one concurrent deployment, skipping runs queued between the run
|
||||
# in-progress and latest queued. However, do NOT cancel in-progress runs as we
|
||||
# want to allow these production deployments to complete.
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
# Common versions
|
||||
PYTHON_VERSION: '3.11.5'
|
||||
PYTHON_VERSION: '3.11'
|
||||
HATCH_VERSION: '1.12.0'
|
||||
|
||||
# The PyPi project version to push. The default is v0.0.0+gitdate-gitsha.
|
||||
PYPI_VERSION: ${{ inputs.version }}
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
@ -32,13 +46,13 @@ jobs:
|
|||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Setup Hatch
|
||||
run: pipx install hatch==1.7.0
|
||||
run: pipx install hatch==${{ env.HATCH_VERSION }}
|
||||
|
||||
- name: Lint
|
||||
run: hatch run lint:check
|
||||
run: hatch fmt
|
||||
|
||||
unit-test:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
@ -49,14 +63,14 @@ jobs:
|
|||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Setup Hatch
|
||||
run: pipx install hatch==1.7.0
|
||||
run: pipx install hatch==${{ env.HATCH_VERSION }}
|
||||
|
||||
- name: Run Unit Tests
|
||||
run: hatch run test:unit
|
||||
run: hatch test --all --randomize
|
||||
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
@ -67,7 +81,7 @@ jobs:
|
|||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Setup Hatch
|
||||
run: pipx install hatch==1.7.0
|
||||
run: pipx install hatch==${{ env.HATCH_VERSION }}
|
||||
|
||||
# If a version wasn't explicitly passed as a workflow_dispatch input we
|
||||
# default to version v0.0.0+<git-commit-date>-<git-short-sha>, for example
|
||||
|
@ -97,7 +111,7 @@ jobs:
|
|||
if: ${{ inputs.version != '' }}
|
||||
needs:
|
||||
- build
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Download Sdist and Wheel from GitHub
|
||||
uses: actions/download-artifact@v4
|
||||
|
@ -106,10 +120,43 @@ jobs:
|
|||
path: "dist"
|
||||
|
||||
- name: Publish to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@v1.8.11
|
||||
uses: pypa/gh-action-pypi-publish@v1.12.4
|
||||
with:
|
||||
# Note that this is currently being pushed to the 'crossplane' PyPI
|
||||
# user (not org). See @negz if you need access - PyPI requires 2FA to
|
||||
# be enabled, which makes sharing the account hard. We're waiting for
|
||||
# a crossplane org to be approved.
|
||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||
|
||||
|
||||
docs:
|
||||
# The simple docs tool we're using doesn't support versions, so our docs
|
||||
# will only reflect what's in main.
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Setup Hatch
|
||||
run: pipx install hatch==${{ env.HATCH_VERSION }}
|
||||
|
||||
- name: Build Documentation
|
||||
run: hatch run docs:pdoc -d google crossplane/function -o docs
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: docs
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
|
@ -158,3 +158,6 @@ cython_debug/
|
|||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
# We don't commit our docs - instead we generate them and upload to GitHub pages.
|
||||
docs
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
# SPDX-FileCopyrightText: 2025 The Crossplane Authors <https://crossplane.io>
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
# This file controls automatic PR reviewer assignment. See the following docs:
|
||||
#
|
||||
# * https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
|
||||
# * https://docs.github.com/en/organizations/organizing-members-into-teams/managing-code-review-settings-for-your-team
|
||||
#
|
||||
# The goal of this file is for most PRs to automatically and fairly have one
|
||||
# maintainer set as PR reviewers. All maintainers have permission to approve
|
||||
# and merge PRs. All PRs must be approved by at least one maintainer before being merged.
|
||||
#
|
||||
# Where possible, prefer explicitly specifying a maintainer who is a subject
|
||||
# matter expert for a particular part of the codebase rather than using fallback
|
||||
# owners. Fallback owners are listed at the bottom of this file.
|
||||
#
|
||||
# See also OWNERS.md for governance details
|
||||
|
||||
# Fallback owners
|
||||
* @negz @bobh66
|
|
@ -0,0 +1,18 @@
|
|||
<!--
|
||||
SPDX-FileCopyrightText: 2025 The Crossplane Authors <https://crossplane.io>
|
||||
|
||||
SPDX-License-Identifier: CC-BY-4.0
|
||||
-->
|
||||
|
||||
# OWNERS
|
||||
|
||||
This page lists all maintainers for **this** repository. Each repository in the
|
||||
[Crossplane Contrib organization](https://github.com/crossplane-contrib/) will list their
|
||||
repository maintainers in their own `OWNERS.md` file.
|
||||
|
||||
## Maintainers
|
||||
* Nic Cope <negz@upbound.com> ([negz](https://github.com/negz))
|
||||
* Bob Haddleton <bob.haddleton@nokia.com> ([bobh66](https://github.com/bobh66))
|
||||
|
||||
|
||||
See [CODEOWNERS](./CODEOWNERS) for automatic PR assignment.
|
22
README.md
22
README.md
|
@ -1,5 +1,6 @@
|
|||
# function-sdk-python
|
||||
[](https://github.com/crossplane/function-sdk-python/actions/workflows/ci.yml) 
|
||||
[](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/)
|
||||
|
||||
|
||||
The [Python][python] SDK for writing [composition functions][functions].
|
||||
|
||||
|
@ -9,14 +10,18 @@ guidelines] as Crossplane.
|
|||
|
||||
To learn how to use this SDK:
|
||||
|
||||
* [Follow the guide to writing a composition function in Python][function guide]
|
||||
* [Learn about how composition functions work][functions]
|
||||
* [Learn about Python code generated from protocol buffers][python-protobuf]
|
||||
* [Read the package documentation][package docs]
|
||||
|
||||
The `RunFunctionRequest` and `RunFunctionResponse` types provided by this SDK
|
||||
are generated from a proto3 protocol buffer schema. Their fields behave
|
||||
similarly to built-in Python types like lists and dictionaries, but there are
|
||||
some differences. Read the generated code documentation to familiarize yourself
|
||||
with the the differences.
|
||||
some differences. Read the [generated code documentation][python-protobuf] to
|
||||
familiarize yourself with the the differences.
|
||||
|
||||
If you just want to jump in and get started, consider using the
|
||||
[function-template-python] template repository.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
@ -29,11 +34,11 @@ Some useful commands:
|
|||
# Generate gRPC stubs.
|
||||
hatch run generate:protoc
|
||||
|
||||
# Lint the code.
|
||||
hatch run lint:check
|
||||
# Format and lint the code.
|
||||
hatch fmt
|
||||
|
||||
# Run unit tests.
|
||||
hatch run test:unit
|
||||
hatch test
|
||||
|
||||
# Build an sdist and wheel.
|
||||
hatch build
|
||||
|
@ -42,5 +47,8 @@ hatch build
|
|||
[python]: https://python.org
|
||||
[functions]: https://docs.crossplane.io/latest/concepts/composition-functions
|
||||
[python-protobuf]: https://protobuf.dev/reference/python/python-generated/
|
||||
[function-template-python]: https://github.com/crossplane/function-template-python
|
||||
[function guide]: https://docs.crossplane.io/knowledge-base/guides/write-a-composition-function-in-python
|
||||
[package docs]: https://crossplane.github.io/function-sdk-python
|
||||
[contributing guidelines]: https://github.com/crossplane/crossplane/tree/master/contributing
|
||||
[hatch]: https://github.com/pypa/hatch
|
||||
|
|
|
@ -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<string, Resources> extra_resources = 6;
|
||||
|
||||
// Optional credentials that this Function may use to communicate with an
|
||||
// external system.
|
||||
map <string, Credentials> 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<string, bytes> 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<string, ResourceSelector> 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<string, string> 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<string, Resource> 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<string, bytes> 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;
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,232 @@
|
|||
from google.protobuf import struct_pb2 as _struct_pb2
|
||||
from google.protobuf import duration_pb2 as _duration_pb2
|
||||
from google.protobuf.internal import containers as _containers
|
||||
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
|
||||
|
||||
DESCRIPTOR: _descriptor.FileDescriptor
|
||||
|
||||
class Ready(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
||||
__slots__ = ()
|
||||
READY_UNSPECIFIED: _ClassVar[Ready]
|
||||
READY_TRUE: _ClassVar[Ready]
|
||||
READY_FALSE: _ClassVar[Ready]
|
||||
|
||||
class Severity(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
||||
__slots__ = ()
|
||||
SEVERITY_UNSPECIFIED: _ClassVar[Severity]
|
||||
SEVERITY_FATAL: _ClassVar[Severity]
|
||||
SEVERITY_WARNING: _ClassVar[Severity]
|
||||
SEVERITY_NORMAL: _ClassVar[Severity]
|
||||
|
||||
class Target(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
||||
__slots__ = ()
|
||||
TARGET_UNSPECIFIED: _ClassVar[Target]
|
||||
TARGET_COMPOSITE: _ClassVar[Target]
|
||||
TARGET_COMPOSITE_AND_CLAIM: _ClassVar[Target]
|
||||
|
||||
class Status(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
||||
__slots__ = ()
|
||||
STATUS_CONDITION_UNSPECIFIED: _ClassVar[Status]
|
||||
STATUS_CONDITION_UNKNOWN: _ClassVar[Status]
|
||||
STATUS_CONDITION_TRUE: _ClassVar[Status]
|
||||
STATUS_CONDITION_FALSE: _ClassVar[Status]
|
||||
READY_UNSPECIFIED: Ready
|
||||
READY_TRUE: Ready
|
||||
READY_FALSE: Ready
|
||||
SEVERITY_UNSPECIFIED: Severity
|
||||
SEVERITY_FATAL: Severity
|
||||
SEVERITY_WARNING: Severity
|
||||
SEVERITY_NORMAL: Severity
|
||||
TARGET_UNSPECIFIED: Target
|
||||
TARGET_COMPOSITE: Target
|
||||
TARGET_COMPOSITE_AND_CLAIM: Target
|
||||
STATUS_CONDITION_UNSPECIFIED: Status
|
||||
STATUS_CONDITION_UNKNOWN: Status
|
||||
STATUS_CONDITION_TRUE: Status
|
||||
STATUS_CONDITION_FALSE: Status
|
||||
|
||||
class RunFunctionRequest(_message.Message):
|
||||
__slots__ = ("meta", "observed", "desired", "input", "context", "extra_resources", "credentials")
|
||||
class ExtraResourcesEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: Resources
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[Resources, _Mapping]] = ...) -> None: ...
|
||||
class CredentialsEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: Credentials
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[Credentials, _Mapping]] = ...) -> None: ...
|
||||
META_FIELD_NUMBER: _ClassVar[int]
|
||||
OBSERVED_FIELD_NUMBER: _ClassVar[int]
|
||||
DESIRED_FIELD_NUMBER: _ClassVar[int]
|
||||
INPUT_FIELD_NUMBER: _ClassVar[int]
|
||||
CONTEXT_FIELD_NUMBER: _ClassVar[int]
|
||||
EXTRA_RESOURCES_FIELD_NUMBER: _ClassVar[int]
|
||||
CREDENTIALS_FIELD_NUMBER: _ClassVar[int]
|
||||
meta: RequestMeta
|
||||
observed: State
|
||||
desired: State
|
||||
input: _struct_pb2.Struct
|
||||
context: _struct_pb2.Struct
|
||||
extra_resources: _containers.MessageMap[str, Resources]
|
||||
credentials: _containers.MessageMap[str, Credentials]
|
||||
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: ...
|
||||
|
||||
class Credentials(_message.Message):
|
||||
__slots__ = ("credential_data",)
|
||||
CREDENTIAL_DATA_FIELD_NUMBER: _ClassVar[int]
|
||||
credential_data: CredentialData
|
||||
def __init__(self, credential_data: _Optional[_Union[CredentialData, _Mapping]] = ...) -> None: ...
|
||||
|
||||
class CredentialData(_message.Message):
|
||||
__slots__ = ("data",)
|
||||
class DataEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: bytes
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[bytes] = ...) -> None: ...
|
||||
DATA_FIELD_NUMBER: _ClassVar[int]
|
||||
data: _containers.ScalarMap[str, bytes]
|
||||
def __init__(self, data: _Optional[_Mapping[str, bytes]] = ...) -> None: ...
|
||||
|
||||
class Resources(_message.Message):
|
||||
__slots__ = ("items",)
|
||||
ITEMS_FIELD_NUMBER: _ClassVar[int]
|
||||
items: _containers.RepeatedCompositeFieldContainer[Resource]
|
||||
def __init__(self, items: _Optional[_Iterable[_Union[Resource, _Mapping]]] = ...) -> None: ...
|
||||
|
||||
class RunFunctionResponse(_message.Message):
|
||||
__slots__ = ("meta", "desired", "results", "context", "requirements", "conditions")
|
||||
META_FIELD_NUMBER: _ClassVar[int]
|
||||
DESIRED_FIELD_NUMBER: _ClassVar[int]
|
||||
RESULTS_FIELD_NUMBER: _ClassVar[int]
|
||||
CONTEXT_FIELD_NUMBER: _ClassVar[int]
|
||||
REQUIREMENTS_FIELD_NUMBER: _ClassVar[int]
|
||||
CONDITIONS_FIELD_NUMBER: _ClassVar[int]
|
||||
meta: ResponseMeta
|
||||
desired: State
|
||||
results: _containers.RepeatedCompositeFieldContainer[Result]
|
||||
context: _struct_pb2.Struct
|
||||
requirements: Requirements
|
||||
conditions: _containers.RepeatedCompositeFieldContainer[Condition]
|
||||
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]] = ..., conditions: _Optional[_Iterable[_Union[Condition, _Mapping]]] = ...) -> None: ...
|
||||
|
||||
class RequestMeta(_message.Message):
|
||||
__slots__ = ("tag",)
|
||||
TAG_FIELD_NUMBER: _ClassVar[int]
|
||||
tag: str
|
||||
def __init__(self, tag: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class Requirements(_message.Message):
|
||||
__slots__ = ("extra_resources",)
|
||||
class ExtraResourcesEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: ResourceSelector
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[ResourceSelector, _Mapping]] = ...) -> None: ...
|
||||
EXTRA_RESOURCES_FIELD_NUMBER: _ClassVar[int]
|
||||
extra_resources: _containers.MessageMap[str, ResourceSelector]
|
||||
def __init__(self, extra_resources: _Optional[_Mapping[str, ResourceSelector]] = ...) -> None: ...
|
||||
|
||||
class ResourceSelector(_message.Message):
|
||||
__slots__ = ("api_version", "kind", "match_name", "match_labels")
|
||||
API_VERSION_FIELD_NUMBER: _ClassVar[int]
|
||||
KIND_FIELD_NUMBER: _ClassVar[int]
|
||||
MATCH_NAME_FIELD_NUMBER: _ClassVar[int]
|
||||
MATCH_LABELS_FIELD_NUMBER: _ClassVar[int]
|
||||
api_version: str
|
||||
kind: str
|
||||
match_name: str
|
||||
match_labels: MatchLabels
|
||||
def __init__(self, api_version: _Optional[str] = ..., kind: _Optional[str] = ..., match_name: _Optional[str] = ..., match_labels: _Optional[_Union[MatchLabels, _Mapping]] = ...) -> None: ...
|
||||
|
||||
class MatchLabels(_message.Message):
|
||||
__slots__ = ("labels",)
|
||||
class LabelsEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: str
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
|
||||
LABELS_FIELD_NUMBER: _ClassVar[int]
|
||||
labels: _containers.ScalarMap[str, str]
|
||||
def __init__(self, labels: _Optional[_Mapping[str, str]] = ...) -> None: ...
|
||||
|
||||
class ResponseMeta(_message.Message):
|
||||
__slots__ = ("tag", "ttl")
|
||||
TAG_FIELD_NUMBER: _ClassVar[int]
|
||||
TTL_FIELD_NUMBER: _ClassVar[int]
|
||||
tag: str
|
||||
ttl: _duration_pb2.Duration
|
||||
def __init__(self, tag: _Optional[str] = ..., ttl: _Optional[_Union[_duration_pb2.Duration, _Mapping]] = ...) -> None: ...
|
||||
|
||||
class State(_message.Message):
|
||||
__slots__ = ("composite", "resources")
|
||||
class ResourcesEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: Resource
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[Resource, _Mapping]] = ...) -> None: ...
|
||||
COMPOSITE_FIELD_NUMBER: _ClassVar[int]
|
||||
RESOURCES_FIELD_NUMBER: _ClassVar[int]
|
||||
composite: Resource
|
||||
resources: _containers.MessageMap[str, Resource]
|
||||
def __init__(self, composite: _Optional[_Union[Resource, _Mapping]] = ..., resources: _Optional[_Mapping[str, Resource]] = ...) -> None: ...
|
||||
|
||||
class Resource(_message.Message):
|
||||
__slots__ = ("resource", "connection_details", "ready")
|
||||
class ConnectionDetailsEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: bytes
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[bytes] = ...) -> None: ...
|
||||
RESOURCE_FIELD_NUMBER: _ClassVar[int]
|
||||
CONNECTION_DETAILS_FIELD_NUMBER: _ClassVar[int]
|
||||
READY_FIELD_NUMBER: _ClassVar[int]
|
||||
resource: _struct_pb2.Struct
|
||||
connection_details: _containers.ScalarMap[str, bytes]
|
||||
ready: Ready
|
||||
def __init__(self, resource: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., connection_details: _Optional[_Mapping[str, bytes]] = ..., ready: _Optional[_Union[Ready, str]] = ...) -> None: ...
|
||||
|
||||
class Result(_message.Message):
|
||||
__slots__ = ("severity", "message", "reason", "target")
|
||||
SEVERITY_FIELD_NUMBER: _ClassVar[int]
|
||||
MESSAGE_FIELD_NUMBER: _ClassVar[int]
|
||||
REASON_FIELD_NUMBER: _ClassVar[int]
|
||||
TARGET_FIELD_NUMBER: _ClassVar[int]
|
||||
severity: Severity
|
||||
message: str
|
||||
reason: str
|
||||
target: Target
|
||||
def __init__(self, severity: _Optional[_Union[Severity, str]] = ..., message: _Optional[str] = ..., reason: _Optional[str] = ..., target: _Optional[_Union[Target, str]] = ...) -> None: ...
|
||||
|
||||
class Condition(_message.Message):
|
||||
__slots__ = ("type", "status", "reason", "message", "target")
|
||||
TYPE_FIELD_NUMBER: _ClassVar[int]
|
||||
STATUS_FIELD_NUMBER: _ClassVar[int]
|
||||
REASON_FIELD_NUMBER: _ClassVar[int]
|
||||
MESSAGE_FIELD_NUMBER: _ClassVar[int]
|
||||
TARGET_FIELD_NUMBER: _ClassVar[int]
|
||||
type: str
|
||||
status: Status
|
||||
reason: str
|
||||
message: str
|
||||
target: Target
|
||||
def __init__(self, type: _Optional[str] = ..., status: _Optional[_Union[Status, str]] = ..., reason: _Optional[str] = ..., message: _Optional[str] = ..., target: _Optional[_Union[Target, str]] = ...) -> None: ...
|
|
@ -0,0 +1,101 @@
|
|||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
||||
"""Client and server classes corresponding to protobuf-defined services."""
|
||||
import grpc
|
||||
import warnings
|
||||
|
||||
from crossplane.function.proto.v1 import run_function_pb2 as crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2
|
||||
|
||||
GRPC_GENERATED_VERSION = '1.71.0'
|
||||
GRPC_VERSION = grpc.__version__
|
||||
_version_not_supported = False
|
||||
|
||||
try:
|
||||
from grpc._utilities import first_version_is_lower
|
||||
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
||||
except ImportError:
|
||||
_version_not_supported = True
|
||||
|
||||
if _version_not_supported:
|
||||
raise RuntimeError(
|
||||
f'The grpc package installed is at version {GRPC_VERSION},'
|
||||
+ f' but the generated code in crossplane/function/proto/v1/run_function_pb2_grpc.py depends on'
|
||||
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
||||
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
||||
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
||||
)
|
||||
|
||||
|
||||
class FunctionRunnerServiceStub(object):
|
||||
"""A FunctionRunnerService is a Composition Function.
|
||||
"""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.RunFunction = channel.unary_unary(
|
||||
'/apiextensions.fn.proto.v1.FunctionRunnerService/RunFunction',
|
||||
request_serializer=crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionRequest.SerializeToString,
|
||||
response_deserializer=crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionResponse.FromString,
|
||||
_registered_method=True)
|
||||
|
||||
|
||||
class FunctionRunnerServiceServicer(object):
|
||||
"""A FunctionRunnerService is a Composition Function.
|
||||
"""
|
||||
|
||||
def RunFunction(self, request, context):
|
||||
"""RunFunction runs the Composition Function.
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_FunctionRunnerServiceServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'RunFunction': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.RunFunction,
|
||||
request_deserializer=crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionRequest.FromString,
|
||||
response_serializer=crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionResponse.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'apiextensions.fn.proto.v1.FunctionRunnerService', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
server.add_registered_method_handlers('apiextensions.fn.proto.v1.FunctionRunnerService', rpc_method_handlers)
|
||||
|
||||
|
||||
# This class is part of an EXPERIMENTAL API.
|
||||
class FunctionRunnerService(object):
|
||||
"""A FunctionRunnerService is a Composition Function.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def RunFunction(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(
|
||||
request,
|
||||
target,
|
||||
'/apiextensions.fn.proto.v1.FunctionRunnerService/RunFunction',
|
||||
crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionRequest.SerializeToString,
|
||||
crossplane_dot_function_dot_proto_dot_v1_dot_run__function__pb2.RunFunctionResponse.FromString,
|
||||
options,
|
||||
channel_credentials,
|
||||
insecure,
|
||||
call_credentials,
|
||||
compression,
|
||||
wait_for_ready,
|
||||
timeout,
|
||||
metadata,
|
||||
_registered_method=True)
|
|
@ -19,11 +19,12 @@ 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/crossplane/apis/apiextensions/fn/proto/v1beta1";
|
||||
|
||||
// A FunctionRunnerService is a Composition Function.
|
||||
service FunctionRunnerService {
|
||||
// RunFunction runs the Composition Function.
|
||||
|
@ -61,6 +62,37 @@ message RunFunctionRequest {
|
|||
// 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<string, Resources> extra_resources = 6;
|
||||
|
||||
// Optional credentials that this Function may use to communicate with an
|
||||
// external system.
|
||||
map <string, Credentials> 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<string, bytes> 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.
|
||||
|
@ -88,6 +120,13 @@ message RunFunctionResponse {
|
|||
// 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.
|
||||
|
@ -97,6 +136,36 @@ message RequestMeta {
|
|||
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<string, ResourceSelector> 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<string, string> labels = 1;
|
||||
}
|
||||
|
||||
// ResponseMeta contains metadata pertaining to a RunFunctionResponse.
|
||||
message ResponseMeta {
|
||||
// An opaque string identifying the content of the request. Must match the
|
||||
|
@ -180,6 +249,13 @@ message Result {
|
|||
|
||||
// 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.
|
||||
|
@ -199,4 +275,54 @@ enum Severity {
|
|||
// 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;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -9,17 +9,30 @@ from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Map
|
|||
DESCRIPTOR: _descriptor.FileDescriptor
|
||||
|
||||
class Ready(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
||||
__slots__ = []
|
||||
__slots__ = ()
|
||||
READY_UNSPECIFIED: _ClassVar[Ready]
|
||||
READY_TRUE: _ClassVar[Ready]
|
||||
READY_FALSE: _ClassVar[Ready]
|
||||
|
||||
class Severity(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
||||
__slots__ = []
|
||||
__slots__ = ()
|
||||
SEVERITY_UNSPECIFIED: _ClassVar[Severity]
|
||||
SEVERITY_FATAL: _ClassVar[Severity]
|
||||
SEVERITY_WARNING: _ClassVar[Severity]
|
||||
SEVERITY_NORMAL: _ClassVar[Severity]
|
||||
|
||||
class Target(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
||||
__slots__ = ()
|
||||
TARGET_UNSPECIFIED: _ClassVar[Target]
|
||||
TARGET_COMPOSITE: _ClassVar[Target]
|
||||
TARGET_COMPOSITE_AND_CLAIM: _ClassVar[Target]
|
||||
|
||||
class Status(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
||||
__slots__ = ()
|
||||
STATUS_CONDITION_UNSPECIFIED: _ClassVar[Status]
|
||||
STATUS_CONDITION_UNKNOWN: _ClassVar[Status]
|
||||
STATUS_CONDITION_TRUE: _ClassVar[Status]
|
||||
STATUS_CONDITION_FALSE: _ClassVar[Status]
|
||||
READY_UNSPECIFIED: Ready
|
||||
READY_TRUE: Ready
|
||||
READY_FALSE: Ready
|
||||
|
@ -27,41 +40,133 @@ SEVERITY_UNSPECIFIED: Severity
|
|||
SEVERITY_FATAL: Severity
|
||||
SEVERITY_WARNING: Severity
|
||||
SEVERITY_NORMAL: Severity
|
||||
TARGET_UNSPECIFIED: Target
|
||||
TARGET_COMPOSITE: Target
|
||||
TARGET_COMPOSITE_AND_CLAIM: Target
|
||||
STATUS_CONDITION_UNSPECIFIED: Status
|
||||
STATUS_CONDITION_UNKNOWN: Status
|
||||
STATUS_CONDITION_TRUE: Status
|
||||
STATUS_CONDITION_FALSE: Status
|
||||
|
||||
class RunFunctionRequest(_message.Message):
|
||||
__slots__ = ["meta", "observed", "desired", "input", "context"]
|
||||
__slots__ = ("meta", "observed", "desired", "input", "context", "extra_resources", "credentials")
|
||||
class ExtraResourcesEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: Resources
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[Resources, _Mapping]] = ...) -> None: ...
|
||||
class CredentialsEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: Credentials
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[Credentials, _Mapping]] = ...) -> None: ...
|
||||
META_FIELD_NUMBER: _ClassVar[int]
|
||||
OBSERVED_FIELD_NUMBER: _ClassVar[int]
|
||||
DESIRED_FIELD_NUMBER: _ClassVar[int]
|
||||
INPUT_FIELD_NUMBER: _ClassVar[int]
|
||||
CONTEXT_FIELD_NUMBER: _ClassVar[int]
|
||||
EXTRA_RESOURCES_FIELD_NUMBER: _ClassVar[int]
|
||||
CREDENTIALS_FIELD_NUMBER: _ClassVar[int]
|
||||
meta: RequestMeta
|
||||
observed: State
|
||||
desired: State
|
||||
input: _struct_pb2.Struct
|
||||
context: _struct_pb2.Struct
|
||||
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]] = ...) -> None: ...
|
||||
extra_resources: _containers.MessageMap[str, Resources]
|
||||
credentials: _containers.MessageMap[str, Credentials]
|
||||
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: ...
|
||||
|
||||
class Credentials(_message.Message):
|
||||
__slots__ = ("credential_data",)
|
||||
CREDENTIAL_DATA_FIELD_NUMBER: _ClassVar[int]
|
||||
credential_data: CredentialData
|
||||
def __init__(self, credential_data: _Optional[_Union[CredentialData, _Mapping]] = ...) -> None: ...
|
||||
|
||||
class CredentialData(_message.Message):
|
||||
__slots__ = ("data",)
|
||||
class DataEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: bytes
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[bytes] = ...) -> None: ...
|
||||
DATA_FIELD_NUMBER: _ClassVar[int]
|
||||
data: _containers.ScalarMap[str, bytes]
|
||||
def __init__(self, data: _Optional[_Mapping[str, bytes]] = ...) -> None: ...
|
||||
|
||||
class Resources(_message.Message):
|
||||
__slots__ = ("items",)
|
||||
ITEMS_FIELD_NUMBER: _ClassVar[int]
|
||||
items: _containers.RepeatedCompositeFieldContainer[Resource]
|
||||
def __init__(self, items: _Optional[_Iterable[_Union[Resource, _Mapping]]] = ...) -> None: ...
|
||||
|
||||
class RunFunctionResponse(_message.Message):
|
||||
__slots__ = ["meta", "desired", "results", "context"]
|
||||
__slots__ = ("meta", "desired", "results", "context", "requirements", "conditions")
|
||||
META_FIELD_NUMBER: _ClassVar[int]
|
||||
DESIRED_FIELD_NUMBER: _ClassVar[int]
|
||||
RESULTS_FIELD_NUMBER: _ClassVar[int]
|
||||
CONTEXT_FIELD_NUMBER: _ClassVar[int]
|
||||
REQUIREMENTS_FIELD_NUMBER: _ClassVar[int]
|
||||
CONDITIONS_FIELD_NUMBER: _ClassVar[int]
|
||||
meta: ResponseMeta
|
||||
desired: State
|
||||
results: _containers.RepeatedCompositeFieldContainer[Result]
|
||||
context: _struct_pb2.Struct
|
||||
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]] = ...) -> None: ...
|
||||
requirements: Requirements
|
||||
conditions: _containers.RepeatedCompositeFieldContainer[Condition]
|
||||
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]] = ..., conditions: _Optional[_Iterable[_Union[Condition, _Mapping]]] = ...) -> None: ...
|
||||
|
||||
class RequestMeta(_message.Message):
|
||||
__slots__ = ["tag"]
|
||||
__slots__ = ("tag",)
|
||||
TAG_FIELD_NUMBER: _ClassVar[int]
|
||||
tag: str
|
||||
def __init__(self, tag: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class Requirements(_message.Message):
|
||||
__slots__ = ("extra_resources",)
|
||||
class ExtraResourcesEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: ResourceSelector
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[ResourceSelector, _Mapping]] = ...) -> None: ...
|
||||
EXTRA_RESOURCES_FIELD_NUMBER: _ClassVar[int]
|
||||
extra_resources: _containers.MessageMap[str, ResourceSelector]
|
||||
def __init__(self, extra_resources: _Optional[_Mapping[str, ResourceSelector]] = ...) -> None: ...
|
||||
|
||||
class ResourceSelector(_message.Message):
|
||||
__slots__ = ("api_version", "kind", "match_name", "match_labels")
|
||||
API_VERSION_FIELD_NUMBER: _ClassVar[int]
|
||||
KIND_FIELD_NUMBER: _ClassVar[int]
|
||||
MATCH_NAME_FIELD_NUMBER: _ClassVar[int]
|
||||
MATCH_LABELS_FIELD_NUMBER: _ClassVar[int]
|
||||
api_version: str
|
||||
kind: str
|
||||
match_name: str
|
||||
match_labels: MatchLabels
|
||||
def __init__(self, api_version: _Optional[str] = ..., kind: _Optional[str] = ..., match_name: _Optional[str] = ..., match_labels: _Optional[_Union[MatchLabels, _Mapping]] = ...) -> None: ...
|
||||
|
||||
class MatchLabels(_message.Message):
|
||||
__slots__ = ("labels",)
|
||||
class LabelsEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: str
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
|
||||
LABELS_FIELD_NUMBER: _ClassVar[int]
|
||||
labels: _containers.ScalarMap[str, str]
|
||||
def __init__(self, labels: _Optional[_Mapping[str, str]] = ...) -> None: ...
|
||||
|
||||
class ResponseMeta(_message.Message):
|
||||
__slots__ = ["tag", "ttl"]
|
||||
__slots__ = ("tag", "ttl")
|
||||
TAG_FIELD_NUMBER: _ClassVar[int]
|
||||
TTL_FIELD_NUMBER: _ClassVar[int]
|
||||
tag: str
|
||||
|
@ -69,9 +174,9 @@ class ResponseMeta(_message.Message):
|
|||
def __init__(self, tag: _Optional[str] = ..., ttl: _Optional[_Union[_duration_pb2.Duration, _Mapping]] = ...) -> None: ...
|
||||
|
||||
class State(_message.Message):
|
||||
__slots__ = ["composite", "resources"]
|
||||
__slots__ = ("composite", "resources")
|
||||
class ResourcesEntry(_message.Message):
|
||||
__slots__ = ["key", "value"]
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
|
@ -84,9 +189,9 @@ class State(_message.Message):
|
|||
def __init__(self, composite: _Optional[_Union[Resource, _Mapping]] = ..., resources: _Optional[_Mapping[str, Resource]] = ...) -> None: ...
|
||||
|
||||
class Resource(_message.Message):
|
||||
__slots__ = ["resource", "connection_details", "ready"]
|
||||
__slots__ = ("resource", "connection_details", "ready")
|
||||
class ConnectionDetailsEntry(_message.Message):
|
||||
__slots__ = ["key", "value"]
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
|
@ -101,9 +206,27 @@ class Resource(_message.Message):
|
|||
def __init__(self, resource: _Optional[_Union[_struct_pb2.Struct, _Mapping]] = ..., connection_details: _Optional[_Mapping[str, bytes]] = ..., ready: _Optional[_Union[Ready, str]] = ...) -> None: ...
|
||||
|
||||
class Result(_message.Message):
|
||||
__slots__ = ["severity", "message"]
|
||||
__slots__ = ("severity", "message", "reason", "target")
|
||||
SEVERITY_FIELD_NUMBER: _ClassVar[int]
|
||||
MESSAGE_FIELD_NUMBER: _ClassVar[int]
|
||||
REASON_FIELD_NUMBER: _ClassVar[int]
|
||||
TARGET_FIELD_NUMBER: _ClassVar[int]
|
||||
severity: Severity
|
||||
message: str
|
||||
def __init__(self, severity: _Optional[_Union[Severity, str]] = ..., message: _Optional[str] = ...) -> None: ...
|
||||
reason: str
|
||||
target: Target
|
||||
def __init__(self, severity: _Optional[_Union[Severity, str]] = ..., message: _Optional[str] = ..., reason: _Optional[str] = ..., target: _Optional[_Union[Target, str]] = ...) -> None: ...
|
||||
|
||||
class Condition(_message.Message):
|
||||
__slots__ = ("type", "status", "reason", "message", "target")
|
||||
TYPE_FIELD_NUMBER: _ClassVar[int]
|
||||
STATUS_FIELD_NUMBER: _ClassVar[int]
|
||||
REASON_FIELD_NUMBER: _ClassVar[int]
|
||||
MESSAGE_FIELD_NUMBER: _ClassVar[int]
|
||||
TARGET_FIELD_NUMBER: _ClassVar[int]
|
||||
type: str
|
||||
status: Status
|
||||
reason: str
|
||||
message: str
|
||||
target: Target
|
||||
def __init__(self, type: _Optional[str] = ..., status: _Optional[_Union[Status, str]] = ..., reason: _Optional[str] = ..., message: _Optional[str] = ..., target: _Optional[_Union[Target, str]] = ...) -> None: ...
|
||||
|
|
|
@ -1,9 +1,29 @@
|
|||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
||||
"""Client and server classes corresponding to protobuf-defined services."""
|
||||
import grpc
|
||||
import warnings
|
||||
|
||||
from crossplane.function.proto.v1beta1 import run_function_pb2 as crossplane_dot_function_dot_proto_dot_v1beta1_dot_run__function__pb2
|
||||
|
||||
GRPC_GENERATED_VERSION = '1.71.0'
|
||||
GRPC_VERSION = grpc.__version__
|
||||
_version_not_supported = False
|
||||
|
||||
try:
|
||||
from grpc._utilities import first_version_is_lower
|
||||
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
||||
except ImportError:
|
||||
_version_not_supported = True
|
||||
|
||||
if _version_not_supported:
|
||||
raise RuntimeError(
|
||||
f'The grpc package installed is at version {GRPC_VERSION},'
|
||||
+ f' but the generated code in crossplane/function/proto/v1beta1/run_function_pb2_grpc.py depends on'
|
||||
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
||||
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
||||
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
||||
)
|
||||
|
||||
|
||||
class FunctionRunnerServiceStub(object):
|
||||
"""A FunctionRunnerService is a Composition Function.
|
||||
|
@ -19,7 +39,7 @@ class FunctionRunnerServiceStub(object):
|
|||
'/apiextensions.fn.proto.v1beta1.FunctionRunnerService/RunFunction',
|
||||
request_serializer=crossplane_dot_function_dot_proto_dot_v1beta1_dot_run__function__pb2.RunFunctionRequest.SerializeToString,
|
||||
response_deserializer=crossplane_dot_function_dot_proto_dot_v1beta1_dot_run__function__pb2.RunFunctionResponse.FromString,
|
||||
)
|
||||
_registered_method=True)
|
||||
|
||||
|
||||
class FunctionRunnerServiceServicer(object):
|
||||
|
@ -45,6 +65,7 @@ def add_FunctionRunnerServiceServicer_to_server(servicer, server):
|
|||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'apiextensions.fn.proto.v1beta1.FunctionRunnerService', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
server.add_registered_method_handlers('apiextensions.fn.proto.v1beta1.FunctionRunnerService', rpc_method_handlers)
|
||||
|
||||
|
||||
# This class is part of an EXPERIMENTAL API.
|
||||
|
@ -63,8 +84,18 @@ class FunctionRunnerService(object):
|
|||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/apiextensions.fn.proto.v1beta1.FunctionRunnerService/RunFunction',
|
||||
return grpc.experimental.unary_unary(
|
||||
request,
|
||||
target,
|
||||
'/apiextensions.fn.proto.v1beta1.FunctionRunnerService/RunFunction',
|
||||
crossplane_dot_function_dot_proto_dot_v1beta1_dot_run__function__pb2.RunFunctionRequest.SerializeToString,
|
||||
crossplane_dot_function_dot_proto_dot_v1beta1_dot_run__function__pb2.RunFunctionResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
options,
|
||||
channel_credentials,
|
||||
insecure,
|
||||
call_credentials,
|
||||
compression,
|
||||
wait_for_ready,
|
||||
timeout,
|
||||
metadata,
|
||||
_registered_method=True)
|
||||
|
|
|
@ -17,12 +17,48 @@
|
|||
import dataclasses
|
||||
import datetime
|
||||
|
||||
import pydantic
|
||||
from google.protobuf import json_format
|
||||
from google.protobuf import struct_pb2 as structpb
|
||||
|
||||
import crossplane.function.proto.v1.run_function_pb2 as fnv1
|
||||
|
||||
# TODO(negz): Do we really need dict_to_struct and struct_to_dict? They don't do
|
||||
# much, but are perhaps useful for discoverability/"documentation" purposes.
|
||||
|
||||
|
||||
def update(r: fnv1.Resource, source: dict | structpb.Struct | pydantic.BaseModel):
|
||||
"""Update a composite or composed resource.
|
||||
|
||||
Use update to add or update the supplied resource. If the resource doesn't
|
||||
exist, it'll be added. If the resource does exist, it'll be updated. The
|
||||
update method semantics are the same as a dictionary's update method. Fields
|
||||
that don't exist will be added. Fields that exist will be overwritten.
|
||||
|
||||
The source can be a dictionary, a protobuf Struct, or a Pydantic model.
|
||||
"""
|
||||
match source:
|
||||
case pydantic.BaseModel():
|
||||
data = source.model_dump(exclude_defaults=True, warnings=False)
|
||||
# In Pydantic, exclude_defaults=True in model_dump excludes fields
|
||||
# that have their value equal to the default. If a field like
|
||||
# apiVersion is set to its default value 's3.aws.upbound.io/v1beta2'
|
||||
# (and not explicitly provided during initialization), it will be
|
||||
# excluded from the serialized output.
|
||||
data["apiVersion"] = source.apiVersion
|
||||
data["kind"] = source.kind
|
||||
r.resource.update(data)
|
||||
case structpb.Struct():
|
||||
# TODO(negz): Use struct_to_dict and update to match other semantics?
|
||||
r.resource.MergeFrom(source)
|
||||
case dict():
|
||||
r.resource.update(source)
|
||||
case _:
|
||||
t = type(source)
|
||||
msg = f"Unsupported type: {t}"
|
||||
raise TypeError(msg)
|
||||
|
||||
|
||||
def dict_to_struct(d: dict) -> structpb.Struct:
|
||||
"""Create a Struct well-known type from the supplied dict.
|
||||
|
||||
|
@ -30,9 +66,7 @@ def dict_to_struct(d: dict) -> structpb.Struct:
|
|||
function makes it possible to work with a Python dict, then convert it to a
|
||||
struct in a RunFunctionResponse.
|
||||
"""
|
||||
s = structpb.Struct()
|
||||
s.update(d)
|
||||
return s
|
||||
return json_format.ParseDict(d, structpb.Struct())
|
||||
|
||||
|
||||
def struct_to_dict(s: structpb.Struct) -> dict:
|
||||
|
@ -42,7 +76,7 @@ def struct_to_dict(s: structpb.Struct) -> dict:
|
|||
protobuf struct. This function makes it possible to convert resources to a
|
||||
dictionary.
|
||||
"""
|
||||
return dict(s)
|
||||
return json_format.MessageToDict(s, preserving_proto_field_name=True)
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
|
@ -80,10 +114,10 @@ def get_condition(resource: structpb.Struct, typ: str) -> Condition:
|
|||
"""
|
||||
unknown = Condition(typ=typ, status="Unknown")
|
||||
|
||||
if "status" not in resource:
|
||||
if not resource or "status" not in resource:
|
||||
return unknown
|
||||
|
||||
if "conditions" not in resource["status"]:
|
||||
if not resource["status"] or "conditions" not in resource["status"]:
|
||||
return unknown
|
||||
|
||||
for c in resource["status"]["conditions"]:
|
||||
|
@ -106,3 +140,24 @@ def get_condition(resource: structpb.Struct, typ: str) -> Condition:
|
|||
return condition
|
||||
|
||||
return unknown
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class Credentials:
|
||||
"""Credentials."""
|
||||
|
||||
type: str
|
||||
data: dict
|
||||
|
||||
|
||||
def get_credentials(req: structpb.Struct, name: str) -> Credentials:
|
||||
"""Get the supplied credentials."""
|
||||
empty = Credentials(type="data", data={})
|
||||
if not req or "credentials" not in req:
|
||||
return empty
|
||||
if not req["credentials"] or name not in req["credentials"]:
|
||||
return empty
|
||||
return Credentials(
|
||||
type=req["credentials"][name]["type"],
|
||||
data=struct_to_dict(req["credentials"][name]["data"]),
|
||||
)
|
||||
|
|
|
@ -18,16 +18,16 @@ import datetime
|
|||
|
||||
from google.protobuf import duration_pb2 as durationpb
|
||||
|
||||
import crossplane.function.proto.v1beta1.run_function_pb2 as fnv1beta1
|
||||
import crossplane.function.proto.v1.run_function_pb2 as fnv1
|
||||
|
||||
"""The default TTL for which a RunFunctionResponse may be cached."""
|
||||
DEFAULT_TTL = datetime.timedelta(minutes=1)
|
||||
|
||||
|
||||
def to(
|
||||
req: fnv1beta1.RunFunctionRequest,
|
||||
req: fnv1.RunFunctionRequest,
|
||||
ttl: datetime.timedelta = DEFAULT_TTL,
|
||||
) -> fnv1beta1.RunFunctionResponse:
|
||||
) -> fnv1.RunFunctionResponse:
|
||||
"""Create a response to the supplied request.
|
||||
|
||||
Args:
|
||||
|
@ -42,38 +42,38 @@ def to(
|
|||
"""
|
||||
dttl = durationpb.Duration()
|
||||
dttl.FromTimedelta(ttl)
|
||||
return fnv1beta1.RunFunctionResponse(
|
||||
meta=fnv1beta1.ResponseMeta(tag=req.meta.tag, ttl=dttl),
|
||||
return fnv1.RunFunctionResponse(
|
||||
meta=fnv1.ResponseMeta(tag=req.meta.tag, ttl=dttl),
|
||||
desired=req.desired,
|
||||
context=req.context,
|
||||
)
|
||||
|
||||
|
||||
def normal(rsp: fnv1beta1.RunFunctionResponse, message: str) -> None:
|
||||
def normal(rsp: fnv1.RunFunctionResponse, message: str) -> None:
|
||||
"""Add a normal result to the response."""
|
||||
rsp.results.append(
|
||||
fnv1beta1.Result(
|
||||
severity=fnv1beta1.SEVERITY_NORMAL,
|
||||
fnv1.Result(
|
||||
severity=fnv1.SEVERITY_NORMAL,
|
||||
message=message,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def warning(rsp: fnv1beta1.RunFunctionResponse, message: str) -> None:
|
||||
def warning(rsp: fnv1.RunFunctionResponse, message: str) -> None:
|
||||
"""Add a warning result to the response."""
|
||||
rsp.results.append(
|
||||
fnv1beta1.Result(
|
||||
severity=fnv1beta1.SEVERITY_WARNING,
|
||||
fnv1.Result(
|
||||
severity=fnv1.SEVERITY_WARNING,
|
||||
message=message,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def fatal(rsp: fnv1beta1.RunFunctionResponse, message: str) -> None:
|
||||
def fatal(rsp: fnv1.RunFunctionResponse, message: str) -> None:
|
||||
"""Add a fatal result to the response."""
|
||||
rsp.results.append(
|
||||
fnv1beta1.Result(
|
||||
severity=fnv1beta1.SEVERITY_FATAL,
|
||||
fnv1.Result(
|
||||
severity=fnv1.SEVERITY_FATAL,
|
||||
message=message,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -16,18 +16,24 @@
|
|||
|
||||
import asyncio
|
||||
import os
|
||||
import signal
|
||||
|
||||
import grpc
|
||||
from grpc_reflection.v1alpha import reflection
|
||||
|
||||
import crossplane.function.proto.v1.run_function_pb2 as fnv1
|
||||
import crossplane.function.proto.v1.run_function_pb2_grpc as grpcv1
|
||||
import crossplane.function.proto.v1beta1.run_function_pb2 as fnv1beta1
|
||||
import crossplane.function.proto.v1beta1.run_function_pb2_grpc as grpcv1beta1
|
||||
|
||||
SERVICE_NAMES = (
|
||||
reflection.SERVICE_NAME,
|
||||
fnv1.DESCRIPTOR.services_by_name["FunctionRunnerService"].full_name,
|
||||
fnv1beta1.DESCRIPTOR.services_by_name["FunctionRunnerService"].full_name,
|
||||
)
|
||||
|
||||
SHUTDOWN_GRACE_PERIOD_SECONDS = 5
|
||||
|
||||
|
||||
def load_credentials(tls_certs_dir: str) -> grpc.ServerCredentials:
|
||||
"""Load TLS credentials for a composition function gRPC server.
|
||||
|
@ -62,7 +68,7 @@ def load_credentials(tls_certs_dir: str) -> grpc.ServerCredentials:
|
|||
|
||||
|
||||
def serve(
|
||||
function: grpcv1beta1.FunctionRunnerService,
|
||||
function: grpcv1.FunctionRunnerService,
|
||||
address: str,
|
||||
*,
|
||||
creds: grpc.ServerCredentials,
|
||||
|
@ -82,9 +88,20 @@ def serve(
|
|||
If insecure is true requests will be served insecurely, even if credentials
|
||||
are supplied.
|
||||
"""
|
||||
# Define the loop before the server so everything uses the same loop.
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
server = grpc.aio.server()
|
||||
|
||||
grpcv1beta1.add_FunctionRunnerServiceServicer_to_server(function, server)
|
||||
loop.add_signal_handler(
|
||||
signal.SIGTERM,
|
||||
lambda: asyncio.ensure_future(server.stop(grace=SHUTDOWN_GRACE_PERIOD_SECONDS)),
|
||||
)
|
||||
|
||||
grpcv1.add_FunctionRunnerServiceServicer_to_server(function, server)
|
||||
grpcv1beta1.add_FunctionRunnerServiceServicer_to_server(
|
||||
BetaFunctionRunner(wrapped=function), server
|
||||
)
|
||||
reflection.enable_server_reflection(SERVICE_NAMES, server)
|
||||
|
||||
if creds is None and insecure is False:
|
||||
|
@ -104,9 +121,35 @@ def serve(
|
|||
await server.start()
|
||||
await server.wait_for_termination()
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
try:
|
||||
loop.run_until_complete(start())
|
||||
finally:
|
||||
loop.run_until_complete(server.stop(grace=5))
|
||||
loop.run_until_complete(server.stop(grace=SHUTDOWN_GRACE_PERIOD_SECONDS))
|
||||
loop.close()
|
||||
|
||||
|
||||
class BetaFunctionRunner(grpcv1beta1.FunctionRunnerService):
|
||||
"""A BetaFunctionRunner handles beta gRPC RunFunctionRequests.
|
||||
|
||||
It handles requests by passing them to a wrapped v1.FunctionRunnerService.
|
||||
Incoming v1beta1 requests are converted to v1 by round-tripping them through
|
||||
serialization. Outgoing requests are converted from v1 to v1beta1 the same
|
||||
way.
|
||||
"""
|
||||
|
||||
def __init__(self, wrapped: grpcv1.FunctionRunnerService):
|
||||
"""Create a new BetaFunctionRunner."""
|
||||
self.wrapped = wrapped
|
||||
|
||||
async def RunFunction( # noqa: N802 # gRPC requires this name.
|
||||
self, req: fnv1beta1.RunFunctionRequest, context: grpc.aio.ServicerContext
|
||||
) -> fnv1beta1.RunFunctionResponse:
|
||||
"""Run the underlying function."""
|
||||
gareq = fnv1.RunFunctionRequest()
|
||||
gareq.ParseFromString(req.SerializeToString())
|
||||
|
||||
garsp = await self.wrapped.RunFunction(gareq, context)
|
||||
rsp = fnv1beta1.RunFunctionResponse()
|
||||
rsp.ParseFromString(garsp.SerializeToString())
|
||||
|
||||
return rsp
|
||||
|
|
|
@ -14,12 +14,15 @@ classifiers = [
|
|||
"Development Status :: 4 - Beta",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Typing :: Typed",
|
||||
]
|
||||
|
||||
dependencies = [
|
||||
"grpcio==1.*",
|
||||
"grpcio==1.71.0",
|
||||
"grpcio-reflection==1.*",
|
||||
"structlog==23.*",
|
||||
"protobuf==6.30.2", # Must be compatible with grpcio-tools.
|
||||
"pydantic==2.*",
|
||||
"structlog==25.*",
|
||||
]
|
||||
|
||||
dynamic = ["version"]
|
||||
|
@ -31,45 +34,45 @@ Source = "https://github.com/crossplane/function-sdk-python"
|
|||
|
||||
[tool.hatch.version]
|
||||
path = "crossplane/function/__version__.py"
|
||||
validate-bump = false # Allow going from 0.0.0.dev0+x to 0.0.0.dev0+y.
|
||||
validate-bump = false # Allow going from 0.0.0.dev0+x to 0.0.0.dev0+y.
|
||||
|
||||
[tool.hatch.envs.default]
|
||||
type = "virtual"
|
||||
path = ".venv-default"
|
||||
dependencies = ["ipython==8.19.0"]
|
||||
dependencies = ["ipython==9.2.0"]
|
||||
|
||||
[tool.hatch.envs.generate]
|
||||
type = "virtual"
|
||||
detached = true
|
||||
path = ".venv-generate"
|
||||
dependencies = ["grpcio-tools==1.60.0"]
|
||||
dependencies = [
|
||||
"grpcio-tools==1.71.0",
|
||||
"protobuf==6.30.2",
|
||||
]
|
||||
|
||||
[tool.hatch.envs.generate.scripts]
|
||||
protoc = "python -m grpc_tools.protoc --proto_path=. --python_out=. --pyi_out=. --grpc_python_out=. crossplane/function/proto/v1beta1/run_function.proto"
|
||||
protoc = "python -m grpc_tools.protoc --proto_path=. --python_out=. --pyi_out=. --grpc_python_out=. crossplane/function/proto/v1beta1/run_function.proto crossplane/function/proto/v1/run_function.proto"
|
||||
|
||||
[tool.hatch.envs.lint]
|
||||
[tool.hatch.envs.docs]
|
||||
type = "virtual"
|
||||
detached = true
|
||||
path = ".venv-lint"
|
||||
dependencies = ["ruff==0.1.11"]
|
||||
path = ".venv-docs"
|
||||
dependencies = ["pdoc"]
|
||||
|
||||
[tool.hatch.envs.lint.scripts]
|
||||
check = "ruff check crossplane tests && ruff format --diff crossplane tests"
|
||||
|
||||
[tool.hatch.envs.test]
|
||||
type = "virtual"
|
||||
path = ".venv-test"
|
||||
|
||||
[tool.hatch.envs.test.scripts]
|
||||
unit = "python -m unittest tests/*.py"
|
||||
[tool.hatch.envs.docs.scripts]
|
||||
generate = "pdoc -m google crossplane/function -o docs"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["crossplane"]
|
||||
|
||||
# This special environment is used by hatch fmt.
|
||||
[tool.hatch.envs.hatch-static-analysis]
|
||||
dependencies = ["ruff==0.11.9"]
|
||||
config-path = "none" # Disable Hatch's default Ruff config.
|
||||
|
||||
[tool.ruff]
|
||||
target-version = "py311"
|
||||
exclude = ["crossplane/function/proto/*"]
|
||||
select = [
|
||||
exclude = ["crossplane/function/proto/*", "tests/testdata/*"]
|
||||
lint.select = [
|
||||
"A",
|
||||
"ARG",
|
||||
"ASYNC",
|
||||
|
@ -99,12 +102,12 @@ select = [
|
|||
"W",
|
||||
"YTT",
|
||||
]
|
||||
ignore = ["ISC001"] # Ruff warns this is incompatible with ruff format.
|
||||
lint.ignore = ["ISC001"] # Ruff warns this is incompatible with ruff format.
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"tests/*" = ["D"] # Don't require docstrings for tests.
|
||||
|
||||
[tool.ruff.isort]
|
||||
[tool.ruff.lint.isort]
|
||||
known-first-party = ["crossplane"]
|
||||
|
||||
[tool.ruff.lint.pydocstyle]
|
||||
|
|
|
@ -16,15 +16,98 @@ import dataclasses
|
|||
import datetime
|
||||
import unittest
|
||||
|
||||
import pydantic
|
||||
from google.protobuf import json_format
|
||||
from google.protobuf import struct_pb2 as structpb
|
||||
|
||||
import crossplane.function.proto.v1.run_function_pb2 as fnv1
|
||||
from crossplane.function import logging, resource
|
||||
from tests.testdata.models.io.upbound.aws.s3 import v1beta2
|
||||
|
||||
|
||||
class TestResource(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
logging.configure(level=logging.Level.DISABLED)
|
||||
|
||||
def test_add(self) -> None:
|
||||
@dataclasses.dataclass
|
||||
class TestCase:
|
||||
reason: str
|
||||
r: fnv1.Resource
|
||||
source: dict | structpb.Struct | pydantic.BaseModel
|
||||
want: fnv1.Resource
|
||||
|
||||
cases = [
|
||||
TestCase(
|
||||
reason="Updating from a dict should work.",
|
||||
r=fnv1.Resource(),
|
||||
source={"apiVersion": "example.org", "kind": "Resource"},
|
||||
want=fnv1.Resource(
|
||||
resource=resource.dict_to_struct(
|
||||
{"apiVersion": "example.org", "kind": "Resource"}
|
||||
),
|
||||
),
|
||||
),
|
||||
TestCase(
|
||||
reason="Updating an existing resource from a dict should work.",
|
||||
r=fnv1.Resource(
|
||||
resource=resource.dict_to_struct(
|
||||
{"apiVersion": "example.org", "kind": "Resource"}
|
||||
),
|
||||
),
|
||||
source={
|
||||
"metadata": {"name": "cool"},
|
||||
},
|
||||
want=fnv1.Resource(
|
||||
resource=resource.dict_to_struct(
|
||||
{
|
||||
"apiVersion": "example.org",
|
||||
"kind": "Resource",
|
||||
"metadata": {"name": "cool"},
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
TestCase(
|
||||
reason="Updating from a struct should work.",
|
||||
r=fnv1.Resource(),
|
||||
source=resource.dict_to_struct(
|
||||
{"apiVersion": "example.org", "kind": "Resource"}
|
||||
),
|
||||
want=fnv1.Resource(
|
||||
resource=resource.dict_to_struct(
|
||||
{"apiVersion": "example.org", "kind": "Resource"}
|
||||
),
|
||||
),
|
||||
),
|
||||
TestCase(
|
||||
reason="Updating from a Pydantic model should work.",
|
||||
r=fnv1.Resource(),
|
||||
source=v1beta2.Bucket(
|
||||
spec=v1beta2.Spec(
|
||||
forProvider=v1beta2.ForProvider(region="us-west-2"),
|
||||
),
|
||||
),
|
||||
want=fnv1.Resource(
|
||||
resource=resource.dict_to_struct(
|
||||
{
|
||||
"apiVersion": "s3.aws.upbound.io/v1beta2",
|
||||
"kind": "Bucket",
|
||||
"spec": {"forProvider": {"region": "us-west-2"}},
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
for case in cases:
|
||||
resource.update(case.r, case.source)
|
||||
self.assertEqual(
|
||||
json_format.MessageToDict(case.want),
|
||||
json_format.MessageToDict(case.r),
|
||||
"-want, +got",
|
||||
)
|
||||
|
||||
def test_get_condition(self) -> None:
|
||||
@dataclasses.dataclass
|
||||
class TestCase:
|
||||
|
@ -122,6 +205,168 @@ class TestResource(unittest.TestCase):
|
|||
dataclasses.asdict(case.want), dataclasses.asdict(got), "-want, +got"
|
||||
)
|
||||
|
||||
def test_get_credentials(self) -> None:
|
||||
@dataclasses.dataclass
|
||||
class TestCase:
|
||||
reason: str
|
||||
req: structpb.Struct
|
||||
name: str
|
||||
want: resource.Credentials
|
||||
|
||||
cases = [
|
||||
TestCase(
|
||||
reason="Return the specified credentials if they exist.",
|
||||
req=resource.dict_to_struct(
|
||||
{"credentials": {"test": {"type": "data", "data": {"foo": "bar"}}}}
|
||||
),
|
||||
name="test",
|
||||
want=resource.Credentials(type="data", data={"foo": "bar"}),
|
||||
),
|
||||
TestCase(
|
||||
reason="Return empty credentials if no credentials section exists.",
|
||||
req=resource.dict_to_struct({}),
|
||||
name="test",
|
||||
want=resource.Credentials(type="data", data={}),
|
||||
),
|
||||
TestCase(
|
||||
reason="Return empty credentials if the specified name does not exist.",
|
||||
req=resource.dict_to_struct(
|
||||
{
|
||||
"credentials": {
|
||||
"nottest": {"type": "data", "data": {"foo": "bar"}}
|
||||
}
|
||||
}
|
||||
),
|
||||
name="test",
|
||||
want=resource.Credentials(type="data", data={}),
|
||||
),
|
||||
]
|
||||
|
||||
for case in cases:
|
||||
got = resource.get_credentials(case.req, case.name)
|
||||
self.assertEqual(
|
||||
dataclasses.asdict(case.want), dataclasses.asdict(got), "-want, +got"
|
||||
)
|
||||
|
||||
def test_dict_to_struct(self) -> None:
|
||||
@dataclasses.dataclass
|
||||
class TestCase:
|
||||
reason: str
|
||||
d: dict
|
||||
want: structpb.Struct
|
||||
|
||||
cases = [
|
||||
TestCase(
|
||||
reason="Convert an empty dictionary to a struct.",
|
||||
d={},
|
||||
want=structpb.Struct(),
|
||||
),
|
||||
TestCase(
|
||||
reason="Convert a dictionary with a single field to a struct.",
|
||||
d={"foo": "bar"},
|
||||
want=structpb.Struct(
|
||||
fields={"foo": structpb.Value(string_value="bar")}
|
||||
),
|
||||
),
|
||||
TestCase(
|
||||
reason="Convert a nested dictionary to a struct.",
|
||||
d={"foo": {"bar": "baz"}},
|
||||
want=structpb.Struct(
|
||||
fields={
|
||||
"foo": structpb.Value(
|
||||
struct_value=structpb.Struct(
|
||||
fields={"bar": structpb.Value(string_value="baz")}
|
||||
)
|
||||
)
|
||||
}
|
||||
),
|
||||
),
|
||||
TestCase(
|
||||
reason="Convert a nested dictionary containing lists to a struct.",
|
||||
d={"foo": {"bar": ["baz", "qux"]}},
|
||||
want=structpb.Struct(
|
||||
fields={
|
||||
"foo": structpb.Value(
|
||||
struct_value=structpb.Struct(
|
||||
fields={
|
||||
"bar": structpb.Value(
|
||||
list_value=structpb.ListValue(
|
||||
values=[
|
||||
structpb.Value(string_value="baz"),
|
||||
structpb.Value(string_value="qux"),
|
||||
]
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
),
|
||||
),
|
||||
]
|
||||
for case in cases:
|
||||
got = resource.dict_to_struct(case.d)
|
||||
self.assertEqual(case.want, got, "-want, +got")
|
||||
|
||||
def test_struct_to_dict(self) -> None:
|
||||
@dataclasses.dataclass
|
||||
class TestCase:
|
||||
reason: str
|
||||
s: structpb.Struct
|
||||
want: dict
|
||||
|
||||
cases = [
|
||||
TestCase(
|
||||
reason="Convert a struct with no fields to an empty dictionary.",
|
||||
s=structpb.Struct(),
|
||||
want={},
|
||||
),
|
||||
TestCase(
|
||||
reason="Convert a struct with a single field to a dictionary.",
|
||||
s=structpb.Struct(fields={"foo": structpb.Value(string_value="bar")}),
|
||||
want={"foo": "bar"},
|
||||
),
|
||||
TestCase(
|
||||
reason="Convert a nested struct to a dictionary.",
|
||||
s=structpb.Struct(
|
||||
fields={
|
||||
"foo": structpb.Value(
|
||||
struct_value=structpb.Struct(
|
||||
fields={"bar": structpb.Value(string_value="baz")}
|
||||
)
|
||||
)
|
||||
}
|
||||
),
|
||||
want={"foo": {"bar": "baz"}},
|
||||
),
|
||||
TestCase(
|
||||
reason="Convert a nested struct containing ListValues to a dictionary.",
|
||||
s=structpb.Struct(
|
||||
fields={
|
||||
"foo": structpb.Value(
|
||||
struct_value=structpb.Struct(
|
||||
fields={
|
||||
"bar": structpb.Value(
|
||||
list_value=structpb.ListValue(
|
||||
values=[
|
||||
structpb.Value(string_value="baz"),
|
||||
structpb.Value(string_value="qux"),
|
||||
]
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
),
|
||||
want={"foo": {"bar": ["baz", "qux"]}},
|
||||
),
|
||||
]
|
||||
|
||||
for case in cases:
|
||||
got = resource.struct_to_dict(case.s)
|
||||
self.assertEqual(case.want, got, "-want, +got")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -20,7 +20,7 @@ from google.protobuf import duration_pb2 as durationpb
|
|||
from google.protobuf import json_format
|
||||
|
||||
from crossplane.function import logging, resource, response
|
||||
from crossplane.function.proto.v1beta1 import run_function_pb2 as fnv1beta1
|
||||
from crossplane.function.proto.v1 import run_function_pb2 as fnv1
|
||||
|
||||
|
||||
class TestResponse(unittest.TestCase):
|
||||
|
@ -31,30 +31,30 @@ class TestResponse(unittest.TestCase):
|
|||
@dataclasses.dataclass
|
||||
class TestCase:
|
||||
reason: str
|
||||
req: fnv1beta1.RunFunctionRequest
|
||||
req: fnv1.RunFunctionRequest
|
||||
ttl: datetime.timedelta
|
||||
want: fnv1beta1.RunFunctionResponse
|
||||
want: fnv1.RunFunctionResponse
|
||||
|
||||
cases = [
|
||||
TestCase(
|
||||
reason="Tag, desired, and context should be copied.",
|
||||
req=fnv1beta1.RunFunctionRequest(
|
||||
meta=fnv1beta1.RequestMeta(tag="hi"),
|
||||
desired=fnv1beta1.State(
|
||||
req=fnv1.RunFunctionRequest(
|
||||
meta=fnv1.RequestMeta(tag="hi"),
|
||||
desired=fnv1.State(
|
||||
resources={
|
||||
"ready-composed-resource": fnv1beta1.Resource(),
|
||||
"ready-composed-resource": fnv1.Resource(),
|
||||
}
|
||||
),
|
||||
context=resource.dict_to_struct({"cool-key": "cool-value"}),
|
||||
),
|
||||
ttl=datetime.timedelta(minutes=10),
|
||||
want=fnv1beta1.RunFunctionResponse(
|
||||
meta=fnv1beta1.ResponseMeta(
|
||||
want=fnv1.RunFunctionResponse(
|
||||
meta=fnv1.ResponseMeta(
|
||||
tag="hi", ttl=durationpb.Duration(seconds=60 * 10)
|
||||
),
|
||||
desired=fnv1beta1.State(
|
||||
desired=fnv1.State(
|
||||
resources={
|
||||
"ready-composed-resource": fnv1beta1.Resource(),
|
||||
"ready-composed-resource": fnv1.Resource(),
|
||||
}
|
||||
),
|
||||
context=resource.dict_to_struct({"cool-key": "cool-value"}),
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
# Copyright 2023 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.
|
||||
|
||||
import dataclasses
|
||||
import unittest
|
||||
|
||||
import grpc
|
||||
|
||||
import crossplane.function.proto.v1.run_function_pb2 as fnv1
|
||||
import crossplane.function.proto.v1.run_function_pb2_grpc as grpcv1
|
||||
import crossplane.function.proto.v1beta1.run_function_pb2 as fnv1beta1
|
||||
from crossplane.function import logging, runtime
|
||||
|
||||
|
||||
class TestRuntime(unittest.IsolatedAsyncioTestCase):
|
||||
def setUp(self) -> None:
|
||||
logging.configure(level=logging.Level.DISABLED)
|
||||
|
||||
async def test_run_function(self) -> None:
|
||||
@dataclasses.dataclass
|
||||
class TestCase:
|
||||
reason: str
|
||||
runner: grpcv1.FunctionRunnerService
|
||||
req: fnv1beta1.RunFunctionRequest
|
||||
want: fnv1beta1.RunFunctionResponse
|
||||
|
||||
cases = [
|
||||
TestCase(
|
||||
reason="The v1 response should be returned as a v1beta1 response.",
|
||||
runner=EchoRunner(),
|
||||
req=fnv1beta1.RunFunctionRequest(meta=fnv1beta1.RequestMeta(tag="hi")),
|
||||
want=fnv1beta1.RunFunctionResponse(
|
||||
meta=fnv1beta1.ResponseMeta(tag="hi")
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
for case in cases:
|
||||
beta_runner = runtime.BetaFunctionRunner(wrapped=case.runner)
|
||||
rsp = await beta_runner.RunFunction(case.req, None)
|
||||
|
||||
self.assertEqual(rsp, case.want, "-want, +got")
|
||||
|
||||
|
||||
class EchoRunner(grpcv1.FunctionRunnerService):
|
||||
def __init__(self):
|
||||
self.log = logging.get_logger()
|
||||
|
||||
async def RunFunction( # noqa: N802 # gRPC requires this name.
|
||||
self,
|
||||
req: fnv1.RunFunctionRequest,
|
||||
_: grpc.aio.ServicerContext,
|
||||
) -> fnv1beta1.RunFunctionResponse:
|
||||
return fnv1beta1.RunFunctionResponse(
|
||||
meta=fnv1beta1.ResponseMeta(tag=req.meta.tag)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
|
@ -0,0 +1,3 @@
|
|||
# generated by datamodel-codegen:
|
||||
# filename: <stdin>
|
||||
# timestamp: 2024-10-04T21:01:52+00:00
|
|
@ -0,0 +1,3 @@
|
|||
# generated by datamodel-codegen:
|
||||
# filename: <stdin>
|
||||
# timestamp: 2024-10-04T21:01:52+00:00
|
|
@ -0,0 +1,301 @@
|
|||
# generated by datamodel-codegen:
|
||||
# filename: <stdin>
|
||||
# timestamp: 2024-10-04T21:01:52+00:00
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from pydantic import AwareDatetime, BaseModel, Field, RootModel
|
||||
|
||||
|
||||
class FieldsV1(BaseModel):
|
||||
pass
|
||||
|
||||
|
||||
class ListMeta(BaseModel):
|
||||
continue_: Optional[str] = Field(None, alias='continue')
|
||||
"""
|
||||
continue may be set if the user set a limit on the number of items returned, and indicates that the server has more data available. The value is opaque and may be used to issue another request to the endpoint that served this list to retrieve the next set of available objects. Continuing a consistent list may not be possible if the server configuration has changed or more than a few minutes have passed. The resourceVersion field returned when using this continue value will be identical to the value in the first response, unless you have received this token from an error message.
|
||||
"""
|
||||
remainingItemCount: Optional[int] = None
|
||||
"""
|
||||
remainingItemCount is the number of subsequent items in the list which are not included in this list response. If the list request contained label or field selectors, then the number of remaining items is unknown and the field will be left unset and omitted during serialization. If the list is complete (either because it is not chunking or because this is the last chunk), then there are no more remaining items and this field will be left unset and omitted during serialization. Servers older than v1.15 do not set this field. The intended use of the remainingItemCount is *estimating* the size of a collection. Clients should not rely on the remainingItemCount to be set or to be exact.
|
||||
"""
|
||||
resourceVersion: Optional[str] = None
|
||||
"""
|
||||
String that identifies the server's internal version of this object that can be used by clients to determine when objects have changed. Value must be treated as opaque by clients and passed unmodified back to the server. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
|
||||
"""
|
||||
selfLink: Optional[str] = None
|
||||
"""
|
||||
Deprecated: selfLink is a legacy read-only field that is no longer populated by the system.
|
||||
"""
|
||||
|
||||
|
||||
class OwnerReference(BaseModel):
|
||||
apiVersion: str
|
||||
"""
|
||||
API version of the referent.
|
||||
"""
|
||||
blockOwnerDeletion: Optional[bool] = None
|
||||
"""
|
||||
If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. See https://kubernetes.io/docs/concepts/architecture/garbage-collection/#foreground-deletion for how the garbage collector interacts with this field and enforces the foreground deletion. Defaults to false. To set this field, a user needs "delete" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned.
|
||||
"""
|
||||
controller: Optional[bool] = None
|
||||
"""
|
||||
If true, this reference points to the managing controller.
|
||||
"""
|
||||
kind: str
|
||||
"""
|
||||
Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
"""
|
||||
name: str
|
||||
"""
|
||||
Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names
|
||||
"""
|
||||
uid: str
|
||||
"""
|
||||
UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids
|
||||
"""
|
||||
|
||||
|
||||
class Patch(BaseModel):
|
||||
pass
|
||||
|
||||
|
||||
class Preconditions(BaseModel):
|
||||
resourceVersion: Optional[str] = None
|
||||
"""
|
||||
Specifies the target ResourceVersion
|
||||
"""
|
||||
uid: Optional[str] = None
|
||||
"""
|
||||
Specifies the target UID.
|
||||
"""
|
||||
|
||||
|
||||
class StatusCause(BaseModel):
|
||||
field: Optional[str] = None
|
||||
"""
|
||||
The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed. Fields may appear more than once in an array of causes due to fields having multiple errors. Optional.
|
||||
|
||||
Examples:
|
||||
"name" - the field "name" on the current resource
|
||||
"items[0].name" - the field "name" on the first array entry in "items"
|
||||
"""
|
||||
message: Optional[str] = None
|
||||
"""
|
||||
A human-readable description of the cause of the error. This field may be presented as-is to a reader.
|
||||
"""
|
||||
reason: Optional[str] = None
|
||||
"""
|
||||
A machine-readable description of the cause of the error. If this value is empty there is no information available.
|
||||
"""
|
||||
|
||||
|
||||
class StatusDetails(BaseModel):
|
||||
causes: Optional[List[StatusCause]] = None
|
||||
"""
|
||||
The Causes array includes more details associated with the StatusReason failure. Not all StatusReasons may provide detailed causes.
|
||||
"""
|
||||
group: Optional[str] = None
|
||||
"""
|
||||
The group attribute of the resource associated with the status StatusReason.
|
||||
"""
|
||||
kind: Optional[str] = None
|
||||
"""
|
||||
The kind attribute of the resource associated with the status StatusReason. On some operations may differ from the requested resource Kind. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
"""
|
||||
name: Optional[str] = None
|
||||
"""
|
||||
The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described).
|
||||
"""
|
||||
retryAfterSeconds: Optional[int] = None
|
||||
"""
|
||||
If specified, the time in seconds before the operation should be retried. Some errors may indicate the client must take an alternate action - for those errors this field may indicate how long to wait before taking the alternate action.
|
||||
"""
|
||||
uid: Optional[str] = None
|
||||
"""
|
||||
UID of the resource. (when there is a single resource which can be described). More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids
|
||||
"""
|
||||
|
||||
|
||||
class Time(RootModel[AwareDatetime]):
|
||||
root: AwareDatetime
|
||||
"""
|
||||
Time is a wrapper around time.Time which supports correct marshaling to YAML and JSON. Wrappers are provided for many of the factory methods that the time package offers.
|
||||
"""
|
||||
|
||||
|
||||
class DeleteOptions(BaseModel):
|
||||
apiVersion: Optional[str] = None
|
||||
"""
|
||||
APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
"""
|
||||
dryRun: Optional[List[str]] = None
|
||||
"""
|
||||
When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed
|
||||
"""
|
||||
gracePeriodSeconds: Optional[int] = None
|
||||
"""
|
||||
The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.
|
||||
"""
|
||||
kind: Optional[str] = None
|
||||
"""
|
||||
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
"""
|
||||
orphanDependents: Optional[bool] = None
|
||||
"""
|
||||
Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.
|
||||
"""
|
||||
preconditions: Optional[Preconditions] = None
|
||||
"""
|
||||
Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.
|
||||
"""
|
||||
propagationPolicy: Optional[str] = None
|
||||
"""
|
||||
Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground.
|
||||
"""
|
||||
|
||||
|
||||
class ManagedFieldsEntry(BaseModel):
|
||||
apiVersion: Optional[str] = None
|
||||
"""
|
||||
APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted.
|
||||
"""
|
||||
fieldsType: Optional[str] = None
|
||||
"""
|
||||
FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: "FieldsV1"
|
||||
"""
|
||||
fieldsV1: Optional[FieldsV1] = None
|
||||
"""
|
||||
FieldsV1 holds the first JSON version format as described in the "FieldsV1" type.
|
||||
"""
|
||||
manager: Optional[str] = None
|
||||
"""
|
||||
Manager is an identifier of the workflow managing these fields.
|
||||
"""
|
||||
operation: Optional[str] = None
|
||||
"""
|
||||
Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'.
|
||||
"""
|
||||
subresource: Optional[str] = None
|
||||
"""
|
||||
Subresource is the name of the subresource used to update that object, or empty string if the object was updated through the main resource. The value of this field is used to distinguish between managers, even if they share the same name. For example, a status update will be distinct from a regular update using the same manager name. Note that the APIVersion field is not related to the Subresource field and it always corresponds to the version of the main resource.
|
||||
"""
|
||||
time: Optional[Time] = None
|
||||
"""
|
||||
Time is the timestamp of when the ManagedFields entry was added. The timestamp will also be updated if a field is added, the manager changes any of the owned fields value or removes a field. The timestamp does not update when a field is removed from the entry because another manager took it over.
|
||||
"""
|
||||
|
||||
|
||||
class ObjectMeta(BaseModel):
|
||||
annotations: Optional[Dict[str, str]] = None
|
||||
"""
|
||||
Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations
|
||||
"""
|
||||
creationTimestamp: Optional[Time] = None
|
||||
"""
|
||||
CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.
|
||||
|
||||
Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
|
||||
"""
|
||||
deletionGracePeriodSeconds: Optional[int] = None
|
||||
"""
|
||||
Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only.
|
||||
"""
|
||||
deletionTimestamp: Optional[Time] = None
|
||||
"""
|
||||
DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field, once the finalizers list is empty. As long as the finalizers list contains items, deletion is blocked. Once the deletionTimestamp is set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested.
|
||||
|
||||
Populated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
|
||||
"""
|
||||
finalizers: Optional[List[str]] = None
|
||||
"""
|
||||
Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order. Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list.
|
||||
"""
|
||||
generateName: Optional[str] = None
|
||||
"""
|
||||
GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server.
|
||||
|
||||
If this field is specified and the generated name exists, the server will return a 409.
|
||||
|
||||
Applied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency
|
||||
"""
|
||||
generation: Optional[int] = None
|
||||
"""
|
||||
A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.
|
||||
"""
|
||||
labels: Optional[Dict[str, str]] = None
|
||||
"""
|
||||
Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
|
||||
"""
|
||||
managedFields: Optional[List[ManagedFieldsEntry]] = None
|
||||
"""
|
||||
ManagedFields maps workflow-id and version to the set of fields that are managed by that workflow. This is mostly for internal housekeeping, and users typically shouldn't need to set or understand this field. A workflow can be the user's name, a controller's name, or the name of a specific apply path like "ci-cd". The set of fields is always in the version that the workflow used when modifying the object.
|
||||
"""
|
||||
name: Optional[str] = None
|
||||
"""
|
||||
Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names
|
||||
"""
|
||||
namespace: Optional[str] = None
|
||||
"""
|
||||
Namespace defines the space within which each name must be unique. An empty namespace is equivalent to the "default" namespace, but "default" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.
|
||||
|
||||
Must be a DNS_LABEL. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces
|
||||
"""
|
||||
ownerReferences: Optional[List[OwnerReference]] = None
|
||||
"""
|
||||
List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.
|
||||
"""
|
||||
resourceVersion: Optional[str] = None
|
||||
"""
|
||||
An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources.
|
||||
|
||||
Populated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
|
||||
"""
|
||||
selfLink: Optional[str] = None
|
||||
"""
|
||||
Deprecated: selfLink is a legacy read-only field that is no longer populated by the system.
|
||||
"""
|
||||
uid: Optional[str] = None
|
||||
"""
|
||||
UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations.
|
||||
|
||||
Populated by the system. Read-only. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids
|
||||
"""
|
||||
|
||||
|
||||
class Status(BaseModel):
|
||||
apiVersion: Optional[str] = None
|
||||
"""
|
||||
APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
"""
|
||||
code: Optional[int] = None
|
||||
"""
|
||||
Suggested HTTP return code for this status, 0 if not set.
|
||||
"""
|
||||
details: Optional[StatusDetails] = None
|
||||
"""
|
||||
Extended data associated with the reason. Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.
|
||||
"""
|
||||
kind: Optional[str] = None
|
||||
"""
|
||||
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
"""
|
||||
message: Optional[str] = None
|
||||
"""
|
||||
A human-readable description of the status of this operation.
|
||||
"""
|
||||
metadata: Optional[ListMeta] = {}
|
||||
"""
|
||||
Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
"""
|
||||
reason: Optional[str] = None
|
||||
"""
|
||||
A machine-readable description of why this operation is in the "Failure" status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it.
|
||||
"""
|
||||
status: Optional[str] = None
|
||||
"""
|
||||
Status of the operation. One of: "Success" or "Failure". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
|
||||
"""
|
|
@ -0,0 +1,3 @@
|
|||
# generated by datamodel-codegen:
|
||||
# filename: <stdin>
|
||||
# timestamp: 2024-10-04T21:01:52+00:00
|
|
@ -0,0 +1,800 @@
|
|||
# generated by datamodel-codegen:
|
||||
# filename: <stdin>
|
||||
# timestamp: 2024-10-04T21:01:52+00:00
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from enum import Enum
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from pydantic import AwareDatetime, BaseModel, Field
|
||||
|
||||
from ....k8s.apimachinery.pkg.apis.meta import v1
|
||||
|
||||
|
||||
class DeletionPolicy(Enum):
|
||||
Orphan = 'Orphan'
|
||||
Delete = 'Delete'
|
||||
|
||||
|
||||
class ForProvider(BaseModel):
|
||||
forceDestroy: Optional[bool] = None
|
||||
"""
|
||||
Boolean that indicates all objects (including any locked objects) should be deleted from the bucket when the bucket is destroyed so that the bucket can be destroyed without error. These objects are not recoverable. This only deletes objects when the bucket is destroyed, not when setting this parameter to true. If setting this field in the same operation that would require replacing the bucket or destroying the bucket, this flag will not work.
|
||||
"""
|
||||
objectLockEnabled: Optional[bool] = None
|
||||
"""
|
||||
Indicates whether this bucket has an Object Lock configuration enabled. Valid values are true or false. This argument is not supported in all regions or partitions.
|
||||
"""
|
||||
region: str
|
||||
"""
|
||||
AWS region this bucket resides in.
|
||||
Region is the region you'd like your resource to be created in.
|
||||
"""
|
||||
tags: Optional[Dict[str, str]] = None
|
||||
"""
|
||||
Key-value map of resource tags.
|
||||
"""
|
||||
|
||||
|
||||
class InitProvider(BaseModel):
|
||||
forceDestroy: Optional[bool] = None
|
||||
"""
|
||||
Boolean that indicates all objects (including any locked objects) should be deleted from the bucket when the bucket is destroyed so that the bucket can be destroyed without error. These objects are not recoverable. This only deletes objects when the bucket is destroyed, not when setting this parameter to true. If setting this field in the same operation that would require replacing the bucket or destroying the bucket, this flag will not work.
|
||||
"""
|
||||
objectLockEnabled: Optional[bool] = None
|
||||
"""
|
||||
Indicates whether this bucket has an Object Lock configuration enabled. Valid values are true or false. This argument is not supported in all regions or partitions.
|
||||
"""
|
||||
tags: Optional[Dict[str, str]] = None
|
||||
"""
|
||||
Key-value map of resource tags.
|
||||
"""
|
||||
|
||||
|
||||
class ManagementPolicy(Enum):
|
||||
Observe = 'Observe'
|
||||
Create = 'Create'
|
||||
Update = 'Update'
|
||||
Delete = 'Delete'
|
||||
LateInitialize = 'LateInitialize'
|
||||
field_ = '*'
|
||||
|
||||
|
||||
class Resolution(Enum):
|
||||
Required = 'Required'
|
||||
Optional = 'Optional'
|
||||
|
||||
|
||||
class Resolve(Enum):
|
||||
Always = 'Always'
|
||||
IfNotPresent = 'IfNotPresent'
|
||||
|
||||
|
||||
class Policy(BaseModel):
|
||||
resolution: Optional[Resolution] = 'Required'
|
||||
"""
|
||||
Resolution specifies whether resolution of this reference is required.
|
||||
The default is 'Required', which means the reconcile will fail if the
|
||||
reference cannot be resolved. 'Optional' means this reference will be
|
||||
a no-op if it cannot be resolved.
|
||||
"""
|
||||
resolve: Optional[Resolve] = None
|
||||
"""
|
||||
Resolve specifies when this reference should be resolved. The default
|
||||
is 'IfNotPresent', which will attempt to resolve the reference only when
|
||||
the corresponding field is not present. Use 'Always' to resolve the
|
||||
reference on every reconcile.
|
||||
"""
|
||||
|
||||
|
||||
class ProviderConfigRef(BaseModel):
|
||||
name: str
|
||||
"""
|
||||
Name of the referenced object.
|
||||
"""
|
||||
policy: Optional[Policy] = None
|
||||
"""
|
||||
Policies for referencing.
|
||||
"""
|
||||
|
||||
|
||||
class ConfigRef(BaseModel):
|
||||
name: str
|
||||
"""
|
||||
Name of the referenced object.
|
||||
"""
|
||||
policy: Optional[Policy] = None
|
||||
"""
|
||||
Policies for referencing.
|
||||
"""
|
||||
|
||||
|
||||
class Metadata(BaseModel):
|
||||
annotations: Optional[Dict[str, str]] = None
|
||||
"""
|
||||
Annotations are the annotations to be added to connection secret.
|
||||
- For Kubernetes secrets, this will be used as "metadata.annotations".
|
||||
- It is up to Secret Store implementation for others store types.
|
||||
"""
|
||||
labels: Optional[Dict[str, str]] = None
|
||||
"""
|
||||
Labels are the labels/tags to be added to connection secret.
|
||||
- For Kubernetes secrets, this will be used as "metadata.labels".
|
||||
- It is up to Secret Store implementation for others store types.
|
||||
"""
|
||||
type: Optional[str] = None
|
||||
"""
|
||||
Type is the SecretType for the connection secret.
|
||||
- Only valid for Kubernetes Secret Stores.
|
||||
"""
|
||||
|
||||
|
||||
class PublishConnectionDetailsTo(BaseModel):
|
||||
configRef: Optional[ConfigRef] = Field(
|
||||
default_factory=lambda: ConfigRef.model_validate({'name': 'default'})
|
||||
)
|
||||
"""
|
||||
SecretStoreConfigRef specifies which secret store config should be used
|
||||
for this ConnectionSecret.
|
||||
"""
|
||||
metadata: Optional[Metadata] = None
|
||||
"""
|
||||
Metadata is the metadata for connection secret.
|
||||
"""
|
||||
name: str
|
||||
"""
|
||||
Name is the name of the connection secret.
|
||||
"""
|
||||
|
||||
|
||||
class WriteConnectionSecretToRef(BaseModel):
|
||||
name: str
|
||||
"""
|
||||
Name of the secret.
|
||||
"""
|
||||
namespace: str
|
||||
"""
|
||||
Namespace of the secret.
|
||||
"""
|
||||
|
||||
|
||||
class Spec(BaseModel):
|
||||
deletionPolicy: Optional[DeletionPolicy] = 'Delete'
|
||||
"""
|
||||
DeletionPolicy specifies what will happen to the underlying external
|
||||
when this managed resource is deleted - either "Delete" or "Orphan" the
|
||||
external resource.
|
||||
This field is planned to be deprecated in favor of the ManagementPolicies
|
||||
field in a future release. Currently, both could be set independently and
|
||||
non-default values would be honored if the feature flag is enabled.
|
||||
See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223
|
||||
"""
|
||||
forProvider: ForProvider
|
||||
initProvider: Optional[InitProvider] = None
|
||||
"""
|
||||
THIS IS A BETA FIELD. It will be honored
|
||||
unless the Management Policies feature flag is disabled.
|
||||
InitProvider holds the same fields as ForProvider, with the exception
|
||||
of Identifier and other resource reference fields. The fields that are
|
||||
in InitProvider are merged into ForProvider when the resource is created.
|
||||
The same fields are also added to the terraform ignore_changes hook, to
|
||||
avoid updating them after creation. This is useful for fields that are
|
||||
required on creation, but we do not desire to update them after creation,
|
||||
for example because of an external controller is managing them, like an
|
||||
autoscaler.
|
||||
"""
|
||||
managementPolicies: Optional[List[ManagementPolicy]] = ['*']
|
||||
"""
|
||||
THIS IS A BETA FIELD. It is on by default but can be opted out
|
||||
through a Crossplane feature flag.
|
||||
ManagementPolicies specify the array of actions Crossplane is allowed to
|
||||
take on the managed and external resources.
|
||||
This field is planned to replace the DeletionPolicy field in a future
|
||||
release. Currently, both could be set independently and non-default
|
||||
values would be honored if the feature flag is enabled. If both are
|
||||
custom, the DeletionPolicy field will be ignored.
|
||||
See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223
|
||||
and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md
|
||||
"""
|
||||
providerConfigRef: Optional[ProviderConfigRef] = Field(
|
||||
default_factory=lambda: ProviderConfigRef.model_validate({'name': 'default'})
|
||||
)
|
||||
"""
|
||||
ProviderConfigReference specifies how the provider that will be used to
|
||||
create, observe, update, and delete this managed resource should be
|
||||
configured.
|
||||
"""
|
||||
publishConnectionDetailsTo: Optional[PublishConnectionDetailsTo] = None
|
||||
"""
|
||||
PublishConnectionDetailsTo specifies the connection secret config which
|
||||
contains a name, metadata and a reference to secret store config to
|
||||
which any connection details for this managed resource should be written.
|
||||
Connection details frequently include the endpoint, username,
|
||||
and password required to connect to the managed resource.
|
||||
"""
|
||||
writeConnectionSecretToRef: Optional[WriteConnectionSecretToRef] = None
|
||||
"""
|
||||
WriteConnectionSecretToReference specifies the namespace and name of a
|
||||
Secret to which any connection details for this managed resource should
|
||||
be written. Connection details frequently include the endpoint, username,
|
||||
and password required to connect to the managed resource.
|
||||
This field is planned to be replaced in a future release in favor of
|
||||
PublishConnectionDetailsTo. Currently, both could be set independently
|
||||
and connection details would be published to both without affecting
|
||||
each other.
|
||||
"""
|
||||
|
||||
|
||||
class CorsRuleItem(BaseModel):
|
||||
allowedHeaders: Optional[List[str]] = None
|
||||
"""
|
||||
List of headers allowed.
|
||||
"""
|
||||
allowedMethods: Optional[List[str]] = None
|
||||
"""
|
||||
One or more HTTP methods that you allow the origin to execute. Can be GET, PUT, POST, DELETE or HEAD.
|
||||
"""
|
||||
allowedOrigins: Optional[List[str]] = None
|
||||
"""
|
||||
One or more origins you want customers to be able to access the bucket from.
|
||||
"""
|
||||
exposeHeaders: Optional[List[str]] = None
|
||||
"""
|
||||
One or more headers in the response that you want customers to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).
|
||||
"""
|
||||
maxAgeSeconds: Optional[float] = None
|
||||
"""
|
||||
Specifies time in seconds that browser can cache the response for a preflight request.
|
||||
"""
|
||||
|
||||
|
||||
class GrantItem(BaseModel):
|
||||
id: Optional[str] = None
|
||||
"""
|
||||
Canonical user id to grant for. Used only when type is CanonicalUser.
|
||||
"""
|
||||
permissions: Optional[List[str]] = None
|
||||
"""
|
||||
List of permissions to apply for grantee. Valid values are READ, WRITE, READ_ACP, WRITE_ACP, FULL_CONTROL.
|
||||
"""
|
||||
type: Optional[str] = None
|
||||
"""
|
||||
Type of grantee to apply for. Valid values are CanonicalUser and Group. AmazonCustomerByEmail is not supported.
|
||||
"""
|
||||
uri: Optional[str] = None
|
||||
"""
|
||||
Uri address to grant for. Used only when type is Group.
|
||||
"""
|
||||
|
||||
|
||||
class Expiration(BaseModel):
|
||||
date: Optional[str] = None
|
||||
"""
|
||||
Specifies the date after which you want the corresponding action to take effect.
|
||||
"""
|
||||
days: Optional[float] = None
|
||||
"""
|
||||
Specifies the number of days after object creation when the specific rule action takes effect.
|
||||
"""
|
||||
expiredObjectDeleteMarker: Optional[bool] = None
|
||||
"""
|
||||
On a versioned bucket (versioning-enabled or versioning-suspended bucket), you can add this element in the lifecycle configuration to direct Amazon S3 to delete expired object delete markers. This cannot be specified with Days or Date in a Lifecycle Expiration Policy.
|
||||
"""
|
||||
|
||||
|
||||
class NoncurrentVersionExpiration(BaseModel):
|
||||
days: Optional[float] = None
|
||||
"""
|
||||
Specifies the number of days after object creation when the specific rule action takes effect.
|
||||
"""
|
||||
|
||||
|
||||
class NoncurrentVersionTransitionItem(BaseModel):
|
||||
days: Optional[float] = None
|
||||
"""
|
||||
Specifies the number of days after object creation when the specific rule action takes effect.
|
||||
"""
|
||||
storageClass: Optional[str] = None
|
||||
"""
|
||||
Specifies the Amazon S3 storage class to which you want the object to transition.
|
||||
"""
|
||||
|
||||
|
||||
class TransitionItem(BaseModel):
|
||||
date: Optional[str] = None
|
||||
"""
|
||||
Specifies the date after which you want the corresponding action to take effect.
|
||||
"""
|
||||
days: Optional[float] = None
|
||||
"""
|
||||
Specifies the number of days after object creation when the specific rule action takes effect.
|
||||
"""
|
||||
storageClass: Optional[str] = None
|
||||
"""
|
||||
Specifies the Amazon S3 storage class to which you want the object to transition.
|
||||
"""
|
||||
|
||||
|
||||
class LifecycleRuleItem(BaseModel):
|
||||
abortIncompleteMultipartUploadDays: Optional[float] = None
|
||||
"""
|
||||
Specifies the number of days after initiating a multipart upload when the multipart upload must be completed.
|
||||
"""
|
||||
enabled: Optional[bool] = None
|
||||
"""
|
||||
Specifies lifecycle rule status.
|
||||
"""
|
||||
expiration: Optional[Expiration] = None
|
||||
"""
|
||||
Specifies a period in the object's expire. See Expiration below for details.
|
||||
"""
|
||||
id: Optional[str] = None
|
||||
"""
|
||||
Unique identifier for the rule. Must be less than or equal to 255 characters in length.
|
||||
"""
|
||||
noncurrentVersionExpiration: Optional[NoncurrentVersionExpiration] = None
|
||||
"""
|
||||
Specifies when noncurrent object versions expire. See Noncurrent Version Expiration below for details.
|
||||
"""
|
||||
noncurrentVersionTransition: Optional[List[NoncurrentVersionTransitionItem]] = None
|
||||
"""
|
||||
Specifies when noncurrent object versions transitions. See Noncurrent Version Transition below for details.
|
||||
"""
|
||||
prefix: Optional[str] = None
|
||||
"""
|
||||
Object key prefix identifying one or more objects to which the rule applies.
|
||||
"""
|
||||
tags: Optional[Dict[str, str]] = None
|
||||
"""
|
||||
Specifies object tags key and value.
|
||||
"""
|
||||
transition: Optional[List[TransitionItem]] = None
|
||||
"""
|
||||
Specifies a period in the object's transitions. See Transition below for details.
|
||||
"""
|
||||
|
||||
|
||||
class Logging(BaseModel):
|
||||
targetBucket: Optional[str] = None
|
||||
"""
|
||||
Name of the bucket that will receive the log objects.
|
||||
"""
|
||||
targetPrefix: Optional[str] = None
|
||||
"""
|
||||
To specify a key prefix for log objects.
|
||||
"""
|
||||
|
||||
|
||||
class DefaultRetention(BaseModel):
|
||||
days: Optional[float] = None
|
||||
"""
|
||||
Number of days that you want to specify for the default retention period.
|
||||
"""
|
||||
mode: Optional[str] = None
|
||||
"""
|
||||
Default Object Lock retention mode you want to apply to new objects placed in this bucket. Valid values are GOVERNANCE and COMPLIANCE.
|
||||
"""
|
||||
years: Optional[float] = None
|
||||
"""
|
||||
Number of years that you want to specify for the default retention period.
|
||||
"""
|
||||
|
||||
|
||||
class Rule(BaseModel):
|
||||
defaultRetention: Optional[DefaultRetention] = None
|
||||
"""
|
||||
Default retention period that you want to apply to new objects placed in this bucket (documented below).
|
||||
"""
|
||||
|
||||
|
||||
class ObjectLockConfiguration(BaseModel):
|
||||
objectLockEnabled: Optional[str] = None
|
||||
"""
|
||||
Indicates whether this bucket has an Object Lock configuration enabled. Valid value is Enabled. Use the top-level argument object_lock_enabled instead.
|
||||
"""
|
||||
rule: Optional[Rule] = None
|
||||
"""
|
||||
Object Lock rule in place for this bucket (documented below).
|
||||
"""
|
||||
|
||||
|
||||
class AccessControlTranslation(BaseModel):
|
||||
owner: Optional[str] = None
|
||||
"""
|
||||
Specifies the replica ownership. For default and valid values, see PUT bucket replication in the Amazon S3 API Reference. The only valid value is Destination.
|
||||
"""
|
||||
|
||||
|
||||
class Metrics(BaseModel):
|
||||
minutes: Optional[float] = None
|
||||
"""
|
||||
Threshold within which objects are to be replicated. The only valid value is 15.
|
||||
"""
|
||||
status: Optional[str] = None
|
||||
"""
|
||||
Status of RTC. Either Enabled or Disabled.
|
||||
"""
|
||||
|
||||
|
||||
class ReplicationTime(BaseModel):
|
||||
minutes: Optional[float] = None
|
||||
"""
|
||||
Threshold within which objects are to be replicated. The only valid value is 15.
|
||||
"""
|
||||
status: Optional[str] = None
|
||||
"""
|
||||
Status of RTC. Either Enabled or Disabled.
|
||||
"""
|
||||
|
||||
|
||||
class Destination(BaseModel):
|
||||
accessControlTranslation: Optional[AccessControlTranslation] = None
|
||||
"""
|
||||
Specifies the overrides to use for object owners on replication (documented below). Must be used in conjunction with account_id owner override configuration.
|
||||
"""
|
||||
accountId: Optional[str] = None
|
||||
"""
|
||||
Account ID to use for overriding the object owner on replication. Must be used in conjunction with access_control_translation override configuration.
|
||||
"""
|
||||
bucket: Optional[str] = None
|
||||
"""
|
||||
ARN of the S3 bucket where you want Amazon S3 to store replicas of the object identified by the rule.
|
||||
"""
|
||||
metrics: Optional[Metrics] = None
|
||||
"""
|
||||
Enables replication metrics (documented below).
|
||||
"""
|
||||
replicaKmsKeyId: Optional[str] = None
|
||||
"""
|
||||
Destination KMS encryption key ARN for SSE-KMS replication. Must be used in conjunction with
|
||||
sse_kms_encrypted_objects source selection criteria.
|
||||
"""
|
||||
replicationTime: Optional[ReplicationTime] = None
|
||||
"""
|
||||
Enables S3 Replication Time Control (S3 RTC) (documented below).
|
||||
"""
|
||||
storageClass: Optional[str] = None
|
||||
"""
|
||||
Specifies the Amazon S3 storage class to which you want the object to transition.
|
||||
"""
|
||||
|
||||
|
||||
class Filter(BaseModel):
|
||||
prefix: Optional[str] = None
|
||||
"""
|
||||
Object keyname prefix that identifies subset of objects to which the rule applies. Must be less than or equal to 1024 characters in length.
|
||||
"""
|
||||
tags: Optional[Dict[str, str]] = None
|
||||
"""
|
||||
A map of tags that identifies subset of objects to which the rule applies.
|
||||
The rule applies only to objects having all the tags in its tagset.
|
||||
"""
|
||||
|
||||
|
||||
class SseKmsEncryptedObjects(BaseModel):
|
||||
enabled: Optional[bool] = None
|
||||
"""
|
||||
Enable versioning. Once you version-enable a bucket, it can never return to an unversioned state. You can, however, suspend versioning on that bucket.
|
||||
"""
|
||||
|
||||
|
||||
class SourceSelectionCriteria(BaseModel):
|
||||
sseKmsEncryptedObjects: Optional[SseKmsEncryptedObjects] = None
|
||||
"""
|
||||
Match SSE-KMS encrypted objects (documented below). If specified, replica_kms_key_id
|
||||
in destination must be specified as well.
|
||||
"""
|
||||
|
||||
|
||||
class RuleModel(BaseModel):
|
||||
deleteMarkerReplicationStatus: Optional[str] = None
|
||||
"""
|
||||
Whether delete markers are replicated. The only valid value is Enabled. To disable, omit this argument. This argument is only valid with V2 replication configurations (i.e., when filter is used).
|
||||
"""
|
||||
destination: Optional[Destination] = None
|
||||
"""
|
||||
Specifies the destination for the rule (documented below).
|
||||
"""
|
||||
filter: Optional[Filter] = None
|
||||
"""
|
||||
Filter that identifies subset of objects to which the replication rule applies (documented below).
|
||||
"""
|
||||
id: Optional[str] = None
|
||||
"""
|
||||
Unique identifier for the rule. Must be less than or equal to 255 characters in length.
|
||||
"""
|
||||
prefix: Optional[str] = None
|
||||
"""
|
||||
Object keyname prefix identifying one or more objects to which the rule applies. Must be less than or equal to 1024 characters in length.
|
||||
"""
|
||||
priority: Optional[float] = None
|
||||
"""
|
||||
Priority associated with the rule. Priority should only be set if filter is configured. If not provided, defaults to 0. Priority must be unique between multiple rules.
|
||||
"""
|
||||
sourceSelectionCriteria: Optional[SourceSelectionCriteria] = None
|
||||
"""
|
||||
Specifies special object selection criteria (documented below).
|
||||
"""
|
||||
status: Optional[str] = None
|
||||
"""
|
||||
Status of the rule. Either Enabled or Disabled. The rule is ignored if status is not Enabled.
|
||||
"""
|
||||
|
||||
|
||||
class ReplicationConfiguration(BaseModel):
|
||||
role: Optional[str] = None
|
||||
"""
|
||||
ARN of the IAM role for Amazon S3 to assume when replicating the objects.
|
||||
"""
|
||||
rules: Optional[List[RuleModel]] = None
|
||||
"""
|
||||
Specifies the rules managing the replication (documented below).
|
||||
"""
|
||||
|
||||
|
||||
class ApplyServerSideEncryptionByDefault(BaseModel):
|
||||
kmsMasterKeyId: Optional[str] = None
|
||||
"""
|
||||
AWS KMS master key ID used for the SSE-KMS encryption. This can only be used when you set the value of sse_algorithm as aws:kms. The default aws/s3 AWS KMS master key is used if this element is absent while the sse_algorithm is aws:kms.
|
||||
"""
|
||||
sseAlgorithm: Optional[str] = None
|
||||
"""
|
||||
Server-side encryption algorithm to use. Valid values are AES256 and aws:kms
|
||||
"""
|
||||
|
||||
|
||||
class RuleModel1(BaseModel):
|
||||
applyServerSideEncryptionByDefault: Optional[ApplyServerSideEncryptionByDefault] = (
|
||||
None
|
||||
)
|
||||
"""
|
||||
Single object for setting server-side encryption by default. (documented below)
|
||||
"""
|
||||
bucketKeyEnabled: Optional[bool] = None
|
||||
"""
|
||||
Whether or not to use Amazon S3 Bucket Keys for SSE-KMS.
|
||||
"""
|
||||
|
||||
|
||||
class ServerSideEncryptionConfiguration(BaseModel):
|
||||
rule: Optional[RuleModel1] = None
|
||||
"""
|
||||
Single object for server-side encryption by default configuration. (documented below)
|
||||
"""
|
||||
|
||||
|
||||
class Versioning(BaseModel):
|
||||
enabled: Optional[bool] = None
|
||||
"""
|
||||
Enable versioning. Once you version-enable a bucket, it can never return to an unversioned state. You can, however, suspend versioning on that bucket.
|
||||
"""
|
||||
mfaDelete: Optional[bool] = None
|
||||
"""
|
||||
Enable MFA delete for either Change the versioning state of your bucket or Permanently delete an object version. Default is false. This cannot be used to toggle this setting but is available to allow managed buckets to reflect the state in AWS
|
||||
"""
|
||||
|
||||
|
||||
class Website(BaseModel):
|
||||
errorDocument: Optional[str] = None
|
||||
"""
|
||||
Absolute path to the document to return in case of a 4XX error.
|
||||
"""
|
||||
indexDocument: Optional[str] = None
|
||||
"""
|
||||
Amazon S3 returns this index document when requests are made to the root domain or any of the subfolders.
|
||||
"""
|
||||
redirectAllRequestsTo: Optional[str] = None
|
||||
"""
|
||||
Hostname to redirect all website requests for this bucket to. Hostname can optionally be prefixed with a protocol (http:// or https://) to use when redirecting requests. The default is the protocol that is used in the original request.
|
||||
"""
|
||||
routingRules: Optional[str] = None
|
||||
"""
|
||||
JSON array containing routing rules
|
||||
describing redirect behavior and when redirects are applied.
|
||||
"""
|
||||
|
||||
|
||||
class AtProvider(BaseModel):
|
||||
accelerationStatus: Optional[str] = None
|
||||
"""
|
||||
Sets the accelerate configuration of an existing bucket. Can be Enabled or Suspended. Cannot be used in cn-north-1 or us-gov-west-1.
|
||||
Use the resource aws_s3_bucket_accelerate_configuration instead.
|
||||
"""
|
||||
acl: Optional[str] = None
|
||||
"""
|
||||
The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, and log-delivery-write. Defaults to private. Conflicts with grant. Use the resource aws_s3_bucket_acl instead.
|
||||
"""
|
||||
arn: Optional[str] = None
|
||||
"""
|
||||
ARN of the bucket. Will be of format arn:aws:s3:::bucketname.
|
||||
"""
|
||||
bucketDomainName: Optional[str] = None
|
||||
"""
|
||||
Bucket domain name. Will be of format bucketname.s3.amazonaws.com.
|
||||
"""
|
||||
bucketRegionalDomainName: Optional[str] = None
|
||||
"""
|
||||
The bucket region-specific domain name. The bucket domain name including the region name. Please refer to the S3 endpoints reference for format. Note: AWS CloudFront allows specifying an S3 region-specific endpoint when creating an S3 origin. This will prevent redirect issues from CloudFront to the S3 Origin URL. For more information, see the Virtual Hosted-Style Requests for Other Regions section in the AWS S3 User Guide.
|
||||
"""
|
||||
corsRule: Optional[List[CorsRuleItem]] = None
|
||||
"""
|
||||
Rule of Cross-Origin Resource Sharing. See CORS rule below for details. Use the resource aws_s3_bucket_cors_configuration instead.
|
||||
"""
|
||||
forceDestroy: Optional[bool] = None
|
||||
"""
|
||||
Boolean that indicates all objects (including any locked objects) should be deleted from the bucket when the bucket is destroyed so that the bucket can be destroyed without error. These objects are not recoverable. This only deletes objects when the bucket is destroyed, not when setting this parameter to true. If setting this field in the same operation that would require replacing the bucket or destroying the bucket, this flag will not work.
|
||||
"""
|
||||
grant: Optional[List[GrantItem]] = None
|
||||
"""
|
||||
An ACL policy grant. See Grant below for details. Conflicts with acl. Use the resource aws_s3_bucket_acl instead.
|
||||
"""
|
||||
hostedZoneId: Optional[str] = None
|
||||
"""
|
||||
Route 53 Hosted Zone ID for this bucket's region.
|
||||
"""
|
||||
id: Optional[str] = None
|
||||
"""
|
||||
Name of the bucket.
|
||||
"""
|
||||
lifecycleRule: Optional[List[LifecycleRuleItem]] = None
|
||||
"""
|
||||
Configuration of object lifecycle management. See Lifecycle Rule below for details.
|
||||
Use the resource aws_s3_bucket_lifecycle_configuration instead.
|
||||
"""
|
||||
logging: Optional[Logging] = None
|
||||
"""
|
||||
Configuration of S3 bucket logging parameters. See Logging below for details.
|
||||
Use the resource aws_s3_bucket_logging instead.
|
||||
"""
|
||||
objectLockConfiguration: Optional[ObjectLockConfiguration] = None
|
||||
"""
|
||||
Configuration of S3 object locking. See Object Lock Configuration below for details.
|
||||
Use the object_lock_enabled parameter and the resource aws_s3_bucket_object_lock_configuration instead.
|
||||
"""
|
||||
objectLockEnabled: Optional[bool] = None
|
||||
"""
|
||||
Indicates whether this bucket has an Object Lock configuration enabled. Valid values are true or false. This argument is not supported in all regions or partitions.
|
||||
"""
|
||||
policy: Optional[str] = None
|
||||
"""
|
||||
Valid bucket policy JSON document. In this case, please make sure you use the verbose/specific version of the policy.
|
||||
Use the resource aws_s3_bucket_policy instead.
|
||||
"""
|
||||
region: Optional[str] = None
|
||||
"""
|
||||
AWS region this bucket resides in.
|
||||
Region is the region you'd like your resource to be created in.
|
||||
"""
|
||||
replicationConfiguration: Optional[ReplicationConfiguration] = None
|
||||
"""
|
||||
Configuration of replication configuration. See Replication Configuration below for details.
|
||||
Use the resource aws_s3_bucket_replication_configuration instead.
|
||||
"""
|
||||
requestPayer: Optional[str] = None
|
||||
"""
|
||||
Specifies who should bear the cost of Amazon S3 data transfer.
|
||||
Can be either BucketOwner or Requester. By default, the owner of the S3 bucket would incur the costs of any data transfer.
|
||||
See Requester Pays Buckets developer guide for more information.
|
||||
Use the resource aws_s3_bucket_request_payment_configuration instead.
|
||||
"""
|
||||
serverSideEncryptionConfiguration: Optional[ServerSideEncryptionConfiguration] = (
|
||||
None
|
||||
)
|
||||
"""
|
||||
Configuration of server-side encryption configuration. See Server Side Encryption Configuration below for details.
|
||||
Use the resource aws_s3_bucket_server_side_encryption_configuration instead.
|
||||
"""
|
||||
tags: Optional[Dict[str, str]] = None
|
||||
"""
|
||||
Key-value map of resource tags.
|
||||
"""
|
||||
tagsAll: Optional[Dict[str, str]] = None
|
||||
"""
|
||||
Map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.
|
||||
"""
|
||||
versioning: Optional[Versioning] = None
|
||||
"""
|
||||
Configuration of the S3 bucket versioning state. See Versioning below for details. Use the resource aws_s3_bucket_versioning instead.
|
||||
"""
|
||||
website: Optional[Website] = None
|
||||
"""
|
||||
Configuration of the S3 bucket website. See Website below for details.
|
||||
Use the resource aws_s3_bucket_website_configuration instead.
|
||||
"""
|
||||
websiteDomain: Optional[str] = None
|
||||
"""
|
||||
(Deprecated) Domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. Use the resource aws_s3_bucket_website_configuration instead.
|
||||
"""
|
||||
websiteEndpoint: Optional[str] = None
|
||||
"""
|
||||
(Deprecated) Website endpoint, if the bucket is configured with a website. If not, this will be an empty string. Use the resource aws_s3_bucket_website_configuration instead.
|
||||
"""
|
||||
|
||||
|
||||
class Condition(BaseModel):
|
||||
lastTransitionTime: AwareDatetime
|
||||
"""
|
||||
LastTransitionTime is the last time this condition transitioned from one
|
||||
status to another.
|
||||
"""
|
||||
message: Optional[str] = None
|
||||
"""
|
||||
A Message containing details about this condition's last transition from
|
||||
one status to another, if any.
|
||||
"""
|
||||
observedGeneration: Optional[int] = None
|
||||
"""
|
||||
ObservedGeneration represents the .metadata.generation that the condition was set based upon.
|
||||
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
|
||||
with respect to the current state of the instance.
|
||||
"""
|
||||
reason: str
|
||||
"""
|
||||
A Reason for this condition's last transition from one status to another.
|
||||
"""
|
||||
status: str
|
||||
"""
|
||||
Status of this condition; is it currently True, False, or Unknown?
|
||||
"""
|
||||
type: str
|
||||
"""
|
||||
Type of this condition. At most one of each condition type may apply to
|
||||
a resource at any point in time.
|
||||
"""
|
||||
|
||||
|
||||
class Status(BaseModel):
|
||||
atProvider: Optional[AtProvider] = None
|
||||
conditions: Optional[List[Condition]] = None
|
||||
"""
|
||||
Conditions of the resource.
|
||||
"""
|
||||
observedGeneration: Optional[int] = None
|
||||
"""
|
||||
ObservedGeneration is the latest metadata.generation
|
||||
which resulted in either a ready state, or stalled due to error
|
||||
it can not recover from without human intervention.
|
||||
"""
|
||||
|
||||
|
||||
class Bucket(BaseModel):
|
||||
apiVersion: Optional[str] = 's3.aws.upbound.io/v1beta2'
|
||||
"""
|
||||
APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
"""
|
||||
kind: Optional[str] = 'Bucket'
|
||||
"""
|
||||
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
"""
|
||||
metadata: Optional[v1.ObjectMeta] = None
|
||||
"""
|
||||
Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
|
||||
"""
|
||||
spec: Spec
|
||||
"""
|
||||
BucketSpec defines the desired state of Bucket
|
||||
"""
|
||||
status: Optional[Status] = None
|
||||
"""
|
||||
BucketStatus defines the observed state of Bucket.
|
||||
"""
|
||||
|
||||
|
||||
class BucketList(BaseModel):
|
||||
apiVersion: Optional[str] = None
|
||||
"""
|
||||
APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||
"""
|
||||
items: List[Bucket]
|
||||
"""
|
||||
List of buckets. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md
|
||||
"""
|
||||
kind: Optional[str] = None
|
||||
"""
|
||||
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
"""
|
||||
metadata: Optional[v1.ListMeta] = None
|
||||
"""
|
||||
Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
"""
|
Loading…
Reference in New Issue