Compare commits

...

226 Commits
v0.1.0 ... main

Author SHA1 Message Date
Bob Haddleton 6e65599e58
Merge pull request #150 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.11.9
2025-05-09 11:41:51 -05:00
Bob Haddleton a5cde9d9ee
Merge pull request #149 from crossplane/renovate/ipython-9.x
chore(deps): update dependency ipython to v9.2.0
2025-05-09 11:41:21 -05:00
renovate[bot] f99b12c0de
chore(deps): update dependency ruff to v0.11.9 2025-05-09 16:39:28 +00:00
Bob Haddleton 27e990f6aa
Merge pull request #146 from crossplane/renovate/protobuf-6.x
fix(deps): update dependency protobuf to v6
2025-05-09 11:39:03 -05:00
Nic Cope cf67e6d0fe
Merge pull request #147 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.11.7
2025-04-28 15:11:45 -07:00
renovate[bot] 14b6502f33
chore(deps): update dependency ipython to v9.2.0 2025-04-25 19:49:36 +00:00
renovate[bot] 7a915c2df7
chore(deps): update dependency ruff to v0.11.7 2025-04-24 19:53:55 +00:00
Bob Haddleton 3931d503fc
Merge pull request #140 from negz/terminal
Shutdown gracefully on SIGTERM
2025-04-23 14:06:31 -05:00
renovate[bot] 82e60b0596
fix(deps): update dependency protobuf to v6 2025-04-23 19:05:17 +00:00
Bob Haddleton 57df02ae00
Merge pull request #144 from fernandezcuesta/fix/protobuf-gencode-misalignment
chore: update gRPC stubs
2025-04-23 14:04:50 -05:00
Bob Haddleton b1e9695250
Merge pull request #143 from crossplane/renovate/ipython-9.x
chore(deps): update dependency ipython to v9.1.0
2025-04-23 14:03:40 -05:00
Bob Haddleton 1f3d442276
Merge pull request #142 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.11.6
2025-04-23 14:03:05 -05:00
renovate[bot] f0bb336ba5
chore(deps): update dependency ruff to v0.11.6 2025-04-17 16:36:17 +00:00
Jesús Fernández 47180d9798
**Summary:**
Functions depending on function-sdk-python 0.6.0 are giving a segmentation fault.
When (re)running the tests for this module, the following is shown:

```
runtime_version.py:98: UserWarning: Protobuf gencode version 5.29.0 is exactly one major version older than the runtime version 6.30.2 at crossplane/function/proto/v1beta1/run_function.proto. Please update the gencode to avoid compatibility violations in the next runtime release.
```

Apparently when renovatebot opened a PR with a bump up on `protobuf` version,
the major version change violated the constraint with `grpcio-tools`, which
has the following dependency:

```
Collecting protobuf<6.0dev,>=5.26.1 (from grpcio-tools==1.71.0)
```

This makes incompatible to have different versions of protobuf for the `build`
venv and the `generate` one.

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
2025-04-10 12:11:43 +02:00
renovate[bot] 869fbfeb3d
chore(deps): update dependency ipython to v9.1.0 2025-04-07 10:26:46 +00:00
Bob Haddleton 9f55079121
Merge pull request #141 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.11.3
2025-04-03 12:38:24 -05:00
renovate[bot] ed95373a01
chore(deps): update dependency ruff to v0.11.3 2025-04-03 14:31:41 +00:00
Nic Cope 0262a24330
Merge pull request #139 from negz/maintaining
Add OWNERS and CODEOWNERS
2025-04-02 14:29:53 +01:00
Nic Cope 8895e9d9af
Merge pull request #138 from negz/typical
Let tools know this library supports type hints
2025-04-02 14:29:30 +01:00
Nic Cope 1e0c20eb61
Merge pull request #135 from crossplane/renovate/grpcio-1.x
fix(deps): update dependency grpcio to v1.71.0
2025-04-01 07:05:09 -07:00
Nic Cope cdaf6697c5 Shutdown gracefully on SIGTERM
Signed-off-by: Nic Cope <nicc@rk0n.org>
2025-04-01 07:00:44 -07:00
Nic Cope fcec201f01 Run hatch fmt
This file wasn't formatted before making it into main. Not sure why the
linter didn't catch it...

Signed-off-by: Nic Cope <nicc@rk0n.org>
2025-04-01 06:59:38 -07:00
renovate[bot] 88d97d3cab
fix(deps): update dependency grpcio to v1.71.0 2025-04-01 13:43:23 +00:00
Nic Cope e2606cff9f Add OWNERS and CODEOWNERS
Signed-off-by: Nic Cope <nicc@rk0n.org>
2025-04-01 06:42:19 -07:00
Nic Cope f295c0144b Let tools know this library supports type hints
https://typing.python.org/en/latest/spec/distributing.html#packaging-type-information
https://typing.python.org/en/latest/guides/libraries.html#marking-a-package-as-providing-type-information

It turns out we need to add a py.typed file so that tools will know this
library has type hints. As far as I can tell we don't need to do
anything special to have our build tool (Hatch) include this file when
it builds and packages the library.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2025-04-01 06:23:58 -07:00
Bob Haddleton 325c37d344
Merge pull request #133 from crossplane/renovate/protobuf-6.x
fix(deps): update dependency protobuf to v6
2025-03-31 14:21:07 -05:00
Bob Haddleton e6b771c3a6
Merge pull request #134 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.71.0
2025-03-31 14:20:36 -05:00
Bob Haddleton 68cbf5f53e
Merge pull request #132 from crossplane/renovate/ipython-9.x
chore(deps): update dependency ipython to v9
2025-03-31 14:20:04 -05:00
renovate[bot] c8bcded971
chore(deps): update dependency ipython to v9 2025-03-31 19:17:37 +00:00
Bob Haddleton e0b964055b
Merge pull request #128 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.11.2
2025-03-31 14:17:28 -05:00
Bob Haddleton 5c1e33baf4
Merge pull request #131 from crossplane/renovate/ipython-8.x
chore(deps): update dependency ipython to v8.34.0
2025-03-31 14:17:02 -05:00
renovate[bot] 466945254d
fix(deps): update dependency protobuf to v6 2025-03-26 19:58:40 +00:00
renovate[bot] 4fb63f221e
chore(deps): update dependency ruff to v0.11.2 2025-03-21 15:57:10 +00:00
renovate[bot] 26bdc926e8
chore(deps): update dependency grpcio-tools to v1.71.0 2025-03-10 22:00:28 +00:00
renovate[bot] 1e0f18263e
chore(deps): update dependency ipython to v8.34.0 2025-03-08 17:46:16 +00:00
Bob Haddleton 4ad65f2934
Merge pull request #127 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.9.5
2025-02-06 16:33:38 -06:00
renovate[bot] aa09bd0632
chore(deps): update dependency ruff to v0.9.5 2025-02-06 21:13:29 +00:00
Bob Haddleton 0f188bcbde
Merge pull request #126 from crossplane/renovate/grpcio-1.x
fix(deps): update dependency grpcio to v1.70.0
2025-02-02 21:31:26 -06:00
renovate[bot] de5a11c59f
fix(deps): update dependency grpcio to v1.70.0 2025-02-01 21:16:32 +00:00
Bob Haddleton afa27a3121
Merge pull request #102 from fernandezcuesta/main
fix: convert listValues to lists in nested structs
2025-02-01 15:16:07 -06:00
Bob Haddleton aaf3d08879
Merge pull request #124 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.9.4
2025-02-01 15:14:32 -06:00
Bob Haddleton aff844707c
Merge pull request #125 from crossplane/renovate/ipython-8.x
chore(deps): update dependency ipython to v8.32.0
2025-02-01 15:14:03 -06:00
renovate[bot] fb5d6fa5ab
chore(deps): update dependency ipython to v8.32.0 2025-02-01 21:11:14 +00:00
renovate[bot] 8525cebb57
chore(deps): update dependency ruff to v0.9.4 2025-01-30 19:15:14 +00:00
Bob Haddleton 597f5ee437
Merge pull request #119 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.9.3
2025-01-27 12:05:54 -06:00
Bob Haddleton ce63739286
Merge pull request #120 from crossplane/renovate/structlog-25.x
fix(deps): update dependency structlog to v25
2025-01-27 12:05:25 -06:00
Bob Haddleton dbc0d0176b
Merge pull request #123 from crossplane/renovate/pypa-gh-action-pypi-publish-1.x
chore(deps): update pypa/gh-action-pypi-publish action to v1.12.4
2025-01-27 12:04:52 -06:00
Bob Haddleton d3bad9135d
Merge pull request #122 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.70.0
2025-01-27 12:04:22 -06:00
renovate[bot] b6d553bdaf
chore(deps): update pypa/gh-action-pypi-publish action to v1.12.4 2025-01-24 05:16:53 +00:00
renovate[bot] cd38d99a5c
chore(deps): update dependency grpcio-tools to v1.70.0 2025-01-23 23:00:08 +00:00
renovate[bot] 0932de3e5d
chore(deps): update dependency ruff to v0.9.3 2025-01-23 23:00:05 +00:00
renovate[bot] 47d0d54b26
fix(deps): update dependency structlog to v25 2025-01-16 18:16:24 +00:00
J. Fernández 54d6e39371
Merge branch 'main' into main 2025-01-15 10:01:42 +01:00
Bob Haddleton 8551576b1f
Merge pull request #118 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.9.1
2025-01-14 13:55:18 -06:00
renovate[bot] f1ae43e725
chore(deps): update dependency ruff to v0.9.1 2025-01-10 21:12:29 +00:00
Bob Haddleton 192b1d0b7a
Merge pull request #117 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.9.0
2025-01-09 11:44:55 -06:00
renovate[bot] a82962a952
chore(deps): update dependency ruff to v0.9.0 2025-01-09 17:42:43 +00:00
Bob Haddleton 0651813b59
Merge pull request #116 from crossplane/renovate/protobuf-5.x
fix(deps): update dependency protobuf to v5.29.3
2025-01-09 11:42:20 -06:00
renovate[bot] 8f57f81ea1
fix(deps): update dependency protobuf to v5.29.3 2025-01-09 01:22:39 +00:00
Bob Haddleton 2c8b642afd
Merge pull request #110 from crossplane/renovate/ipython-8.x
chore(deps): update dependency ipython to v8.31.0
2025-01-08 14:30:31 -06:00
renovate[bot] 479335d1e3
chore(deps): update dependency ipython to v8.31.0 2025-01-08 20:16:39 +00:00
Bob Haddleton 84cf34e482
Merge pull request #107 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.8.6
2025-01-08 13:56:36 -06:00
Bob Haddleton 81df679319
Merge pull request #111 from crossplane/renovate/pypa-gh-action-pypi-publish-1.x
chore(deps): update pypa/gh-action-pypi-publish action to v1.12.3
2025-01-08 13:53:15 -06:00
renovate[bot] 773346f3f8
chore(deps): update dependency ruff to v0.8.6 2025-01-08 19:52:55 +00:00
Bob Haddleton 77f1f6e8dd
Merge pull request #105 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.69.0
2025-01-08 13:52:21 -06:00
renovate[bot] b8dd9ec256
chore(deps): update dependency grpcio-tools to v1.69.0 2025-01-08 19:50:52 +00:00
renovate[bot] 6b3e0cbcc4
chore(deps): update pypa/gh-action-pypi-publish action to v1.12.3 2025-01-08 19:50:30 +00:00
Bob Haddleton d9e26f5b03
Merge pull request #89 from crossplane/renovate/protobuf-5.x
fix(deps): update dependency protobuf to v5.29.2
2025-01-08 13:49:57 -06:00
renovate[bot] 5139481ee5
fix(deps): update dependency protobuf to v5.29.2 2025-01-08 19:48:30 +00:00
Nic Cope a8999723f4
Merge pull request #115 from bobh66/fix_bucket_version
fix(unittests): fix bucket api version
2025-01-08 11:47:05 -08:00
Bob Haddleton 9ef55d251c fix(unittests): fix bucket api version 2025-01-08 13:33:33 -06:00
Nic Cope 064ffe7458
Merge pull request #112 from crossplane/fix_unit_tests
Bump protobuf and add defensive checks to get_* helpers
2025-01-08 11:19:46 -08:00
Nic Cope d4b3506ec7
Merge pull request #114 from haarchri/test
Pydantic, exclude_defaults=True re-add `apiVersion` and `kind`
2025-01-08 11:18:57 -08:00
Christopher Haar 70e86c0d30 fix(defaults): add apiVersion and kind
Signed-off-by: Christopher Haar <christopher.haar@upbound.io>
2025-01-06 17:10:32 +01:00
Bob Haddleton 685918f02d Bump protobuf and add defensive checks to get_* helpers
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
2024-12-18 14:27:11 -06:00
Bob Haddleton 9c44291da2
Merge pull request #106 from crossplane/renovate/pypa-gh-action-pypi-publish-1.x
chore(deps): update pypa/gh-action-pypi-publish action to v1.12.2
2024-11-30 14:54:48 -06:00
Jesús Fernández 36e5600356
chore: stick to grpcio 1.67.0
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
2024-11-26 20:04:55 +01:00
J. Fernández 5cf7fffbf1
bump protobuf
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
2024-11-26 19:55:16 +01:00
Jesús Fernández c632b0c1ad
feat: use json_format.ParseDict to convert dicts to structs
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
2024-11-25 12:08:06 +01:00
Jesús Fernández 25e49cf3bd
fix: structs containing listvalues are properly converted
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
2024-11-13 22:23:14 +01:00
renovate[bot] 7452119ba8
chore(deps): update pypa/gh-action-pypi-publish action to v1.12.2 2024-11-07 01:51:37 +00:00
Bob Haddleton 870edfcd76
Merge pull request #104 from crossplane/renovate/ipython-8.x
chore(deps): update dependency ipython to v8.29.0
2024-10-25 07:52:00 -05:00
Bob Haddleton fc8796d42b
Merge pull request #103 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.7.1
2024-10-25 07:51:07 -05:00
renovate[bot] 569af1d6d3
chore(deps): update dependency ipython to v8.29.0 2024-10-25 10:48:41 +00:00
renovate[bot] 41eca588a1
chore(deps): update dependency ruff to v0.7.1 2024-10-24 16:33:59 +00:00
Bob Haddleton 50086a69b2
Merge pull request #101 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.7.0
2024-10-17 22:40:11 -05:00
Bob Haddleton 1bf5f444e4
Merge pull request #100 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.67.0
2024-10-17 22:39:31 -05:00
renovate[bot] 5a3e1536ee
chore(deps): update dependency ruff to v0.7.0 2024-10-17 17:25:30 +00:00
renovate[bot] 6a256486e2
chore(deps): update dependency grpcio-tools to v1.67.0 2024-10-16 08:53:28 +00:00
Nic Cope fde5b7ef84
Merge pull request #93 from crossplane/renovate/ubuntu-24.x
chore(deps): update dependency ubuntu to v24
2024-10-09 20:02:22 -07:00
renovate[bot] 266dd49d93
chore(deps): update dependency ubuntu to v24 2024-10-10 03:00:53 +00:00
Nic Cope 5ceb76308d
Merge pull request #99 from negz/hatchery
Update to hatch v0.12, which includes new `hatch test` and `hatch fmt` commands
2024-10-09 20:00:23 -07:00
Nic Cope 59f8ccc62a Use latest available Python 3.11.x
Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-10-09 19:58:54 -07:00
Nic Cope 8057458e36 Bump Python version
Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-10-09 19:57:32 -07:00
Nic Cope 7990ab8939 Use the new hatch fmt command to run linters and formatting
Right now this defaults to a pretty old version of ruff. Hatch pins a
ruff version though, so I'm inclined to just use whatever ruff version
Hatch uses.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-10-09 19:54:19 -07:00
Nic Cope d10f084b84 Use the new hatch test command to run tests
Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-10-09 19:54:19 -07:00
Nic Cope 33ee9e1c4a
Merge pull request #98 from negz/pydants
Add a `resource.update` convenience function
2024-10-09 19:11:05 -07:00
Nic Cope df655cabec Use class matches in resource.update()
This was introduced in 3.10, and seems like a much better way to handle
matching a type.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-10-09 18:04:33 -07:00
Nic Cope 5fe3b5c9e0 Don't lint (generated) testdata
Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-10-09 18:04:33 -07:00
Nic Cope 974bdc45a6 Add a resource.update convenience function
This function can be used to add or update a resource.

For example, to add a desired composed bucket (assuming the "bucket"
resource doesn't yet exist):

```python
resource.update(rsp.desired.resources["bucket"], bucket)
```

Or to update the desired XR:

```python
resource.update(rsp.desired.composite.resource, partial_xr)
```

The source resource can be a dictionary, a protobuf struct, or a
Pydantic model.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-10-09 18:04:33 -07:00
Nic Cope b57a5cc532
Merge pull request #97 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.6.9
2024-10-09 17:59:42 -07:00
renovate[bot] e6638d23de
chore(deps): update dependency ruff to v0.6.9 2024-10-04 15:57:27 +00:00
Bob Haddleton c359461aba
Merge pull request #92 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.6.8
2024-10-04 08:20:10 -05:00
Bob Haddleton 6e741032dd
Merge pull request #96 from crossplane/renovate/pypa-gh-action-pypi-publish-1.x
chore(deps): update pypa/gh-action-pypi-publish action to v1.10.3
2024-10-04 08:19:40 -05:00
renovate[bot] ed8a958352
chore(deps): update pypa/gh-action-pypi-publish action to v1.10.3 2024-10-04 04:42:12 +00:00
Bob Haddleton 3c487eb331
Merge pull request #95 from crossplane/renovate/ipython-8.x
chore(deps): update dependency ipython to v8.28.0
2024-10-02 07:33:38 -05:00
renovate[bot] c3e673d75d
chore(deps): update dependency ipython to v8.28.0 2024-10-02 12:02:04 +00:00
Bob Haddleton 362377d127
Merge pull request #94 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.66.2
2024-09-28 10:23:19 -05:00
renovate[bot] 6724d5f751
chore(deps): update dependency grpcio-tools to v1.66.2 2024-09-28 15:15:56 +00:00
renovate[bot] 180ecf03c9
chore(deps): update dependency ruff to v0.6.8 2024-09-26 14:26:44 +00:00
Bob Haddleton dc2184e615
Merge pull request #90 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.6.7
2024-09-21 15:55:51 -05:00
renovate[bot] 064e2aa9fd
chore(deps): update dependency ruff to v0.6.7 2024-09-21 19:16:46 +00:00
Bob Haddleton dc14d6ee97
Merge pull request #91 from crossplane/renovate/pypa-gh-action-pypi-publish-1.x
chore(deps): update pypa/gh-action-pypi-publish action to v1.10.2
2024-09-20 17:41:33 -05:00
renovate[bot] 0d5c56841d
chore(deps): update pypa/gh-action-pypi-publish action to v1.10.2 2024-09-20 22:24:19 +00:00
Nic Cope f283740fcc
Merge pull request #87 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.6.5
2024-09-18 17:50:37 -07:00
renovate[bot] 7c4fc33106
chore(deps): update dependency ruff to v0.6.5 2024-09-13 17:15:21 +00:00
Bob Haddleton 8e4f43b297
Merge pull request #85 from crossplane/renovate/pypa-gh-action-pypi-publish-1.x
chore(deps): update pypa/gh-action-pypi-publish action to v1.10.1
2024-09-03 14:36:45 -05:00
renovate[bot] 8f0f8b2455
chore(deps): update pypa/gh-action-pypi-publish action to v1.10.1 2024-09-03 19:35:13 +00:00
Bob Haddleton 147a52d1fc
Merge pull request #83 from crossplane/renovate/ipython-8.x
chore(deps): update dependency ipython to v8.27.0
2024-09-03 14:33:58 -05:00
renovate[bot] 8b868813ef
chore(deps): update dependency ipython to v8.27.0 2024-09-03 19:30:17 +00:00
Bob Haddleton 6cf22d08e9
Merge pull request #82 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.6.3
2024-09-03 14:29:09 -05:00
renovate[bot] 7980096588
chore(deps): update dependency ruff to v0.6.3 2024-09-03 19:27:28 +00:00
Bob Haddleton 05f4c59f9b
Merge pull request #81 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.66.1
2024-09-03 14:24:14 -05:00
renovate[bot] b03cbba90f
chore(deps): update dependency grpcio-tools to v1.66.1 2024-09-03 19:22:47 +00:00
Bob Haddleton 8a723bc386
Merge pull request #84 from bobh66/update_grpc_proto
Update protobuf to 5.27.2
2024-09-03 14:19:50 -05:00
Bob Haddleton b3ca1f4350 Pin protobuf to resolve errors
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
2024-08-30 21:01:23 -05:00
Bob Haddleton ff67b54871 Update grpcio to at least 1.66.0
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
2024-08-30 16:27:27 -05:00
Bob Haddleton f197e4153b Update grpc proto to 1.66
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
2024-08-30 16:22:12 -05:00
Bob Haddleton d287926b81
Merge pull request #80 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.66.0
2024-08-22 19:08:53 -05:00
renovate[bot] 4c92b3d67b
chore(deps): update dependency grpcio-tools to v1.66.0 2024-08-22 22:25:40 +00:00
Bob Haddleton ad29667aca
Merge pull request #79 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.6.2
2024-08-22 12:08:06 -05:00
renovate[bot] 8460e7c175
chore(deps): update dependency ruff to v0.6.2 2024-08-22 17:03:39 +00:00
Bob Haddleton 114092deec
Merge pull request #78 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.65.5
2024-08-17 21:13:12 -05:00
renovate[bot] c2c39d437c
chore(deps): update dependency grpcio-tools to v1.65.5 2024-08-17 05:26:04 +00:00
Nic Cope 9850b183f5
Merge pull request #77 from negz/its-happening-dot-gif
Return a response, not a request
2024-08-16 17:30:24 -07:00
Nic Cope 39b1128332 Return a response, not a request
Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-08-16 17:17:05 -07:00
Nic Cope f8f842de82
Merge pull request #75 from negz/its-happening-dot-gif
Promote composition functions to v1
2024-08-16 15:09:05 -07:00
Nic Cope 0f7d85f43d Promote composition functions to v1
Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-08-16 15:05:29 -07:00
Bob Haddleton 7837143425
Merge pull request #76 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.6.1
2024-08-16 15:54:53 -05:00
renovate[bot] 8d6112205f
chore(deps): update dependency ruff to v0.6.1 2024-08-16 20:14:09 +00:00
Bob Haddleton 069cd68c28
Merge pull request #74 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.6.0
2024-08-15 10:46:49 -05:00
renovate[bot] e19fa8bf57
chore(deps): update dependency ruff to v0.6.0 2024-08-15 15:44:59 +00:00
Nic Cope 6037575281
Merge pull request #73 from fernandezcuesta/main
fix: recursively convert struct to dict
2024-08-13 12:41:18 -07:00
Jesús Fernández 556607ede7
fix: recursively convert struct to dict
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
2024-08-13 10:13:28 +02:00
Bob Haddleton 50f301a73e
Merge pull request #72 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.5.7
2024-08-08 12:04:34 -04:00
Bob Haddleton b65bce9787
Merge pull request #71 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.65.4
2024-08-08 12:04:06 -04:00
renovate[bot] 0cf78a98a6
chore(deps): update dependency ruff to v0.5.7 2024-08-08 16:00:57 +00:00
renovate[bot] b79146a8c4
chore(deps): update dependency grpcio-tools to v1.65.4 2024-08-02 18:19:41 +00:00
Bob Haddleton f0dd3c41e3
Merge pull request #70 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.5.5
2024-07-25 13:23:44 -05:00
renovate[bot] 626c01a3c6
chore(deps): update dependency ruff to v0.5.5 2024-07-25 18:06:09 +00:00
Bob Haddleton ee47c2bbe3
Merge pull request #69 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.65.1
2024-07-18 13:26:58 -05:00
renovate[bot] 34f26a171f
chore(deps): update dependency grpcio-tools to v1.65.1 2024-07-18 08:48:27 +00:00
Bob Haddleton 1939eecd6b
Merge pull request #68 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.5.2
2024-07-14 12:25:17 -05:00
renovate[bot] ab8fdbf378
chore(deps): update dependency ruff to v0.5.2 2024-07-14 16:43:33 +00:00
Bob Haddleton b20b98b072
Merge pull request #67 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.65.0
2024-07-11 15:18:08 -05:00
renovate[bot] 7b92076473
chore(deps): update dependency grpcio-tools to v1.65.0 2024-07-11 10:13:09 +00:00
Bob Haddleton 193d468376
Merge pull request #66 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.5.1
2024-07-05 09:48:17 -05:00
renovate[bot] 2ba56eac92
chore(deps): update dependency ruff to v0.5.1 2024-07-05 14:05:01 +00:00
Bob Haddleton 7eaa507eb1
Merge pull request #65 from crossplane/renovate/ipython-8.x
chore(deps): update dependency ipython to v8.26.0
2024-07-01 10:33:14 -05:00
renovate[bot] 95d7dc7195
chore(deps): update dependency ipython to v8.26.0 2024-06-28 09:27:10 +00:00
Bob Haddleton 3aa74114fa
Merge pull request #64 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.5.0
2024-06-27 13:42:31 -05:00
renovate[bot] 4cdd26b141
chore(deps): update dependency ruff to v0.5.0 2024-06-27 18:41:13 +00:00
Nic Cope d1c067e388
Merge pull request #62 from bobh66/loop
Fix different loop errors on python 3.12
2024-06-26 13:38:13 -07:00
Nic Cope 8261272aff
Merge pull request #63 from bobh66/credentials
Add support for credentials
2024-06-26 13:36:51 -07:00
Bob Haddleton d383a331a7
Merge pull request #58 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.64.1
2024-06-26 13:47:35 -05:00
renovate[bot] 73c8c299bb
chore(deps): update dependency grpcio-tools to v1.64.1 2024-06-26 18:46:34 +00:00
Bob Haddleton be1ea67d2e
Merge pull request #59 from crossplane/renovate/ipython-8.x
chore(deps): update dependency ipython to v8.25.0
2024-06-26 13:45:34 -05:00
Bob Haddleton 1bab07c2c9
Merge pull request #61 from crossplane/renovate/pypa-gh-action-pypi-publish-1.x
chore(deps): update pypa/gh-action-pypi-publish action to v1.9.0
2024-06-26 13:43:13 -05:00
Bob Haddleton 86e715d718 Add support for credentials
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
2024-06-26 13:36:08 -05:00
Bob Haddleton c214b4b1ba Fix lint configuration warnings
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
2024-06-25 18:37:39 -05:00
Bob Haddleton a24b927baf Fix different loop errors in 3.12
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
2024-06-25 18:35:10 -05:00
Bob Haddleton 00beeb1ba7
Merge pull request #57 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.4.10
2024-06-20 14:19:07 -05:00
renovate[bot] c7e73d1823
chore(deps): update dependency ruff to v0.4.10 2024-06-20 19:05:47 +00:00
renovate[bot] c9551c9e88
chore(deps): update pypa/gh-action-pypi-publish action to v1.9.0 2024-06-16 19:29:49 +00:00
renovate[bot] 40638f325e
chore(deps): update dependency ipython to v8.25.0 2024-05-31 15:09:20 +00:00
Bob Haddleton 8ad3d882d3
Merge pull request #50 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.62.2
2024-04-21 09:22:33 -05:00
Bob Haddleton 315857ee26
Merge pull request #56 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.4.1
2024-04-21 09:21:23 -05:00
renovate[bot] 860ec281f2
chore(deps): update dependency ruff to v0.4.1 2024-04-20 14:22:58 +00:00
renovate[bot] 07cea82fd4
chore(deps): update dependency grpcio-tools to v1.62.2 2024-04-20 14:22:55 +00:00
Bob Haddleton 6e8530c0f0
Merge pull request #55 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.3.5
2024-04-01 15:41:09 -05:00
renovate[bot] aac80f59e1
chore(deps): update dependency ruff to v0.3.5 2024-04-01 19:23:15 +00:00
Bob Haddleton 579ae97773
Merge pull request #54 from crossplane/renovate/ipython-8.x
chore(deps): update dependency ipython to v8.23.0
2024-03-31 12:27:47 -05:00
Bob Haddleton 268bf2a362
Merge pull request #53 from crossplane/renovate/actions-configure-pages-5.x
chore(deps): update actions/configure-pages action to v5
2024-03-31 12:27:16 -05:00
Bob Haddleton 202a88a29f
Merge pull request #52 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.3.4
2024-03-31 12:26:44 -05:00
renovate[bot] 5d480b46cf
chore(deps): update dependency ipython to v8.23.0 2024-03-31 17:13:31 +00:00
renovate[bot] 8df052e3eb
chore(deps): update actions/configure-pages action to v5 2024-03-30 01:19:11 +00:00
renovate[bot] d5d463e542
chore(deps): update dependency ruff to v0.3.4 2024-03-21 22:11:18 +00:00
Bob Haddleton c6f91a93e8
Merge pull request #51 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.3.2
2024-03-11 09:21:14 -05:00
renovate[bot] c6896415c5
chore(deps): update dependency ruff to v0.3.2 2024-03-09 03:09:52 +00:00
Bob Haddleton 30c66c4fb7
Merge pull request #49 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.3.1
2024-03-08 14:00:15 -06:00
Bob Haddleton a4e53820c8
Merge pull request #48 from crossplane/renovate/ipython-8.x
chore(deps): update dependency ipython to v8.22.2
2024-03-08 13:59:51 -06:00
Bob Haddleton 3bf234c44d
Merge pull request #46 from crossplane/renovate/pypa-gh-action-pypi-publish-1.x
chore(deps): update pypa/gh-action-pypi-publish action to v1.8.14
2024-03-08 13:59:26 -06:00
Bob Haddleton 5e2cede190
Merge pull request #44 from crossplane/renovate/grpcio-tools-1.x
chore(deps): update dependency grpcio-tools to v1.62.0
2024-03-08 13:58:53 -06:00
renovate[bot] 97dd555f03
chore(deps): update pypa/gh-action-pypi-publish action to v1.8.14 2024-03-08 00:59:58 +00:00
renovate[bot] 24930e5d73
chore(deps): update dependency ruff to v0.3.1 2024-03-07 02:22:01 +00:00
renovate[bot] 068fbb01ba
chore(deps): update dependency ipython to v8.22.2 2024-03-04 10:39:31 +00:00
Bob Haddleton 6e8f78e42d
Merge pull request #47 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.3.0
2024-02-29 09:39:24 -06:00
renovate[bot] 09ed73551b
chore(deps): update dependency ruff to v0.3.0 2024-02-29 15:37:47 +00:00
Bob Haddleton c8c6afa295
Merge pull request #45 from crossplane/renovate/ipython-8.x
chore(deps): update dependency ipython to v8.22.1
2024-02-22 12:50:27 -06:00
renovate[bot] 24839a25df
chore(deps): update dependency ipython to v8.22.1 2024-02-22 15:53:28 +00:00
renovate[bot] c056300872
chore(deps): update dependency grpcio-tools to v1.62.0 2024-02-21 23:28:55 +00:00
Nic Cope f7230fdd3e
Merge pull request #43 from crossplane/renovate/ruff-0.x
chore(deps): update dependency ruff to v0.2.2
2024-02-21 15:28:38 -08:00
renovate[bot] 9c282500be
chore(deps): update dependency ruff to v0.2.2 2024-02-18 00:27:57 +00:00
Nic Cope 4ea7a909ef
Merge pull request #39 from vibe/main
feat: generate extra resources proto
2024-02-01 22:07:55 -08:00
Nic Cope 439ecb87ec
Merge pull request #42 from crossplane/renovate/grpcio-tools-1.x
Update dependency grpcio-tools to v1.60.1
2024-02-01 22:07:06 -08:00
Nic Cope 5e2643b8c2
Merge pull request #41 from crossplane/renovate/ipython-8.x
Update dependency ipython to v8.21.0
2024-02-01 22:06:42 -08:00
renovate[bot] 7f4f118925
Update dependency grpcio-tools to v1.60.1 2024-02-01 22:41:57 +00:00
renovate[bot] 6f043878ac
Update dependency ipython to v8.21.0 2024-01-31 14:01:34 +00:00
Bob Haddleton 1f49c3437c
Merge pull request #40 from crossplane/renovate/ruff-0.x
Update dependency ruff to v0.1.15
2024-01-29 19:35:03 -06:00
renovate[bot] fe8c323754
Update dependency ruff to v0.1.15 2024-01-30 00:47:44 +00:00
vibe e1851feb69 feat: generate extra resources proto
Signed-off-by: vibe <francoc137@icloud.com>
2024-01-25 06:20:38 -08:00
Nic Cope 5c354a9041
Merge pull request #38 from crossplane/renovate/ruff-0.x
Update dependency ruff to v0.1.14
2024-01-24 16:37:06 -08:00
renovate[bot] 4d1542ab2c
Update dependency ruff to v0.1.14 2024-01-19 22:40:30 +00:00
Nic Cope efe587b0b5
Merge pull request #35 from negz/link-get
Link guide, package docs
2024-01-12 16:06:00 -08:00
Nic Cope 73cfd7dc91 Link guide, package docs
Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-01-12 16:04:21 -08:00
Nic Cope c05a20bfbf
Merge pull request #34 from crossplane/renovate/ruff-0.x
Update dependency ruff to v0.1.13
2024-01-12 16:01:12 -08:00
renovate[bot] c1a32d1bf9
Update dependency ruff to v0.1.13 2024-01-12 17:11:04 +00:00
Bob Haddleton fd28b20cb7
Merge pull request #32 from crossplane/renovate/ipython-8.x
Update dependency ipython to v8.20.0
2024-01-08 07:57:46 -06:00
Bob Haddleton f6194cc1e9
Merge pull request #33 from crossplane/renovate/structlog-24.x
Update dependency structlog to v24
2024-01-08 07:57:18 -06:00
renovate[bot] d87d844949
Update dependency structlog to v24 2024-01-08 12:39:29 +00:00
renovate[bot] 8f66ed0f63
Update dependency ipython to v8.20.0 2024-01-08 12:39:26 +00:00
Nic Cope 7ec501d193
Merge pull request #31 from negz/i-love-you-godoc
Generate and publish API docs to GitHub pages
2024-01-05 17:42:24 -08:00
Nic Cope 2c6a27627e Generate and publish API docs to GitHub pages
I suspect we'll need a more actively maintained docs tool that supports
versions etc in future. Unfortunately Sphinx and Pydoc both seem more
heavyweight than I'd like right now, and I can't find any other great
options.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-01-05 13:08:30 -08:00
Nic Cope 4569ef1018
Merge pull request #30 from negz/in-the-pipe
Add PyPI badge, function-template-python link
2024-01-04 16:44:58 -08:00
Nic Cope 9190f78c9f Link to GitHub releases, and PyPI, from badges
Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-01-04 16:39:26 -08:00
Nic Cope 25f400bb45 Add PyPI badge, function-template-python link
I considered adding instructions to pip install this package, but
decided against it. I think almost everyone should be using the template
instead.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-01-04 16:35:54 -08:00
26 changed files with 2845 additions and 128 deletions

View File

@ -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

3
.gitignore vendored
View File

@ -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

22
CODEOWNERS Normal file
View File

@ -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

18
OWNERS.md Normal file
View File

@ -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.

View File

@ -1,5 +1,6 @@
# function-sdk-python
[![CI](https://github.com/crossplane/function-sdk-python/actions/workflows/ci.yml/badge.svg)](https://github.com/crossplane/function-sdk-python/actions/workflows/ci.yml) ![GitHub release (latest SemVer)](https://img.shields.io/github/release/crossplane/function-sdk-python)
[![CI](https://github.com/crossplane/function-sdk-python/actions/workflows/ci.yml/badge.svg)](https://github.com/crossplane/function-sdk-python/actions/workflows/ci.yml) [![GitHub release (latest SemVer)](https://img.shields.io/github/release/crossplane/function-sdk-python)](https://github.com/crossplane/function-sdk-python/releases) [![PyPI - Version](https://img.shields.io/pypi/v/crossplane-function-sdk-python)](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

View File

@ -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

View File

@ -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: ...

View File

@ -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)

View File

@ -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

View File

@ -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: ...

View File

@ -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)

View File

View File

@ -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"]),
)

View File

@ -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,
)
)

View File

@ -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

View File

@ -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]

View File

@ -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()

View File

@ -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"}),

71
tests/test_runtime.py Normal file
View File

@ -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()

View File

@ -0,0 +1,3 @@
# generated by datamodel-codegen:
# filename: <stdin>
# timestamp: 2024-10-04T21:01:52+00:00

View File

@ -0,0 +1,3 @@
# generated by datamodel-codegen:
# filename: <stdin>
# timestamp: 2024-10-04T21:01:52+00:00

View File

@ -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
"""

View File

@ -0,0 +1,3 @@
# generated by datamodel-codegen:
# filename: <stdin>
# timestamp: 2024-10-04T21:01:52+00:00

View File

@ -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
"""