diff --git a/.gitattributes b/.gitattributes index 2af3ba9..28c3e1e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,3 @@ Cargo.lock linguist-generated=false +Makefile linguist-detectable=false +scripts/generators/** linguist-detectable=false diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6ea7a24..0f5a583 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -3,54 +3,103 @@ name: tests on: pull_request: branches: - - '*' + - "*" push: branches: - - 'main' + - "main" tags: - - '*' + - "*" workflow_dispatch: {} jobs: - unit-tests: + lockfile: + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: regenerate Cargo.lock + run: cargo generate-lockfile + + - name: check Cargo.lock is up to date + run: | + git diff --exit-code -- Cargo.lock || ( + echo "Cargo.lock is out of date or differs from the lockfile Cargo would generate." && + echo "Run 'cargo generate-lockfile' (or 'cargo update' if appropriate) and commit the updated Cargo.lock." && + exit 1 + ) + + generators: runs-on: ubuntu-latest + needs: lockfile steps: + - name: checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true - - name: checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - name: install kopium + run: cargo install kopium --version 0.22.5 - - name: install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true + - name: run generators + run: make generate - - name: run unit tests - uses: actions-rs/cargo@v1 - with: - command: test - args: -v -- --nocapture + - name: check for uncommitted changes + run: | + git diff --exit-code || (echo "Generator produced changes. Please run 'make generate' locally and commit the results." && exit 1) + + unit-tests: + runs-on: ubuntu-latest + needs: generators + steps: + - name: checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: run unit tests + uses: actions-rs/cargo@v1 + with: + command: test + args: -v -- --nocapture integration-tests: runs-on: ubuntu-latest - needs: unit-tests + needs: [generators, unit-tests] steps: + - name: checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true - - name: checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - - name: run integration tests - uses: actions-rs/cargo@v1 - with: - command: test - args: -v -- --nocapture --ignored + - name: run integration tests + uses: actions-rs/cargo@v1 + with: + command: test + args: -v -- --nocapture --ignored diff --git a/.gitignore b/.gitignore index eb5a316..1415097 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ target +*.txt +TODO diff --git a/Cargo.lock b/Cargo.lock index 6c23b21..28177cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,55 +3,81 @@ version = 4 [[package]] -name = "addr2line" -version = "0.24.2" +name = "aho-corasick" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ - "gimli", + "memchr", ] [[package]] -name = "adler2" -version = "2.0.0" +name = "anstream" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] [[package]] -name = "aho-corasick" -version = "1.1.3" +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" dependencies = [ - "memchr", + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", ] [[package]] name = "anyhow" -version = "1.0.98" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" [[package]] -name = "autocfg" -version = "1.4.0" +name = "atomic-waker" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] -name = "backtrace" -version = "0.3.75" +name = "autocfg" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-targets", -] +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "base64" @@ -61,9 +87,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" -version = "2.9.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" [[package]] name = "block-buffer" @@ -76,41 +102,83 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.18.1" +version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db76d6187cd04dff33004d8e6c9cc4e05cd330500379d2394209271b4aeee" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" [[package]] name = "cc" -version = "1.2.26" +version = "1.2.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956a5e21988b87f372569b66183b78babf23ebc2e744b733e4350a752c4dafac" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" dependencies = [ + "find-msvc-tools", "shlex", ] [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] -name = "chrono" -version = "0.4.41" +name = "chacha20" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" dependencies = [ - "num-traits", - "serde", + "cfg-if", + "cpufeatures 0.3.0", + "rand_core", +] + +[[package]] +name = "clap" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", ] +[[package]] +name = "clap_lex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" + [[package]] name = "codegen" version = "0.2.0" @@ -121,13 +189,18 @@ dependencies = [ ] [[package]] -name = "core-foundation" -version = "0.9.4" +name = "colorchoice" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "colored" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" dependencies = [ - "core-foundation-sys", - "libc", + "windows-sys 0.61.2", ] [[package]] @@ -155,11 +228,20 @@ dependencies = [ "libc", ] +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "typenum", @@ -167,9 +249,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.11" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" dependencies = [ "darling_core", "darling_macro", @@ -177,11 +259,10 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.11" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" dependencies = [ - "fnv", "ident_case", "proc-macro2", "quote", @@ -191,9 +272,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.11" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ "darling_core", "quote", @@ -202,32 +283,42 @@ dependencies = [ [[package]] name = "delegate" -version = "0.13.3" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b6483c2bbed26f97861cf57651d4f2b731964a28cd2257f934a4b452480d21" +checksum = "780eb241654bf097afb00fc5f054a09b687dad862e485fdcf8399bb056565370" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "powerfmt", +] + [[package]] name = "derive_more" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" dependencies = [ "derive_more-impl", ] [[package]] name = "derive_more-impl" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" dependencies = [ "proc-macro2", "quote", + "rustc_version", "syn", ] @@ -243,9 +334,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "either" @@ -255,7 +346,7 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "enum_default_generator" -version = "0.16.0" +version = "0.22.0+gw150-ie140" dependencies = [ "codegen", ] @@ -267,25 +358,41 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] -name = "fnv" -version = "1.0.7" +name = "errno" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "form_urlencoded" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" dependencies = [ "percent-encoding", ] [[package]] name = "futures" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" dependencies = [ "futures-channel", "futures-core", @@ -297,9 +404,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" dependencies = [ "futures-core", "futures-sink", @@ -307,33 +414,33 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" [[package]] name = "futures-io" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" [[package]] name = "futures-sink" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" [[package]] name = "futures-task" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" [[package]] name = "futures-util" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" dependencies = [ "futures-channel", "futures-core", @@ -342,39 +449,35 @@ dependencies = [ "futures-task", "memchr", "pin-project-lite", - "pin-utils", "slab", ] [[package]] name = "gateway-api" -version = "0.16.0" +version = "0.150.0" dependencies = [ - "anyhow", + "cfg-if", "delegate", - "hyper-util", "k8s-openapi", "kube", + "kube-core", + "kube-derive", "once_cell", "regex-lite", "schemars", "serde", "serde_json", "serde_yaml", - "tokio", - "tower", - "uuid", ] [[package]] name = "gateway-api-examples" -version = "0.16.0" +version = "0.22.0+gw150-ie140" dependencies = [ "anyhow", "gateway-api", "hyper-util", "k8s-openapi", - "kube", "serde_json", "tokio", "tower", @@ -383,6 +486,47 @@ dependencies = [ "uuid", ] +[[package]] +name = "gateway-api-inference-extension" +version = "0.130.0" +dependencies = [ + "cfg-if", + "delegate", + "k8s-openapi", + "kube", + "kube-core", + "kube-derive", + "once_cell", + "regex-lite", + "schemars", + "serde", + "serde_json", + "serde_yaml", +] + +[[package]] +name = "gateway-api-with-extensions" +version = "0.150.130" +dependencies = [ + "anyhow", + "cfg-if", + "delegate", + "hyper-util", + "k8s-openapi", + "kube", + "kube-core", + "kube-derive", + "once_cell", + "regex-lite", + "schemars", + "serde", + "serde_json", + "serde_yaml", + "tokio", + "tower", + "uuid", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -395,33 +539,29 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] name = "getrandom" -version = "0.3.3" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" dependencies = [ "cfg-if", "libc", "r-efi", - "wasi 0.14.2+wasi-0.2.4", + "rand_core", + "wasip2", + "wasip3", ] -[[package]] -name = "gimli" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" - [[package]] name = "hashbrown" version = "0.12.3" @@ -430,51 +570,32 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.15.3" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" - -[[package]] -name = "headers" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3314d5adb5d94bcdf56771f2e50dbbc80bb4bdf88967526706205ac9eff24eb" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ - "base64", - "bytes", - "headers-core", - "http", - "httpdate", - "mime", - "sha1", + "foldhash", ] [[package]] -name = "headers-core" -version = "0.3.0" +name = "hashbrown" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" -dependencies = [ - "http", -] +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" [[package]] -name = "home" -version = "0.5.11" +name = "heck" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" -dependencies = [ - "windows-sys 0.59.0", -] +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "http" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" dependencies = [ "bytes", - "fnv", "itoa", ] @@ -507,51 +628,27 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - [[package]] name = "hyper" -version = "1.6.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" dependencies = [ + "atomic-waker", "bytes", "futures-channel", - "futures-util", + "futures-core", "http", "http-body", "httparse", "itoa", "pin-project-lite", + "pin-utils", "smallvec", "tokio", "want", ] -[[package]] -name = "hyper-http-proxy" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ad4b0a1e37510028bc4ba81d0e38d239c39671b0f0ce9e02dfa93a8133f7c08" -dependencies = [ - "bytes", - "futures-util", - "headers", - "http", - "hyper", - "hyper-rustls", - "hyper-util", - "pin-project-lite", - "rustls-native-certs 0.7.3", - "tokio", - "tokio-rustls", - "tower-service", -] - [[package]] name = "hyper-rustls" version = "0.27.7" @@ -563,7 +660,7 @@ dependencies = [ "hyper-util", "log", "rustls", - "rustls-native-certs 0.8.1", + "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls", @@ -585,13 +682,12 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.14" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc2fdfdbff08affe55bb779f33b053aa1fe5dd5b54c257343c17edfa55711bdb" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ "bytes", "futures-channel", - "futures-core", "futures-util", "http", "http-body", @@ -604,6 +700,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + [[package]] name = "ident_case" version = "1.0.1" @@ -622,25 +724,66 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.9.0" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", - "hashbrown 0.15.3", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", ] [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "jiff" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819b44bc7c87d9117eb522f14d46e918add69ff12713c475946b0a29363ed1c2" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "470252db18ecc35fd766c0891b1e3ec6cbbcd62507e85276c01bf75d8e94d4a1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" dependencies = [ "once_cell", "wasm-bindgen", @@ -648,9 +791,9 @@ dependencies = [ [[package]] name = "jsonpath-rust" -version = "0.7.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c00ae348f9f8fd2d09f82a98ca381c60df9e0820d8d79fce43e649b4dc3128b" +checksum = "633a7320c4bb672863a3782e89b9094ad70285e097ff6832cddd0ec615beadfa" dependencies = [ "pest", "pest_derive", @@ -661,12 +804,12 @@ dependencies = [ [[package]] name = "k8s-openapi" -version = "0.25.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa60a41b57ae1a0a071af77dbcf89fc9819cfe66edaf2beeb204c34459dcf0b2" +checksum = "05a6d6f3611ad1d21732adbd7a2e921f598af6c92d71ae6e2620da4b67ee1f0d" dependencies = [ "base64", - "chrono", + "jiff", "schemars", "serde", "serde_json", @@ -674,36 +817,33 @@ dependencies = [ [[package]] name = "kube" -version = "1.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "778f98664beaf4c3c11372721e14310d1ae00f5e2d9aabcf8906c881aa4e9f51" +checksum = "f96b537b4c4f61fc183594edbecbbefa3037e403feac0701bb24e6eff78e0034" dependencies = [ "k8s-openapi", "kube-client", "kube-core", - "kube-derive", ] [[package]] name = "kube-client" -version = "1.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cb276b85b6e94ded00ac8ea2c68fcf4697ea0553cb25fddc35d4a0ab718db8d" +checksum = "af97b8b696eb737e5694f087c498ca725b172c2a5bc3a6916328d160225537ee" dependencies = [ "base64", "bytes", - "chrono", "either", "futures", - "home", "http", "http-body", "http-body-util", "hyper", - "hyper-http-proxy", "hyper-rustls", "hyper-timeout", "hyper-util", + "jiff", "jsonpath-rust", "k8s-openapi", "kube-core", @@ -723,14 +863,14 @@ dependencies = [ [[package]] name = "kube-core" -version = "1.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c56ff45deb0031f2a476017eed60c06872251f271b8387ad8020b8fef60960" +checksum = "e7aeade7d2e9f165f96b3c1749ff01a8e2dc7ea954bd333bcfcecc37d5226bdd" dependencies = [ - "chrono", "derive_more", "form_urlencoded", "http", + "jiff", "k8s-openapi", "schemars", "serde", @@ -741,9 +881,9 @@ dependencies = [ [[package]] name = "kube-derive" -version = "1.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "079fc8c1c397538628309cfdee20696ebdcc26745f9fb17f89b78782205bd995" +checksum = "c98f59f4e68864624a0b993a1cc2424439ab7238eaede5c299e89943e2a093ff" dependencies = [ "darling", "proc-macro2", @@ -759,33 +899,41 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "libc" -version = "0.2.172" +version = "0.2.182" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" [[package]] name = "lock_api" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] [[package]] name = "log" -version = "0.4.27" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +dependencies = [ + "serde_core", +] [[package]] name = "memchr" -version = "2.7.4" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "mime" @@ -794,35 +942,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] -name = "miniz_oxide" -version = "0.8.8" +name = "mio" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" dependencies = [ - "adler2", + "libc", + "wasi", + "windows-sys 0.61.2", ] [[package]] -name = "mio" -version = "1.0.4" +name = "multimap" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" dependencies = [ - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.59.0", + "serde", ] [[package]] name = "nu-ansi-term" -version = "0.46.0" +version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "overload", - "winapi", + "windows-sys 0.61.2", ] +[[package]] +name = "num-conv" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" + [[package]] name = "num-traits" version = "0.2.19" @@ -833,12 +986,12 @@ dependencies = [ ] [[package]] -name = "object" -version = "0.36.7" +name = "num_threads" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" dependencies = [ - "memchr", + "libc", ] [[package]] @@ -847,11 +1000,17 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + [[package]] name = "openssl-probe" -version = "0.1.6" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" [[package]] name = "ordered-float" @@ -862,17 +1021,11 @@ dependencies = [ "num-traits", ] -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "parking_lot" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", "parking_lot_core", @@ -880,49 +1033,48 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-link", ] [[package]] name = "pem" -version = "3.0.5" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3" +checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" dependencies = [ "base64", - "serde", + "serde_core", ] [[package]] name = "percent-encoding" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pest" -version = "2.8.0" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "198db74531d58c70a361c42201efde7e2591e976d518caf7662a47dc5720e7b6" +checksum = "e0848c601009d37dfa3430c4666e147e49cdcf1b92ecd3e63657d8a5f19da662" dependencies = [ "memchr", - "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.8.0" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d725d9cfd79e87dccc9341a2ef39d1b6f6353d68c4b33c177febbe1a402c97c5" +checksum = "11f486f1ea21e6c10ed15d5a7c77165d0ee443402f0780849d1768e7d9d6fe77" dependencies = [ "pest", "pest_generator", @@ -930,9 +1082,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.0" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db7d01726be8ab66ab32f9df467ae8b1148906685bbe75c82d1e65d7f5b3f841" +checksum = "8040c4647b13b210a963c1ed407c1ff4fdfa01c31d6d2a098218702e6664f94f" dependencies = [ "pest", "pest_meta", @@ -943,20 +1095,19 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.8.0" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9f832470494906d1fca5329f8ab5791cc60beb230c74815dff541cbd2b5ca0" +checksum = "89815c69d36021a140146f26659a81d6c2afa33d216d736dd4be5381a7362220" dependencies = [ - "once_cell", "pest", "sha2", ] [[package]] name = "pin-project-lite" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pin-utils" @@ -965,81 +1116,111 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "ppv-lite86" -version = "0.2.21" +name = "portable-atomic" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "portable-atomic-util" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9db96d7fa8782dd8c15ce32ffe8680bbd1e978a43bf51a34d39483540495f5" dependencies = [ - "zerocopy", + "portable-atomic", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", ] [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" dependencies = [ "proc-macro2", ] [[package]] name = "r-efi" -version = "5.2.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8" dependencies = [ - "rand_chacha", + "chacha20", + "getrandom 0.4.2", "rand_core", ] [[package]] -name = "rand_chacha" -version = "0.9.0" +name = "rand_core" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba" + +[[package]] +name = "redox_syscall" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "ppv-lite86", - "rand_core", + "bitflags", ] [[package]] -name = "rand_core" -version = "0.9.3" +name = "ref-cast" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" dependencies = [ - "getrandom 0.3.3", + "ref-cast-impl", ] [[package]] -name = "redox_syscall" -version = "0.5.12" +name = "ref-cast-impl" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ - "bitflags", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "regex" -version = "1.11.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" dependencies = [ "aho-corasick", "memchr", @@ -1049,9 +1230,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", @@ -1060,15 +1241,15 @@ dependencies = [ [[package]] name = "regex-lite" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" +checksum = "cab834c73d247e67f4fae452806d17d3c7501756d98c8808d7c9c7aa7d18f973" [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" [[package]] name = "ring" @@ -1078,23 +1259,26 @@ checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.16", + "getrandom 0.2.17", "libc", "untrusted", "windows-sys 0.52.0", ] [[package]] -name = "rustc-demangle" -version = "0.1.24" +name = "rustc_version" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] [[package]] name = "rustls" -version = "0.23.27" +version = "0.23.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321" +checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" dependencies = [ "log", "once_cell", @@ -1107,52 +1291,30 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.3" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63" dependencies = [ "openssl-probe", - "rustls-pemfile", "rustls-pki-types", "schannel", - "security-framework 2.11.1", -] - -[[package]] -name = "rustls-native-certs" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" -dependencies = [ - "openssl-probe", - "rustls-pki-types", - "schannel", - "security-framework 3.2.0", -] - -[[package]] -name = "rustls-pemfile" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" -dependencies = [ - "rustls-pki-types", + "security-framework", ] [[package]] name = "rustls-pki-types" -version = "1.12.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" dependencies = [ "zeroize", ] [[package]] name = "rustls-webpki" -version = "0.103.3" +version = "0.103.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" +checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" dependencies = [ "ring", "rustls-pki-types", @@ -1161,32 +1323,33 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" -version = "1.0.20" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "schannel" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] name = "schemars" -version = "0.8.22" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" +checksum = "a2b42f36aa1cd011945615b92222f6bf73c599a102a300334cd7f8dbeec726cc" dependencies = [ "dyn-clone", + "ref-cast", "schemars_derive", "serde", "serde_json", @@ -1194,9 +1357,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.22" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" +checksum = "7d115b50f4aaeea07e79c1912f645c7513d81715d0420f8bc77a18c6260b307f" dependencies = [ "proc-macro2", "quote", @@ -1221,46 +1384,40 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.11.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ "bitflags", - "core-foundation 0.9.4", + "core-foundation", "core-foundation-sys", "libc", "security-framework-sys", ] [[package]] -name = "security-framework" -version = "3.2.0" +name = "security-framework-sys" +version = "2.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" dependencies = [ - "bitflags", - "core-foundation 0.10.1", "core-foundation-sys", "libc", - "security-framework-sys", ] [[package]] -name = "security-framework-sys" -version = "2.14.0" +name = "semver" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" -dependencies = [ - "core-foundation-sys", - "libc", -] +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ + "serde_core", "serde_derive", ] @@ -1274,11 +1431,20 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -1298,14 +1464,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ "itoa", "memchr", - "ryu", "serde", + "serde_core", + "zmij", ] [[package]] @@ -1314,24 +1481,13 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.9.0", + "indexmap 2.13.0", "itoa", "ryu", "serde", "unsafe-libyaml", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sha2" version = "0.10.9" @@ -1339,7 +1495,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", - "cpufeatures", + "cpufeatures 0.2.17", "digest", ] @@ -1360,22 +1516,32 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.5" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" dependencies = [ + "errno", "libc", ] [[package]] -name = "slab" -version = "0.4.9" +name = "simple_logger" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +checksum = "c7038d0e96661bf9ce647e1a6f6ef6d6f3663f66d9bf741abf14ba4876071c17" dependencies = [ - "autocfg", + "colored", + "log", + "time", + "windows-sys 0.61.2", ] +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + [[package]] name = "smallvec" version = "1.15.1" @@ -1384,12 +1550,12 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.5.10" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -1406,9 +1572,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.101" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -1423,18 +1589,18 @@ checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" [[package]] name = "thiserror" -version = "2.0.12" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.12" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", @@ -1443,21 +1609,52 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" dependencies = [ "cfg-if", - "once_cell", +] + +[[package]] +name = "time" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +dependencies = [ + "deranged", + "itoa", + "libc", + "num-conv", + "num_threads", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" + +[[package]] +name = "time-macros" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +dependencies = [ + "num-conv", + "time-core", ] [[package]] name = "tokio" -version = "1.45.1" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" dependencies = [ - "backtrace", "bytes", "libc", "mio", @@ -1466,14 +1663,14 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] name = "tokio-macros" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" dependencies = [ "proc-macro2", "quote", @@ -1482,9 +1679,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.2" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" dependencies = [ "rustls", "tokio", @@ -1492,9 +1689,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.15" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" dependencies = [ "bytes", "futures-core", @@ -1505,9 +1702,9 @@ dependencies = [ [[package]] name = "tower" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" dependencies = [ "futures-core", "futures-util", @@ -1522,9 +1719,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" dependencies = [ "base64", "bitflags", @@ -1533,6 +1730,7 @@ dependencies = [ "http-body", "mime", "pin-project-lite", + "tower", "tower-layer", "tower-service", "tracing", @@ -1552,9 +1750,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ "log", "pin-project-lite", @@ -1564,9 +1762,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.29" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1ffbcf9c6f6b99d386e7444eb608ba646ae452a36b39737deb9663b610f662" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", @@ -1575,9 +1773,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.34" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" dependencies = [ "once_cell", "valuable", @@ -1596,9 +1794,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ "nu-ansi-term", "sharded-slab", @@ -1614,11 +1812,25 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "type-reducer" +version = "0.22.0+gw150-ie140" +dependencies = [ + "clap", + "itertools", + "log", + "multimap", + "prettyplease", + "proc-macro2", + "simple_logger", + "syn", +] + [[package]] name = "typenum" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" [[package]] name = "ucd-trie" @@ -1628,9 +1840,15 @@ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "unsafe-libyaml" @@ -1644,13 +1862,19 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" -version = "1.17.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" +checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.4.2", "js-sys", "rand", "wasm-bindgen", @@ -1679,50 +1903,46 @@ dependencies = [ [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] -name = "wasi" -version = "0.14.2+wasi-0.2.4" +name = "wasip2" +version = "1.0.2+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" dependencies = [ - "wit-bindgen-rt", + "wit-bindgen", ] [[package]] -name = "wasm-bindgen" -version = "0.2.100" +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" dependencies = [ - "cfg-if", - "once_cell", - "rustversion", - "wasm-bindgen-macro", + "wit-bindgen", ] [[package]] -name = "wasm-bindgen-backend" -version = "0.2.100" +name = "wasm-bindgen" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn", + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1730,47 +1950,65 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" dependencies = [ + "bumpalo", "proc-macro2", "quote", "syn", - "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" dependencies = [ "unicode-ident", ] [[package]] -name = "winapi" -version = "0.3.9" +name = "wasm-encoder" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "leb128fmt", + "wasmparser", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "wasm-metadata" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap 2.13.0", + "wasm-encoder", + "wasmparser", +] [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "wasmparser" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap 2.13.0", + "semver", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] name = "windows-sys" @@ -1783,11 +2021,11 @@ dependencies = [ [[package]] name = "windows-sys" -version = "0.59.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-targets", + "windows-link", ] [[package]] @@ -1855,36 +2093,101 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "wit-bindgen-rt" -version = "0.39.0" +name = "wit-bindgen" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" dependencies = [ - "bitflags", + "wit-bindgen-rust-macro", ] [[package]] -name = "zerocopy" -version = "0.8.25" +name = "wit-bindgen-core" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" dependencies = [ - "zerocopy-derive", + "anyhow", + "heck", + "wit-parser", ] [[package]] -name = "zerocopy-derive" -version = "0.8.25" +name = "wit-bindgen-rust" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" dependencies = [ + "anyhow", + "heck", + "indexmap 2.13.0", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", "proc-macro2", "quote", "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap 2.13.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.13.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", ] [[package]] name = "zeroize" -version = "1.8.1" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zmij" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index f808cf1..c5e9172 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,27 +1,33 @@ [workspace] -members = ["gateway-api", "gateway-api/examples", "xtask"] +members = ["gateway-api", "gateway-api-with-extensions", "gateway-api-inference-extension","gateway-api/examples", "xtask", "type-reducer"] +#members = [ "gateway-api", "xtask", "type-reducer"] resolver = "2" [workspace.package] -authors = ["Shane Utt "] +authors = ["kube-rs (https://kube.rs)"] edition = "2024" license = "MIT" -version = "0.16.0" +version = "0.22.0+gw150-ie140" +description ="Rust APIs for Gateway API 1.5.0 and Gateway API Inference Extension 1.4.0" [workspace.dependencies] -anyhow = "1.0.98" -delegate = "0.13.3" -hyper-util = "0.1.14" -kube = { version = "1.1.0" } -k8s-openapi = { version = "0.25.0" } +anyhow = "1.0.100" +delegate = "0.13.5" +hyper-util = "0.1.19" +kube = { version = "3.0.0", default-features = false } +kube-core = { version = "3.0.0", default-features = false } +kube-derive = { version = "3.0.0" } +k8s-openapi = { version = "0.27.0", features = ["v1_33"] } once_cell = "1.21.3" -regex = { package = "regex-lite", version = "0.1.6" } -schemars = "0.8.22" -serde_json = "1.0.140" -serde = { version = "1.0.219", features = ["derive"] } +regex = { package = "regex-lite", version = "0.1.8" } +schemars = "1.2.0" +serde_json = "1.0.149" +serde = { version = "1.0.228", features = ["derive"] } serde_yaml = "0.9.34" -tokio = { version = "1.45.1", features = ["full"] } -tower = { version = "0.5.2", features = ["limit"] } -tracing = "0.1.41" -tracing-subscriber = "0.3.19" -uuid = { version = "1.17.0", features = ["v4", "fast-rng"] } +tokio = { version = "1.49.0", features = ["full"] } +tower = { version = "0.5.3", features = ["limit"] } +tracing = "0.1.44" +tracing-subscriber = "0.3.22" +uuid = { version = "1.19.0", features = ["v4", "fast-rng"] } +cfg-if= "1.0" + diff --git a/Makefile b/Makefile index 02febb2..37fcadb 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,8 @@ build: .PHONY: generate generate: - ./update.sh + ./scripts/generators/gateway.sh + ./scripts/generators/extensions/inference.sh .PHONY: test.all test.all: test.unit test.integration diff --git a/README.md b/README.md index 5b1cdf6..88af3c9 100644 --- a/README.md +++ b/README.md @@ -2,53 +2,48 @@ [![crates.io](https://img.shields.io/crates/v/gateway-api.svg)](https://crates.io/crates/gateway-api) [![License](https://img.shields.io/badge/license-mit-blue.svg)](https://raw.githubusercontent.com/kube-rs/gateway-api-rs/main/LICENSE) -> **Warning**: EXPERIMENTAL. **Not ready for production use**. - -> **Note**: While the aspiration is to eventually become the "official" Gateway -> API bindings for Rust, [Kubernetes SIG Network] has not yet (and may never) -> officially endorsed it so this should be considered "unofficial" for now. - -[Kubernetes SIG Network]:https://github.com/kubernetes/community/tree/master/sig-network +> **Warning**: EXPERIMENTAL. # Gateway API (Rust) -> **Note**: Currently supports [Gateway API version v1.2.1][gwv] +[Rust] bindings for [Kubernetes] [Gateway API]. -This project provides bindings in [Rust] for [Kubernetes] [Gateway API]. +> **Note**: Currently supports [Gateway API version v1.4.0][gwv] -[gwv]:https://github.com/kubernetes-sigs/gateway-api/releases/tag/v1.2.1 +[gwv]:https://github.com/kubernetes-sigs/gateway-api/releases/tag/v1.4.0 [Rust]:https://rust-lang.org [Kubernetes]:https://kubernetes.io/ [Gateway API]:https://gateway-api.sigs.k8s.io/ ## Usage -Basic usage involves using a [kube-rs] [Client] to perform create, read, update -and delete (CRUD) operations on [Gateway API resources]. You can either use a -basic `Client` to perform CRUD operations, or you can build a [Controller]. See -the `gateway-api/examples/` directory for detailed (and specific) usage examples. +This library is intended to be paired with [kube-rs]. Use a [Client] to perform +operations on [Gateway API resources]. This enables you to build [Controllers], +so you can create a [Gateway API Implementation] in Rust. See the +`gateway-api/examples/` directory for example code. -[kube-rs]:https://github.com/kube-rs/kube -[Gateway API resources]:https://gateway-api.sigs.k8s.io/api-types/gateway/ +[kube-rs]:https://docs.rs/kube/latest/kube [Client]:https://docs.rs/kube/latest/kube/struct.Client.html +[Gateway API resources]:https://gateway-api.sigs.k8s.io/api-types/gateway/ [Controller]:https://kube.rs/controllers/intro/ +[Gateway API Implemention]:https://gateway-api.sigs.k8s.io/implementations/ ## Development This project uses [Kopium] to automatically generate API bindings from upstream -Gateway API. Make sure you install `kopium` locally in order to run the -generator: +Gateway API and Extensions. Make sure you install `kopium` locally in order to run the generator: ```console -$ cargo install kopium --version 0.21.1 +$ cargo install kopium --version 0.22.5 ``` -After which you can run the `update.sh` script: +### Generate APIs ```console -$ ./update.sh +$ ./scripts/generators/gateway_all.sh ``` + Check for errors and/or a non-zero exit code, but upon success you should see updates automatically generated for code in the `gateway-api/src/api` directory which you can then commit. @@ -57,19 +52,13 @@ which you can then commit. ## Contributions -Contributions are welcome, and appreciated! In general (for larger changes) -please create an issue describing the contribution needed prior to creating a -PR. +For questions and general discussion, please use the [discussion board]. -If you're looking for something to do, we organize the work for this project -with a [project board][board], please check out the `next` column for -unassigned tasks as these are the things prioritized to be worked on in the -immediate. +Contributions are welcome. Please create an issue describing what changes are +desired prior to creating a PR. -For development support we do have an org-wide [#kube channel on the Tokio -Discord server][discord], but please note that for this project in particular we -prefer questions be posted in the [discussions board][forum]. +Please check our [project board] to see what work has been accepted and is +in need of an owner. The `next` column contains high priority items. -[board]:https://github.com/orgs/kube-rs/projects/3 -[discord]:https://discord.gg/tokio -[forum]:https://github.com/kube-rs/gateway-api-rs/discussions +[project board]:https://github.com/orgs/kube-rs/projects/3 +[discussion board]:https://github.com/kube-rs/gateway-api-rs/discussions diff --git a/gateway-api-inference-extension/Cargo.toml b/gateway-api-inference-extension/Cargo.toml new file mode 100644 index 0000000..8b170d5 --- /dev/null +++ b/gateway-api-inference-extension/Cargo.toml @@ -0,0 +1,46 @@ +[package] +name = "gateway-api-inference-extension" +description = "Kubernetes Gateway API Inference Extensions bindings in Rust" +categories = ["api-bindings"] +keywords = ["kubernetes", "gateway-api-inference-extension"] + +homepage = "https://docs.rs/crate/gateway-api/" +readme = "../README.md" +repository = "https://github.com/kube-rs/gateway-api-rs" +version= "0.130.0" + +authors.workspace = true +edition.workspace = true +license.workspace = true + + +[dependencies] +delegate.workspace = true +k8s-openapi = { workspace = true, features = ["schemars"] } +kube = { workspace = true, default-features = false, features = [] } +kube-core = { workspace = true, features = ["schema"] } +kube-derive.workspace = true +once_cell.workspace = true +regex.workspace = true +schemars.workspace = true +serde_json.workspace = true +serde.workspace = true +serde_yaml.workspace = true +cfg-if.workspace = true + + +[package.metadata.docs.rs] +features = ["k8s-openapi/v1_33"] + +[features] +default = ["standard"] +standard = [] +experimental=[] + + + +[lints.clippy] +derivable_impls = "allow" +doc_lazy_continuation = "allow" +tabs_in_doc_comments = "allow" +empty_line_after_doc_comments = "allow" diff --git a/gateway-api-inference-extension/src/experimental/common.rs b/gateway-api-inference-extension/src/experimental/common.rs new file mode 100644 index 0000000..a75bcfc --- /dev/null +++ b/gateway-api-inference-extension/src/experimental/common.rs @@ -0,0 +1,34 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolImportStatusControllersParentsParentRef { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolRef { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceStatus { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, +} diff --git a/gateway-api-inference-extension/src/experimental/enum_defaults.rs b/gateway-api-inference-extension/src/experimental/enum_defaults.rs new file mode 100644 index 0000000..cc481c3 --- /dev/null +++ b/gateway-api-inference-extension/src/experimental/enum_defaults.rs @@ -0,0 +1,17 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +pub mod prelude { + + pub use super::super::inferenceobjectives::*; + pub use super::super::inferencepools::*; + + pub use super::super::common::*; +} +use prelude::*; + +impl Default for InferencePoolExtensionRefFailureMode { + fn default() -> Self { + InferencePoolExtensionRefFailureMode::FailOpen + } +} diff --git a/gateway-api-inference-extension/src/experimental/inferencemodelrewrites.rs b/gateway-api-inference-extension/src/experimental/inferencemodelrewrites.rs new file mode 100644 index 0000000..ea7e9d5 --- /dev/null +++ b/gateway-api-inference-extension/src/experimental/inferencemodelrewrites.rs @@ -0,0 +1,85 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// InferenceModelRewriteSpec defines the desired state of InferenceModelRewrite. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "inference.networking.x-k8s.io", + version = "v1alpha2", + kind = "InferenceModelRewrite", + plural = "inferencemodelrewrites" +)] +#[kube(namespaced)] +#[kube(status = "InferenceStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct InferenceModelRewriteSpec { + /// PoolRef is a reference to the inference pool. + #[serde(rename = "poolRef")] + pub pool_ref: InferencePoolRef, + pub rules: Vec, +} +/// InferenceModelRewriteRule defines the match criteria and corresponding action. +/// For details on how precedence is determined across multiple rules and +/// InferenceModelRewrite resources, see the "Precedence and Conflict Resolution" +/// section in InferenceModelRewriteSpec. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceModelRewriteRules { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub matches: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub targets: Option>, +} +/// Match defines the criteria for matching the LLM requests. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceModelRewriteRulesMatches { + /// Model specifies the criteria for matching the 'model' field + /// within the JSON request body. + pub model: InferenceModelRewriteRulesMatchesModel, +} +/// Model specifies the criteria for matching the 'model' field +/// within the JSON request body. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceModelRewriteRulesMatchesModel { + /// Type specifies the kind of string matching to use. + /// Supported value is "Exact". Defaults to "Exact". + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// Value is the model name string to match against. + pub value: String, +} +/// Model specifies the criteria for matching the 'model' field +/// within the JSON request body. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum InferenceModelRewriteRulesMatchesModelType { + Exact, +} +/// TargetModel defines a weighted model destination for traffic distribution. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceModelRewriteRulesTargets { + #[serde(rename = "modelRewrite")] + pub model_rewrite: String, + /// (The following comment is copied from the original targetModel) + /// Weight is used to determine the proportion of traffic that should be + /// sent to this model when multiple target models are specified. + /// + /// Weight defines the proportion of requests forwarded to the specified + /// model. This is computed as weight/(sum of all weights in this + /// TargetModels list). For non-zero values, there may be some epsilon from + /// the exact proportion defined here depending on the precision an + /// implementation supports. Weight is not a percentage and the sum of + /// weights does not need to equal 100. + /// + /// If a weight is set for any targetModel, it must be set for all targetModels. + /// Conversely weights are optional, so long as ALL targetModels do not specify a weight. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} diff --git a/gateway-api-inference-extension/src/experimental/inferenceobjectives.rs b/gateway-api-inference-extension/src/experimental/inferenceobjectives.rs new file mode 100644 index 0000000..676439b --- /dev/null +++ b/gateway-api-inference-extension/src/experimental/inferenceobjectives.rs @@ -0,0 +1,50 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// InferenceObjectiveSpec represents the desired state of a specific model use case. This resource is +/// managed by the "Inference Workload Owner" persona. +/// +/// The Inference Workload Owner persona is someone that trains, verifies, and +/// leverages a large language model from a model frontend, drives the lifecycle +/// and rollout of new versions of those models, and defines the specific +/// performance and latency goals for the model. These workloads are +/// expected to operate within an InferencePool sharing compute capacity with other +/// InferenceObjectives, defined by the Inference Platform Admin. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "inference.networking.x-k8s.io", + version = "v1alpha2", + kind = "InferenceObjective", + plural = "inferenceobjectives" +)] +#[kube(namespaced)] +#[kube(status = "InferenceStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct InferenceObjectiveSpec { + /// PoolRef is a reference to the inference pool, the pool must exist in the same namespace. + #[serde(rename = "poolRef")] + pub pool_ref: InferencePoolRef, + /// Priority defines how important it is to serve the request compared to other requests in the same pool. + /// Priority is an integer value that defines the priority of the request. + /// The higher the value, the more critical the request is; negative values _are_ allowed. + /// No default value is set for this field, allowing for future additions of new fields that may 'one of' with this field. + /// However, implementations that consume this field (such as the Endpoint Picker) will treat an unset value as '0'. + /// Priority is used in flow control, primarily in the event of resource scarcity(requests need to be queued). + /// All requests will be queued, and flow control will _always_ allow requests of higher priority to be served first. + /// Fairness is only enforced and tracked between requests of the same priority. + /// + /// Example: requests with Priority 10 will always be served before + /// requests with Priority of 0 (the value used if Priority is unset or no InfereneceObjective is specified). + /// Similarly requests with a Priority of -10 will always be served after requests with Priority of 0. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub priority: Option, +} diff --git a/gateway-api-inference-extension/src/experimental/inferencepoolimports.rs b/gateway-api-inference-extension/src/experimental/inferencepoolimports.rs new file mode 100644 index 0000000..6122538 --- /dev/null +++ b/gateway-api-inference-extension/src/experimental/inferencepoolimports.rs @@ -0,0 +1,103 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Status defines the observed state of the InferencePoolImport. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolImportStatus { + /// Controllers is a list of controllers that are responsible for managing the InferencePoolImport. + pub controllers: Vec, +} +/// ImportController defines a controller that is responsible for managing the InferencePoolImport. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolImportStatusControllers { + /// Conditions track the state of the InferencePoolImport. + /// + /// Known condition types are: + /// + /// * "Accepted" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// ExportingClusters is a list of clusters that exported the InferencePool(s) that back the + /// InferencePoolImport. Required when the controller is responsible for CRUD'ing the InferencePoolImport + /// from the exported InferencePool(s). + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "exportingClusters" + )] + pub exporting_clusters: Option>, + /// Name is a domain/path string that indicates the name of the controller that manages the + /// InferencePoolImport. Name corresponds to the GatewayClass controllerName field when the + /// controller will manage parents of type "Gateway". Otherwise, the name is implementation-specific. + /// + /// Example: "example.net/import-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are valid Kubernetes + /// names ( + /// + /// A controller MUST populate this field when writing status and ensure that entries to status + /// populated with their controller name are removed when they are no longer necessary. + pub name: String, + /// Parents is a list of parent resources, typically Gateways, that are associated with the + /// InferencePoolImport, and the status of the InferencePoolImport with respect to each parent. + /// + /// Ancestor would be a more accurate name, but Parent is consistent with InferencePool terminology. + /// + /// Required when the controller manages the InferencePoolImport as an HTTPRoute backendRef. The controller + /// must add an entry for each parent it manages and remove the parent entry when the controller no longer + /// considers the InferencePoolImport to be associated with that parent. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub parents: Option>, +} +/// ExportingCluster defines a cluster that exported the InferencePool that backs this InferencePoolImport. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolImportStatusControllersExportingClusters { + /// Name of the exporting cluster (must be unique within the list). + pub name: String, +} +/// ParentStatus defines the observed state of InferencePool from a Parent, i.e. Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolImportStatusControllersParents { + /// Conditions is a list of status conditions that provide information about the observed + /// state of the InferencePool. This field is required to be set by the controller that + /// manages the InferencePool. + /// + /// Supported condition types are: + /// + /// * "Accepted" + /// * "ResolvedRefs" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// ControllerName is a domain/path string that indicates the name of the controller that + /// wrote this status. This corresponds with the GatewayClass controllerName field when the + /// parentRef references a Gateway kind. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are valid Kubernetes names: + /// + /// + /// + /// Controllers MAY populate this field when writing status. When populating this field, controllers + /// should ensure that entries to status populated with their ControllerName are cleaned up when they + /// are no longer necessary. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "controllerName" + )] + pub controller_name: Option, + /// ParentRef is used to identify the parent resource that this status + /// is associated with. It is used to match the InferencePool with the parent + /// resource, such as a Gateway. + #[serde(rename = "parentRef")] + pub parent_ref: InferencePoolImportStatusControllersParentsParentRef, +} diff --git a/gateway-api-inference-extension/src/experimental/inferencepools.rs b/gateway-api-inference-extension/src/experimental/inferencepools.rs new file mode 100644 index 0000000..f5d73de --- /dev/null +++ b/gateway-api-inference-extension/src/experimental/inferencepools.rs @@ -0,0 +1,116 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// InferencePoolSpec defines the desired state of InferencePool +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "inference.networking.x-k8s.io", + version = "v1alpha2", + kind = "InferencePool", + plural = "inferencepools" +)] +#[kube(namespaced)] +#[kube(status = "InferencePoolStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct InferencePoolSpec { + /// Extension configures an endpoint picker as an extension service. + #[serde(rename = "extensionRef")] + pub extension_ref: InferencePoolExtensionRef, + /// Selector defines a map of labels to watch model server Pods + /// that should be included in the InferencePool. + /// In some cases, implementations may translate this field to a Service selector, so this matches the simple + /// map used for Service selectors instead of the full Kubernetes LabelSelector type. + /// If specified, it will be applied to match the model server pods in the same namespace as the InferencePool. + /// Cross namesoace selector is not supported. + pub selector: BTreeMap, + /// TargetPortNumber defines the port number to access the selected model server Pods. + /// The number must be in the range 1 to 65535. + #[serde(rename = "targetPortNumber")] + pub target_port_number: i32, +} +/// Extension configures an endpoint picker as an extension service. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolExtensionRef { + /// Configures how the gateway handles the case when the extension is not responsive. + /// Defaults to failClose. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "failureMode" + )] + pub failure_mode: Option, + /// Group is the group of the referent. + /// The default value is "", representing the Core API group. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations MUST NOT + /// support ExternalName Services. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent. + pub name: String, + /// The port number on the service running the extension. When unspecified, + /// implementations SHOULD infer a default value of 9002 when the Kind is + /// Service. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "portNumber" + )] + pub port_number: Option, +} +/// Extension configures an endpoint picker as an extension service. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum InferencePoolExtensionRefFailureMode { + FailOpen, + FailClose, +} +/// Status defines the observed state of InferencePool. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolStatus { + /// Parents is a list of parent resources (usually Gateways) that are + /// associated with the InferencePool, and the status of the InferencePool with respect to + /// each parent. + /// + /// A maximum of 32 Gateways will be represented in this list. When the list contains + /// `kind: Status, name: default`, it indicates that the InferencePool is not + /// associated with any Gateway and a controller must perform the following: + /// + /// - Remove the parent when setting the "Accepted" condition. + /// - Add the parent when the controller will no longer manage the InferencePool + /// and no other parents exist. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub parent: Option>, +} +/// PoolStatus defines the observed state of InferencePool from a Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolStatusParent { + /// Conditions track the state of the InferencePool. + /// + /// Known condition types are: + /// + /// * "Accepted" + /// * "ResolvedRefs" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// GatewayRef indicates the gateway that observed state of InferencePool. + #[serde(rename = "parentRef")] + pub parent_ref: InferencePoolImportStatusControllersParentsParentRef, +} diff --git a/gateway-api-inference-extension/src/experimental/mod.rs b/gateway-api-inference-extension/src/experimental/mod.rs new file mode 100644 index 0000000..35a97f3 --- /dev/null +++ b/gateway-api-inference-extension/src/experimental/mod.rs @@ -0,0 +1,7 @@ +// WARNING: generated file - manual changes will be overriden +pub mod common; +pub mod enum_defaults; +pub mod inferencemodelrewrites; +pub mod inferenceobjectives; +pub mod inferencepoolimports; +pub mod inferencepools; diff --git a/gateway-api-inference-extension/src/lib.rs b/gateway-api-inference-extension/src/lib.rs new file mode 100644 index 0000000..615b6e4 --- /dev/null +++ b/gateway-api-inference-extension/src/lib.rs @@ -0,0 +1,9 @@ +cfg_if::cfg_if! { + if #[cfg(feature = "experimental")] { + mod experimental; + pub use experimental::*; + } else { + mod standard; + pub use standard::*; + } +} diff --git a/gateway-api/src/apis/mod.rs b/gateway-api-inference-extension/src/mod.rs similarity index 100% rename from gateway-api/src/apis/mod.rs rename to gateway-api-inference-extension/src/mod.rs diff --git a/gateway-api-inference-extension/src/standard/common.rs b/gateway-api-inference-extension/src/standard/common.rs new file mode 100644 index 0000000..e7ef280 --- /dev/null +++ b/gateway-api-inference-extension/src/standard/common.rs @@ -0,0 +1,15 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolEndpointPickerRefPort { + pub number: i32, +} diff --git a/gateway-api-inference-extension/src/standard/enum_defaults.rs b/gateway-api-inference-extension/src/standard/enum_defaults.rs new file mode 100644 index 0000000..3de644d --- /dev/null +++ b/gateway-api-inference-extension/src/standard/enum_defaults.rs @@ -0,0 +1,16 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +pub mod prelude { + + pub use super::super::inferencepools::*; + + pub use super::super::common::*; +} +use prelude::*; + +impl Default for InferencePoolEndpointPickerRefFailureMode { + fn default() -> Self { + InferencePoolEndpointPickerRefFailureMode::FailOpen + } +} diff --git a/gateway-api-inference-extension/src/standard/inferencepools.rs b/gateway-api-inference-extension/src/standard/inferencepools.rs new file mode 100644 index 0000000..65fe40f --- /dev/null +++ b/gateway-api-inference-extension/src/standard/inferencepools.rs @@ -0,0 +1,183 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of the InferencePool. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "inference.networking.k8s.io", + version = "v1", + kind = "InferencePool", + plural = "inferencepools" +)] +#[kube(namespaced)] +#[kube(status = "InferencePoolStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct InferencePoolSpec { + /// EndpointPickerRef is a reference to the Endpoint Picker extension and its + /// associated configuration. + #[serde(rename = "endpointPickerRef")] + pub endpoint_picker_ref: InferencePoolEndpointPickerRef, + /// Selector determines which Pods are members of this inference pool. + /// It matches Pods by their labels only within the same namespace; cross-namespace + /// selection is not supported. + /// + /// The structure of this LabelSelector is intentionally simple to be compatible + /// with Kubernetes Service selectors, as some implementations may translate + /// this configuration into a Service resource. + pub selector: InferencePoolSelector, + /// TargetPorts defines a list of ports that are exposed by this InferencePool. + /// Every port will be treated as a distinctive endpoint by EPP, + /// addressable as a 'podIP:portNumber' combination. + #[serde(rename = "targetPorts")] + pub target_ports: Vec, +} +/// EndpointPickerRef is a reference to the Endpoint Picker extension and its +/// associated configuration. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolEndpointPickerRef { + /// FailureMode configures how the parent handles the case when the Endpoint Picker extension + /// is non-responsive. When unspecified, defaults to "FailClose". + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "failureMode" + )] + pub failure_mode: Option, + /// Group is the group of the referent API object. When unspecified, the default value + /// is "", representing the Core API group. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. + /// + /// Required if the referent is ambiguous, e.g. service with multiple ports. + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations MUST NOT + /// support ExternalName Services. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent API object. + pub name: String, + /// Port is the port of the Endpoint Picker extension service. + /// + /// Port is required when the referent is a Kubernetes Service. In this + /// case, the port number is the service port number, not the target port. + /// For other resources, destination port might be derived from the referent + /// resource or this field. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, +} +/// EndpointPickerRef is a reference to the Endpoint Picker extension and its +/// associated configuration. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum InferencePoolEndpointPickerRefFailureMode { + FailOpen, + FailClose, +} +/// Selector determines which Pods are members of this inference pool. +/// It matches Pods by their labels only within the same namespace; cross-namespace +/// selection is not supported. +/// +/// The structure of this LabelSelector is intentionally simple to be compatible +/// with Kubernetes Service selectors, as some implementations may translate +/// this configuration into a Service resource. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolSelector { + /// MatchLabels contains a set of required {key,value} pairs. + /// An object must match every label in this map to be selected. + /// The matching logic is an AND operation on all entries. + #[serde(rename = "matchLabels")] + pub match_labels: BTreeMap, +} +/// Status defines the observed state of the InferencePool. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolStatus { + /// Parents is a list of parent resources, typically Gateways, that are associated with + /// the InferencePool, and the status of the InferencePool with respect to each parent. + /// + /// A controller that manages the InferencePool, must add an entry for each parent it manages + /// and remove the parent entry when the controller no longer considers the InferencePool to + /// be associated with that parent. + /// + /// A maximum of 32 parents will be represented in this list. When the list is empty, + /// it indicates that the InferencePool is not associated with any parents. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub parents: Option>, +} +/// ParentStatus defines the observed state of InferencePool from a Parent, i.e. Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolStatusParents { + /// Conditions is a list of status conditions that provide information about the observed + /// state of the InferencePool. This field is required to be set by the controller that + /// manages the InferencePool. + /// + /// Supported condition types are: + /// + /// * "Accepted" + /// * "ResolvedRefs" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// ControllerName is a domain/path string that indicates the name of the controller that + /// wrote this status. This corresponds with the GatewayClass controllerName field when the + /// parentRef references a Gateway kind. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are valid Kubernetes names: + /// + /// + /// + /// Controllers MAY populate this field when writing status. When populating this field, controllers + /// should ensure that entries to status populated with their ControllerName are cleaned up when they + /// are no longer necessary. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "controllerName" + )] + pub controller_name: Option, + /// ParentRef is used to identify the parent resource that this status + /// is associated with. It is used to match the InferencePool with the parent + /// resource, such as a Gateway. + #[serde(rename = "parentRef")] + pub parent_ref: InferencePoolStatusParentsParentRef, +} +/// ParentRef is used to identify the parent resource that this status +/// is associated with. It is used to match the InferencePool with the parent +/// resource, such as a Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolStatusParentsParentRef { + /// Group is the group of the referent API object. When unspecified, the referent is assumed + /// to be in the "gateway.networking.k8s.io" API group. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the kind of the referent API object. When unspecified, the referent is assumed + /// to be a "Gateway" kind. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent API object. + pub name: String, + /// Namespace is the namespace of the referenced object. When unspecified, the local + /// namespace is inferred. + /// + /// Note that when a namespace different than the local namespace is specified, + /// a ReferenceGrant object is required in the referent namespace to allow that + /// namespace's owner to accept the reference. See the ReferenceGrant + /// documentation for details: + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, +} diff --git a/gateway-api-inference-extension/src/standard/mod.rs b/gateway-api-inference-extension/src/standard/mod.rs new file mode 100644 index 0000000..d450098 --- /dev/null +++ b/gateway-api-inference-extension/src/standard/mod.rs @@ -0,0 +1,4 @@ +// WARNING: generated file - manual changes will be overriden +pub mod common; +pub mod enum_defaults; +pub mod inferencepools; diff --git a/gateway-api-with-extensions/CHANGELOG.md b/gateway-api-with-extensions/CHANGELOG.md new file mode 100644 index 0000000..6b69549 --- /dev/null +++ b/gateway-api-with-extensions/CHANGELOG.md @@ -0,0 +1,42 @@ +# Changelog + +## Next + +Supports: Gateway API `v1.4.0` + +>[!IMPORTANT] +Breaking change + +### Breaking Changes + +* The structure of APIs has changed to promote the re-use of types in the generated code. The APIs are still generated with Kopium in the first step, but there is a second stage where additional task is executed to reduce and rename the Kopium-generated types. While with this approach we can significantly reduce the surface of exposed APIs, it is also a breaking change. See [issue](https://github.com/kube-rs/gateway-api-rs/issues/38) for more context. + +### Changes + +* Updated to [kube](https://github.com/kube-rs/kube) `v2.0.1` +* Updated to Gateway API `v1.4.0` + +## 0.19.0 + +Supports: Gateway API `v1.4.0` + +### Changes + +* Updated to Gateway API `v1.4.0` +* Adds support for `BackendTLSPolicy` + +## 0.18.0 + +Supports: Gateway API `v1.2.1` + +### Changes + +* Updated to [kube](https://github.com/kube-rs/kube) `v2.0.1` + +## 0.16.0 + +Supports: Gateway API `v1.2.1` + +### Changes + +Initial release. All types are generated with Kopium. diff --git a/gateway-api-with-extensions/Cargo.toml b/gateway-api-with-extensions/Cargo.toml new file mode 100644 index 0000000..edd70b5 --- /dev/null +++ b/gateway-api-with-extensions/Cargo.toml @@ -0,0 +1,54 @@ +[package] +name = "gateway-api-with-extensions" +description = "Kubernetes Gateway API bindings in Rust" +categories = ["api-bindings"] +keywords = ["kubernetes", "gateway-api","gateway-api-inference-extension"] + +homepage = "https://docs.rs/crate/gateway-api/" +readme = "../README.md" +repository = "https://github.com/kube-rs/gateway-api-rs" +version = "0.150.130" + +authors.workspace = true +edition.workspace = true +license.workspace = true + +[dependencies] +delegate.workspace = true +k8s-openapi = { workspace = true, features = ["schemars"] } +kube = { workspace = true, default-features = false, features = [] } +kube-core = { workspace = true, features = ["schema"] } +kube-derive.workspace = true +once_cell.workspace = true +regex.workspace = true +schemars.workspace = true +serde_json.workspace = true +serde.workspace = true +serde_yaml.workspace = true +cfg-if.workspace = true + +[dev-dependencies] +k8s-openapi = { workspace = true, features = ["v1_33", "schemars"] } +kube = { workspace = true, features = ["client", "rustls-tls", "ring"] } + +anyhow.workspace = true +hyper-util.workspace = true +tokio.workspace = true +tower.workspace = true +uuid.workspace = true + +[package.metadata.docs.rs] +features = ["k8s-openapi/v1_33"] + +[features] +default = ["standard"] +standard = [] +experimental=[] + + + +[lints.clippy] +derivable_impls = "allow" +doc_lazy_continuation = "allow" +tabs_in_doc_comments = "allow" +empty_line_after_doc_comments = "allow" diff --git a/gateway-api-with-extensions/examples/Cargo.toml b/gateway-api-with-extensions/examples/Cargo.toml new file mode 100644 index 0000000..fb392c9 --- /dev/null +++ b/gateway-api-with-extensions/examples/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "gateway-api-examples" +publish = false + +authors.workspace = true +edition.workspace = true +license.workspace = true +version.workspace = true + +[package.metadata.release] +release = false + +[dependencies] +gateway-api = { path = "../" } + +anyhow.workspace = true +hyper-util.workspace = true +k8s-openapi.workspace = true +serde_json.workspace = true +tokio.workspace = true +tower.workspace = true +tracing.workspace = true +tracing-subscriber.workspace = true +uuid.workspace = true + +[features] +default = [ "k8s-openapi/v1_33" ] + +[[bin]] +name = "gep2257" +path = "gep2257.rs" diff --git a/gateway-api-with-extensions/examples/gep2257.rs b/gateway-api-with-extensions/examples/gep2257.rs new file mode 100644 index 0000000..c83c3fd --- /dev/null +++ b/gateway-api-with-extensions/examples/gep2257.rs @@ -0,0 +1,37 @@ +use gateway_api::Duration; +use std::env; +use std::str::FromStr; + +/// Simple example of using the gateway_api::Duration: just parse the duration +/// string given on the command line, then print it back out (which formats it). +/// +/// See the format specification here: https://gateway-api.sigs.k8s.io/geps/gep-2257/ +/// +/// Good things to try: +/// cargo run --example gep2257 1h (should print "Parsed duration: 1h") +/// cargo run --example gep2257 1h30m (should print "Parsed duration: 1h30m") +/// cargo run --example gep2257 30m1h10s5s (should print "Parsed duration: 1h30m15s") +fn main() { + // Get the command line argument + let args: Vec = env::args().collect(); + if args.len() < 2 { + println!("Please provide a duration input"); + return; + } + + let value = &args[1]; + + // Parse the duration input using gateway_api::Duration + match Duration::from_str(value) { + Ok(duration) => { + println!("Parsed duration: {}", duration); + } + Err(error) => { + eprintln!( + "Failed to parse duration from: {}\nError: {:#?}", + value, error + ); + std::process::exit(1); + } + } +} diff --git a/gateway-api-with-extensions/src/duration.rs b/gateway-api-with-extensions/src/duration.rs new file mode 100644 index 0000000..087b0e8 --- /dev/null +++ b/gateway-api-with-extensions/src/duration.rs @@ -0,0 +1,724 @@ +//! GEP-2257-compliant Duration type for Gateway API +//! +//! `gateway_api::Duration` is a duration type where parsing and formatting +//! obey GEP-2257. It is based on `std::time::Duration` and uses +//! `kube::core::Duration` for the heavy lifting of parsing. +//! +//! GEP-2257 defines a duration format for the Gateway API that is based on +//! Go's `time.ParseDuration`, with additional restrictions: negative +//! durations, units smaller than millisecond, and floating point are not +//! allowed, and durations are limited to four components of no more than five +//! digits each. See for the +//! complete specification. + +use kube_core::Duration as k8sDuration; +use once_cell::sync::Lazy; +use regex::Regex; +use std::fmt; +use std::str::FromStr; +use std::time::Duration as stdDuration; + +/// GEP-2257-compliant Duration type for Gateway API +/// +/// `gateway_api::Duration` is a duration type where parsing and formatting +/// obey GEP-2257. It is based on `std::time::Duration` and uses +/// `kube::core::Duration` for the heavy lifting of parsing. +/// +/// See for the complete +/// specification. +/// +/// Per GEP-2257, when parsing a `gateway_api::Duration` from a string, the +/// string must match +/// +/// `^([0-9]{1,5}(h|m|s|ms)){1,4}$` +/// +/// and is otherwise parsed the same way that Go's `time.ParseDuration` parses +/// durations. When formatting a `gateway_api::Duration` as a string, +/// zero-valued durations must always be formatted as `0s`, and non-zero +/// durations must be formatted to with only one instance of each applicable +/// unit, greatest unit first. +/// +/// The rules above imply that `gateway_api::Duration` cannot represent +/// negative durations, durations with sub-millisecond precision, or durations +/// larger than 99999h59m59s999ms. Since there's no meaningful way in Rust to +/// allow string formatting to fail, these conditions are checked instead when +/// instantiating `gateway_api::Duration`. +#[derive(Copy, Clone, PartialEq, Eq)] +pub struct Duration(stdDuration); + +/// Regex pattern defining valid GEP-2257 Duration strings. +const GEP2257_PATTERN: &str = r"^([0-9]{1,5}(h|m|s|ms)){1,4}$"; + +/// Maximum duration that can be represented by GEP-2257, in milliseconds. +const MAX_DURATION_MS: u128 = (((99999 * 3600) + (59 * 60) + 59) * 1_000) + 999; + +/// Checks if a duration is valid according to GEP-2257. If it's not, return +/// an error result explaining why the duration is not valid. +/// +/// ```rust +/// use gateway_api::duration::is_valid; +/// use std::time::Duration as stdDuration; +/// +/// // sub-millisecond precision is not allowed +/// let sub_millisecond_duration = stdDuration::from_nanos(600); +/// # assert!(is_valid(sub_millisecond_duration).is_err()); +/// +/// // but precision at a millisecond is fine +/// let non_sub_millisecond_duration = stdDuration::from_millis(1); +/// # assert!(is_valid(non_sub_millisecond_duration).is_ok()); +/// ``` +pub fn is_valid(duration: stdDuration) -> Result<(), String> { + // Check nanoseconds to see if we have sub-millisecond precision in + // this duration. + if !duration.subsec_nanos().is_multiple_of(1_000_000) { + return Err("Cannot express sub-millisecond precision in GEP-2257".to_string()); + } + + // Check the duration to see if it's greater than GEP-2257's maximum. + if duration.as_millis() > MAX_DURATION_MS { + return Err("Duration exceeds GEP-2257 maximum 99999h59m59s999ms".to_string()); + } + + Ok(()) +} + +/// Converting from `std::time::Duration` to `gateway_api::Duration` is +/// allowed, but we need to make sure that the incoming duration is valid +/// according to GEP-2257. +/// +/// ```rust +/// use gateway_api::Duration; +/// use std::convert::TryFrom; +/// use std::time::Duration as stdDuration; +/// +/// // A one-hour duration is valid according to GEP-2257. +/// let std_duration = stdDuration::from_secs(3600); +/// let duration = Duration::try_from(std_duration); +/// # assert!(duration.as_ref().is_ok()); +/// # assert_eq!(format!("{}", duration.as_ref().unwrap()), "1h"); +/// +/// // This should output "Duration: 1h". +/// match duration { +/// Ok(d) => println!("Duration: {}", d), +/// Err(e) => eprintln!("Error: {}", e), +/// } +/// +/// // A 600-nanosecond duration is not valid according to GEP-2257. +/// let std_duration = stdDuration::from_nanos(600); +/// let duration = Duration::try_from(std_duration); +/// # assert!(duration.is_err()); +/// +/// // This should output "Error: Cannot express sub-millisecond +/// // precision in GEP-2257". +/// match duration { +/// Ok(d) => println!("Duration: {}", d), +/// Err(e) => eprintln!("Error: {}", e), +/// } +/// ``` +impl TryFrom for Duration { + type Error = String; + + fn try_from(duration: stdDuration) -> Result { + // Check validity, and propagate any error if it's not. + is_valid(duration)?; + + // It's valid, so we can safely convert it to a gateway_api::Duration. + Ok(Duration(duration)) + } +} + +/// Converting from `k8s::time::Duration` to `gateway_api::Duration` is +/// allowed, but we need to make sure that the incoming duration is valid +/// according to GEP-2257. +/// +/// ```rust +/// use gateway_api::Duration; +/// use std::convert::TryFrom; +/// use std::str::FromStr; +/// use kube::core::Duration as k8sDuration; +/// +/// // A one-hour duration is valid according to GEP-2257. +/// let k8s_duration = k8sDuration::from_str("1h").unwrap(); +/// let duration = Duration::try_from(k8s_duration); +/// # assert!(duration.as_ref().is_ok()); +/// # assert_eq!(format!("{}", duration.as_ref().unwrap()), "1h"); +/// +/// // This should output "Duration: 1h". +/// match duration { +/// Ok(d) => println!("Duration: {}", d), +/// Err(e) => eprintln!("Error: {}", e), +/// } +/// +/// // A 600-nanosecond duration is not valid according to GEP-2257. +/// let k8s_duration = k8sDuration::from_str("600ns").unwrap(); +/// let duration = Duration::try_from(k8s_duration); +/// # assert!(duration.as_ref().is_err()); +/// +/// // This should output "Error: Cannot express sub-millisecond +/// // precision in GEP-2257". +/// match duration { +/// Ok(d) => println!("Duration: {}", d), +/// Err(e) => eprintln!("Error: {}", e), +/// } +/// +/// // kube::core::Duration can also express negative durations, which are not +/// // valid according to GEP-2257. +/// let k8s_duration = k8sDuration::from_str("-5s").unwrap(); +/// let duration = Duration::try_from(k8s_duration); +/// # assert!(duration.as_ref().is_err()); +/// +/// // This should output "Error: Cannot express sub-millisecond +/// // precision in GEP-2257". +/// match duration { +/// Ok(d) => println!("Duration: {}", d), +/// Err(e) => eprintln!("Error: {}", e), +/// } +/// ``` + +impl TryFrom for Duration { + type Error = String; + + fn try_from(duration: k8sDuration) -> Result { + // We can't rely on kube::core::Duration to check validity for + // gateway_api::Duration, so first we need to make sure that our + // k8sDuration is not negative... + if duration.is_negative() { + return Err("Duration cannot be negative".to_string()); + } + + // Once we know it's not negative, we can safely convert it to a + // std::time::Duration (which will always succeed) and then check it + // for validity as in TryFrom. + let stddur = stdDuration::from(duration); + is_valid(stddur)?; + Ok(Duration(stddur)) + } +} + +impl Duration { + /// Create a new `gateway_api::Duration` from seconds and nanoseconds, + /// while requiring that the resulting duration is valid according to + /// GEP-2257. + /// + /// ```rust + /// use gateway_api::Duration; + /// + /// let duration = Duration::new(7200, 600_000_000); + /// # assert!(duration.as_ref().is_ok()); + /// # assert_eq!(format!("{}", duration.unwrap()), "2h600ms"); + /// ``` + pub fn new(secs: u64, nanos: u32) -> Result { + let stddur = stdDuration::new(secs, nanos); + + // Propagate errors if not valid, or unwrap the new Duration if all's + // well. + is_valid(stddur)?; + Ok(Self(stddur)) + } + + /// Create a new `gateway_api::Duration` from seconds, while requiring + /// that the resulting duration is valid according to GEP-2257. + /// + /// ```rust + /// use gateway_api::Duration; + /// let duration = Duration::from_secs(3600); + /// # assert!(duration.as_ref().is_ok()); + /// # assert_eq!(format!("{}", duration.unwrap()), "1h"); + /// ``` + pub fn from_secs(secs: u64) -> Result { + Self::new(secs, 0) + } + + /// Create a new `gateway_api::Duration` from microseconds, while + /// requiring that the resulting duration is valid according to GEP-2257. + /// + /// ```rust + /// use gateway_api::Duration; + /// let duration = Duration::from_micros(1_000_000); + /// # assert!(duration.as_ref().is_ok()); + /// # assert_eq!(format!("{}", duration.unwrap()), "1s"); + /// ``` + pub fn from_micros(micros: u64) -> Result { + let sec = micros / 1_000_000; + let ns = ((micros % 1_000_000) * 1_000) as u32; + + Self::new(sec, ns) + } + + /// Create a new `gateway_api::Duration` from milliseconds, while + /// requiring that the resulting duration is valid according to GEP-2257. + /// + /// ```rust + /// use gateway_api::Duration; + /// let duration = Duration::from_millis(1000); + /// # assert!(duration.as_ref().is_ok()); + /// # assert_eq!(format!("{}", duration.unwrap()), "1s"); + /// ``` + pub fn from_millis(millis: u64) -> Result { + let sec = millis / 1_000; + let ns = ((millis % 1_000) * 1_000_000) as u32; + + Self::new(sec, ns) + } + + /// The number of whole seconds in the entire duration. + /// + /// ```rust + /// use gateway_api::Duration; + /// + /// let duration = Duration::from_secs(3600); // 1h + /// # assert!(duration.as_ref().is_ok()); + /// let seconds = duration.unwrap().as_secs(); // 3600 + /// # assert_eq!(seconds, 3600); + /// + /// let duration = Duration::from_millis(1500); // 1s500ms + /// # assert!(duration.as_ref().is_ok()); + /// let seconds = duration.unwrap().as_secs(); // 1 + /// # assert_eq!(seconds, 1); + /// ``` + pub fn as_secs(&self) -> u64 { + self.0.as_secs() + } + + /// The number of milliseconds in the whole duration. GEP-2257 doesn't + /// support sub-millisecond precision, so this is always exact. + /// + /// ```rust + /// use gateway_api::Duration; + /// + /// let duration = Duration::from_millis(1500); // 1s500ms + /// # assert!(duration.as_ref().is_ok()); + /// let millis = duration.unwrap().as_millis(); // 1500 + /// # assert_eq!(millis, 1500); + /// ``` + pub fn as_millis(&self) -> u128 { + self.0.as_millis() + } + + /// The number of nanoseconds in the whole duration. This is always exact. + /// + /// ```rust + /// use gateway_api::Duration; + /// + /// let duration = Duration::from_millis(1500); // 1s500ms + /// # assert!(duration.as_ref().is_ok()); + /// let nanos = duration.unwrap().as_nanos(); // 1_500_000_000 + /// # assert_eq!(nanos, 1_500_000_000); + /// ``` + pub fn as_nanos(&self) -> u128 { + self.0.as_nanos() + } + + /// The number of nanoseconds in the part of the duration that's not whole + /// seconds. Since GEP-2257 doesn't support sub-millisecond precision, this + /// will always be 0 or a multiple of 1,000,000. + /// + /// ```rust + /// use gateway_api::Duration; + /// + /// let duration = Duration::from_millis(1500); // 1s500ms + /// # assert!(duration.as_ref().is_ok()); + /// let subsec_nanos = duration.unwrap().subsec_nanos(); // 500_000_000 + /// # assert_eq!(subsec_nanos, 500_000_000); + /// ``` + pub fn subsec_nanos(&self) -> u32 { + self.0.subsec_nanos() + } + + /// Checks whether the duration is zero. + /// + /// ```rust + /// use gateway_api::Duration; + /// + /// let duration = Duration::from_secs(0); + /// # assert!(duration.as_ref().is_ok()); + /// assert!(duration.unwrap().is_zero()); + /// + /// let duration = Duration::from_secs(1); + /// # assert!(duration.as_ref().is_ok()); + /// assert!(!duration.unwrap().is_zero()); + /// ``` + pub fn is_zero(&self) -> bool { + self.0.is_zero() + } +} + +/// Parsing a `gateway_api::Duration` from a string requires that the input +/// string obey GEP-2257: +/// +/// - input strings must match `^([0-9]{1,5}(h|m|s|ms)){1,4}$` +/// - durations are parsed the same way that Go's `time.ParseDuration` does +/// +/// If the input string is not valid according to GEP-2257, an error is +/// returned explaining what went wrong. +/// +/// ```rust +/// use gateway_api::Duration; +/// use std::str::FromStr; +/// +/// let duration = Duration::from_str("1h"); +/// # assert!(duration.as_ref().is_ok()); +/// # assert_eq!(format!("{}", duration.as_ref().unwrap()), "1h"); +/// +/// // This should output "Parsed duration: 1h". +/// match duration { +/// Ok(d) => println!("Parsed duration: {}", d), +/// Err(e) => eprintln!("Error: {}", e), +/// } +/// +/// let duration = Duration::from_str("1h30m500ns"); +/// # assert!(duration.as_ref().is_err()); +/// +/// // This should output "Error: Cannot express sub-millisecond +/// // precision in GEP-2257". +/// match duration { +/// Ok(d) => println!("Parsed duration: {}", d), +/// Err(e) => eprintln!("Error: {}", e), +/// } +/// ``` +impl FromStr for Duration { + type Err = String; + + // Parse a GEP-2257-compliant duration string into a + // `gateway_api::Duration`. + fn from_str(duration_str: &str) -> Result { + // GEP-2257 dictates that string values must match GEP2257_PATTERN and + // be parsed the same way that Go's time.ParseDuration parses + // durations. + // + // This Lazy Regex::new should never ever fail, given that the regex + // is a compile-time constant. But just in case..... + static RE: Lazy = Lazy::new(|| { + Regex::new(GEP2257_PATTERN).unwrap_or_else(|_| { + panic!( + r#"GEP2257 regex "{}" did not compile (this is a bug!)"#, + GEP2257_PATTERN + ) + }) + }); + + // If the string doesn't match the regex, it's invalid. + if !RE.is_match(duration_str) { + return Err("Invalid duration format".to_string()); + } + + // We use kube::core::Duration to do the heavy lifting of parsing. + match k8sDuration::from_str(duration_str) { + // If the parse fails, return an error immediately... + Err(err) => Err(err.to_string()), + + // ...otherwise, we need to try to turn the k8sDuration into a + // gateway_api::Duration (which will check validity). + Ok(kd) => Duration::try_from(kd), + } + } +} + +/// Formatting a `gateway_api::Duration` for display is defined only for valid +/// durations, and must follow the GEP-2257 rules for formatting: +/// +/// - zero-valued durations must always be formatted as `0s` +/// - non-zero durations must be formatted with only one instance of each +/// applicable unit, greatest unit first. +/// +/// ```rust +/// use gateway_api::Duration; +/// use std::fmt::Display; +/// +/// // Zero-valued durations are always formatted as "0s". +/// let duration = Duration::from_secs(0); +/// # assert!(duration.as_ref().is_ok()); +/// assert_eq!(format!("{}", duration.unwrap()), "0s"); +/// +/// // Non-zero durations are formatted with only one instance of each +/// // applicable unit, greatest unit first. +/// let duration = Duration::from_secs(3600); +/// # assert!(duration.as_ref().is_ok()); +/// assert_eq!(format!("{}", duration.unwrap()), "1h"); +/// +/// let duration = Duration::from_millis(1500); +/// # assert!(duration.as_ref().is_ok()); +/// assert_eq!(format!("{}", duration.unwrap()), "1s500ms"); +/// +/// let duration = Duration::from_millis(9005500); +/// # assert!(duration.as_ref().is_ok()); +/// assert_eq!(format!("{}", duration.unwrap()), "2h30m5s500ms"); +/// ``` +impl fmt::Display for Duration { + /// Format a `gateway_api::Duration` for display, following GEP-2257 rules. + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Short-circuit if the duration is zero, since "0s" is the special + // case for a zero-valued duration. + if self.is_zero() { + return write!(f, "0s"); + } + + // Unfortunately, we can't rely on kube::core::Duration for + // formatting, since it can happily hand back things like "5400s" + // instead of "1h30m". + // + // So we'll do the formatting ourselves. Start by grabbing the + // milliseconds part of the Duration (remember, the constructors make + // sure that we don't have sub-millisecond precision)... + let ms = self.subsec_nanos() / 1_000_000; + + // ...then after that, do the usual div & mod tree to take seconds and + // get hours, minutes, and seconds from it. + let mut secs = self.as_secs(); + + let hours = secs / 3600; + + if hours > 0 { + secs -= hours * 3600; + write!(f, "{}h", hours)?; + } + + let minutes = secs / 60; + if minutes > 0 { + secs -= minutes * 60; + write!(f, "{}m", minutes)?; + } + + if secs > 0 { + write!(f, "{}s", secs)?; + } + + if ms > 0 { + write!(f, "{}ms", ms)?; + } + + Ok(()) + } +} + +/// Formatting a `gateway_api::Duration` for debug is the same as formatting +/// it for display. +impl fmt::Debug for Duration { + /// Format a `gateway_api::Duration` for debug, following GEP-2257 rules. + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Yes, we format GEP-2257 Durations the same in debug and display. + fmt::Display::fmt(self, f) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + /// Test that the validation logic in `Duration`'s constructor + /// method(s) correctly handles known-good durations. (The tests are + /// ordered to match the from_str test cases.) + fn test_gep2257_from_valid_duration() { + let test_cases = vec![ + Duration::from_secs(0), // 0s / 0h0m0s / 0m0s + Duration::from_secs(3600), // 1h + Duration::from_secs(1800), // 30m + Duration::from_secs(10), // 10s + Duration::from_millis(500), // 500ms + Duration::from_secs(9000), // 2h30m / 150m + Duration::from_secs(5410), // 1h30m10s / 10s30m1h + Duration::new(7200, 600_000_000), // 2h600ms + Duration::new(7200 + 1800, 600_000_000), // 2h30m600ms + Duration::new(7200 + 1800 + 10, 600_000_000), // 2h30m10s600ms + Duration::from_millis(MAX_DURATION_MS as u64), // 99999h59m59s999ms + ]; + + for (idx, duration) in test_cases.iter().enumerate() { + assert!( + duration.is_ok(), + "{:?}: Duration {:?} should be OK", + idx, + duration + ); + } + } + + #[test] + /// Test that the validation logic in `Duration`'s constructor + /// method(s) correctly handles known-bad durations. + fn test_gep2257_from_invalid_duration() { + let test_cases = vec![ + ( + Duration::from_micros(100), + Err("Cannot express sub-millisecond precision in GEP-2257".to_string()), + ), + ( + Duration::from_secs(10000 * 86400), + Err("Duration exceeds GEP-2257 maximum 99999h59m59s999ms".to_string()), + ), + ( + Duration::from_millis((MAX_DURATION_MS + 1) as u64), + Err("Duration exceeds GEP-2257 maximum 99999h59m59s999ms".to_string()), + ), + ]; + + for (idx, (duration, expected)) in test_cases.into_iter().enumerate() { + assert_eq!( + duration, expected, + "{:?}: Duration {:?} should be an error", + idx, duration + ); + } + } + + #[test] + /// Test that the TryFrom implementation for k8sDuration correctly converts + /// to gateway_api::Duration and validates the result. + fn test_gep2257_from_valid_k8s_duration() { + let test_cases = vec![ + ( + k8sDuration::from_str("0s").unwrap(), + Duration::from_secs(0).unwrap(), + ), + ( + k8sDuration::from_str("1h").unwrap(), + Duration::from_secs(3600).unwrap(), + ), + ( + k8sDuration::from_str("500ms").unwrap(), + Duration::from_millis(500).unwrap(), + ), + ( + k8sDuration::from_str("2h600ms").unwrap(), + Duration::new(7200, 600_000_000).unwrap(), + ), + ]; + + for (idx, (k8s_duration, expected)) in test_cases.into_iter().enumerate() { + let duration = Duration::try_from(k8s_duration); + + assert!( + duration.as_ref().is_ok_and(|d| *d == expected), + "{:?}: Duration {:?} should be {:?}", + idx, + duration, + expected + ); + } + } + + #[test] + /// Test that the TryFrom implementation for k8sDuration correctly fails + /// for kube::core::Durations that aren't valid GEP-2257 durations. + fn test_gep2257_from_invalid_k8s_duration() { + let test_cases: Vec<(k8sDuration, Result)> = vec![ + ( + k8sDuration::from_str("100us").unwrap(), + Err("Cannot express sub-millisecond precision in GEP-2257".to_string()), + ), + ( + k8sDuration::from_str("100000h").unwrap(), + Err("Duration exceeds GEP-2257 maximum 99999h59m59s999ms".to_string()), + ), + ( + k8sDuration::from(stdDuration::from_millis((MAX_DURATION_MS + 1) as u64)), + Err("Duration exceeds GEP-2257 maximum 99999h59m59s999ms".to_string()), + ), + ( + k8sDuration::from_str("-5s").unwrap(), + Err("Duration cannot be negative".to_string()), + ), + ]; + + for (idx, (k8s_duration, expected)) in test_cases.into_iter().enumerate() { + assert_eq!( + Duration::try_from(k8s_duration), + expected, + "{:?}: k8sDuration {:?} should be error {:?}", + idx, + k8s_duration, + expected + ); + } + } + + #[test] + fn test_gep2257_from_str() { + // Test vectors are mostly taken directly from GEP-2257, but there are + // some extras thrown in and it's not meaningful to test e.g. "0.5m" + // in Rust. + let test_cases = vec![ + ("0h", Duration::from_secs(0)), + ("0s", Duration::from_secs(0)), + ("0h0m0s", Duration::from_secs(0)), + ("1h", Duration::from_secs(3600)), + ("30m", Duration::from_secs(1800)), + ("10s", Duration::from_secs(10)), + ("500ms", Duration::from_millis(500)), + ("2h30m", Duration::from_secs(9000)), + ("150m", Duration::from_secs(9000)), + ("7230s", Duration::from_secs(7230)), + ("1h30m10s", Duration::from_secs(5410)), + ("10s30m1h", Duration::from_secs(5410)), + ("100ms200ms300ms", Duration::from_millis(600)), + ("100ms200ms300ms", Duration::from_millis(600)), + ( + "99999h59m59s999ms", + Duration::from_millis(MAX_DURATION_MS as u64), + ), + ("1d", Err("Invalid duration format".to_string())), + ("1", Err("Invalid duration format".to_string())), + ("1m1", Err("Invalid duration format".to_string())), + ( + "1h30m10s20ms50h", + Err("Invalid duration format".to_string()), + ), + ("999999h", Err("Invalid duration format".to_string())), + ("1.5h", Err("Invalid duration format".to_string())), + ("-15m", Err("Invalid duration format".to_string())), + ( + "99999h59m59s1000ms", + Err("Duration exceeds GEP-2257 maximum 99999h59m59s999ms".to_string()), + ), + ]; + + for (idx, (duration_str, expected)) in test_cases.into_iter().enumerate() { + assert_eq!( + Duration::from_str(duration_str), + expected, + "{:?}: Duration {:?} should be {:?}", + idx, + duration_str, + expected + ); + } + } + + #[test] + fn test_gep2257_format() { + // Formatting should always succeed for valid durations, and we've + // covered invalid durations in the constructor and parse tests. + let test_cases = vec![ + (Duration::from_secs(0), "0s".to_string()), + (Duration::from_secs(3600), "1h".to_string()), + (Duration::from_secs(1800), "30m".to_string()), + (Duration::from_secs(10), "10s".to_string()), + (Duration::from_millis(500), "500ms".to_string()), + (Duration::from_secs(9000), "2h30m".to_string()), + (Duration::from_secs(5410), "1h30m10s".to_string()), + (Duration::from_millis(600), "600ms".to_string()), + (Duration::new(7200, 600_000_000), "2h600ms".to_string()), + ( + Duration::new(7200 + 1800, 600_000_000), + "2h30m600ms".to_string(), + ), + ( + Duration::new(7200 + 1800 + 10, 600_000_000), + "2h30m10s600ms".to_string(), + ), + ]; + + for (idx, (duration, expected)) in test_cases.into_iter().enumerate() { + assert!( + duration + .as_ref() + .is_ok_and(|d| format!("{}", d) == expected), + "{:?}: Duration {:?} should be {:?}", + idx, + duration, + expected + ); + } + } +} diff --git a/gateway-api-with-extensions/src/experimental/backendtlspolicies.rs b/gateway-api-with-extensions/src/experimental/backendtlspolicies.rs new file mode 100644 index 0000000..10c7b7e --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/backendtlspolicies.rs @@ -0,0 +1,354 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of BackendTLSPolicy. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "BackendTLSPolicy", + plural = "backendtlspolicies" +)] +#[kube(namespaced)] +#[kube(status = "BackendTlsPolicyStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct BackendTlsPolicySpec { + /// Options are a list of key/value pairs to enable extended TLS + /// configuration for each implementation. For example, configuring the + /// minimum TLS version or supported cipher suites. + /// + /// A set of common keys MAY be defined by the API in the future. To avoid + /// any ambiguity, implementation-specific definitions MUST use + /// domain-prefixed names, such as `example.com/my-custom-option`. + /// Un-prefixed names are reserved for key names defined by Gateway API. + /// + /// Support: Implementation-specific + #[serde(default, skip_serializing_if = "Option::is_none")] + pub options: Option>, + /// TargetRefs identifies an API object to apply the policy to. + /// Note that this config applies to the entire referenced resource + /// by default, but this default may change in the future to provide + /// a more granular application of the policy. + /// + /// TargetRefs must be _distinct_. This means either that: + /// + /// * They select different targets. If this is the case, then targetRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, and `name` must + /// be unique across all targetRef entries in the BackendTLSPolicy. + /// * They select different sectionNames in the same target. + /// + /// When more than one BackendTLSPolicy selects the same target and + /// sectionName, implementations MUST determine precedence using the + /// following criteria, continuing on ties: + /// + /// * The older policy by creation timestamp takes precedence. For + /// example, a policy with a creation timestamp of "2021-07-15 + /// 01:02:03" MUST be given precedence over a policy with a + /// creation timestamp of "2021-07-15 01:02:04". + /// * The policy appearing first in alphabetical order by {namespace}/{name}. + /// For example, a policy named `foo/bar` is given precedence over a + /// policy named `foo/baz`. + /// + /// For any BackendTLSPolicy that does not take precedence, the + /// implementation MUST ensure the `Accepted` Condition is set to + /// `status: False`, with Reason `Conflicted`. + /// + /// Implementations SHOULD NOT support more than one targetRef at this + /// time. Although the API technically allows for this, the current guidance + /// for conflict resolution and status handling is lacking. Until that can be + /// clarified in a future release, the safest approach is to support a single + /// targetRef. + /// + /// Support Levels: + /// + /// * Extended: Kubernetes Service referenced by HTTPRoute backendRefs. + /// + /// * Implementation-Specific: Services not connected via HTTPRoute, and any + /// other kind of backend. Implementations MAY use BackendTLSPolicy for: + /// - Services not referenced by any Route (e.g., infrastructure services) + /// - Gateway feature backends (e.g., ExternalAuth, rate-limiting services) + /// - Service mesh workload-to-service communication + /// - Other resource types beyond Service + /// + /// Implementations SHOULD aim to ensure that BackendTLSPolicy behavior is consistent, + /// even outside of the extended HTTPRoute -(backendRef) -> Service path. + /// They SHOULD clearly document how BackendTLSPolicy is interpreted in these + /// scenarios, including: + /// - Which resources beyond Service are supported + /// - How the policy is discovered and applied + /// - Any implementation-specific semantics or restrictions + /// + /// Note that this config applies to the entire referenced resource + /// by default, but this default may change in the future to provide + /// a more granular application of the policy. + #[serde(rename = "targetRefs")] + pub target_refs: Vec, + /// Validation contains backend TLS validation configuration. + pub validation: BackendTlsPolicyValidation, +} +/// LocalPolicyTargetReferenceWithSectionName identifies an API object to apply a +/// direct policy to. This should be used as part of Policy resources that can +/// target single resources. For more information on how this policy attachment +/// mode works, and a sample Policy resource, refer to the policy attachment +/// documentation for Gateway API. +/// +/// Note: This should only be used for direct policy attachment when references +/// to SectionName are actually needed. In all other cases, +/// LocalPolicyTargetReference should be used. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyTargetRefs { + /// Group is the group of the target resource. + pub group: String, + /// Kind is kind of the target resource. + pub kind: String, + /// Name is the name of the target resource. + pub name: String, + /// SectionName is the name of a section within the target resource. When + /// unspecified, this targetRef targets the entire resource. In the following + /// resources, SectionName is interpreted as the following: + /// + /// * Gateway: Listener name + /// * HTTPRoute: HTTPRouteRule name + /// * Service: Port name + /// + /// If a SectionName is specified, but does not exist on the targeted object, + /// the Policy must fail to attach, and the policy implementation should record + /// a `ResolvedRefs` or similar Condition in the Policy's status. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sectionName" + )] + pub section_name: Option, +} +/// Validation contains backend TLS validation configuration. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyValidation { + /// CACertificateRefs contains one or more references to Kubernetes objects that + /// contain a PEM-encoded TLS CA certificate bundle, which is used to + /// validate a TLS handshake between the Gateway and backend Pod. + /// + /// If CACertificateRefs is empty or unspecified, then WellKnownCACertificates must be + /// specified. Only one of CACertificateRefs or WellKnownCACertificates may be specified, + /// not both. If CACertificateRefs is empty or unspecified, the configuration for + /// WellKnownCACertificates MUST be honored instead if supported by the implementation. + /// + /// A CACertificateRef is invalid if: + /// + /// * It refers to a resource that cannot be resolved (e.g., the referenced resource + /// does not exist) or is misconfigured (e.g., a ConfigMap does not contain a key + /// named `ca.crt`). In this case, the Reason must be set to `InvalidCACertificateRef` + /// and the Message of the Condition must indicate which reference is invalid and why. + /// + /// * It refers to an unknown or unsupported kind of resource. In this case, the Reason + /// must be set to `InvalidKind` and the Message of the Condition must explain which + /// kind of resource is unknown or unsupported. + /// + /// * It refers to a resource in another namespace. This may change in future + /// spec updates. + /// + /// Implementations MAY choose to perform further validation of the certificate + /// content (e.g., checking expiry or enforcing specific formats). In such cases, + /// an implementation-specific Reason and Message must be set for the invalid reference. + /// + /// In all cases, the implementation MUST ensure the `ResolvedRefs` Condition on + /// the BackendTLSPolicy is set to `status: False`, with a Reason and Message + /// that indicate the cause of the error. Connections using an invalid + /// CACertificateRef MUST fail, and the client MUST receive an HTTP 5xx error + /// response. If ALL CACertificateRefs are invalid, the implementation MUST also + /// ensure the `Accepted` Condition on the BackendTLSPolicy is set to + /// `status: False`, with a Reason `NoValidCACertificate`. + /// + /// A single CACertificateRef to a Kubernetes ConfigMap kind has "Core" support. + /// Implementations MAY choose to support attaching multiple certificates to + /// a backend, but this behavior is implementation-specific. + /// + /// Support: Core - An optional single reference to a Kubernetes ConfigMap, + /// with the CA certificate in a key named `ca.crt`. + /// + /// Support: Implementation-specific - More than one reference, other kinds + /// of resources, or a single reference that includes multiple certificates. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "caCertificateRefs" + )] + pub ca_certificate_refs: Option>, + /// Hostname is used for two purposes in the connection between Gateways and + /// backends: + /// + /// 1. Hostname MUST be used as the SNI to connect to the backend (RFC 6066). + /// 2. Hostname MUST be used for authentication and MUST match the certificate + /// served by the matching backend, unless SubjectAltNames is specified. + /// 3. If SubjectAltNames are specified, Hostname can be used for certificate selection + /// but MUST NOT be used for authentication. If you want to use the value + /// of the Hostname field for authentication, you MUST add it to the SubjectAltNames list. + /// + /// Support: Core + pub hostname: String, + /// SubjectAltNames contains one or more Subject Alternative Names. + /// When specified the certificate served from the backend MUST + /// have at least one Subject Alternate Name matching one of the specified SubjectAltNames. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "subjectAltNames" + )] + pub subject_alt_names: Option>, + /// WellKnownCACertificates specifies whether a well-known set of CA certificates + /// may be used in the TLS handshake between the gateway and backend pod. + /// + /// If WellKnownCACertificates is unspecified or empty (""), then CACertificateRefs + /// must be specified with at least one entry for a valid configuration. Only one of + /// CACertificateRefs or WellKnownCACertificates may be specified, not both. + /// If an implementation does not support the WellKnownCACertificates field, or + /// the supplied value is not recognized, the implementation MUST ensure the + /// `Accepted` Condition on the BackendTLSPolicy is set to `status: False`, with + /// a Reason `Invalid`. + /// + /// Valid values include: + /// * "System" - indicates that well-known system CA certificates should be used. + /// + /// Implementations MAY define their own sets of CA certificates. Such definitions + /// MUST use an implementation-specific, prefixed name, such as + /// `mycompany.com/my-custom-ca-certificates`. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "wellKnownCACertificates" + )] + pub well_known_ca_certificates: Option, +} +/// SubjectAltName represents Subject Alternative Name. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyValidationSubjectAltNames { + /// Hostname contains Subject Alternative Name specified in DNS name format. + /// Required when Type is set to Hostname, ignored otherwise. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + /// Type determines the format of the Subject Alternative Name. Always required. + /// + /// Support: Core + #[serde(rename = "type")] + pub r#type: BackendTlsPolicyValidationSubjectAltNamesType, + /// URI contains Subject Alternative Name specified in a full URI format. + /// It MUST include both a scheme (e.g., "http" or "ftp") and a scheme-specific-part. + /// Common values include SPIFFE IDs like "spiffe://mycluster.example.com/ns/myns/sa/svc1sa". + /// Required when Type is set to URI, ignored otherwise. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub uri: Option, +} +/// SubjectAltName represents Subject Alternative Name. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum BackendTlsPolicyValidationSubjectAltNamesType { + Hostname, + #[serde(rename = "URI")] + Uri, +} +/// Status defines the current state of BackendTLSPolicy. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyStatus { + /// Ancestors is a list of ancestor resources (usually Gateways) that are + /// associated with the policy, and the status of the policy with respect to + /// each ancestor. When this policy attaches to a parent, the controller that + /// manages the parent and the ancestors MUST add an entry to this list when + /// the controller first sees the policy and SHOULD update the entry as + /// appropriate when the relevant ancestor is modified. + /// + /// Note that choosing the relevant ancestor is left to the Policy designers; + /// an important part of Policy design is designing the right object level at + /// which to namespace this status. + /// + /// Note also that implementations MUST ONLY populate ancestor status for + /// the Ancestor resources they are responsible for. Implementations MUST + /// use the ControllerName field to uniquely identify the entries in this list + /// that they are responsible for. + /// + /// Note that to achieve this, the list of PolicyAncestorStatus structs + /// MUST be treated as a map with a composite key, made up of the AncestorRef + /// and ControllerName fields combined. + /// + /// A maximum of 16 ancestors will be represented in this list. An empty list + /// means the Policy is not relevant for any ancestors. + /// + /// If this slice is full, implementations MUST NOT add further entries. + /// Instead they MUST consider the policy unimplementable and signal that + /// on any related resources such as the ancestor that would be referenced + /// here. For example, if this list was full on BackendTLSPolicy, no + /// additional Gateways would be able to reference the Service targeted by + /// the BackendTLSPolicy. + pub ancestors: Vec, +} +/// PolicyAncestorStatus describes the status of a route with respect to an +/// associated Ancestor. +/// +/// Ancestors refer to objects that are either the Target of a policy or above it +/// in terms of object hierarchy. For example, if a policy targets a Service, the +/// Policy's Ancestors are, in order, the Service, the HTTPRoute, the Gateway, and +/// the GatewayClass. Almost always, in this hierarchy, the Gateway will be the most +/// useful object to place Policy status on, so we recommend that implementations +/// SHOULD use Gateway as the PolicyAncestorStatus object unless the designers +/// have a _very_ good reason otherwise. +/// +/// In the context of policy attachment, the Ancestor is used to distinguish which +/// resource results in a distinct application of this policy. For example, if a policy +/// targets a Service, it may have a distinct result per attached Gateway. +/// +/// Policies targeting the same resource may have different effects depending on the +/// ancestors of those resources. For example, different Gateways targeting the same +/// Service may have different capabilities, especially if they have different underlying +/// implementations. +/// +/// For example, in BackendTLSPolicy, the Policy attaches to a Service that is +/// used as a backend in a HTTPRoute that is itself attached to a Gateway. +/// In this case, the relevant object for status is the Gateway, and that is the +/// ancestor object referred to in this status. +/// +/// Note that a parent is also an ancestor, so for objects where the parent is the +/// relevant object for status, this struct SHOULD still be used. +/// +/// This struct is intended to be used in a slice that's effectively a map, +/// with a composite key made up of the AncestorRef and the ControllerName. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyStatusAncestors { + /// AncestorRef corresponds with a ParentRef in the spec that this + /// PolicyAncestorStatus struct describes the status of. + #[serde(rename = "ancestorRef")] + pub ancestor_ref: ParentReference, + /// Conditions describes the status of the Policy with respect to the given Ancestor. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, +} diff --git a/gateway-api-with-extensions/src/experimental/common.rs b/gateway-api-with-extensions/src/experimental/common.rs new file mode 100644 index 0000000..31bc6aa --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/common.rs @@ -0,0 +1,458 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum AllowedRoutesNamespacesFrom { + All, + Selector, + Same, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum CookieConfigLifetimeType { + Permanent, + Session, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum DefaultGateway { + All, + None, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum ExternalAuthProtocol { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "GRPC")] + Grpc, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GRPCFilterType { + ResponseHeaderModifier, + RequestHeaderModifier, + RequestMirror, + ExtensionRef, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HTTPFilterType { + RequestHeaderModifier, + ResponseHeaderModifier, + RequestMirror, + RequestRedirect, + #[serde(rename = "URLRewrite")] + UrlRewrite, + ExtensionRef, + #[serde(rename = "CORS")] + Cors, + ExternalAuth, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HeaderMatchType { + Exact, + RegularExpression, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RedirectStatusCode { + #[serde(rename = "301")] + r#_301, + #[serde(rename = "302")] + r#_302, + #[serde(rename = "303")] + r#_303, + #[serde(rename = "307")] + r#_307, + #[serde(rename = "308")] + r#_308, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RequestOperationType { + ReplaceFullPath, + ReplacePrefixMatch, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RequestRedirectScheme { + #[serde(rename = "http")] + Http, + #[serde(rename = "https")] + Https, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum SessionPersistenceType { + Cookie, + Header, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum TlsMode { + Terminate, + Passthrough, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum TlsValidationMode { + AllowValidOnly, + AllowInsecureFallback, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendObjectReference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ExtensionParametersReference { + pub group: String, + pub kind: String, + pub name: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ExternalAuthGrpc { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedHeaders" + )] + pub allowed_headers: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ExternalAuthHttp { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedHeaders" + )] + pub allowed_headers: Option>, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedResponseHeaders" + )] + pub allowed_response_headers: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ForwardBody { + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxSize")] + pub max_size: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayParametersRef { + pub group: String, + pub kind: String, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HTTPHeader { + pub name: String, + pub value: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolRef { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceStatus { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Kind { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + pub kind: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct MatchExpressions { + pub key: String, + pub operator: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub values: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ParentReference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sectionName" + )] + pub section_name: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Reference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestMirrorFraction { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub denominator: Option, + pub numerator: i32, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct SupportedFeatures { + pub name: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TcpRouteRulesBackendRefs { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ExternalAuthFilter { + #[serde(rename = "backendRef")] + pub backend_ref: BackendObjectReference, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "forwardBody" + )] + pub forward_body: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub grpc: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub http: Option, + pub protocol: ExternalAuthProtocol, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct FrontendTlsValidation { + #[serde(rename = "caCertificateRefs")] + pub ca_certificate_refs: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HeaderMatch { + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + pub value: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HeaderModifier { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub add: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub remove: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub set: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerTls { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "certificateRefs" + )] + pub certificate_refs: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub options: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct NamespaceSelector { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "matchExpressions" + )] + pub match_expressions: Option>, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "matchLabels" + )] + pub match_labels: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct PersistenceCookieConfig { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "lifetimeType" + )] + pub lifetime_type: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestMirror { + #[serde(rename = "backendRef")] + pub backend_ref: BackendObjectReference, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub fraction: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub percent: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestRedirectPath { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "replaceFullPath" + )] + pub replace_full_path: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "replacePrefixMatch" + )] + pub replace_prefix_match: Option, + #[serde(rename = "type")] + pub r#type: RequestOperationType, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct AllowedRoutesNamespaces { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub from: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub selector: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct FilterRequestRedirect { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub scheme: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "statusCode" + )] + pub status_code: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct FrontendTls { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub validation: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GrpcRouteFilter { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + #[serde(rename = "type")] + pub r#type: GRPCFilterType, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteUrlRewrite { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct SessionPersistence { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "absoluteTimeout" + )] + pub absolute_timeout: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "cookieConfig" + )] + pub cookie_config: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "idleTimeout" + )] + pub idle_timeout: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sessionName" + )] + pub session_name: Option, + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct AllowedRoutes { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kinds: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespaces: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Listeners { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedRoutes" + )] + pub allowed_routes: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + pub name: String, + pub port: i32, + pub protocol: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tls: Option, +} diff --git a/gateway-api/src/apis/experimental/constants.rs b/gateway-api-with-extensions/src/experimental/constants.rs similarity index 76% rename from gateway-api/src/apis/experimental/constants.rs rename to gateway-api-with-extensions/src/experimental/constants.rs index 83691ec..8995c8a 100644 --- a/gateway-api/src/apis/experimental/constants.rs +++ b/gateway-api-with-extensions/src/experimental/constants.rs @@ -5,13 +5,11 @@ pub enum GatewayClassConditionType { Accepted, SupportedVersion, } - impl std::fmt::Display for GatewayClassConditionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum GatewayClassConditionReason { Accepted, @@ -22,26 +20,22 @@ pub enum GatewayClassConditionReason { SupportedVersion, UnsupportedVersion, } - impl std::fmt::Display for GatewayClassConditionReason { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum GatewayConditionType { Programmed, Accepted, Ready, } - impl std::fmt::Display for GatewayConditionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum GatewayConditionReason { Programmed, @@ -57,13 +51,11 @@ pub enum GatewayConditionReason { Ready, ListenersNotReady, } - impl std::fmt::Display for GatewayConditionReason { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum ListenerConditionType { Conflicted, @@ -72,13 +64,11 @@ pub enum ListenerConditionType { Programmed, Ready, } - impl std::fmt::Display for ListenerConditionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum ListenerConditionReason { HostnameConflict, @@ -96,9 +86,35 @@ pub enum ListenerConditionReason { Pending, Ready, } - impl std::fmt::Display for ListenerConditionReason { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } +#[derive(Debug, PartialEq, Eq)] +pub enum RouteConditionType { + Accepted, + ResolvedRefs, +} +impl std::fmt::Display for RouteConditionType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum RouteConditionReason { + Accepted, + NotAllowedByListeners, + NoMatchingListenerHostname, + UnsupportedValue, + Pending, + ResolvedRefs, + RefNotPermitted, + InvalidKind, + BackendNotFound, +} +impl std::fmt::Display for RouteConditionReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} diff --git a/gateway-api-with-extensions/src/experimental/enum_defaults.rs b/gateway-api-with-extensions/src/experimental/enum_defaults.rs new file mode 100644 index 0000000..5c3b225 --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/enum_defaults.rs @@ -0,0 +1,123 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +pub mod prelude { + + pub use super::super::backendtlspolicies::*; + pub use super::super::gatewayclasses::*; + pub use super::super::gateways::*; + pub use super::super::grpcroutes::*; + pub use super::super::httproutes::*; + pub use super::super::listenersets::*; + pub use super::super::referencegrants::*; + pub use super::super::tcproutes::*; + pub use super::super::tlsroutes::*; + pub use super::super::udproutes::*; + + pub use super::super::inferenceobjectives::*; + pub use super::super::inferencepools::*; + + pub use super::super::common::*; +} +use prelude::*; +impl Default for AllowedRoutesNamespacesFrom { + fn default() -> Self { + AllowedRoutesNamespacesFrom::Same + } +} + +impl Default for BackendTlsPolicyValidationSubjectAltNamesType { + fn default() -> Self { + BackendTlsPolicyValidationSubjectAltNamesType::Hostname + } +} + +impl Default for CookieConfigLifetimeType { + fn default() -> Self { + CookieConfigLifetimeType::Session + } +} + +impl Default for ExternalAuthProtocol { + fn default() -> Self { + ExternalAuthProtocol::Http + } +} + +impl Default for GRPCFilterType { + fn default() -> Self { + GRPCFilterType::RequestHeaderModifier + } +} + +impl Default for GatewayAllowedListenersNamespacesFrom { + fn default() -> Self { + GatewayAllowedListenersNamespacesFrom::Same + } +} + +impl Default for HTTPFilterType { + fn default() -> Self { + HTTPFilterType::RequestHeaderModifier + } +} + +impl Default for HTTPMethodMatch { + fn default() -> Self { + HTTPMethodMatch::Get + } +} + +impl Default for HeaderMatchType { + fn default() -> Self { + HeaderMatchType::Exact + } +} + +impl Default for HttpRouteRulesMatchesPathType { + fn default() -> Self { + HttpRouteRulesMatchesPathType::Exact + } +} + +impl Default for RedirectStatusCode { + fn default() -> Self { + RedirectStatusCode::r#_301 + } +} + +impl Default for RequestOperationType { + fn default() -> Self { + RequestOperationType::ReplaceFullPath + } +} + +impl Default for RequestRedirectScheme { + fn default() -> Self { + RequestRedirectScheme::Https + } +} + +impl Default for SessionPersistenceType { + fn default() -> Self { + SessionPersistenceType::Cookie + } +} + +impl Default for TlsMode { + fn default() -> Self { + TlsMode::Terminate + } +} + +impl Default for TlsValidationMode { + fn default() -> Self { + TlsValidationMode::AllowValidOnly + } +} +impl Default for InferencePoolExtensionRefFailureMode { + fn default() -> Self { + InferencePoolExtensionRefFailureMode::FailOpen + } +} +use crate::experimental::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType; diff --git a/gateway-api-with-extensions/src/experimental/gatewayclasses.rs b/gateway-api-with-extensions/src/experimental/gatewayclasses.rs new file mode 100644 index 0000000..773da0d --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/gatewayclasses.rs @@ -0,0 +1,83 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of GatewayClass. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "GatewayClass", + plural = "gatewayclasses" +)] +#[kube(status = "GatewayClassStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct GatewayClassSpec { + /// ControllerName is the name of the controller that is managing Gateways of + /// this class. The value of this field MUST be a domain prefixed path. + /// + /// Example: "example.net/gateway-controller". + /// + /// This field is not mutable and cannot be empty. + /// + /// Support: Core + #[serde(rename = "controllerName")] + pub controller_name: String, + /// Description helps describe a GatewayClass with more details. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + /// ParametersRef is a reference to a resource that contains the configuration + /// parameters corresponding to the GatewayClass. This is optional if the + /// controller does not require any additional configuration. + /// + /// ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap, + /// or an implementation-specific custom resource. The resource can be + /// cluster-scoped or namespace-scoped. + /// + /// If the referent cannot be found, refers to an unsupported kind, or when + /// the data within that resource is malformed, the GatewayClass SHOULD be + /// rejected with the "Accepted" status condition set to "False" and an + /// "InvalidParameters" reason. + /// + /// A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, + /// the merging behavior is implementation specific. + /// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parametersRef" + )] + pub parameters_ref: Option, +} +/// Status defines the current state of GatewayClass. +/// +/// Implementations MUST populate status on all GatewayClass resources which +/// specify their controller name. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayClassStatus { + /// Conditions is the current status from the controller for + /// this GatewayClass. + /// + /// Controllers should prefer to publish conditions using values + /// of GatewayClassConditionType for the type of each Condition. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// SupportedFeatures is the set of features the GatewayClass support. + /// It MUST be sorted in ascending alphabetical order by the Name key. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "supportedFeatures" + )] + pub supported_features: Option>, +} diff --git a/gateway-api-with-extensions/src/experimental/gateways.rs b/gateway-api-with-extensions/src/experimental/gateways.rs new file mode 100644 index 0000000..0741959 --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/gateways.rs @@ -0,0 +1,561 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of Gateway. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "Gateway", + plural = "gateways" +)] +#[kube(namespaced)] +#[kube(status = "GatewayStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct GatewaySpec { + /// Addresses requested for this Gateway. This is optional and behavior can + /// depend on the implementation. If a value is set in the spec and the + /// requested address is invalid or unavailable, the implementation MUST + /// indicate this in an associated entry in GatewayStatus.Conditions. + /// + /// The Addresses field represents a request for the address(es) on the + /// "outside of the Gateway", that traffic bound for this Gateway will use. + /// This could be the IP address or hostname of an external load balancer or + /// other networking infrastructure, or some other address that traffic will + /// be sent to. + /// + /// If no Addresses are specified, the implementation MAY schedule the + /// Gateway in an implementation-specific manner, assigning an appropriate + /// set of Addresses. + /// + /// The implementation MUST bind all Listeners to every GatewayAddress that + /// it assigns to the Gateway and add a corresponding entry in + /// GatewayStatus.Addresses. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub addresses: Option>, + /// AllowedListeners defines which ListenerSets can be attached to this Gateway. + /// The default value is to allow no ListenerSets. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedListeners" + )] + pub allowed_listeners: Option, + /// DefaultScope, when set, configures the Gateway as a default Gateway, + /// meaning it will dynamically and implicitly have Routes (e.g. HTTPRoute) + /// attached to it, according to the scope configured here. + /// + /// If unset (the default) or set to None, the Gateway will not act as a + /// default Gateway; if set, the Gateway will claim any Route with a + /// matching scope set in its UseDefaultGateway field, subject to the usual + /// rules about which routes the Gateway can attach to. + /// + /// Think carefully before using this functionality! While the normal rules + /// about which Route can apply are still enforced, it is simply easier for + /// the wrong Route to be accidentally attached to this Gateway in this + /// configuration. If the Gateway operator is not also the operator in + /// control of the scope (e.g. namespace) with tight controls and checks on + /// what kind of workloads and Routes get added in that scope, we strongly + /// recommend not using this just because it seems convenient, and instead + /// stick to direct Route attachment. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "defaultScope" + )] + pub default_scope: Option, + /// GatewayClassName used for this Gateway. This is the name of a + /// GatewayClass resource. + #[serde(rename = "gatewayClassName")] + pub gateway_class_name: String, + /// Infrastructure defines infrastructure level attributes about this Gateway instance. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub infrastructure: Option, + /// Listeners associated with this Gateway. Listeners define + /// logical endpoints that are bound on this Gateway's addresses. + /// At least one Listener MUST be specified. + /// + /// ## Distinct Listeners + /// + /// Each Listener in a set of Listeners (for example, in a single Gateway) + /// MUST be _distinct_, in that a traffic flow MUST be able to be assigned to + /// exactly one listener. (This section uses "set of Listeners" rather than + /// "Listeners in a single Gateway" because implementations MAY merge configuration + /// from multiple Gateways onto a single data plane, and these rules _also_ + /// apply in that case). + /// + /// Practically, this means that each listener in a set MUST have a unique + /// combination of Port, Protocol, and, if supported by the protocol, Hostname. + /// + /// Some combinations of port, protocol, and TLS settings are considered + /// Core support and MUST be supported by implementations based on the objects + /// they support: + /// + /// HTTPRoute + /// + /// 1. HTTPRoute, Port: 80, Protocol: HTTP + /// 2. HTTPRoute, Port: 443, Protocol: HTTPS, TLS Mode: Terminate, TLS keypair provided + /// + /// TLSRoute + /// + /// 1. TLSRoute, Port: 443, Protocol: TLS, TLS Mode: Passthrough + /// + /// "Distinct" Listeners have the following property: + /// + /// **The implementation can match inbound requests to a single distinct + /// Listener**. + /// + /// When multiple Listeners share values for fields (for + /// example, two Listeners with the same Port value), the implementation + /// can match requests to only one of the Listeners using other + /// Listener fields. + /// + /// When multiple listeners have the same value for the Protocol field, then + /// each of the Listeners with matching Protocol values MUST have different + /// values for other fields. + /// + /// The set of fields that MUST be different for a Listener differs per protocol. + /// The following rules define the rules for what fields MUST be considered for + /// Listeners to be distinct with each protocol currently defined in the + /// Gateway API spec. + /// + /// The set of listeners that all share a protocol value MUST have _different_ + /// values for _at least one_ of these fields to be distinct: + /// + /// * **HTTP, HTTPS, TLS**: Port, Hostname + /// * **TCP, UDP**: Port + /// + /// One **very** important rule to call out involves what happens when an + /// implementation: + /// + /// * Supports TCP protocol Listeners, as well as HTTP, HTTPS, or TLS protocol + /// Listeners, and + /// * sees HTTP, HTTPS, or TLS protocols with the same `port` as one with TCP + /// Protocol. + /// + /// In this case all the Listeners that share a port with the + /// TCP Listener are not distinct and so MUST NOT be accepted. + /// + /// If an implementation does not support TCP Protocol Listeners, then the + /// previous rule does not apply, and the TCP Listeners SHOULD NOT be + /// accepted. + /// + /// Note that the `tls` field is not used for determining if a listener is distinct, because + /// Listeners that _only_ differ on TLS config will still conflict in all cases. + /// + /// ### Listeners that are distinct only by Hostname + /// + /// When the Listeners are distinct based only on Hostname, inbound request + /// hostnames MUST match from the most specific to least specific Hostname + /// values to choose the correct Listener and its associated set of Routes. + /// + /// Exact matches MUST be processed before wildcard matches, and wildcard + /// matches MUST be processed before fallback (empty Hostname value) + /// matches. For example, `"foo.example.com"` takes precedence over + /// `"*.example.com"`, and `"*.example.com"` takes precedence over `""`. + /// + /// Additionally, if there are multiple wildcard entries, more specific + /// wildcard entries must be processed before less specific wildcard entries. + /// For example, `"*.foo.example.com"` takes precedence over `"*.example.com"`. + /// + /// The precise definition here is that the higher the number of dots in the + /// hostname to the right of the wildcard character, the higher the precedence. + /// + /// The wildcard character will match any number of characters _and dots_ to + /// the left, however, so `"*.example.com"` will match both + /// `"foo.bar.example.com"` _and_ `"bar.example.com"`. + /// + /// ## Handling indistinct Listeners + /// + /// If a set of Listeners contains Listeners that are not distinct, then those + /// Listeners are _Conflicted_, and the implementation MUST set the "Conflicted" + /// condition in the Listener Status to "True". + /// + /// The words "indistinct" and "conflicted" are considered equivalent for the + /// purpose of this documentation. + /// + /// Implementations MAY choose to accept a Gateway with some Conflicted + /// Listeners only if they only accept the partial Listener set that contains + /// no Conflicted Listeners. + /// + /// Specifically, an implementation MAY accept a partial Listener set subject to + /// the following rules: + /// + /// * The implementation MUST NOT pick one conflicting Listener as the winner. + /// ALL indistinct Listeners must not be accepted for processing. + /// * At least one distinct Listener MUST be present, or else the Gateway effectively + /// contains _no_ Listeners, and must be rejected from processing as a whole. + /// + /// The implementation MUST set a "ListenersNotValid" condition on the + /// Gateway Status when the Gateway contains Conflicted Listeners whether or + /// not they accept the Gateway. That Condition SHOULD clearly + /// indicate in the Message which Listeners are conflicted, and which are + /// Accepted. Additionally, the Listener status for those listeners SHOULD + /// indicate which Listeners are conflicted and not Accepted. + /// + /// ## General Listener behavior + /// + /// Note that, for all distinct Listeners, requests SHOULD match at most one Listener. + /// For example, if Listeners are defined for "foo.example.com" and "*.example.com", a + /// request to "foo.example.com" SHOULD only be routed using routes attached + /// to the "foo.example.com" Listener (and not the "*.example.com" Listener). + /// + /// This concept is known as "Listener Isolation", and it is an Extended feature + /// of Gateway API. Implementations that do not support Listener Isolation MUST + /// clearly document this, and MUST NOT claim support for the + /// `GatewayHTTPListenerIsolation` feature. + /// + /// Implementations that _do_ support Listener Isolation SHOULD claim support + /// for the Extended `GatewayHTTPListenerIsolation` feature and pass the associated + /// conformance tests. + /// + /// ## Compatible Listeners + /// + /// A Gateway's Listeners are considered _compatible_ if: + /// + /// 1. They are distinct. + /// 2. The implementation can serve them in compliance with the Addresses + /// requirement that all Listeners are available on all assigned + /// addresses. + /// + /// Compatible combinations in Extended support are expected to vary across + /// implementations. A combination that is compatible for one implementation + /// may not be compatible for another. + /// + /// For example, an implementation that cannot serve both TCP and UDP listeners + /// on the same address, or cannot mix HTTPS and generic TLS listens on the same port + /// would not consider those cases compatible, even though they are distinct. + /// + /// Implementations MAY merge separate Gateways onto a single set of + /// Addresses if all Listeners across all Gateways are compatible. + /// + /// In a future release the MinItems=1 requirement MAY be dropped. + /// + /// Support: Core + pub listeners: Vec, + /// TLS specifies frontend and backend tls configuration for entire gateway. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tls: Option, +} +/// GatewaySpecAddress describes an address that can be bound to a Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAddresses { + /// Type of the address. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// When a value is unspecified, an implementation SHOULD automatically + /// assign an address matching the requested type if possible. + /// + /// If an implementation does not support an empty value, they MUST set the + /// "Programmed" condition in status to False with a reason of "AddressNotAssigned". + /// + /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, +} +/// AllowedListeners defines which ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAllowedListeners { + /// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. + /// The default value is to allow no ListenerSets. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespaces: Option, +} +/// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAllowedListenersNamespaces { + /// From indicates where ListenerSets can attach to this Gateway. Possible + /// values are: + /// + /// * Same: Only ListenerSets in the same namespace may be attached to this Gateway. + /// * Selector: ListenerSets in namespaces selected by the selector may be attached to this Gateway. + /// * All: ListenerSets in all namespaces may be attached to this Gateway. + /// * None: Only listeners defined in the Gateway's spec are allowed + /// + /// The default value None + #[serde(default, skip_serializing_if = "Option::is_none")] + pub from: Option, + /// Selector must be specified when From is set to "Selector". In that case, + /// only ListenerSets in Namespaces matching this Selector will be selected by this + /// Gateway. This field is ignored for other values of "From". + #[serde(default, skip_serializing_if = "Option::is_none")] + pub selector: Option, +} +/// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GatewayAllowedListenersNamespacesFrom { + All, + Selector, + Same, + None, +} +/// Infrastructure defines infrastructure level attributes about this Gateway instance. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayInfrastructure { + /// Annotations that SHOULD be applied to any resources created in response to this Gateway. + /// + /// For implementations creating other Kubernetes objects, this should be the `metadata.annotations` field on resources. + /// For other implementations, this refers to any relevant (implementation specific) "annotations" concepts. + /// + /// An implementation may chose to add additional implementation-specific annotations as they see fit. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub annotations: Option>, + /// Labels that SHOULD be applied to any resources created in response to this Gateway. + /// + /// For implementations creating other Kubernetes objects, this should be the `metadata.labels` field on resources. + /// For other implementations, this refers to any relevant (implementation specific) "labels" concepts. + /// + /// An implementation may chose to add additional implementation-specific labels as they see fit. + /// + /// If an implementation maps these labels to Pods, or any other resource that would need to be recreated when labels + /// change, it SHOULD clearly warn about this behavior in documentation. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub labels: Option>, + /// ParametersRef is a reference to a resource that contains the configuration + /// parameters corresponding to the Gateway. This is optional if the + /// controller does not require any additional configuration. + /// + /// This follows the same semantics as GatewayClass's `parametersRef`, but on a per-Gateway basis + /// + /// The Gateway's GatewayClass may provide its own `parametersRef`. When both are specified, + /// the merging behavior is implementation specific. + /// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. + /// + /// If the referent cannot be found, refers to an unsupported kind, or when + /// the data within that resource is malformed, the Gateway SHOULD be + /// rejected with the "Accepted" status condition set to "False" and an + /// "InvalidParameters" reason. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parametersRef" + )] + pub parameters_ref: Option, +} +/// TLS specifies frontend and backend tls configuration for entire gateway. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTls { + /// Backend describes TLS configuration for gateway when connecting + /// to backends. + /// + /// Note that this contains only details for the Gateway as a TLS client, + /// and does _not_ imply behavior about how to choose which backend should + /// get a TLS connection. That is determined by the presence of a BackendTLSPolicy. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub backend: Option, + /// Frontend describes TLS config when client connects to Gateway. + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub frontend: Option, +} +/// Backend describes TLS configuration for gateway when connecting +/// to backends. +/// +/// Note that this contains only details for the Gateway as a TLS client, +/// and does _not_ imply behavior about how to choose which backend should +/// get a TLS connection. That is determined by the presence of a BackendTLSPolicy. +/// +/// Support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsBackend { + /// ClientCertificateRef references an object that contains a client certificate + /// and its associated private key. It can reference standard Kubernetes resources, + /// i.e., Secret, or implementation-specific custom resources. + /// + /// A ClientCertificateRef is considered invalid if: + /// + /// * It refers to a resource that cannot be resolved (e.g., the referenced resource + /// does not exist) or is misconfigured (e.g., a Secret does not contain the keys + /// named `tls.crt` and `tls.key`). In this case, the `ResolvedRefs` condition + /// on the Gateway MUST be set to False with the Reason `InvalidClientCertificateRef` + /// and the Message of the Condition MUST indicate why the reference is invalid. + /// + /// * It refers to a resource in another namespace UNLESS there is a ReferenceGrant + /// in the target namespace that allows the certificate to be attached. + /// If a ReferenceGrant does not allow this reference, the `ResolvedRefs` condition + /// on the Gateway MUST be set to False with the Reason `RefNotPermitted`. + /// + /// Implementations MAY choose to perform further validation of the certificate + /// content (e.g., checking expiry or enforcing specific formats). In such cases, + /// an implementation-specific Reason and Message MUST be set. + /// + /// Support: Core - Reference to a Kubernetes TLS Secret (with the type `kubernetes.io/tls`). + /// Support: Implementation-specific - Other resource kinds or Secrets with a + /// different type (e.g., `Opaque`). + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "clientCertificateRef" + )] + pub client_certificate_ref: Option, +} +/// Frontend describes TLS config when client connects to Gateway. +/// Support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontend { + /// Default specifies the default client certificate validation configuration + /// for all Listeners handling HTTPS traffic, unless a per-port configuration + /// is defined. + /// + /// support: Core + pub default: FrontendTls, + /// PerPort specifies tls configuration assigned per port. + /// Per port configuration is optional. Once set this configuration overrides + /// the default configuration for all Listeners handling HTTPS traffic + /// that match this port. + /// Each override port requires a unique TLS configuration. + /// + /// support: Core + #[serde(default, skip_serializing_if = "Option::is_none", rename = "perPort")] + pub per_port: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendPerPort { + /// The Port indicates the Port Number to which the TLS configuration will be + /// applied. This configuration will be applied to all Listeners handling HTTPS + /// traffic that match this port. + /// + /// Support: Core + pub port: i32, + /// TLS store the configuration that will be applied to all Listeners handling + /// HTTPS traffic and matching given port. + /// + /// Support: Core + pub tls: FrontendTls, +} +/// Status defines the current state of Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatus { + /// Addresses lists the network addresses that have been bound to the + /// Gateway. + /// + /// This list may differ from the addresses provided in the spec under some + /// conditions: + /// + /// * no addresses are specified, all addresses are dynamically assigned + /// * a combination of specified and dynamic addresses are assigned + /// * a specified address was unusable (e.g. already in use) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub addresses: Option>, + /// AttachedListenerSets represents the total number of ListenerSets that have been + /// successfully attached to this Gateway. + /// + /// A ListenerSet is successfully attached to a Gateway when all the following conditions are met: + /// - The ListenerSet is selected by the Gateway's AllowedListeners field + /// - The ListenerSet has a valid ParentRef selecting the Gateway + /// - The ListenerSet's status has the condition "Accepted: true" + /// + /// Uses for this field include troubleshooting AttachedListenerSets attachment and + /// measuring blast radius/impact of changes to a Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "attachedListenerSets" + )] + pub attached_listener_sets: Option, + /// Conditions describe the current conditions of the Gateway. + /// + /// Implementations should prefer to express Gateway conditions + /// using the `GatewayConditionType` and `GatewayConditionReason` + /// constants so that operators and tools can converge on a common + /// vocabulary to describe Gateway state. + /// + /// Known condition types are: + /// + /// * "Accepted" + /// * "Programmed" + /// * "Ready" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// Listeners provide status for each unique listener port defined in the Spec. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub listeners: Option>, +} +/// GatewayStatusAddress describes a network address that is bound to a Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatusAddresses { + /// Type of the address. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// Value of the address. The validity of the values will depend + /// on the type and support by the controller. + /// + /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. + pub value: String, +} +/// ListenerStatus is the status associated with a Listener. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatusListeners { + /// AttachedRoutes represents the total number of Routes that have been + /// successfully attached to this Listener. + /// + /// Successful attachment of a Route to a Listener is based solely on the + /// combination of the AllowedRoutes field on the corresponding Listener + /// and the Route's ParentRefs field. A Route is successfully attached to + /// a Listener when it is selected by the Listener's AllowedRoutes field + /// AND the Route has a valid ParentRef selecting the whole Gateway + /// resource or a specific Listener as a parent resource (more detail on + /// attachment semantics can be found in the documentation on the various + /// Route kinds ParentRefs fields). Listener or Route status does not impact + /// successful attachment, i.e. the AttachedRoutes field count MUST be set + /// for Listeners, even if the Accepted condition of an individual Listener is set + /// to "False". The AttachedRoutes number represents the number of Routes with + /// the Accepted condition set to "True" that have been attached to this Listener. + /// Routes with any other value for the Accepted condition MUST NOT be included + /// in this count. + /// + /// Uses for this field include troubleshooting Route attachment and + /// measuring blast radius/impact of changes to a Listener. + #[serde(rename = "attachedRoutes")] + pub attached_routes: i32, + /// Conditions describe the current condition of this listener. + pub conditions: Vec, + /// Name is the name of the Listener that this status corresponds to. + pub name: String, + /// SupportedKinds is the list indicating the Kinds supported by this + /// listener. This MUST represent the kinds supported by an implementation for + /// that Listener configuration. + /// + /// If kinds are specified in Spec that are not supported, they MUST NOT + /// appear in this list and an implementation MUST set the "ResolvedRefs" + /// condition to "False" with the "InvalidRouteKinds" reason. If both valid + /// and invalid Route kinds are specified, the implementation MUST + /// reference the valid Route kinds that have been specified. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "supportedKinds" + )] + pub supported_kinds: Option>, +} diff --git a/gateway-api/src/apis/experimental/udproutes.rs b/gateway-api-with-extensions/src/experimental/grpcroutes.rs similarity index 50% rename from gateway-api/src/apis/experimental/udproutes.rs rename to gateway-api-with-extensions/src/experimental/grpcroutes.rs index b531c7e..51ee5d8 100644 --- a/gateway-api/src/apis/experimental/udproutes.rs +++ b/gateway-api-with-extensions/src/experimental/grpcroutes.rs @@ -1,29 +1,79 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 +// WARNING: generated file - manual changes will be overriden +use super::common::*; #[allow(unused_imports)] mod prelude { pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube::CustomResource; + pub use kube_derive::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } use self::prelude::*; - -/// Spec defines the desired state of UDPRoute. +/// Spec defines the desired state of GRPCRoute. #[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] #[kube( group = "gateway.networking.k8s.io", - version = "v1alpha2", - kind = "UDPRoute", - plural = "udproutes" + version = "v1", + kind = "GRPCRoute", + plural = "grpcroutes" )] #[kube(namespaced)] -#[kube(status = "UDPRouteStatus")] +#[kube(status = "GrpcRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct UDPRouteSpec { +pub struct GrpcRouteSpec { + /// Hostnames defines a set of hostnames to match against the GRPC + /// Host header to select a GRPCRoute to process the request. This matches + /// the RFC 1123 definition of a hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label MUST appear by itself as the first label. + /// + /// If a hostname is specified by both the Listener and GRPCRoute, there + /// MUST be at least one intersecting hostname for the GRPCRoute to be + /// attached to the Listener. For example: + /// + /// * A Listener with `test.example.com` as the hostname matches GRPCRoutes + /// that have either not specified any hostnames, or have specified at + /// least one of `test.example.com` or `*.example.com`. + /// * A Listener with `*.example.com` as the hostname matches GRPCRoutes + /// that have either not specified any hostnames or have specified at least + /// one hostname that matches the Listener hostname. For example, + /// `test.example.com` and `*.example.com` would both match. On the other + /// hand, `example.com` and `test.example.net` would not match. + /// + /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted + /// as a suffix match. That means that a match for `*.example.com` would match + /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. + /// + /// If both the Listener and GRPCRoute have specified hostnames, any + /// GRPCRoute hostnames that do not match the Listener hostname MUST be + /// ignored. For example, if a Listener specified `*.example.com`, and the + /// GRPCRoute specified `test.example.com` and `test.example.net`, + /// `test.example.net` MUST NOT be considered for a match. + /// + /// If both the Listener and GRPCRoute have specified hostnames, and none + /// match with the criteria above, then the GRPCRoute MUST NOT be accepted by + /// the implementation. The implementation MUST raise an 'Accepted' Condition + /// with a status of `False` in the corresponding RouteParentStatus. + /// + /// If a Route (A) of type HTTPRoute or GRPCRoute is attached to a + /// Listener and that listener already has another Route (B) of the other + /// type attached and the intersection of the hostnames of A and B is + /// non-empty, then the implementation MUST accept exactly one of these two + /// routes, determined by the following criteria, in order: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// The rejected Route MUST raise an 'Accepted' condition with a status of + /// 'False' in the corresponding RouteParentStatus. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostnames: Option>, /// ParentRefs references the resources (usually Gateways) that a Route wants /// to be attached to. Note that the referenced parent resource needs to /// allow this for the attachment to be complete. For Gateways, that means @@ -85,187 +135,173 @@ pub struct UDPRouteSpec { /// connections originating from the same namespace as the Route, for which /// the intended destination of the connections are a Service targeted as a /// ParentRef of the Route. - /// - /// - /// - /// - /// - /// #[serde( default, skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, - /// Rules are a list of UDP matchers and actions. - /// - /// - pub rules: Vec, + pub parent_refs: Option>, + /// Rules are a list of GRPC matchers, filters and actions. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rules: Option>, + /// UseDefaultGateways indicates the default Gateway scope to use for this + /// Route. If unset (the default) or set to None, the Route will not be + /// attached to any default Gateway; if set, it will be attached to any + /// default Gateway supporting the named scope, subject to the usual rules + /// about which Routes a Gateway is allowed to claim. + /// + /// Think carefully before using this functionality! The set of default + /// Gateways supporting the requested scope can change over time without + /// any notice to the Route author, and in many situations it will not be + /// appropriate to request a default Gateway for a given Route -- for + /// example, a Route with specific security requirements should almost + /// certainly not use a default Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "useDefaultGateways" + )] + pub use_default_gateways: Option, } - -/// ParentReference identifies an API object (usually a Gateway) that can be considered -/// a parent of this resource (usually a route). There are two kinds of parent resources -/// with "Core" support: -/// -/// * Gateway (Gateway conformance profile) -/// * Service (Mesh conformance profile, ClusterIP Services only) -/// -/// This API may be extended in the future to support additional kinds of parent -/// resources. -/// -/// The API object must be valid in the cluster; the Group and Kind must -/// be registered in the cluster for this reference to be valid. +/// GRPCRouteRule defines the semantics for matching a gRPC request based on +/// conditions (matches), processing it (filters), and forwarding the request to +/// an API object (backendRefs). #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct UDPRouteParentRefs { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) +pub struct GrpcRouteRule { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. + /// Failure behavior here depends on how many BackendRefs are specified and + /// how many are invalid. /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. + /// If *all* entries in BackendRefs are invalid, and there are also no filters + /// specified in this route rule, *all* traffic which matches this rule MUST + /// receive an `UNAVAILABLE` status. /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. + /// See the GRPCBackendRef definition for the rules about what makes a single + /// GRPCBackendRef invalid. /// + /// When a GRPCBackendRef is invalid, `UNAVAILABLE` statuses MUST be returned for + /// requests that would have otherwise been routed to an invalid backend. If + /// multiple backends are specified, and some are invalid, the proportion of + /// requests that would otherwise have been routed to an invalid backend + /// MUST receive an `UNAVAILABLE` status. /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. + /// For example, if two backends are specified with equal weights, and one is + /// invalid, 50 percent of traffic MUST receive an `UNAVAILABLE` status. + /// Implementations may choose how that 50 percent is determined. /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. + /// Support: Core for Kubernetes Service /// + /// Support: Implementation-specific for any other resource /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. + /// Support for weight: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRefs" + )] + pub backend_refs: Option>, + /// Filters define the filters that are applied to requests that match + /// this rule. /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. + /// The effects of ordering of multiple behaviors are currently unspecified. + /// This can change in the future based on feedback during the alpha stage. /// + /// Conformance-levels at this level are defined based on the type of filter: /// - /// When the parent resource is a Service, this targets a specific port in the - /// Service spec. When both Port (experimental) and SectionName are specified, - /// the name and port of the selected port must match both specified values. + /// - ALL core filters MUST be supported by all implementations that support + /// GRPCRoute. + /// - Implementers are encouraged to support extended filters. + /// - Implementation-specific custom filters have no API guarantees across + /// implementations. /// + /// Specifying the same filter multiple times is not supported unless explicitly + /// indicated in the filter. /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. + /// If an implementation cannot support a combination of filters, it must clearly + /// document that limitation. In cases where incompatible or unsupported + /// filters are specified and cause the `Accepted` condition to be set to status + /// `False`, implementations may use the `IncompatibleFilters` reason to specify + /// this configuration error. /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Matches define conditions used for matching the rule against incoming + /// gRPC requests. Each match is independent, i.e. this rule will be matched + /// if **any** one of the matches is satisfied. + /// + /// For example, take the following matches configuration: + /// + /// ```text + /// matches: + /// - method: + /// service: foo.bar + /// headers: + /// values: + /// version: 2 + /// - method: + /// service: foo.bar.v2 + /// ``` + /// + /// For a request to match against this rule, it MUST satisfy + /// EITHER of the two conditions: + /// + /// - service of foo.bar AND contains the header `version: 2` + /// - service of foo.bar.v2 + /// + /// See the documentation for GRPCRouteMatch on how to specify multiple + /// match conditions to be ANDed together. + /// + /// If no matches are specified, the implementation MUST match every gRPC request. + /// + /// Proxy or Load Balancer routing configuration generated from GRPCRoutes + /// MUST prioritize rules based on the following criteria, continuing on + /// ties. Merging MUST not be done between GRPCRoutes and HTTPRoutes. + /// Precedence MUST be given to the rule with the largest number of: + /// + /// * Characters in a matching non-wildcard hostname. + /// * Characters in a matching hostname. + /// * Characters in a matching service. + /// * Characters in a matching method. + /// * Header matches. + /// + /// If ties still exist across multiple Routes, matching precedence MUST be + /// determined in order of the following criteria, continuing on ties: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// If ties still exist within the Route that has been given precedence, + /// matching precedence MUST be granted to the first matching rule meeting + /// the above criteria. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub matches: Option>, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. /// /// Support: Extended #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. + pub name: Option, + /// SessionPersistence defines and configures session persistence + /// for the route rule. /// - /// Support: Core + /// Support: Extended #[serde( default, skip_serializing_if = "Option::is_none", - rename = "sectionName" + rename = "sessionPersistence" )] - pub section_name: Option, + pub session_persistence: Option, } - -/// UDPRouteRule is the configuration for a given rule. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct UDPRouteRules { - /// BackendRefs defines the backend(s) where matching requests should be - /// sent. If unspecified or invalid (refers to a non-existent resource or a - /// Service with no endpoints), the underlying implementation MUST actively - /// reject connection attempts to this backend. Packet drops must - /// respect weight; if an invalid backend is requested to have 80% of - /// the packets, then 80% of packets must be dropped instead. - /// - /// Support: Core for Kubernetes Service - /// - /// Support: Extended for Kubernetes ServiceImport - /// - /// Support: Implementation-specific for any other resource - /// - /// Support for weight: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "backendRefs" - )] - pub backend_refs: Option>, - /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub name: Option, -} - -/// BackendRef defines how a Route should forward a request to a Kubernetes -/// resource. +/// GRPCBackendRef defines how a GRPCRoute forwards a gRPC request. /// /// Note that when a namespace different than the local namespace is specified, a /// ReferenceGrant object is required in the referent namespace to allow that /// namespace's owner to accept the reference. See the ReferenceGrant /// documentation for details. /// -/// /// /// When the BackendRef points to a Kubernetes Service, implementations SHOULD /// honor the appProtocol field if it is set for the target Service Port. @@ -280,14 +316,15 @@ pub struct UDPRouteRules { /// If a Route is not able to send traffic to the backend using the specified /// protocol then the backend is considered invalid. Implementations MUST set the /// "ResolvedRefs" condition to "False" with the "UnsupportedProtocol" reason. -/// -/// -/// -/// Note that when the BackendTLSPolicy object is enabled by the implementation, -/// there are some extra rules about validity to consider here. See the fields -/// where this struct is used for more information about the exact behavior. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct UDPRouteRulesBackendRefs { +pub struct GRPCBackendReference { + /// Filters defined at this level MUST be executed if and only if the + /// request is being forwarded to the backend defined here. + /// + /// Support: Implementation-specific (For broader support of filters, use the + /// Filters field in GRPCRouteRule.) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, /// Group is the group of the referent. For example, "gateway.networking.k8s.io". /// When unspecified or empty string, core API group is inferred. #[serde(default, skip_serializing_if = "Option::is_none")] @@ -344,10 +381,63 @@ pub struct UDPRouteRulesBackendRefs { #[serde(default, skip_serializing_if = "Option::is_none")] pub weight: Option, } - -/// Status defines the current state of UDPRoute. +/// GRPCRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a gRPC request only if its service +/// is `foo` AND it contains the `version: v1` header: +/// +/// ```text +/// matches: +/// - method: +/// type: Exact +/// service: "foo" +/// - headers: +/// name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GrpcRouteMatch { + /// Headers specifies gRPC request header matchers. Multiple match values are + /// ANDed together, meaning, a request MUST match all the specified headers + /// to select the route. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub headers: Option>, + /// Method specifies a gRPC request service/method matcher. If this field is + /// not specified, all services and methods will match. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, +} +/// Method specifies a gRPC request service/method matcher. If this field is +/// not specified, all services and methods will match. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GRPCMethodMatch { + /// Value of the method to match against. If left empty or omitted, will + /// match all services. + /// + /// At least one of Service and Method MUST be a non-empty string. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, + /// Value of the service to match against. If left empty or omitted, will + /// match any service. + /// + /// At least one of Service and Method MUST be a non-empty string. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub service: Option, + /// Type specifies how to match against the service and/or method. + /// Support: Core (Exact with service and method specified) + /// + /// Support: Implementation-specific (Exact with method specified but no service specified) + /// + /// Support: Implementation-specific (RegularExpression) + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, +} +/// Status defines the current state of GRPCRoute. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct UDPRouteStatus { +pub struct GrpcRouteStatus { /// Parents is a list of parent resources (usually Gateways) that are /// associated with the route, and the status of the route with respect to /// each parent. When this route attaches to a parent, the controller that @@ -362,13 +452,12 @@ pub struct UDPRouteStatus { /// /// A maximum of 32 Gateways will be represented in this list. An empty list /// means the route has not been attached to any Gateway. - pub parents: Vec, + pub parents: Vec, } - /// RouteParentStatus describes the status of a route with respect to an /// associated Parent. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct UDPRouteStatusParents { +pub struct GrpcRouteStatusParents { /// Conditions describes the status of the route with respect to the Gateway. /// Note that the route's availability is also subject to the Gateway's own /// status conditions and listener status. @@ -385,11 +474,10 @@ pub struct UDPRouteStatusParents { /// There are a number of cases where the "Accepted" condition may not be set /// due to lack of controller visibility, that includes when: /// - /// * The Route refers to a non-existent parent. + /// * The Route refers to a nonexistent parent. /// * The Route is of a type that the controller does not support. - /// * The Route is in a namespace the controller does not have access to. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: Option>, + /// * The Route is in a namespace to which the controller does not have access. + pub conditions: Vec, /// ControllerName is a domain/path string that indicates the name of the /// controller that wrote this status. This corresponds with the /// controllerName field on GatewayClass. @@ -398,7 +486,7 @@ pub struct UDPRouteStatusParents { /// /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are /// valid Kubernetes names - /// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names). + /// ( /// /// Controllers MUST populate this field when writing status. Controllers should ensure that /// entries to status populated with their ControllerName are cleaned up when they are no @@ -408,119 +496,5 @@ pub struct UDPRouteStatusParents { /// ParentRef corresponds with a ParentRef in the spec that this /// RouteParentStatus struct describes the status of. #[serde(rename = "parentRef")] - pub parent_ref: UDPRouteStatusParentsParentRef, -} - -/// ParentRef corresponds with a ParentRef in the spec that this -/// RouteParentStatus struct describes the status of. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct UDPRouteStatusParentsParentRef { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. - /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// When the parent resource is a Service, this targets a specific port in the - /// Service spec. When both Port (experimental) and SectionName are specified, - /// the name and port of the selected port must match both specified values. - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, + pub parent_ref: ParentReference, } diff --git a/gateway-api-with-extensions/src/experimental/httproutes.rs b/gateway-api-with-extensions/src/experimental/httproutes.rs new file mode 100644 index 0000000..d8a98c8 --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/httproutes.rs @@ -0,0 +1,1452 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of HTTPRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "HTTPRoute", + plural = "httproutes" +)] +#[kube(namespaced)] +#[kube(status = "HttpRouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct HttpRouteSpec { + /// Hostnames defines a set of hostnames that should match against the HTTP Host + /// header to select a HTTPRoute used to process the request. Implementations + /// MUST ignore any port value specified in the HTTP Host header while + /// performing a match and (absent of any applicable header modification + /// configuration) MUST forward this header unmodified to the backend. + /// + /// Valid values for Hostnames are determined by RFC 1123 definition of a + /// hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label must appear by itself as the first label. + /// + /// If a hostname is specified by both the Listener and HTTPRoute, there + /// must be at least one intersecting hostname for the HTTPRoute to be + /// attached to the Listener. For example: + /// + /// * A Listener with `test.example.com` as the hostname matches HTTPRoutes + /// that have either not specified any hostnames, or have specified at + /// least one of `test.example.com` or `*.example.com`. + /// * A Listener with `*.example.com` as the hostname matches HTTPRoutes + /// that have either not specified any hostnames or have specified at least + /// one hostname that matches the Listener hostname. For example, + /// `*.example.com`, `test.example.com`, and `foo.test.example.com` would + /// all match. On the other hand, `example.com` and `test.example.net` would + /// not match. + /// + /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted + /// as a suffix match. That means that a match for `*.example.com` would match + /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. + /// + /// If both the Listener and HTTPRoute have specified hostnames, any + /// HTTPRoute hostnames that do not match the Listener hostname MUST be + /// ignored. For example, if a Listener specified `*.example.com`, and the + /// HTTPRoute specified `test.example.com` and `test.example.net`, + /// `test.example.net` must not be considered for a match. + /// + /// If both the Listener and HTTPRoute have specified hostnames, and none + /// match with the criteria above, then the HTTPRoute is not accepted. The + /// implementation must raise an 'Accepted' Condition with a status of + /// `False` in the corresponding RouteParentStatus. + /// + /// In the event that multiple HTTPRoutes specify intersecting hostnames (e.g. + /// overlapping wildcard matching and exact matching hostnames), precedence must + /// be given to rules from the HTTPRoute with the largest number of: + /// + /// * Characters in a matching non-wildcard hostname. + /// * Characters in a matching hostname. + /// + /// If ties exist across multiple Routes, the matching precedence rules for + /// HTTPRouteMatches takes over. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostnames: Option>, + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + /// + /// + /// ParentRefs from a Route to a Service in the same namespace are "producer" + /// routes, which apply default routing rules to inbound connections from + /// any namespace to the Service. + /// + /// ParentRefs from a Route to a Service in a different namespace are + /// "consumer" routes, and these routing rules are only applied to outbound + /// connections originating from the same namespace as the Route, for which + /// the intended destination of the connections are a Service targeted as a + /// ParentRef of the Route. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of HTTP matchers, filters and actions. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rules: Option>, + /// UseDefaultGateways indicates the default Gateway scope to use for this + /// Route. If unset (the default) or set to None, the Route will not be + /// attached to any default Gateway; if set, it will be attached to any + /// default Gateway supporting the named scope, subject to the usual rules + /// about which Routes a Gateway is allowed to claim. + /// + /// Think carefully before using this functionality! The set of default + /// Gateways supporting the requested scope can change over time without + /// any notice to the Route author, and in many situations it will not be + /// appropriate to request a default Gateway for a given Route -- for + /// example, a Route with specific security requirements should almost + /// certainly not use a default Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "useDefaultGateways" + )] + pub use_default_gateways: Option, +} +/// HTTPRouteRule defines semantics for matching an HTTP request based on +/// conditions (matches), processing it (filters), and forwarding the request to +/// an API object (backendRefs). +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRule { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. + /// + /// Failure behavior here depends on how many BackendRefs are specified and + /// how many are invalid. + /// + /// If *all* entries in BackendRefs are invalid, and there are also no filters + /// specified in this route rule, *all* traffic which matches this rule MUST + /// receive a 500 status code. + /// + /// See the HTTPBackendRef definition for the rules about what makes a single + /// HTTPBackendRef invalid. + /// + /// When a HTTPBackendRef is invalid, 500 status codes MUST be returned for + /// requests that would have otherwise been routed to an invalid backend. If + /// multiple backends are specified, and some are invalid, the proportion of + /// requests that would otherwise have been routed to an invalid backend + /// MUST receive a 500 status code. + /// + /// For example, if two backends are specified with equal weights, and one is + /// invalid, 50 percent of traffic must receive a 500. Implementations may + /// choose how that 50 percent is determined. + /// + /// When a HTTPBackendRef refers to a Service that has no ready endpoints, + /// implementations SHOULD return a 503 for requests to that backend instead. + /// If an implementation chooses to do this, all of the above rules for 500 responses + /// MUST also apply for responses that return a 503. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRefs" + )] + pub backend_refs: Option>, + /// Filters define the filters that are applied to requests that match + /// this rule. + /// + /// Wherever possible, implementations SHOULD implement filters in the order + /// they are specified. + /// + /// Implementations MAY choose to implement this ordering strictly, rejecting + /// any combination or order of filters that cannot be supported. If implementations + /// choose a strict interpretation of filter ordering, they MUST clearly document + /// that behavior. + /// + /// To reject an invalid combination or order of filters, implementations SHOULD + /// consider the Route Rules with this configuration invalid. If all Route Rules + /// in a Route are invalid, the entire Route would be considered invalid. If only + /// a portion of Route Rules are invalid, implementations MUST set the + /// "PartiallyInvalid" condition for the Route. + /// + /// Conformance-levels at this level are defined based on the type of filter: + /// + /// - ALL core filters MUST be supported by all implementations. + /// - Implementers are encouraged to support extended filters. + /// - Implementation-specific custom filters have no API guarantees across + /// implementations. + /// + /// Specifying the same filter multiple times is not supported unless explicitly + /// indicated in the filter. + /// + /// All filters are expected to be compatible with each other except for the + /// URLRewrite and RequestRedirect filters, which may not be combined. If an + /// implementation cannot support other combinations of filters, they must clearly + /// document that limitation. In cases where incompatible or unsupported + /// filters are specified and cause the `Accepted` condition to be set to status + /// `False`, implementations may use the `IncompatibleFilters` reason to specify + /// this configuration error. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Matches define conditions used for matching the rule against incoming + /// HTTP requests. Each match is independent, i.e. this rule will be matched + /// if **any** one of the matches is satisfied. + /// + /// For example, take the following matches configuration: + /// + /// ```text + /// matches: + /// - path: + /// value: "/foo" + /// headers: + /// - name: "version" + /// value: "v2" + /// - path: + /// value: "/v2/foo" + /// ``` + /// + /// For a request to match against this rule, a request must satisfy + /// EITHER of the two conditions: + /// + /// - path prefixed with `/foo` AND contains the header `version: v2` + /// - path prefix of `/v2/foo` + /// + /// See the documentation for HTTPRouteMatch on how to specify multiple + /// match conditions that should be ANDed together. + /// + /// If no matches are specified, the default is a prefix + /// path match on "/", which has the effect of matching every + /// HTTP request. + /// + /// Proxy or Load Balancer routing configuration generated from HTTPRoutes + /// MUST prioritize matches based on the following criteria, continuing on + /// ties. Across all rules specified on applicable Routes, precedence must be + /// given to the match having: + /// + /// * "Exact" path match. + /// * "Prefix" path match with largest number of characters. + /// * Method match. + /// * Largest number of header matches. + /// * Largest number of query param matches. + /// + /// Note: The precedence of RegularExpression path matches are implementation-specific. + /// + /// If ties still exist across multiple Routes, matching precedence MUST be + /// determined in order of the following criteria, continuing on ties: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// If ties still exist within an HTTPRoute, matching precedence MUST be granted + /// to the FIRST matching rule (in list order) with a match meeting the above + /// criteria. + /// + /// When no rules matching a request have been successfully attached to the + /// parent a request is coming from, a HTTP 404 status code MUST be returned. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub matches: Option>, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + /// Retry defines the configuration for when to retry an HTTP request. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub retry: Option, + /// SessionPersistence defines and configures session persistence + /// for the route rule. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sessionPersistence" + )] + pub session_persistence: Option, + /// Timeouts defines the timeouts that can be configured for an HTTP request. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub timeouts: Option, +} +/// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. +/// +/// Note that when a namespace different than the local namespace is specified, a +/// ReferenceGrant object is required in the referent namespace to allow that +/// namespace's owner to accept the reference. See the ReferenceGrant +/// documentation for details. +/// +/// +/// When the BackendRef points to a Kubernetes Service, implementations SHOULD +/// honor the appProtocol field if it is set for the target Service Port. +/// +/// Implementations supporting appProtocol SHOULD recognize the Kubernetes +/// Standard Application Protocols defined in KEP-3726. +/// +/// If a Service appProtocol isn't specified, an implementation MAY infer the +/// backend protocol through its own means. Implementations MAY infer the +/// protocol from the Route type referring to the backend Service. +/// +/// If a Route is not able to send traffic to the backend using the specified +/// protocol then the backend is considered invalid. Implementations MUST set the +/// "ResolvedRefs" condition to "False" with the "UnsupportedProtocol" reason. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HTTPBackendReference { + /// Filters defined at this level should be executed if and only if the + /// request is being forwarded to the backend defined here. + /// + /// Support: Implementation-specific (For broader support of filters, use the + /// Filters field in HTTPRouteRule.) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Group is the group of the referent. For example, "gateway.networking.k8s.io". + /// When unspecified or empty string, core API group is inferred. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. For example + /// "Service". + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations SHOULD NOT + /// support ExternalName Services. + /// + /// Support: Core (Services with a type other than ExternalName) + /// + /// Support: Implementation-specific (Services with type ExternalName) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent. + pub name: String, + /// Namespace is the namespace of the backend. When unspecified, the local + /// namespace is inferred. + /// + /// Note that when a namespace different than the local namespace is specified, + /// a ReferenceGrant object is required in the referent namespace to allow that + /// namespace's owner to accept the reference. See the ReferenceGrant + /// documentation for details. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + /// Port specifies the destination port number to use for this resource. + /// Port is required when the referent is a Kubernetes Service. In this + /// case, the port number is the service port number, not the target port. + /// For other resources, destination port might be derived from the referent + /// resource or this field. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + /// Weight specifies the proportion of requests forwarded to the referenced + /// backend. This is computed as weight/(sum of all weights in this + /// BackendRefs list). For non-zero values, there may be some epsilon from + /// the exact proportion defined here depending on the precision an + /// implementation supports. Weight is not a percentage and the sum of + /// weights does not need to equal 100. + /// + /// If only one backend is specified and it has a weight greater than 0, 100% + /// of the traffic is forwarded to that backend. If weight is set to 0, no + /// traffic should be forwarded for this entry. If unspecified, weight + /// defaults to 1. + /// + /// Support for this field varies based on the context where used. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} +/// HTTPRouteFilter defines processing steps that must be completed during the +/// request or response lifecycle. HTTPRouteFilters are meant as an extension +/// point to express processing that may be done in Gateway implementations. Some +/// examples include request or response modification, implementing +/// authentication strategies, rate-limiting, and traffic shaping. API +/// guarantee/conformance is defined based on the type of the filter. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteBackendFilter { + /// CORS defines a schema for a filter that responds to the + /// cross-origin request based on HTTP response header. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cors: Option, + /// ExtensionRef is an optional, implementation-specific extension to the + /// "filter" behavior. For example, resource "myroutefilter" in group + /// "networking.example.net"). ExtensionRef MUST NOT be used for core and + /// extended filters. + /// + /// This filter can be used multiple times within the same rule. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + /// ExternalAuth configures settings related to sending request details + /// to an external auth service. The external service MUST authenticate + /// the request, and MAY authorize the request as well. + /// + /// If there is any problem communicating with the external service, + /// this filter MUST fail closed. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "externalAuth" + )] + pub external_auth: Option, + /// RequestHeaderModifier defines a schema for a filter that modifies request + /// headers. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + /// RequestMirror defines a schema for a filter that mirrors requests. + /// Requests are sent to the specified destination, but responses from + /// that destination are ignored. + /// + /// This filter can be used multiple times within the same rule. Note that + /// not all implementations will be able to support mirroring to multiple + /// backends. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + /// RequestRedirect defines a schema for a filter that responds to the + /// request with an HTTP redirection. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestRedirect" + )] + pub request_redirect: Option, + /// ResponseHeaderModifier defines a schema for a filter that modifies response + /// headers. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + /// Type identifies the type of filter to apply. As with other API fields, + /// types are classified into three conformance levels: + /// + /// - Core: Filter types and their corresponding configuration defined by + /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All + /// implementations must support core filters. + /// + /// - Extended: Filter types and their corresponding configuration defined by + /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers + /// are encouraged to support extended filters. + /// + /// - Implementation-specific: Filters that are defined and supported by + /// specific vendors. + /// In the future, filters showing convergence in behavior across multiple + /// implementations will be considered for inclusion in extended or core + /// conformance levels. Filter-specific configuration for such filters + /// is specified using the ExtensionRef field. `Type` should be set to + /// "ExtensionRef" for custom filters. + /// + /// Implementers are encouraged to define custom implementation types to + /// extend the core API with implementation-specific behavior. + /// + /// If a reference to a custom filter type cannot be resolved, the filter + /// MUST NOT be skipped. Instead, requests that would have been processed by + /// that filter MUST receive a HTTP error response. + /// + /// Note that values may be added to this enum, implementations + /// must ensure that unknown values will not cause a crash. + /// + /// Unknown values here must result in the implementation setting the + /// Accepted Condition for the Route to `status: False`, with a + /// Reason of `UnsupportedValue`. + #[serde(rename = "type")] + pub r#type: HTTPFilterType, + /// URLRewrite defines a schema for a filter that modifies a request during forwarding. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "urlRewrite" + )] + pub url_rewrite: Option, +} +/// CORS defines a schema for a filter that responds to the +/// cross-origin request based on HTTP response header. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesBackendRefsFiltersCors { + /// AllowCredentials indicates whether the actual cross-origin request allows + /// to include credentials. + /// + /// When set to true, the gateway will include the `Access-Control-Allow-Credentials` + /// response header with value true (case-sensitive). + /// + /// When set to false or omitted the gateway will omit the header + /// `Access-Control-Allow-Credentials` entirely (this is the standard CORS + /// behavior). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowCredentials" + )] + pub allow_credentials: Option, + /// AllowHeaders indicates which HTTP request headers are supported for + /// accessing the requested resource. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Allow-Headers` + /// response header are separated by a comma (","). + /// + /// When the `AllowHeaders` field is configured with one or more headers, the + /// gateway must return the `Access-Control-Allow-Headers` response header + /// which value is present in the `AllowHeaders` field. + /// + /// If any header name in the `Access-Control-Request-Headers` request header + /// is not included in the list of header names specified by the response + /// header `Access-Control-Allow-Headers`, it will present an error on the + /// client side. + /// + /// If any header name in the `Access-Control-Allow-Headers` response header + /// does not recognize by the client, it will also occur an error on the + /// client side. + /// + /// A wildcard indicates that the requests with all HTTP headers are allowed. + /// If config contains the wildcard "*" in allowHeaders and the request is + /// not credentialed, the `Access-Control-Allow-Headers` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Headers from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Headers` response header. When + /// also the `AllowCredentials` field is true and `AllowHeaders` field + /// is specified with the `*` wildcard, the gateway must specify one or more + /// HTTP headers in the value of the `Access-Control-Allow-Headers` response + /// header. The value of the header `Access-Control-Allow-Headers` is same as + /// the `Access-Control-Request-Headers` header provided by the client. If + /// the header `Access-Control-Request-Headers` is not included in the + /// request, the gateway will omit the `Access-Control-Allow-Headers` + /// response header, instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowHeaders" + )] + pub allow_headers: Option>, + /// AllowMethods indicates which HTTP methods are supported for accessing the + /// requested resource. + /// + /// Valid values are any method defined by RFC9110, along with the special + /// value `*`, which represents all HTTP methods are allowed. + /// + /// Method names are case-sensitive, so these values are also case-sensitive. + /// (See + /// + /// Multiple method names in the value of the `Access-Control-Allow-Methods` + /// response header are separated by a comma (","). + /// + /// A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`. + /// (See The + /// CORS-safelisted methods are always allowed, regardless of whether they + /// are specified in the `AllowMethods` field. + /// + /// When the `AllowMethods` field is configured with one or more methods, the + /// gateway must return the `Access-Control-Allow-Methods` response header + /// which value is present in the `AllowMethods` field. + /// + /// If the HTTP method of the `Access-Control-Request-Method` request header + /// is not included in the list of methods specified by the response header + /// `Access-Control-Allow-Methods`, it will present an error on the client + /// side. + /// + /// If config contains the wildcard "*" in allowMethods and the request is + /// not credentialed, the `Access-Control-Allow-Methods` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Method from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Methods` response header. When + /// also the `AllowCredentials` field is true and `AllowMethods` field + /// specified with the `*` wildcard, the gateway must specify one HTTP method + /// in the value of the Access-Control-Allow-Methods response header. The + /// value of the header `Access-Control-Allow-Methods` is same as the + /// `Access-Control-Request-Method` header provided by the client. If the + /// header `Access-Control-Request-Method` is not included in the request, + /// the gateway will omit the `Access-Control-Allow-Methods` response header, + /// instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowMethods" + )] + pub allow_methods: Option>, + /// AllowOrigins indicates whether the response can be shared with requested + /// resource from the given `Origin`. + /// + /// The `Origin` consists of a scheme and a host, with an optional port, and + /// takes the form `://(:)`. + /// + /// Valid values for scheme are: `http` and `https`. + /// + /// Valid values for port are any integer between 1 and 65535 (the list of + /// available TCP/UDP ports). Note that, if not included, port `80` is + /// assumed for `http` scheme origins, and port `443` is assumed for `https` + /// origins. This may affect origin matching. + /// + /// The host part of the origin may contain the wildcard character `*`. These + /// wildcard characters behave as follows: + /// + /// * `*` is a greedy match to the _left_, including any number of + /// DNS labels to the left of its position. This also means that + /// `*` will include any number of period `.` characters to the + /// left of its position. + /// * A wildcard by itself matches all hosts. + /// + /// An origin value that includes _only_ the `*` character indicates requests + /// from all `Origin`s are allowed. + /// + /// When the `AllowOrigins` field is configured with multiple origins, it + /// means the server supports clients from multiple origins. If the request + /// `Origin` matches the configured allowed origins, the gateway must return + /// the given `Origin` and sets value of the header + /// `Access-Control-Allow-Origin` same as the `Origin` header provided by the + /// client. + /// + /// The status code of a successful response to a "preflight" request is + /// always an OK status (i.e., 204 or 200). + /// + /// If the request `Origin` does not match the configured allowed origins, + /// the gateway returns 204/200 response but doesn't set the relevant + /// cross-origin response headers. Alternatively, the gateway responds with + /// 403 status to the "preflight" request is denied, coupled with omitting + /// the CORS headers. The cross-origin request fails on the client side. + /// Therefore, the client doesn't attempt the actual cross-origin request. + /// + /// Conversely, if the request `Origin` matches one of the configured + /// allowed origins, the gateway sets the response header + /// `Access-Control-Allow-Origin` to the same value as the `Origin` + /// header provided by the client. + /// + /// When config has the wildcard ("*") in allowOrigins, and the request + /// is not credentialed (e.g., it is a preflight request), the + /// `Access-Control-Allow-Origin` response header either contains the + /// wildcard as well or the Origin from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Origin` response header. When + /// also the `AllowCredentials` field is true and `AllowOrigins` field + /// specified with the `*` wildcard, the gateway must return a single origin + /// in the value of the `Access-Control-Allow-Origin` response header, + /// instead of specifying the `*` wildcard. The value of the header + /// `Access-Control-Allow-Origin` is same as the `Origin` header provided by + /// the client. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowOrigins" + )] + pub allow_origins: Option>, + /// ExposeHeaders indicates which HTTP response headers can be exposed + /// to client-side scripts in response to a cross-origin request. + /// + /// A CORS-safelisted response header is an HTTP header in a CORS response + /// that it is considered safe to expose to the client scripts. + /// The CORS-safelisted response headers include the following headers: + /// `Cache-Control` + /// `Content-Language` + /// `Content-Length` + /// `Content-Type` + /// `Expires` + /// `Last-Modified` + /// `Pragma` + /// (See + /// The CORS-safelisted response headers are exposed to client by default. + /// + /// When an HTTP header name is specified using the `ExposeHeaders` field, + /// this additional header will be exposed as part of the response to the + /// client. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Expose-Headers` + /// response header are separated by a comma (","). + /// + /// A wildcard indicates that the responses with all HTTP headers are exposed + /// to clients. The `Access-Control-Expose-Headers` response header can only + /// use `*` wildcard as value when the request is not credentialed. + /// + /// When the `exposeHeaders` config field contains the "*" wildcard and + /// the request is credentialed, the gateway cannot use the `*` wildcard in + /// the `Access-Control-Expose-Headers` response header. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "exposeHeaders" + )] + pub expose_headers: Option>, + /// MaxAge indicates the duration (in seconds) for the client to cache the + /// results of a "preflight" request. + /// + /// The information provided by the `Access-Control-Allow-Methods` and + /// `Access-Control-Allow-Headers` response headers can be cached by the + /// client until the time specified by `Access-Control-Max-Age` elapses. + /// + /// The default value of `Access-Control-Max-Age` response header is 5 + /// (seconds). + /// + /// When the `MaxAge` field is unspecified, the gateway sets the response + /// header "Access-Control-Max-Age: 5" by default. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] + pub max_age: Option, +} +/// HTTPRouteFilter defines processing steps that must be completed during the +/// request or response lifecycle. HTTPRouteFilters are meant as an extension +/// point to express processing that may be done in Gateway implementations. Some +/// examples include request or response modification, implementing +/// authentication strategies, rate-limiting, and traffic shaping. API +/// guarantee/conformance is defined based on the type of the filter. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteFilter { + /// CORS defines a schema for a filter that responds to the + /// cross-origin request based on HTTP response header. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cors: Option, + /// ExtensionRef is an optional, implementation-specific extension to the + /// "filter" behavior. For example, resource "myroutefilter" in group + /// "networking.example.net"). ExtensionRef MUST NOT be used for core and + /// extended filters. + /// + /// This filter can be used multiple times within the same rule. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + /// ExternalAuth configures settings related to sending request details + /// to an external auth service. The external service MUST authenticate + /// the request, and MAY authorize the request as well. + /// + /// If there is any problem communicating with the external service, + /// this filter MUST fail closed. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "externalAuth" + )] + pub external_auth: Option, + /// RequestHeaderModifier defines a schema for a filter that modifies request + /// headers. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + /// RequestMirror defines a schema for a filter that mirrors requests. + /// Requests are sent to the specified destination, but responses from + /// that destination are ignored. + /// + /// This filter can be used multiple times within the same rule. Note that + /// not all implementations will be able to support mirroring to multiple + /// backends. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + /// RequestRedirect defines a schema for a filter that responds to the + /// request with an HTTP redirection. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestRedirect" + )] + pub request_redirect: Option, + /// ResponseHeaderModifier defines a schema for a filter that modifies response + /// headers. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + /// Type identifies the type of filter to apply. As with other API fields, + /// types are classified into three conformance levels: + /// + /// - Core: Filter types and their corresponding configuration defined by + /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All + /// implementations must support core filters. + /// + /// - Extended: Filter types and their corresponding configuration defined by + /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers + /// are encouraged to support extended filters. + /// + /// - Implementation-specific: Filters that are defined and supported by + /// specific vendors. + /// In the future, filters showing convergence in behavior across multiple + /// implementations will be considered for inclusion in extended or core + /// conformance levels. Filter-specific configuration for such filters + /// is specified using the ExtensionRef field. `Type` should be set to + /// "ExtensionRef" for custom filters. + /// + /// Implementers are encouraged to define custom implementation types to + /// extend the core API with implementation-specific behavior. + /// + /// If a reference to a custom filter type cannot be resolved, the filter + /// MUST NOT be skipped. Instead, requests that would have been processed by + /// that filter MUST receive a HTTP error response. + /// + /// Note that values may be added to this enum, implementations + /// must ensure that unknown values will not cause a crash. + /// + /// Unknown values here must result in the implementation setting the + /// Accepted Condition for the Route to `status: False`, with a + /// Reason of `UnsupportedValue`. + #[serde(rename = "type")] + pub r#type: HTTPFilterType, + /// URLRewrite defines a schema for a filter that modifies a request during forwarding. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "urlRewrite" + )] + pub url_rewrite: Option, +} +/// CORS defines a schema for a filter that responds to the +/// cross-origin request based on HTTP response header. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesFiltersCors { + /// AllowCredentials indicates whether the actual cross-origin request allows + /// to include credentials. + /// + /// When set to true, the gateway will include the `Access-Control-Allow-Credentials` + /// response header with value true (case-sensitive). + /// + /// When set to false or omitted the gateway will omit the header + /// `Access-Control-Allow-Credentials` entirely (this is the standard CORS + /// behavior). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowCredentials" + )] + pub allow_credentials: Option, + /// AllowHeaders indicates which HTTP request headers are supported for + /// accessing the requested resource. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Allow-Headers` + /// response header are separated by a comma (","). + /// + /// When the `AllowHeaders` field is configured with one or more headers, the + /// gateway must return the `Access-Control-Allow-Headers` response header + /// which value is present in the `AllowHeaders` field. + /// + /// If any header name in the `Access-Control-Request-Headers` request header + /// is not included in the list of header names specified by the response + /// header `Access-Control-Allow-Headers`, it will present an error on the + /// client side. + /// + /// If any header name in the `Access-Control-Allow-Headers` response header + /// does not recognize by the client, it will also occur an error on the + /// client side. + /// + /// A wildcard indicates that the requests with all HTTP headers are allowed. + /// If config contains the wildcard "*" in allowHeaders and the request is + /// not credentialed, the `Access-Control-Allow-Headers` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Headers from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Headers` response header. When + /// also the `AllowCredentials` field is true and `AllowHeaders` field + /// is specified with the `*` wildcard, the gateway must specify one or more + /// HTTP headers in the value of the `Access-Control-Allow-Headers` response + /// header. The value of the header `Access-Control-Allow-Headers` is same as + /// the `Access-Control-Request-Headers` header provided by the client. If + /// the header `Access-Control-Request-Headers` is not included in the + /// request, the gateway will omit the `Access-Control-Allow-Headers` + /// response header, instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowHeaders" + )] + pub allow_headers: Option>, + /// AllowMethods indicates which HTTP methods are supported for accessing the + /// requested resource. + /// + /// Valid values are any method defined by RFC9110, along with the special + /// value `*`, which represents all HTTP methods are allowed. + /// + /// Method names are case-sensitive, so these values are also case-sensitive. + /// (See + /// + /// Multiple method names in the value of the `Access-Control-Allow-Methods` + /// response header are separated by a comma (","). + /// + /// A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`. + /// (See The + /// CORS-safelisted methods are always allowed, regardless of whether they + /// are specified in the `AllowMethods` field. + /// + /// When the `AllowMethods` field is configured with one or more methods, the + /// gateway must return the `Access-Control-Allow-Methods` response header + /// which value is present in the `AllowMethods` field. + /// + /// If the HTTP method of the `Access-Control-Request-Method` request header + /// is not included in the list of methods specified by the response header + /// `Access-Control-Allow-Methods`, it will present an error on the client + /// side. + /// + /// If config contains the wildcard "*" in allowMethods and the request is + /// not credentialed, the `Access-Control-Allow-Methods` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Method from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Methods` response header. When + /// also the `AllowCredentials` field is true and `AllowMethods` field + /// specified with the `*` wildcard, the gateway must specify one HTTP method + /// in the value of the Access-Control-Allow-Methods response header. The + /// value of the header `Access-Control-Allow-Methods` is same as the + /// `Access-Control-Request-Method` header provided by the client. If the + /// header `Access-Control-Request-Method` is not included in the request, + /// the gateway will omit the `Access-Control-Allow-Methods` response header, + /// instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowMethods" + )] + pub allow_methods: Option>, + /// AllowOrigins indicates whether the response can be shared with requested + /// resource from the given `Origin`. + /// + /// The `Origin` consists of a scheme and a host, with an optional port, and + /// takes the form `://(:)`. + /// + /// Valid values for scheme are: `http` and `https`. + /// + /// Valid values for port are any integer between 1 and 65535 (the list of + /// available TCP/UDP ports). Note that, if not included, port `80` is + /// assumed for `http` scheme origins, and port `443` is assumed for `https` + /// origins. This may affect origin matching. + /// + /// The host part of the origin may contain the wildcard character `*`. These + /// wildcard characters behave as follows: + /// + /// * `*` is a greedy match to the _left_, including any number of + /// DNS labels to the left of its position. This also means that + /// `*` will include any number of period `.` characters to the + /// left of its position. + /// * A wildcard by itself matches all hosts. + /// + /// An origin value that includes _only_ the `*` character indicates requests + /// from all `Origin`s are allowed. + /// + /// When the `AllowOrigins` field is configured with multiple origins, it + /// means the server supports clients from multiple origins. If the request + /// `Origin` matches the configured allowed origins, the gateway must return + /// the given `Origin` and sets value of the header + /// `Access-Control-Allow-Origin` same as the `Origin` header provided by the + /// client. + /// + /// The status code of a successful response to a "preflight" request is + /// always an OK status (i.e., 204 or 200). + /// + /// If the request `Origin` does not match the configured allowed origins, + /// the gateway returns 204/200 response but doesn't set the relevant + /// cross-origin response headers. Alternatively, the gateway responds with + /// 403 status to the "preflight" request is denied, coupled with omitting + /// the CORS headers. The cross-origin request fails on the client side. + /// Therefore, the client doesn't attempt the actual cross-origin request. + /// + /// Conversely, if the request `Origin` matches one of the configured + /// allowed origins, the gateway sets the response header + /// `Access-Control-Allow-Origin` to the same value as the `Origin` + /// header provided by the client. + /// + /// When config has the wildcard ("*") in allowOrigins, and the request + /// is not credentialed (e.g., it is a preflight request), the + /// `Access-Control-Allow-Origin` response header either contains the + /// wildcard as well or the Origin from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Origin` response header. When + /// also the `AllowCredentials` field is true and `AllowOrigins` field + /// specified with the `*` wildcard, the gateway must return a single origin + /// in the value of the `Access-Control-Allow-Origin` response header, + /// instead of specifying the `*` wildcard. The value of the header + /// `Access-Control-Allow-Origin` is same as the `Origin` header provided by + /// the client. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowOrigins" + )] + pub allow_origins: Option>, + /// ExposeHeaders indicates which HTTP response headers can be exposed + /// to client-side scripts in response to a cross-origin request. + /// + /// A CORS-safelisted response header is an HTTP header in a CORS response + /// that it is considered safe to expose to the client scripts. + /// The CORS-safelisted response headers include the following headers: + /// `Cache-Control` + /// `Content-Language` + /// `Content-Length` + /// `Content-Type` + /// `Expires` + /// `Last-Modified` + /// `Pragma` + /// (See + /// The CORS-safelisted response headers are exposed to client by default. + /// + /// When an HTTP header name is specified using the `ExposeHeaders` field, + /// this additional header will be exposed as part of the response to the + /// client. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Expose-Headers` + /// response header are separated by a comma (","). + /// + /// A wildcard indicates that the responses with all HTTP headers are exposed + /// to clients. The `Access-Control-Expose-Headers` response header can only + /// use `*` wildcard as value when the request is not credentialed. + /// + /// When the `exposeHeaders` config field contains the "*" wildcard and + /// the request is credentialed, the gateway cannot use the `*` wildcard in + /// the `Access-Control-Expose-Headers` response header. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "exposeHeaders" + )] + pub expose_headers: Option>, + /// MaxAge indicates the duration (in seconds) for the client to cache the + /// results of a "preflight" request. + /// + /// The information provided by the `Access-Control-Allow-Methods` and + /// `Access-Control-Allow-Headers` response headers can be cached by the + /// client until the time specified by `Access-Control-Max-Age` elapses. + /// + /// The default value of `Access-Control-Max-Age` response header is 5 + /// (seconds). + /// + /// When the `MaxAge` field is unspecified, the gateway sets the response + /// header "Access-Control-Max-Age: 5" by default. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] + pub max_age: Option, +} +/// HTTPRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a HTTP request only if its path +/// starts with `/foo` AND it contains the `version: v1` header: +/// +/// ```text +/// match: +/// +/// path: +/// value: "/foo" +/// headers: +/// - name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RouteMatch { + /// Headers specifies HTTP request header matchers. Multiple match values are + /// ANDed together, meaning, a request must match all the specified headers + /// to select the route. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub headers: Option>, + /// Method specifies HTTP method matcher. + /// When specified, this route will be matched only if the request has the + /// specified method. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, + /// Path specifies a HTTP request path matcher. If this field is not + /// specified, a default prefix match on the "/" path is provided. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, + /// QueryParams specifies HTTP query parameter matchers. Multiple match + /// values are ANDed together, meaning, a request must match all the + /// specified query parameters to select the route. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "queryParams" + )] + pub query_params: Option>, +} +/// HTTPRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a HTTP request only if its path +/// starts with `/foo` AND it contains the `version: v1` header: +/// +/// ```text +/// match: +/// +/// path: +/// value: "/foo" +/// headers: +/// - name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HTTPMethodMatch { + #[serde(rename = "GET")] + Get, + #[serde(rename = "HEAD")] + Head, + #[serde(rename = "POST")] + Post, + #[serde(rename = "PUT")] + Put, + #[serde(rename = "DELETE")] + Delete, + #[serde(rename = "CONNECT")] + Connect, + #[serde(rename = "OPTIONS")] + Options, + #[serde(rename = "TRACE")] + Trace, + #[serde(rename = "PATCH")] + Patch, +} +/// Path specifies a HTTP request path matcher. If this field is not +/// specified, a default prefix match on the "/" path is provided. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct PathMatch { + /// Type specifies how to match against the path Value. + /// + /// Support: Core (Exact, PathPrefix) + /// + /// Support: Implementation-specific (RegularExpression) + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// Value of the HTTP path to match against. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, +} +/// Path specifies a HTTP request path matcher. If this field is not +/// specified, a default prefix match on the "/" path is provided. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HttpRouteRulesMatchesPathType { + Exact, + PathPrefix, + RegularExpression, +} +/// Retry defines the configuration for when to retry an HTTP request. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesRetry { + /// Attempts specifies the maximum number of times an individual request + /// from the gateway to a backend should be retried. + /// + /// If the maximum number of retries has been attempted without a successful + /// response from the backend, the Gateway MUST return an error. + /// + /// When this field is unspecified, the number of times to attempt to retry + /// a backend request is implementation-specific. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub attempts: Option, + /// Backoff specifies the minimum duration a Gateway should wait between + /// retry attempts and is represented in Gateway API Duration formatting. + /// + /// For example, setting the `rules[].retry.backoff` field to the value + /// `100ms` will cause a backend request to first be retried approximately + /// 100 milliseconds after timing out or receiving a response code configured + /// to be retriable. + /// + /// An implementation MAY use an exponential or alternative backoff strategy + /// for subsequent retry attempts, MAY cap the maximum backoff duration to + /// some amount greater than the specified minimum, and MAY add arbitrary + /// jitter to stagger requests, as long as unsuccessful backend requests are + /// not retried before the configured minimum duration. + /// + /// If a Request timeout (`rules[].timeouts.request`) is configured on the + /// route, the entire duration of the initial request and any retry attempts + /// MUST not exceed the Request timeout duration. If any retry attempts are + /// still in progress when the Request timeout duration has been reached, + /// these SHOULD be canceled if possible and the Gateway MUST immediately + /// return a timeout error. + /// + /// If a BackendRequest timeout (`rules[].timeouts.backendRequest`) is + /// configured on the route, any retry attempts which reach the configured + /// BackendRequest timeout duration without a response SHOULD be canceled if + /// possible and the Gateway should wait for at least the specified backoff + /// duration before attempting to retry the backend request again. + /// + /// If a BackendRequest timeout is _not_ configured on the route, retry + /// attempts MAY time out after an implementation default duration, or MAY + /// remain pending until a configured Request timeout or implementation + /// default duration for total request time is reached. + /// + /// When this field is unspecified, the time to wait between retry attempts + /// is implementation-specific. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub backoff: Option, + /// Codes defines the HTTP response status codes for which a backend request + /// should be retried. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub codes: Option>, +} +/// Timeouts defines the timeouts that can be configured for an HTTP request. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteTimeout { + /// BackendRequest specifies a timeout for an individual request from the gateway + /// to a backend. This covers the time from when the request first starts being + /// sent from the gateway to when the full response has been received from the backend. + /// + /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout + /// completely. Implementations that cannot completely disable the timeout MUST + /// instead interpret the zero duration as the longest possible value to which + /// the timeout can be set. + /// + /// An entire client HTTP transaction with a gateway, covered by the Request timeout, + /// may result in more than one call from the gateway to the destination backend, + /// for example, if automatic retries are supported. + /// + /// The value of BackendRequest must be a Gateway API Duration string as defined by + /// GEP-2257. When this field is unspecified, its behavior is implementation-specific; + /// when specified, the value of BackendRequest must be no more than the value of the + /// Request timeout (since the Request timeout encompasses the BackendRequest timeout). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRequest" + )] + pub backend_request: Option, + /// Request specifies the maximum duration for a gateway to respond to an HTTP request. + /// If the gateway has not been able to respond before this deadline is met, the gateway + /// MUST return a timeout error. + /// + /// For example, setting the `rules.timeouts.request` field to the value `10s` in an + /// `HTTPRoute` will cause a timeout if a client request is taking longer than 10 seconds + /// to complete. + /// + /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout + /// completely. Implementations that cannot completely disable the timeout MUST + /// instead interpret the zero duration as the longest possible value to which + /// the timeout can be set. + /// + /// This timeout is intended to cover as close to the whole request-response transaction + /// as possible although an implementation MAY choose to start the timeout after the entire + /// request stream has been received instead of immediately after the transaction is + /// initiated by the client. + /// + /// The value of Request is a Gateway API Duration string as defined by GEP-2257. When this + /// field is unspecified, request timeout behavior is implementation-specific. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub request: Option, +} +/// Status defines the current state of HTTPRoute. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteStatus { + /// Parents is a list of parent resources (usually Gateways) that are + /// associated with the route, and the status of the route with respect to + /// each parent. When this route attaches to a parent, the controller that + /// manages the parent must add an entry to this list when the controller + /// first sees the route and should update the entry as appropriate when the + /// route or gateway is modified. + /// + /// Note that parent references that cannot be resolved by an implementation + /// of this API will not be added to this list. Implementations of this API + /// can only populate Route status for the Gateways/parent resources they are + /// responsible for. + /// + /// A maximum of 32 Gateways will be represented in this list. An empty list + /// means the route has not been attached to any Gateway. + pub parents: Vec, +} +/// RouteParentStatus describes the status of a route with respect to an +/// associated Parent. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteStatusParents { + /// Conditions describes the status of the route with respect to the Gateway. + /// Note that the route's availability is also subject to the Gateway's own + /// status conditions and listener status. + /// + /// If the Route's ParentRef specifies an existing Gateway that supports + /// Routes of this kind AND that Gateway's controller has sufficient access, + /// then that Gateway's controller MUST set the "Accepted" condition on the + /// Route, to indicate whether the route has been accepted or rejected by the + /// Gateway, and why. + /// + /// A Route MUST be considered "Accepted" if at least one of the Route's + /// rules is implemented by the Gateway. + /// + /// There are a number of cases where the "Accepted" condition may not be set + /// due to lack of controller visibility, that includes when: + /// + /// * The Route refers to a nonexistent parent. + /// * The Route is of a type that the controller does not support. + /// * The Route is in a namespace to which the controller does not have access. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, + /// ParentRef corresponds with a ParentRef in the spec that this + /// RouteParentStatus struct describes the status of. + #[serde(rename = "parentRef")] + pub parent_ref: ParentReference, +} diff --git a/gateway-api-with-extensions/src/experimental/inferencemodelrewrites.rs b/gateway-api-with-extensions/src/experimental/inferencemodelrewrites.rs new file mode 100644 index 0000000..ea7e9d5 --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/inferencemodelrewrites.rs @@ -0,0 +1,85 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// InferenceModelRewriteSpec defines the desired state of InferenceModelRewrite. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "inference.networking.x-k8s.io", + version = "v1alpha2", + kind = "InferenceModelRewrite", + plural = "inferencemodelrewrites" +)] +#[kube(namespaced)] +#[kube(status = "InferenceStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct InferenceModelRewriteSpec { + /// PoolRef is a reference to the inference pool. + #[serde(rename = "poolRef")] + pub pool_ref: InferencePoolRef, + pub rules: Vec, +} +/// InferenceModelRewriteRule defines the match criteria and corresponding action. +/// For details on how precedence is determined across multiple rules and +/// InferenceModelRewrite resources, see the "Precedence and Conflict Resolution" +/// section in InferenceModelRewriteSpec. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceModelRewriteRules { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub matches: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub targets: Option>, +} +/// Match defines the criteria for matching the LLM requests. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceModelRewriteRulesMatches { + /// Model specifies the criteria for matching the 'model' field + /// within the JSON request body. + pub model: InferenceModelRewriteRulesMatchesModel, +} +/// Model specifies the criteria for matching the 'model' field +/// within the JSON request body. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceModelRewriteRulesMatchesModel { + /// Type specifies the kind of string matching to use. + /// Supported value is "Exact". Defaults to "Exact". + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// Value is the model name string to match against. + pub value: String, +} +/// Model specifies the criteria for matching the 'model' field +/// within the JSON request body. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum InferenceModelRewriteRulesMatchesModelType { + Exact, +} +/// TargetModel defines a weighted model destination for traffic distribution. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceModelRewriteRulesTargets { + #[serde(rename = "modelRewrite")] + pub model_rewrite: String, + /// (The following comment is copied from the original targetModel) + /// Weight is used to determine the proportion of traffic that should be + /// sent to this model when multiple target models are specified. + /// + /// Weight defines the proportion of requests forwarded to the specified + /// model. This is computed as weight/(sum of all weights in this + /// TargetModels list). For non-zero values, there may be some epsilon from + /// the exact proportion defined here depending on the precision an + /// implementation supports. Weight is not a percentage and the sum of + /// weights does not need to equal 100. + /// + /// If a weight is set for any targetModel, it must be set for all targetModels. + /// Conversely weights are optional, so long as ALL targetModels do not specify a weight. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} diff --git a/gateway-api-with-extensions/src/experimental/inferenceobjectives.rs b/gateway-api-with-extensions/src/experimental/inferenceobjectives.rs new file mode 100644 index 0000000..676439b --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/inferenceobjectives.rs @@ -0,0 +1,50 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// InferenceObjectiveSpec represents the desired state of a specific model use case. This resource is +/// managed by the "Inference Workload Owner" persona. +/// +/// The Inference Workload Owner persona is someone that trains, verifies, and +/// leverages a large language model from a model frontend, drives the lifecycle +/// and rollout of new versions of those models, and defines the specific +/// performance and latency goals for the model. These workloads are +/// expected to operate within an InferencePool sharing compute capacity with other +/// InferenceObjectives, defined by the Inference Platform Admin. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "inference.networking.x-k8s.io", + version = "v1alpha2", + kind = "InferenceObjective", + plural = "inferenceobjectives" +)] +#[kube(namespaced)] +#[kube(status = "InferenceStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct InferenceObjectiveSpec { + /// PoolRef is a reference to the inference pool, the pool must exist in the same namespace. + #[serde(rename = "poolRef")] + pub pool_ref: InferencePoolRef, + /// Priority defines how important it is to serve the request compared to other requests in the same pool. + /// Priority is an integer value that defines the priority of the request. + /// The higher the value, the more critical the request is; negative values _are_ allowed. + /// No default value is set for this field, allowing for future additions of new fields that may 'one of' with this field. + /// However, implementations that consume this field (such as the Endpoint Picker) will treat an unset value as '0'. + /// Priority is used in flow control, primarily in the event of resource scarcity(requests need to be queued). + /// All requests will be queued, and flow control will _always_ allow requests of higher priority to be served first. + /// Fairness is only enforced and tracked between requests of the same priority. + /// + /// Example: requests with Priority 10 will always be served before + /// requests with Priority of 0 (the value used if Priority is unset or no InfereneceObjective is specified). + /// Similarly requests with a Priority of -10 will always be served after requests with Priority of 0. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub priority: Option, +} diff --git a/gateway-api-with-extensions/src/experimental/inferencepoolimports.rs b/gateway-api-with-extensions/src/experimental/inferencepoolimports.rs new file mode 100644 index 0000000..83d2459 --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/inferencepoolimports.rs @@ -0,0 +1,97 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Status defines the observed state of the InferencePoolImport. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolImportStatus { + /// Controllers is a list of controllers that are responsible for managing the InferencePoolImport. + pub controllers: Vec, +} +/// ImportController defines a controller that is responsible for managing the InferencePoolImport. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolImportStatusControllers { + /// Conditions track the state of the InferencePoolImport. + /// + /// Known condition types are: + /// + /// * "Accepted" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// ExportingClusters is a list of clusters that exported the InferencePool(s) that back the + /// InferencePoolImport. Required when the controller is responsible for CRUD'ing the InferencePoolImport + /// from the exported InferencePool(s). + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "exportingClusters" + )] + pub exporting_clusters: Option>, + /// Name is a domain/path string that indicates the name of the controller that manages the + /// InferencePoolImport. Name corresponds to the GatewayClass controllerName field when the + /// controller will manage parents of type "Gateway". Otherwise, the name is implementation-specific. + /// + /// Example: "example.net/import-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are valid Kubernetes + /// names ( + /// + /// A controller MUST populate this field when writing status and ensure that entries to status + /// populated with their controller name are removed when they are no longer necessary. + pub name: String, + /// Parents is a list of parent resources, typically Gateways, that are associated with the + /// InferencePoolImport, and the status of the InferencePoolImport with respect to each parent. + /// + /// Ancestor would be a more accurate name, but Parent is consistent with InferencePool terminology. + /// + /// Required when the controller manages the InferencePoolImport as an HTTPRoute backendRef. The controller + /// must add an entry for each parent it manages and remove the parent entry when the controller no longer + /// considers the InferencePoolImport to be associated with that parent. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub parents: Option>, +} +/// ParentStatus defines the observed state of InferencePool from a Parent, i.e. Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolImportStatusControllersParents { + /// Conditions is a list of status conditions that provide information about the observed + /// state of the InferencePool. This field is required to be set by the controller that + /// manages the InferencePool. + /// + /// Supported condition types are: + /// + /// * "Accepted" + /// * "ResolvedRefs" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// ControllerName is a domain/path string that indicates the name of the controller that + /// wrote this status. This corresponds with the GatewayClass controllerName field when the + /// parentRef references a Gateway kind. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are valid Kubernetes names: + /// + /// + /// + /// Controllers MAY populate this field when writing status. When populating this field, controllers + /// should ensure that entries to status populated with their ControllerName are cleaned up when they + /// are no longer necessary. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "controllerName" + )] + pub controller_name: Option, + /// ParentRef is used to identify the parent resource that this status + /// is associated with. It is used to match the InferencePool with the parent + /// resource, such as a Gateway. + #[serde(rename = "parentRef")] + pub parent_ref: Reference, +} diff --git a/gateway-api-with-extensions/src/experimental/inferencepools.rs b/gateway-api-with-extensions/src/experimental/inferencepools.rs new file mode 100644 index 0000000..adf9a64 --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/inferencepools.rs @@ -0,0 +1,116 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// InferencePoolSpec defines the desired state of InferencePool +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "inference.networking.x-k8s.io", + version = "v1alpha2", + kind = "InferencePool", + plural = "inferencepools" +)] +#[kube(namespaced)] +#[kube(status = "InferencePoolStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct InferencePoolSpec { + /// Extension configures an endpoint picker as an extension service. + #[serde(rename = "extensionRef")] + pub extension_ref: InferencePoolExtensionRef, + /// Selector defines a map of labels to watch model server Pods + /// that should be included in the InferencePool. + /// In some cases, implementations may translate this field to a Service selector, so this matches the simple + /// map used for Service selectors instead of the full Kubernetes LabelSelector type. + /// If specified, it will be applied to match the model server pods in the same namespace as the InferencePool. + /// Cross namesoace selector is not supported. + pub selector: BTreeMap, + /// TargetPortNumber defines the port number to access the selected model server Pods. + /// The number must be in the range 1 to 65535. + #[serde(rename = "targetPortNumber")] + pub target_port_number: i32, +} +/// Extension configures an endpoint picker as an extension service. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolExtensionRef { + /// Configures how the gateway handles the case when the extension is not responsive. + /// Defaults to failClose. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "failureMode" + )] + pub failure_mode: Option, + /// Group is the group of the referent. + /// The default value is "", representing the Core API group. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations MUST NOT + /// support ExternalName Services. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent. + pub name: String, + /// The port number on the service running the extension. When unspecified, + /// implementations SHOULD infer a default value of 9002 when the Kind is + /// Service. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "portNumber" + )] + pub port_number: Option, +} +/// Extension configures an endpoint picker as an extension service. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum InferencePoolExtensionRefFailureMode { + FailOpen, + FailClose, +} +/// Status defines the observed state of InferencePool. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolStatus { + /// Parents is a list of parent resources (usually Gateways) that are + /// associated with the InferencePool, and the status of the InferencePool with respect to + /// each parent. + /// + /// A maximum of 32 Gateways will be represented in this list. When the list contains + /// `kind: Status, name: default`, it indicates that the InferencePool is not + /// associated with any Gateway and a controller must perform the following: + /// + /// - Remove the parent when setting the "Accepted" condition. + /// - Add the parent when the controller will no longer manage the InferencePool + /// and no other parents exist. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub parent: Option>, +} +/// PoolStatus defines the observed state of InferencePool from a Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolStatusParent { + /// Conditions track the state of the InferencePool. + /// + /// Known condition types are: + /// + /// * "Accepted" + /// * "ResolvedRefs" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// GatewayRef indicates the gateway that observed state of InferencePool. + #[serde(rename = "parentRef")] + pub parent_ref: Reference, +} diff --git a/gateway-api-with-extensions/src/experimental/listenersets.rs b/gateway-api-with-extensions/src/experimental/listenersets.rs new file mode 100644 index 0000000..4dfbec8 --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/listenersets.rs @@ -0,0 +1,121 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of ListenerSet. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "ListenerSet", + plural = "listenersets" +)] +#[kube(namespaced)] +#[kube(status = "ListenerSetStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct ListenerSetSpec { + /// Listeners associated with this ListenerSet. Listeners define + /// logical endpoints that are bound on this referenced parent Gateway's addresses. + /// + /// Listeners in a `Gateway` and their attached `ListenerSets` are concatenated + /// as a list when programming the underlying infrastructure. Each listener + /// name does not need to be unique across the Gateway and ListenerSets. + /// See ListenerEntry.Name for more details. + /// + /// Implementations MUST treat the parent Gateway as having the merged + /// list of all listeners from itself and attached ListenerSets using + /// the following precedence: + /// + /// 1. "parent" Gateway + /// 2. ListenerSet ordered by creation time (oldest first) + /// 3. ListenerSet ordered alphabetically by "{namespace}/{name}". + /// + /// An implementation MAY reject listeners by setting the ListenerEntryStatus + /// `Accepted` condition to False with the Reason `TooManyListeners` + /// + /// If a listener has a conflict, this will be reported in the + /// Status.ListenerEntryStatus setting the `Conflicted` condition to True. + /// + /// Implementations SHOULD be cautious about what information from the + /// parent or siblings are reported to avoid accidentally leaking + /// sensitive information that the child would not otherwise have access + /// to. This can include contents of secrets etc. + pub listeners: Vec, + /// ParentRef references the Gateway that the listeners are attached to. + #[serde(rename = "parentRef")] + pub parent_ref: Reference, +} +/// Status defines the current state of ListenerSet. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetStatus { + /// Conditions describe the current conditions of the ListenerSet. + /// + /// Implementations MUST express ListenerSet conditions using the + /// `ListenerSetConditionType` and `ListenerSetConditionReason` + /// constants so that operators and tools can converge on a common + /// vocabulary to describe ListenerSet state. + /// + /// Known condition types are: + /// + /// * "Accepted" + /// * "Programmed" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// Listeners provide status for each unique listener port defined in the Spec. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub listeners: Option>, +} +/// ListenerStatus is the status associated with a Listener. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetStatusListeners { + /// AttachedRoutes represents the total number of Routes that have been + /// successfully attached to this Listener. + /// + /// Successful attachment of a Route to a Listener is based solely on the + /// combination of the AllowedRoutes field on the corresponding Listener + /// and the Route's ParentRefs field. A Route is successfully attached to + /// a Listener when it is selected by the Listener's AllowedRoutes field + /// AND the Route has a valid ParentRef selecting the whole Gateway + /// resource or a specific Listener as a parent resource (more detail on + /// attachment semantics can be found in the documentation on the various + /// Route kinds ParentRefs fields). Listener status does not impact + /// successful attachment, i.e. the AttachedRoutes field count MUST be set + /// for Listeners, even if the Accepted condition of an individual Listener is set + /// to "False". The AttachedRoutes number represents the number of Routes with + /// the Accepted condition set to "True" that have been attached to this Listener. + /// Routes with any other value for the Accepted condition MUST NOT be included + /// in this count. + /// + /// Uses for this field include troubleshooting Route attachment and + /// measuring blast radius/impact of changes to a Listener. + #[serde(rename = "attachedRoutes")] + pub attached_routes: i32, + /// Conditions describe the current condition of this listener. + pub conditions: Vec, + /// Name is the name of the Listener that this status corresponds to. + pub name: String, + /// SupportedKinds is the list indicating the Kinds supported by this + /// listener. This MUST represent the kinds supported by an implementation for + /// that Listener configuration. + /// + /// If kinds are specified in Spec that are not supported, they MUST NOT + /// appear in this list and an implementation MUST set the "ResolvedRefs" + /// condition to "False" with the "InvalidRouteKinds" reason. If both valid + /// and invalid Route kinds are specified, the implementation MUST + /// reference the valid Route kinds that have been specified. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "supportedKinds" + )] + pub supported_kinds: Option>, +} diff --git a/gateway-api-with-extensions/src/experimental/mod.rs b/gateway-api-with-extensions/src/experimental/mod.rs new file mode 100644 index 0000000..2e6a7ca --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/mod.rs @@ -0,0 +1,18 @@ +// WARNING: generated file - manual changes will be overriden +pub mod backendtlspolicies; +pub mod common; +pub mod constants; +pub mod enum_defaults; +pub mod gatewayclasses; +pub mod gateways; +pub mod grpcroutes; +pub mod httproutes; +pub mod inferencemodelrewrites; +pub mod inferenceobjectives; +pub mod inferencepoolimports; +pub mod inferencepools; +pub mod listenersets; +pub mod referencegrants; +pub mod tcproutes; +pub mod tlsroutes; +pub mod udproutes; diff --git a/gateway-api/src/apis/standard/referencegrants.rs b/gateway-api-with-extensions/src/experimental/referencegrants.rs similarity index 92% rename from gateway-api/src/apis/standard/referencegrants.rs rename to gateway-api-with-extensions/src/experimental/referencegrants.rs index a383a35..6eb6981 100644 --- a/gateway-api/src/apis/standard/referencegrants.rs +++ b/gateway-api-with-extensions/src/experimental/referencegrants.rs @@ -1,20 +1,17 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 +// WARNING: generated file - manual changes will be overriden #[allow(unused_imports)] mod prelude { - pub use kube::CustomResource; + pub use kube_derive::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } use self::prelude::*; - /// Spec defines the desired state of ReferenceGrant. #[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] #[kube( group = "gateway.networking.k8s.io", - version = "v1beta1", + version = "v1", kind = "ReferenceGrant", plural = "referencegrants" )] @@ -37,7 +34,6 @@ pub struct ReferenceGrantSpec { /// Support: Core pub to: Vec, } - /// ReferenceGrantFrom describes trusted namespaces and kinds. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct ReferenceGrantFrom { @@ -67,7 +63,6 @@ pub struct ReferenceGrantFrom { /// Support: Core pub namespace: String, } - /// ReferenceGrantTo describes what Kinds are allowed as targets of the /// references. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] diff --git a/gateway-api-with-extensions/src/experimental/tcproutes.rs b/gateway-api-with-extensions/src/experimental/tcproutes.rs new file mode 100644 index 0000000..29652be --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/tcproutes.rs @@ -0,0 +1,200 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of TCPRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1alpha2", + kind = "TCPRoute", + plural = "tcproutes" +)] +#[kube(namespaced)] +#[kube(status = "TcpRouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct TcpRouteSpec { + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + /// + /// + /// ParentRefs from a Route to a Service in the same namespace are "producer" + /// routes, which apply default routing rules to inbound connections from + /// any namespace to the Service. + /// + /// ParentRefs from a Route to a Service in a different namespace are + /// "consumer" routes, and these routing rules are only applied to outbound + /// connections originating from the same namespace as the Route, for which + /// the intended destination of the connections are a Service targeted as a + /// ParentRef of the Route. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of TCP matchers and actions. + pub rules: Vec, + /// UseDefaultGateways indicates the default Gateway scope to use for this + /// Route. If unset (the default) or set to None, the Route will not be + /// attached to any default Gateway; if set, it will be attached to any + /// default Gateway supporting the named scope, subject to the usual rules + /// about which Routes a Gateway is allowed to claim. + /// + /// Think carefully before using this functionality! The set of default + /// Gateways supporting the requested scope can change over time without + /// any notice to the Route author, and in many situations it will not be + /// appropriate to request a default Gateway for a given Route -- for + /// example, a Route with specific security requirements should almost + /// certainly not use a default Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "useDefaultGateways" + )] + pub use_default_gateways: Option, +} +/// TCPRouteRule is the configuration for a given rule. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TcpRouteRules { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. If unspecified or invalid (refers to a nonexistent resource or a + /// Service with no endpoints), the underlying implementation MUST actively + /// reject connection attempts to this backend. Connection rejections must + /// respect weight; if an invalid backend is requested to have 80% of + /// connections, then 80% of connections must be rejected instead. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Extended + #[serde(rename = "backendRefs")] + pub backend_refs: Vec, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} +/// Status defines the current state of TCPRoute. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TcpRouteStatus { + /// Parents is a list of parent resources (usually Gateways) that are + /// associated with the route, and the status of the route with respect to + /// each parent. When this route attaches to a parent, the controller that + /// manages the parent must add an entry to this list when the controller + /// first sees the route and should update the entry as appropriate when the + /// route or gateway is modified. + /// + /// Note that parent references that cannot be resolved by an implementation + /// of this API will not be added to this list. Implementations of this API + /// can only populate Route status for the Gateways/parent resources they are + /// responsible for. + /// + /// A maximum of 32 Gateways will be represented in this list. An empty list + /// means the route has not been attached to any Gateway. + pub parents: Vec, +} +/// RouteParentStatus describes the status of a route with respect to an +/// associated Parent. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TcpRouteStatusParents { + /// Conditions describes the status of the route with respect to the Gateway. + /// Note that the route's availability is also subject to the Gateway's own + /// status conditions and listener status. + /// + /// If the Route's ParentRef specifies an existing Gateway that supports + /// Routes of this kind AND that Gateway's controller has sufficient access, + /// then that Gateway's controller MUST set the "Accepted" condition on the + /// Route, to indicate whether the route has been accepted or rejected by the + /// Gateway, and why. + /// + /// A Route MUST be considered "Accepted" if at least one of the Route's + /// rules is implemented by the Gateway. + /// + /// There are a number of cases where the "Accepted" condition may not be set + /// due to lack of controller visibility, that includes when: + /// + /// * The Route refers to a nonexistent parent. + /// * The Route is of a type that the controller does not support. + /// * The Route is in a namespace to which the controller does not have access. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, + /// ParentRef corresponds with a ParentRef in the spec that this + /// RouteParentStatus struct describes the status of. + #[serde(rename = "parentRef")] + pub parent_ref: ParentReference, +} diff --git a/gateway-api-with-extensions/src/experimental/tlsroutes.rs b/gateway-api-with-extensions/src/experimental/tlsroutes.rs new file mode 100644 index 0000000..d9dc1af --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/tlsroutes.rs @@ -0,0 +1,208 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of TLSRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "TLSRoute", + plural = "tlsroutes" +)] +#[kube(namespaced)] +#[kube(status = "TlsRouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct TlsRouteSpec { + /// Hostnames defines a set of SNI hostnames that should match against the + /// SNI attribute of TLS ClientHello message in TLS handshake. This matches + /// the RFC 1123 definition of a hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed in SNI hostnames per RFC 6066. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label must appear by itself as the first label. + pub hostnames: Vec, + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + /// + /// + /// ParentRefs from a Route to a Service in the same namespace are "producer" + /// routes, which apply default routing rules to inbound connections from + /// any namespace to the Service. + /// + /// ParentRefs from a Route to a Service in a different namespace are + /// "consumer" routes, and these routing rules are only applied to outbound + /// connections originating from the same namespace as the Route, for which + /// the intended destination of the connections are a Service targeted as a + /// ParentRef of the Route. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of actions. + pub rules: Vec, + /// UseDefaultGateways indicates the default Gateway scope to use for this + /// Route. If unset (the default) or set to None, the Route will not be + /// attached to any default Gateway; if set, it will be attached to any + /// default Gateway supporting the named scope, subject to the usual rules + /// about which Routes a Gateway is allowed to claim. + /// + /// Think carefully before using this functionality! The set of default + /// Gateways supporting the requested scope can change over time without + /// any notice to the Route author, and in many situations it will not be + /// appropriate to request a default Gateway for a given Route -- for + /// example, a Route with specific security requirements should almost + /// certainly not use a default Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "useDefaultGateways" + )] + pub use_default_gateways: Option, +} +/// TLSRouteRule is the configuration for a given rule. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TlsRouteRules { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. If unspecified or invalid (refers to a nonexistent resource or + /// a Service with no endpoints), the rule performs no forwarding; if no + /// filters are specified that would result in a response being sent, the + /// underlying implementation must actively reject request attempts to this + /// backend, by rejecting the connection. Request rejections must respect + /// weight; if an invalid backend is requested to have 80% of requests, then + /// 80% of requests must be rejected instead. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Extended + #[serde(rename = "backendRefs")] + pub backend_refs: Vec, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} +/// Status defines the current state of TLSRoute. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TlsRouteStatus { + /// Parents is a list of parent resources (usually Gateways) that are + /// associated with the route, and the status of the route with respect to + /// each parent. When this route attaches to a parent, the controller that + /// manages the parent must add an entry to this list when the controller + /// first sees the route and should update the entry as appropriate when the + /// route or gateway is modified. + /// + /// Note that parent references that cannot be resolved by an implementation + /// of this API will not be added to this list. Implementations of this API + /// can only populate Route status for the Gateways/parent resources they are + /// responsible for. + /// + /// A maximum of 32 Gateways will be represented in this list. An empty list + /// means the route has not been attached to any Gateway. + pub parents: Vec, +} +/// RouteParentStatus describes the status of a route with respect to an +/// associated Parent. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TlsRouteStatusParents { + /// Conditions describes the status of the route with respect to the Gateway. + /// Note that the route's availability is also subject to the Gateway's own + /// status conditions and listener status. + /// + /// If the Route's ParentRef specifies an existing Gateway that supports + /// Routes of this kind AND that Gateway's controller has sufficient access, + /// then that Gateway's controller MUST set the "Accepted" condition on the + /// Route, to indicate whether the route has been accepted or rejected by the + /// Gateway, and why. + /// + /// A Route MUST be considered "Accepted" if at least one of the Route's + /// rules is implemented by the Gateway. + /// + /// There are a number of cases where the "Accepted" condition may not be set + /// due to lack of controller visibility, that includes when: + /// + /// * The Route refers to a nonexistent parent. + /// * The Route is of a type that the controller does not support. + /// * The Route is in a namespace to which the controller does not have access. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, + /// ParentRef corresponds with a ParentRef in the spec that this + /// RouteParentStatus struct describes the status of. + #[serde(rename = "parentRef")] + pub parent_ref: ParentReference, +} diff --git a/gateway-api-with-extensions/src/experimental/udproutes.rs b/gateway-api-with-extensions/src/experimental/udproutes.rs new file mode 100644 index 0000000..0d0c996 --- /dev/null +++ b/gateway-api-with-extensions/src/experimental/udproutes.rs @@ -0,0 +1,200 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of UDPRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1alpha2", + kind = "UDPRoute", + plural = "udproutes" +)] +#[kube(namespaced)] +#[kube(status = "UdpRouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct UdpRouteSpec { + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + /// + /// + /// ParentRefs from a Route to a Service in the same namespace are "producer" + /// routes, which apply default routing rules to inbound connections from + /// any namespace to the Service. + /// + /// ParentRefs from a Route to a Service in a different namespace are + /// "consumer" routes, and these routing rules are only applied to outbound + /// connections originating from the same namespace as the Route, for which + /// the intended destination of the connections are a Service targeted as a + /// ParentRef of the Route. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of UDP matchers and actions. + pub rules: Vec, + /// UseDefaultGateways indicates the default Gateway scope to use for this + /// Route. If unset (the default) or set to None, the Route will not be + /// attached to any default Gateway; if set, it will be attached to any + /// default Gateway supporting the named scope, subject to the usual rules + /// about which Routes a Gateway is allowed to claim. + /// + /// Think carefully before using this functionality! The set of default + /// Gateways supporting the requested scope can change over time without + /// any notice to the Route author, and in many situations it will not be + /// appropriate to request a default Gateway for a given Route -- for + /// example, a Route with specific security requirements should almost + /// certainly not use a default Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "useDefaultGateways" + )] + pub use_default_gateways: Option, +} +/// UDPRouteRule is the configuration for a given rule. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct UdpRouteRules { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. If unspecified or invalid (refers to a nonexistent resource or a + /// Service with no endpoints), the underlying implementation MUST actively + /// reject connection attempts to this backend. Packet drops must + /// respect weight; if an invalid backend is requested to have 80% of + /// the packets, then 80% of packets must be dropped instead. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Extended + #[serde(rename = "backendRefs")] + pub backend_refs: Vec, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} +/// Status defines the current state of UDPRoute. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct UdpRouteStatus { + /// Parents is a list of parent resources (usually Gateways) that are + /// associated with the route, and the status of the route with respect to + /// each parent. When this route attaches to a parent, the controller that + /// manages the parent must add an entry to this list when the controller + /// first sees the route and should update the entry as appropriate when the + /// route or gateway is modified. + /// + /// Note that parent references that cannot be resolved by an implementation + /// of this API will not be added to this list. Implementations of this API + /// can only populate Route status for the Gateways/parent resources they are + /// responsible for. + /// + /// A maximum of 32 Gateways will be represented in this list. An empty list + /// means the route has not been attached to any Gateway. + pub parents: Vec, +} +/// RouteParentStatus describes the status of a route with respect to an +/// associated Parent. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct UdpRouteStatusParents { + /// Conditions describes the status of the route with respect to the Gateway. + /// Note that the route's availability is also subject to the Gateway's own + /// status conditions and listener status. + /// + /// If the Route's ParentRef specifies an existing Gateway that supports + /// Routes of this kind AND that Gateway's controller has sufficient access, + /// then that Gateway's controller MUST set the "Accepted" condition on the + /// Route, to indicate whether the route has been accepted or rejected by the + /// Gateway, and why. + /// + /// A Route MUST be considered "Accepted" if at least one of the Route's + /// rules is implemented by the Gateway. + /// + /// There are a number of cases where the "Accepted" condition may not be set + /// due to lack of controller visibility, that includes when: + /// + /// * The Route refers to a nonexistent parent. + /// * The Route is of a type that the controller does not support. + /// * The Route is in a namespace to which the controller does not have access. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, + /// ParentRef corresponds with a ParentRef in the spec that this + /// RouteParentStatus struct describes the status of. + #[serde(rename = "parentRef")] + pub parent_ref: ParentReference, +} diff --git a/gateway-api-with-extensions/src/lib.rs b/gateway-api-with-extensions/src/lib.rs new file mode 100644 index 0000000..43696e7 --- /dev/null +++ b/gateway-api-with-extensions/src/lib.rs @@ -0,0 +1,527 @@ +pub mod duration; +pub use duration::Duration; + +cfg_if::cfg_if! { + if #[cfg(feature = "experimental")] { + mod experimental; + pub use experimental::*; + } else { + mod standard; + pub use standard::*; + } +} + +#[cfg(test)] +mod tests { + use std::process::Command; + + use anyhow::{Error, Ok}; + use hyper_util::client::legacy::Client as HTTPClient; + use hyper_util::rt::TokioExecutor; + use k8s_openapi::apimachinery::pkg::apis::meta::v1::{Condition, Time}; + use k8s_openapi::jiff::Timestamp; + use kube::Client as KubeClient; + use kube::api::{Patch, PatchParams, PostParams}; + use kube::config::{KubeConfigOptions, Kubeconfig}; + use kube::core::ObjectMeta; + use kube::{Api, Config, CustomResourceExt, client::ConfigExt}; + use serde_json::json; + use tower::BoxError; + use tower::ServiceBuilder; + use uuid::Uuid; + + use crate::common::{ParentReference, ParentRouteStatus, RouteStatus}; + use crate::{ + common::GatewayStatusListeners, + constants::{ + GatewayConditionReason, GatewayConditionType, ListenerConditionReason, + ListenerConditionType, RouteConditionReason, RouteConditionType, + }, + gatewayclasses::{GatewayClass, GatewayClassSpec}, + gateways::{Gateway, GatewayListeners, GatewaySpec, GatewayStatus, GatewayStatusAddresses}, + grpcroutes::GrpcRouteSpec, + httproutes::HttpRouteSpec, + referencegrants::{ReferenceGrantFrom, ReferenceGrantSpec, ReferenceGrantTo}, + }; + + const DEFAULT_GATEWAY_API_VERSION: &str = "v1.5.0"; + + // ------------------------------------------------------------------------- + // Tests + // ------------------------------------------------------------------------- + + #[ignore] + #[tokio::test] + async fn test_deploy_resources() -> Result<(), Error> { + let (client, cluster) = get_client(false).await?; + let info = client.apiserver_version().await?; + + println!( + "kind cluster {} is running, server version: {}", + cluster.name, info.git_version + ); + + test_resource_deployment(client).await?; + + println!("cleaning up kind cluster {}", cluster.name); + + Ok(()) + } + + #[ignore] + #[tokio::test] + async fn test_deploy_resources_upstream_crds() -> Result<(), Error> { + let (client, cluster) = get_client(true).await?; + let info = client.apiserver_version().await?; + + println!( + "kind cluster {} is running, server version: {}", + cluster.name, info.git_version + ); + + test_resource_deployment(client).await?; + + println!("cleaning up kind cluster {}", cluster.name); + + Ok(()) + } + + // ------------------------------------------------------------------------- + // Test Resources + // ------------------------------------------------------------------------- + + async fn test_resource_deployment(client: kube::Client) -> Result<(), Error> { + let mut gwc = GatewayClass { + metadata: ObjectMeta::default(), + spec: GatewayClassSpec { + controller_name: "example.com/gateway-controller".to_string(), + description: None, + parameters_ref: None, + }, + status: None, + }; + gwc.metadata.name = Some("test-gateway-class".to_string()); + gwc = Api::all(client.clone()) + .create(&PostParams::default(), &gwc) + .await?; + + assert!(gwc.metadata.name.is_some()); + assert!(gwc.metadata.uid.is_some()); + + let mut gw = Gateway { + metadata: ObjectMeta::default(), + spec: GatewaySpec { + gateway_class_name: gwc + .metadata + .name + .ok_or(Error::msg("could not find GatewayClass name"))?, + listeners: vec![GatewayListeners { + name: "http".to_string(), + port: 80, + protocol: "HTTP".to_string(), + hostname: None, + allowed_routes: None, + tls: None, + }], + addresses: None, + infrastructure: None, + allowed_listeners: None, + tls: None, + }, + status: None, + }; + gw.metadata.name = Some("test-gateway".to_string()); + gw = Api::default_namespaced(client.clone()) + .create(&PostParams::default(), &gw) + .await?; + + assert!(gw.metadata.name.is_some()); + assert!(gw.metadata.uid.is_some()); + + let gw_status = GatewayStatus { + addresses: Some(vec![GatewayStatusAddresses { + r#type: Some("IPAddress".to_string()), + value: "10.0.0.1".to_string(), + }]), + listeners: Some(vec![GatewayStatusListeners { + name: "http".into(), + attached_routes: 0, + supported_kinds: None, + conditions: vec![Condition { + last_transition_time: Time(Timestamp::now()), + message: "testing gateway".to_string(), + observed_generation: Some(1), + reason: ListenerConditionReason::Programmed.to_string(), + status: "True".to_string(), + type_: ListenerConditionType::Programmed.to_string(), + }], + }]), + conditions: Some(vec![Condition { + last_transition_time: Time(Timestamp::now()), + message: "testing gateway".to_string(), + observed_generation: Some(1), + reason: GatewayConditionReason::Programmed.to_string(), + status: "True".to_string(), + type_: GatewayConditionType::Programmed.to_string(), + }]), + attached_listener_sets: None, + }; + + gw = Api::default_namespaced(client.clone()) + .patch_status( + gw.metadata.name.clone().unwrap().as_str(), + &PatchParams::default(), + &Patch::Merge(json!({ + "status": Some(gw_status) + })), + ) + .await?; + + assert!(gw.status.is_some()); + assert!(gw.status.clone().unwrap().addresses.is_some()); + assert!(gw.status.clone().unwrap().listeners.is_some()); + assert!(gw.status.clone().unwrap().conditions.is_some()); + + let mut http_route = crate::httproutes::HTTPRoute { + metadata: ObjectMeta::default(), + spec: HttpRouteSpec { + hostnames: Some(vec!["example.com".to_string()]), + parent_refs: Some(vec![ParentReference { + group: Some("gateway.networking.k8s.io".to_string()), + kind: Some("Gateway".to_string()), + namespace: Some("default".to_string()), + name: gw.metadata.name.clone().unwrap(), + section_name: None, + port: None, + }]), + rules: Some(vec![]), + }, + status: None, + }; + http_route.metadata.name = Some("test-http-route".to_string()); + http_route = Api::default_namespaced(client.clone()) + .create(&PostParams::default(), &http_route) + .await?; + + assert!(http_route.metadata.name.is_some()); + assert!(http_route.metadata.uid.is_some()); + assert!(http_route.spec.hostnames.is_some()); + assert!(http_route.spec.parent_refs.is_some()); + + let http_route_status = RouteStatus { + parents: vec![ParentRouteStatus { + parent_ref: ParentReference { + group: Some("gateway.networking.k8s.io".to_string()), + kind: Some("Gateway".to_string()), + namespace: Some("default".to_string()), + name: gw.metadata.name.clone().unwrap(), + section_name: None, + port: None, + }, + controller_name: "example.com/gateway-controller".to_string(), + conditions: vec![Condition { + last_transition_time: Time(Timestamp::now()), + message: "testing http route".to_string(), + observed_generation: Some(1), + reason: RouteConditionReason::Accepted.to_string(), + status: "True".to_string(), + type_: RouteConditionType::Accepted.to_string(), + }], + }], + }; + + http_route = Api::default_namespaced(client.clone()) + .patch_status( + http_route.metadata.name.clone().unwrap().as_str(), + &PatchParams::default(), + &Patch::Merge(json!({ + "status": Some(http_route_status) + })), + ) + .await?; + + assert!(http_route.status.is_some()); + assert!(!http_route.status.clone().unwrap().parents.is_empty()); + + let mut grpc_route = crate::grpcroutes::GRPCRoute { + metadata: ObjectMeta::default(), + spec: GrpcRouteSpec { + hostnames: Some(vec!["grpc.example.com".to_string()]), + parent_refs: Some(vec![ParentReference { + group: Some("gateway.networking.k8s.io".to_string()), + kind: Some("Gateway".to_string()), + namespace: Some("default".to_string()), + name: gw.metadata.name.clone().unwrap(), + section_name: None, + port: None, + }]), + rules: Some(vec![]), + }, + status: None, + }; + grpc_route.metadata.name = Some("test-grpc-route".to_string()); + grpc_route = Api::default_namespaced(client.clone()) + .create(&PostParams::default(), &grpc_route) + .await?; + + assert!(grpc_route.metadata.name.is_some()); + assert!(grpc_route.metadata.uid.is_some()); + assert!(grpc_route.spec.hostnames.is_some()); + assert!(grpc_route.spec.parent_refs.is_some()); + + let grpc_route_status = RouteStatus { + parents: vec![ParentRouteStatus { + parent_ref: ParentReference { + group: Some("gateway.networking.k8s.io".to_string()), + kind: Some("Gateway".to_string()), + namespace: Some("default".to_string()), + name: gw.metadata.name.clone().unwrap(), + section_name: None, + port: None, + }, + controller_name: "example.com/gateway-controller".to_string(), + conditions: vec![Condition { + last_transition_time: Time(Timestamp::now()), + message: "testing grpc route".to_string(), + observed_generation: Some(1), + reason: RouteConditionReason::Accepted.to_string(), + status: "True".to_string(), + type_: RouteConditionType::Accepted.to_string(), + }], + }], + }; + + grpc_route = Api::default_namespaced(client.clone()) + .patch_status( + grpc_route.metadata.name.clone().unwrap().as_str(), + &PatchParams::default(), + &Patch::Merge(json!({ + "status": Some(grpc_route_status) + })), + ) + .await?; + + assert!(grpc_route.status.is_some()); + assert!(!grpc_route.status.clone().unwrap().parents.is_empty()); + + let mut ref_grant = crate::referencegrants::ReferenceGrant { + metadata: ObjectMeta::default(), + spec: ReferenceGrantSpec { + from: vec![ReferenceGrantFrom { + group: "gateway.networking.k8s.io".to_string(), + kind: "HTTPRoute".to_string(), + namespace: "default".to_string(), + }], + to: vec![ReferenceGrantTo { + group: "".to_string(), + kind: "Service".to_string(), + name: Some("backend-service".to_string()), + }], + }, + }; + ref_grant.metadata.name = Some("test-reference-grant".to_string()); + ref_grant = Api::default_namespaced(client.clone()) + .create(&PostParams::default(), &ref_grant) + .await?; + + assert!(ref_grant.metadata.name.is_some()); + assert!(ref_grant.metadata.uid.is_some()); + assert!(!ref_grant.spec.from.is_empty()); + assert_eq!(ref_grant.spec.from[0].group, "gateway.networking.k8s.io"); + assert_eq!(ref_grant.spec.from[0].kind, "HTTPRoute"); + assert_eq!(ref_grant.spec.from[0].namespace, "default"); + assert!(!ref_grant.spec.to.is_empty()); + assert_eq!(ref_grant.spec.to[0].group, ""); + assert_eq!(ref_grant.spec.to[0].kind, "Service"); + assert_eq!( + ref_grant.spec.to[0].name, + Some("backend-service".to_string()) + ); + + Ok(()) + } + + // ------------------------------------------------------------------------- + // Test Utilities + // ------------------------------------------------------------------------- + + struct Cluster { + name: String, + } + + impl Drop for Cluster { + fn drop(&mut self) { + if let Err(err) = delete_kind_cluster(&self.name) { + panic!("failed to cleanup kind cluster {}: {}", self.name, err) + } + } + } + + async fn get_client(upstream: bool) -> Result<(kube::Client, Cluster), Error> { + let cluster = create_kind_cluster()?; + let kubeconfig_yaml = get_kind_kubeconfig(&cluster.name)?; + let kubeconfig = Kubeconfig::from_yaml(&kubeconfig_yaml)?; + let config = + Config::from_custom_kubeconfig(kubeconfig, &KubeConfigOptions::default()).await?; + + let https = config.rustls_https_connector()?; + let http_client = HTTPClient::builder(TokioExecutor::new()).build(https); + let service = ServiceBuilder::new() + .layer(config.base_uri_layer()) + .option_layer(config.auth_layer()?) + .map_err(BoxError::from) + .service(http_client); + + let client = KubeClient::new(service, config.default_namespace); + + if upstream { + deploy_crds_upstream(&cluster.name).await?; + } else { + deploy_crds(client.clone()).await?; + } + + Ok((client, cluster)) + } + + async fn deploy_crds_upstream(cluster_name: &str) -> Result<(), Error> { + let version = std::env::var("GATEWAY_API_VERSION") + .unwrap_or_else(|_| DEFAULT_GATEWAY_API_VERSION.to_string()); + + let semver_pattern = regex::Regex::new(r"^v?\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$") + .map_err(|e| Error::msg(format!("Failed to compile regex: {}", e)))?; + if !semver_pattern.is_match(&version) { + return Err(Error::msg(format!( + "GATEWAY_API_VERSION '{}' is not a valid semver version", + version + ))); + } + + let kubeconfig_yaml = get_kind_kubeconfig(cluster_name)?; + let temp_dir = std::env::temp_dir(); + let kubeconfig_path = temp_dir.join(format!("kubeconfig-{}", cluster_name)); + std::fs::write(&kubeconfig_path, kubeconfig_yaml)?; + + let url = format!( + "https://github.com/kubernetes-sigs/gateway-api/releases/download/{}/standard-install.yaml", + version + ); + + let output = Command::new("kubectl") + .arg("--kubeconfig") + .arg(&kubeconfig_path) + .arg("apply") + .arg("-f") + .arg(&url) + .output()?; + + if !output.status.success() { + return Err(Error::msg(format!( + "Failed to apply CRDs: {}", + String::from_utf8_lossy(&output.stderr) + ))); + } + + Ok(()) + } + + async fn deploy_crds(client: kube::Client) -> Result<(), Error> { + let mut gwc_crd = GatewayClass::crd(); + gwc_crd.metadata.annotations = Some(std::collections::BTreeMap::from([( + "api-approved.kubernetes.io".to_string(), + "https://github.com/kubernetes/enhancements/pull/1111".to_string(), + )])); + + Api::all(client.clone()) + .create(&PostParams::default(), &gwc_crd) + .await?; + + let mut gw_crd = Gateway::crd(); + gw_crd.metadata.annotations = Some(std::collections::BTreeMap::from([( + "api-approved.kubernetes.io".to_string(), + "https://github.com/kubernetes/enhancements/pull/1111".to_string(), + )])); + + Api::all(client.clone()) + .create(&PostParams::default(), &gw_crd) + .await?; + + let mut http_route_crd = crate::httproutes::HTTPRoute::crd(); + http_route_crd.metadata.annotations = Some(std::collections::BTreeMap::from([( + "api-approved.kubernetes.io".to_string(), + "https://github.com/kubernetes/enhancements/pull/1111".to_string(), + )])); + + Api::all(client.clone()) + .create(&PostParams::default(), &http_route_crd) + .await?; + + let mut grpc_route_crd = crate::grpcroutes::GRPCRoute::crd(); + grpc_route_crd.metadata.annotations = Some(std::collections::BTreeMap::from([( + "api-approved.kubernetes.io".to_string(), + "https://github.com/kubernetes/enhancements/pull/1111".to_string(), + )])); + + Api::all(client.clone()) + .create(&PostParams::default(), &grpc_route_crd) + .await?; + + let mut ref_grant_crd = crate::referencegrants::ReferenceGrant::crd(); + ref_grant_crd.metadata.annotations = Some(std::collections::BTreeMap::from([( + "api-approved.kubernetes.io".to_string(), + "https://github.com/kubernetes/enhancements/pull/1111".to_string(), + )])); + + Api::all(client.clone()) + .create(&PostParams::default(), &ref_grant_crd) + .await?; + + Ok(()) + } + + fn create_kind_cluster() -> Result { + let cluster_name = Uuid::new_v4().to_string(); + + let output = Command::new("kind") + .arg("create") + .arg("cluster") + .arg("--name") + .arg(&cluster_name) + .output()?; + + if !output.status.success() { + return Err(Error::msg(String::from_utf8(output.stderr)?)); + } + + Ok(Cluster { name: cluster_name }) + } + + fn delete_kind_cluster(cluster_name: &str) -> Result<(), Error> { + let output = Command::new("kind") + .arg("delete") + .arg("cluster") + .arg("--name") + .arg(cluster_name) + .output()?; + + if !output.status.success() { + return Err(Error::msg(String::from_utf8(output.stderr)?)); + } + + Ok(()) + } + + fn get_kind_kubeconfig(cluster_name: &str) -> Result { + let output = Command::new("kind") + .arg("get") + .arg("kubeconfig") + .arg("--name") + .arg(cluster_name) + .output()?; + + if !output.status.success() { + return Err(Error::msg(String::from_utf8(output.stderr)?)); + } + + Ok(String::from_utf8(output.stdout)?) + } +} diff --git a/gateway-api-with-extensions/src/mod.rs b/gateway-api-with-extensions/src/mod.rs new file mode 100644 index 0000000..7651e9f --- /dev/null +++ b/gateway-api-with-extensions/src/mod.rs @@ -0,0 +1,2 @@ +pub mod experimental; +pub mod standard; diff --git a/gateway-api-with-extensions/src/standard/backendtlspolicies.rs b/gateway-api-with-extensions/src/standard/backendtlspolicies.rs new file mode 100644 index 0000000..10c7b7e --- /dev/null +++ b/gateway-api-with-extensions/src/standard/backendtlspolicies.rs @@ -0,0 +1,354 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of BackendTLSPolicy. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "BackendTLSPolicy", + plural = "backendtlspolicies" +)] +#[kube(namespaced)] +#[kube(status = "BackendTlsPolicyStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct BackendTlsPolicySpec { + /// Options are a list of key/value pairs to enable extended TLS + /// configuration for each implementation. For example, configuring the + /// minimum TLS version or supported cipher suites. + /// + /// A set of common keys MAY be defined by the API in the future. To avoid + /// any ambiguity, implementation-specific definitions MUST use + /// domain-prefixed names, such as `example.com/my-custom-option`. + /// Un-prefixed names are reserved for key names defined by Gateway API. + /// + /// Support: Implementation-specific + #[serde(default, skip_serializing_if = "Option::is_none")] + pub options: Option>, + /// TargetRefs identifies an API object to apply the policy to. + /// Note that this config applies to the entire referenced resource + /// by default, but this default may change in the future to provide + /// a more granular application of the policy. + /// + /// TargetRefs must be _distinct_. This means either that: + /// + /// * They select different targets. If this is the case, then targetRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, and `name` must + /// be unique across all targetRef entries in the BackendTLSPolicy. + /// * They select different sectionNames in the same target. + /// + /// When more than one BackendTLSPolicy selects the same target and + /// sectionName, implementations MUST determine precedence using the + /// following criteria, continuing on ties: + /// + /// * The older policy by creation timestamp takes precedence. For + /// example, a policy with a creation timestamp of "2021-07-15 + /// 01:02:03" MUST be given precedence over a policy with a + /// creation timestamp of "2021-07-15 01:02:04". + /// * The policy appearing first in alphabetical order by {namespace}/{name}. + /// For example, a policy named `foo/bar` is given precedence over a + /// policy named `foo/baz`. + /// + /// For any BackendTLSPolicy that does not take precedence, the + /// implementation MUST ensure the `Accepted` Condition is set to + /// `status: False`, with Reason `Conflicted`. + /// + /// Implementations SHOULD NOT support more than one targetRef at this + /// time. Although the API technically allows for this, the current guidance + /// for conflict resolution and status handling is lacking. Until that can be + /// clarified in a future release, the safest approach is to support a single + /// targetRef. + /// + /// Support Levels: + /// + /// * Extended: Kubernetes Service referenced by HTTPRoute backendRefs. + /// + /// * Implementation-Specific: Services not connected via HTTPRoute, and any + /// other kind of backend. Implementations MAY use BackendTLSPolicy for: + /// - Services not referenced by any Route (e.g., infrastructure services) + /// - Gateway feature backends (e.g., ExternalAuth, rate-limiting services) + /// - Service mesh workload-to-service communication + /// - Other resource types beyond Service + /// + /// Implementations SHOULD aim to ensure that BackendTLSPolicy behavior is consistent, + /// even outside of the extended HTTPRoute -(backendRef) -> Service path. + /// They SHOULD clearly document how BackendTLSPolicy is interpreted in these + /// scenarios, including: + /// - Which resources beyond Service are supported + /// - How the policy is discovered and applied + /// - Any implementation-specific semantics or restrictions + /// + /// Note that this config applies to the entire referenced resource + /// by default, but this default may change in the future to provide + /// a more granular application of the policy. + #[serde(rename = "targetRefs")] + pub target_refs: Vec, + /// Validation contains backend TLS validation configuration. + pub validation: BackendTlsPolicyValidation, +} +/// LocalPolicyTargetReferenceWithSectionName identifies an API object to apply a +/// direct policy to. This should be used as part of Policy resources that can +/// target single resources. For more information on how this policy attachment +/// mode works, and a sample Policy resource, refer to the policy attachment +/// documentation for Gateway API. +/// +/// Note: This should only be used for direct policy attachment when references +/// to SectionName are actually needed. In all other cases, +/// LocalPolicyTargetReference should be used. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyTargetRefs { + /// Group is the group of the target resource. + pub group: String, + /// Kind is kind of the target resource. + pub kind: String, + /// Name is the name of the target resource. + pub name: String, + /// SectionName is the name of a section within the target resource. When + /// unspecified, this targetRef targets the entire resource. In the following + /// resources, SectionName is interpreted as the following: + /// + /// * Gateway: Listener name + /// * HTTPRoute: HTTPRouteRule name + /// * Service: Port name + /// + /// If a SectionName is specified, but does not exist on the targeted object, + /// the Policy must fail to attach, and the policy implementation should record + /// a `ResolvedRefs` or similar Condition in the Policy's status. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sectionName" + )] + pub section_name: Option, +} +/// Validation contains backend TLS validation configuration. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyValidation { + /// CACertificateRefs contains one or more references to Kubernetes objects that + /// contain a PEM-encoded TLS CA certificate bundle, which is used to + /// validate a TLS handshake between the Gateway and backend Pod. + /// + /// If CACertificateRefs is empty or unspecified, then WellKnownCACertificates must be + /// specified. Only one of CACertificateRefs or WellKnownCACertificates may be specified, + /// not both. If CACertificateRefs is empty or unspecified, the configuration for + /// WellKnownCACertificates MUST be honored instead if supported by the implementation. + /// + /// A CACertificateRef is invalid if: + /// + /// * It refers to a resource that cannot be resolved (e.g., the referenced resource + /// does not exist) or is misconfigured (e.g., a ConfigMap does not contain a key + /// named `ca.crt`). In this case, the Reason must be set to `InvalidCACertificateRef` + /// and the Message of the Condition must indicate which reference is invalid and why. + /// + /// * It refers to an unknown or unsupported kind of resource. In this case, the Reason + /// must be set to `InvalidKind` and the Message of the Condition must explain which + /// kind of resource is unknown or unsupported. + /// + /// * It refers to a resource in another namespace. This may change in future + /// spec updates. + /// + /// Implementations MAY choose to perform further validation of the certificate + /// content (e.g., checking expiry or enforcing specific formats). In such cases, + /// an implementation-specific Reason and Message must be set for the invalid reference. + /// + /// In all cases, the implementation MUST ensure the `ResolvedRefs` Condition on + /// the BackendTLSPolicy is set to `status: False`, with a Reason and Message + /// that indicate the cause of the error. Connections using an invalid + /// CACertificateRef MUST fail, and the client MUST receive an HTTP 5xx error + /// response. If ALL CACertificateRefs are invalid, the implementation MUST also + /// ensure the `Accepted` Condition on the BackendTLSPolicy is set to + /// `status: False`, with a Reason `NoValidCACertificate`. + /// + /// A single CACertificateRef to a Kubernetes ConfigMap kind has "Core" support. + /// Implementations MAY choose to support attaching multiple certificates to + /// a backend, but this behavior is implementation-specific. + /// + /// Support: Core - An optional single reference to a Kubernetes ConfigMap, + /// with the CA certificate in a key named `ca.crt`. + /// + /// Support: Implementation-specific - More than one reference, other kinds + /// of resources, or a single reference that includes multiple certificates. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "caCertificateRefs" + )] + pub ca_certificate_refs: Option>, + /// Hostname is used for two purposes in the connection between Gateways and + /// backends: + /// + /// 1. Hostname MUST be used as the SNI to connect to the backend (RFC 6066). + /// 2. Hostname MUST be used for authentication and MUST match the certificate + /// served by the matching backend, unless SubjectAltNames is specified. + /// 3. If SubjectAltNames are specified, Hostname can be used for certificate selection + /// but MUST NOT be used for authentication. If you want to use the value + /// of the Hostname field for authentication, you MUST add it to the SubjectAltNames list. + /// + /// Support: Core + pub hostname: String, + /// SubjectAltNames contains one or more Subject Alternative Names. + /// When specified the certificate served from the backend MUST + /// have at least one Subject Alternate Name matching one of the specified SubjectAltNames. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "subjectAltNames" + )] + pub subject_alt_names: Option>, + /// WellKnownCACertificates specifies whether a well-known set of CA certificates + /// may be used in the TLS handshake between the gateway and backend pod. + /// + /// If WellKnownCACertificates is unspecified or empty (""), then CACertificateRefs + /// must be specified with at least one entry for a valid configuration. Only one of + /// CACertificateRefs or WellKnownCACertificates may be specified, not both. + /// If an implementation does not support the WellKnownCACertificates field, or + /// the supplied value is not recognized, the implementation MUST ensure the + /// `Accepted` Condition on the BackendTLSPolicy is set to `status: False`, with + /// a Reason `Invalid`. + /// + /// Valid values include: + /// * "System" - indicates that well-known system CA certificates should be used. + /// + /// Implementations MAY define their own sets of CA certificates. Such definitions + /// MUST use an implementation-specific, prefixed name, such as + /// `mycompany.com/my-custom-ca-certificates`. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "wellKnownCACertificates" + )] + pub well_known_ca_certificates: Option, +} +/// SubjectAltName represents Subject Alternative Name. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyValidationSubjectAltNames { + /// Hostname contains Subject Alternative Name specified in DNS name format. + /// Required when Type is set to Hostname, ignored otherwise. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + /// Type determines the format of the Subject Alternative Name. Always required. + /// + /// Support: Core + #[serde(rename = "type")] + pub r#type: BackendTlsPolicyValidationSubjectAltNamesType, + /// URI contains Subject Alternative Name specified in a full URI format. + /// It MUST include both a scheme (e.g., "http" or "ftp") and a scheme-specific-part. + /// Common values include SPIFFE IDs like "spiffe://mycluster.example.com/ns/myns/sa/svc1sa". + /// Required when Type is set to URI, ignored otherwise. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub uri: Option, +} +/// SubjectAltName represents Subject Alternative Name. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum BackendTlsPolicyValidationSubjectAltNamesType { + Hostname, + #[serde(rename = "URI")] + Uri, +} +/// Status defines the current state of BackendTLSPolicy. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyStatus { + /// Ancestors is a list of ancestor resources (usually Gateways) that are + /// associated with the policy, and the status of the policy with respect to + /// each ancestor. When this policy attaches to a parent, the controller that + /// manages the parent and the ancestors MUST add an entry to this list when + /// the controller first sees the policy and SHOULD update the entry as + /// appropriate when the relevant ancestor is modified. + /// + /// Note that choosing the relevant ancestor is left to the Policy designers; + /// an important part of Policy design is designing the right object level at + /// which to namespace this status. + /// + /// Note also that implementations MUST ONLY populate ancestor status for + /// the Ancestor resources they are responsible for. Implementations MUST + /// use the ControllerName field to uniquely identify the entries in this list + /// that they are responsible for. + /// + /// Note that to achieve this, the list of PolicyAncestorStatus structs + /// MUST be treated as a map with a composite key, made up of the AncestorRef + /// and ControllerName fields combined. + /// + /// A maximum of 16 ancestors will be represented in this list. An empty list + /// means the Policy is not relevant for any ancestors. + /// + /// If this slice is full, implementations MUST NOT add further entries. + /// Instead they MUST consider the policy unimplementable and signal that + /// on any related resources such as the ancestor that would be referenced + /// here. For example, if this list was full on BackendTLSPolicy, no + /// additional Gateways would be able to reference the Service targeted by + /// the BackendTLSPolicy. + pub ancestors: Vec, +} +/// PolicyAncestorStatus describes the status of a route with respect to an +/// associated Ancestor. +/// +/// Ancestors refer to objects that are either the Target of a policy or above it +/// in terms of object hierarchy. For example, if a policy targets a Service, the +/// Policy's Ancestors are, in order, the Service, the HTTPRoute, the Gateway, and +/// the GatewayClass. Almost always, in this hierarchy, the Gateway will be the most +/// useful object to place Policy status on, so we recommend that implementations +/// SHOULD use Gateway as the PolicyAncestorStatus object unless the designers +/// have a _very_ good reason otherwise. +/// +/// In the context of policy attachment, the Ancestor is used to distinguish which +/// resource results in a distinct application of this policy. For example, if a policy +/// targets a Service, it may have a distinct result per attached Gateway. +/// +/// Policies targeting the same resource may have different effects depending on the +/// ancestors of those resources. For example, different Gateways targeting the same +/// Service may have different capabilities, especially if they have different underlying +/// implementations. +/// +/// For example, in BackendTLSPolicy, the Policy attaches to a Service that is +/// used as a backend in a HTTPRoute that is itself attached to a Gateway. +/// In this case, the relevant object for status is the Gateway, and that is the +/// ancestor object referred to in this status. +/// +/// Note that a parent is also an ancestor, so for objects where the parent is the +/// relevant object for status, this struct SHOULD still be used. +/// +/// This struct is intended to be used in a slice that's effectively a map, +/// with a composite key made up of the AncestorRef and the ControllerName. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyStatusAncestors { + /// AncestorRef corresponds with a ParentRef in the spec that this + /// PolicyAncestorStatus struct describes the status of. + #[serde(rename = "ancestorRef")] + pub ancestor_ref: ParentReference, + /// Conditions describes the status of the Policy with respect to the given Ancestor. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, +} diff --git a/gateway-api-with-extensions/src/standard/common.rs b/gateway-api-with-extensions/src/standard/common.rs new file mode 100644 index 0000000..9cd8633 --- /dev/null +++ b/gateway-api-with-extensions/src/standard/common.rs @@ -0,0 +1,343 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum AllowedRoutesNamespacesFrom { + All, + Selector, + Same, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GRPCFilterType { + ResponseHeaderModifier, + RequestHeaderModifier, + RequestMirror, + ExtensionRef, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HTTPFilterType { + RequestHeaderModifier, + ResponseHeaderModifier, + RequestMirror, + RequestRedirect, + #[serde(rename = "URLRewrite")] + UrlRewrite, + ExtensionRef, + #[serde(rename = "CORS")] + Cors, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HeaderMatchType { + Exact, + RegularExpression, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RedirectStatusCode { + #[serde(rename = "301")] + r#_301, + #[serde(rename = "302")] + r#_302, + #[serde(rename = "303")] + r#_303, + #[serde(rename = "307")] + r#_307, + #[serde(rename = "308")] + r#_308, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RequestOperationType { + ReplaceFullPath, + ReplacePrefixMatch, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RequestRedirectScheme { + #[serde(rename = "http")] + Http, + #[serde(rename = "https")] + Https, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum TlsMode { + Terminate, + Passthrough, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum TlsValidationMode { + AllowValidOnly, + AllowInsecureFallback, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendObjectReference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ExtensionParametersReference { + pub group: String, + pub kind: String, + pub name: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayParametersRef { + pub group: String, + pub kind: String, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HTTPHeader { + pub name: String, + pub value: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolEndpointPickerRefPort { + pub number: i32, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Kind { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + pub kind: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct MatchExpressions { + pub key: String, + pub operator: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub values: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ParentReference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sectionName" + )] + pub section_name: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Reference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestMirrorFraction { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub denominator: Option, + pub numerator: i32, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendDefaultValidation { + #[serde(rename = "caCertificateRefs")] + pub ca_certificate_refs: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HeaderMatch { + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + pub value: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HeaderModifier { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub add: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub remove: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub set: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerStatus { + #[serde(rename = "attachedRoutes")] + pub attached_routes: i32, + pub conditions: Vec, + pub name: String, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "supportedKinds" + )] + pub supported_kinds: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerTls { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "certificateRefs" + )] + pub certificate_refs: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub options: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct NamespaceSelector { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "matchExpressions" + )] + pub match_expressions: Option>, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "matchLabels" + )] + pub match_labels: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ParentRouteStatus { + pub conditions: Vec, + #[serde(rename = "controllerName")] + pub controller_name: String, + #[serde(rename = "parentRef")] + pub parent_ref: ParentReference, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestMirror { + #[serde(rename = "backendRef")] + pub backend_ref: BackendObjectReference, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub fraction: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub percent: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestRedirectPath { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "replaceFullPath" + )] + pub replace_full_path: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "replacePrefixMatch" + )] + pub replace_prefix_match: Option, + #[serde(rename = "type")] + pub r#type: RequestOperationType, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct AllowedRoutesNamespaces { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub from: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub selector: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct FilterRequestRedirect { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub scheme: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "statusCode" + )] + pub status_code: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GrpcRouteFilter { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + #[serde(rename = "type")] + pub r#type: GRPCFilterType, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteUrlRewrite { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RouteStatus { + pub parents: Vec, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct AllowedRoutes { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kinds: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespaces: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Listeners { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedRoutes" + )] + pub allowed_routes: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + pub name: String, + pub port: i32, + pub protocol: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tls: Option, +} diff --git a/gateway-api-with-extensions/src/standard/constants.rs b/gateway-api-with-extensions/src/standard/constants.rs new file mode 100644 index 0000000..bf2a178 --- /dev/null +++ b/gateway-api-with-extensions/src/standard/constants.rs @@ -0,0 +1,121 @@ +// WARNING: generated file - manual changes will be overriden + +#[derive(Debug, PartialEq, Eq)] +pub enum GatewayClassConditionType { + Accepted, +} +impl std::fmt::Display for GatewayClassConditionType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum GatewayClassConditionReason { + Accepted, + InvalidParameters, + Pending, + Unsupported, + Waiting, +} +impl std::fmt::Display for GatewayClassConditionReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum GatewayConditionType { + Programmed, + Accepted, + Ready, +} +impl std::fmt::Display for GatewayConditionType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum GatewayConditionReason { + Programmed, + Invalid, + NoResources, + AddressNotAssigned, + AddressNotUsable, + Accepted, + ListenersNotValid, + Pending, + UnsupportedAddress, + InvalidParameters, + Ready, + ListenersNotReady, +} +impl std::fmt::Display for GatewayConditionReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum ListenerConditionType { + Conflicted, + Accepted, + ResolvedRefs, + Programmed, + Ready, +} +impl std::fmt::Display for ListenerConditionType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum ListenerConditionReason { + HostnameConflict, + ProtocolConflict, + NoConflicts, + Accepted, + PortUnavailable, + UnsupportedProtocol, + ResolvedRefs, + InvalidCertificateRef, + InvalidRouteKinds, + RefNotPermitted, + Programmed, + Invalid, + Pending, + Ready, +} +impl std::fmt::Display for ListenerConditionReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum RouteConditionType { + Accepted, + ResolvedRefs, + PartiallyInvalid, +} +impl std::fmt::Display for RouteConditionType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum RouteConditionReason { + Accepted, + NotAllowedByListeners, + NoMatchingListenerHostname, + NoMatchingParent, + UnsupportedValue, + Pending, + IncompatibleFilters, + ResolvedRefs, + RefNotPermitted, + InvalidKind, + BackendNotFound, + UnsupportedProtocol, +} +impl std::fmt::Display for RouteConditionReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} diff --git a/gateway-api-with-extensions/src/standard/enum_defaults.rs b/gateway-api-with-extensions/src/standard/enum_defaults.rs new file mode 100644 index 0000000..72a9ff1 --- /dev/null +++ b/gateway-api-with-extensions/src/standard/enum_defaults.rs @@ -0,0 +1,102 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +pub mod prelude { + + pub use super::super::backendtlspolicies::*; + pub use super::super::gatewayclasses::*; + pub use super::super::gateways::*; + pub use super::super::grpcroutes::*; + pub use super::super::httproutes::*; + pub use super::super::listenersets::*; + pub use super::super::referencegrants::*; + pub use super::super::tlsroutes::*; + + pub use super::super::inferencepools::*; + + pub use super::super::common::*; +} +use prelude::*; +impl Default for AllowedRoutesNamespacesFrom { + fn default() -> Self { + AllowedRoutesNamespacesFrom::Same + } +} + +impl Default for BackendTlsPolicyValidationSubjectAltNamesType { + fn default() -> Self { + BackendTlsPolicyValidationSubjectAltNamesType::Hostname + } +} + +impl Default for GRPCFilterType { + fn default() -> Self { + GRPCFilterType::RequestHeaderModifier + } +} + +impl Default for GatewayAllowedListenersNamespacesFrom { + fn default() -> Self { + GatewayAllowedListenersNamespacesFrom::Same + } +} + +impl Default for HTTPFilterType { + fn default() -> Self { + HTTPFilterType::RequestHeaderModifier + } +} + +impl Default for HTTPMethodMatch { + fn default() -> Self { + HTTPMethodMatch::Get + } +} + +impl Default for HeaderMatchType { + fn default() -> Self { + HeaderMatchType::Exact + } +} + +impl Default for HttpRouteRulesMatchesPathType { + fn default() -> Self { + HttpRouteRulesMatchesPathType::Exact + } +} + +impl Default for RedirectStatusCode { + fn default() -> Self { + RedirectStatusCode::r#_301 + } +} + +impl Default for RequestOperationType { + fn default() -> Self { + RequestOperationType::ReplaceFullPath + } +} + +impl Default for RequestRedirectScheme { + fn default() -> Self { + RequestRedirectScheme::Https + } +} + +impl Default for TlsMode { + fn default() -> Self { + TlsMode::Terminate + } +} + +impl Default for TlsValidationMode { + fn default() -> Self { + TlsValidationMode::AllowValidOnly + } +} +impl Default for InferencePoolEndpointPickerRefFailureMode { + fn default() -> Self { + InferencePoolEndpointPickerRefFailureMode::FailOpen + } +} +use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType; diff --git a/gateway-api/src/apis/experimental/gatewayclasses.rs b/gateway-api-with-extensions/src/standard/gatewayclasses.rs similarity index 65% rename from gateway-api/src/apis/experimental/gatewayclasses.rs rename to gateway-api-with-extensions/src/standard/gatewayclasses.rs index 2d6053a..2c224a1 100644 --- a/gateway-api/src/apis/experimental/gatewayclasses.rs +++ b/gateway-api-with-extensions/src/standard/gatewayclasses.rs @@ -1,16 +1,14 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 +// WARNING: generated file - manual changes will be overriden +use super::common::*; #[allow(unused_imports)] mod prelude { pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube::CustomResource; + pub use kube_derive::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } use self::prelude::*; - /// Spec defines the desired state of GatewayClass. #[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] #[kube( @@ -59,42 +57,8 @@ pub struct GatewayClassSpec { skip_serializing_if = "Option::is_none", rename = "parametersRef" )] - pub parameters_ref: Option, + pub parameters_ref: Option, } - -/// ParametersRef is a reference to a resource that contains the configuration -/// parameters corresponding to the GatewayClass. This is optional if the -/// controller does not require any additional configuration. -/// -/// ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap, -/// or an implementation-specific custom resource. The resource can be -/// cluster-scoped or namespace-scoped. -/// -/// If the referent cannot be found, refers to an unsupported kind, or when -/// the data within that resource is malformed, the GatewayClass SHOULD be -/// rejected with the "Accepted" status condition set to "False" and an -/// "InvalidParameters" reason. -/// -/// A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, -/// the merging behavior is implementation specific. -/// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. -/// -/// Support: Implementation-specific -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayClassParametersRef { - /// Group is the group of the referent. - pub group: String, - /// Kind is kind of the referent. - pub kind: String, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the referent. - /// This field is required when referring to a Namespace-scoped resource and - /// MUST be unset when referring to a Cluster-scoped resource. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, -} - /// Status defines the current state of GatewayClass. /// /// Implementations MUST populate status on all GatewayClass resources which @@ -110,7 +74,6 @@ pub struct GatewayClassStatus { pub conditions: Option>, /// SupportedFeatures is the set of features the GatewayClass support. /// It MUST be sorted in ascending alphabetical order by the Name key. - /// #[serde( default, skip_serializing_if = "Option::is_none", @@ -118,7 +81,6 @@ pub struct GatewayClassStatus { )] pub supported_features: Option>, } - #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct GatewayClassStatusSupportedFeatures { /// FeatureName is used to describe distinct features that are covered by diff --git a/gateway-api-with-extensions/src/standard/gateways.rs b/gateway-api-with-extensions/src/standard/gateways.rs new file mode 100644 index 0000000..8d967c5 --- /dev/null +++ b/gateway-api-with-extensions/src/standard/gateways.rs @@ -0,0 +1,526 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of Gateway. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "Gateway", + plural = "gateways" +)] +#[kube(namespaced)] +#[kube(status = "GatewayStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct GatewaySpec { + /// Addresses requested for this Gateway. This is optional and behavior can + /// depend on the implementation. If a value is set in the spec and the + /// requested address is invalid or unavailable, the implementation MUST + /// indicate this in an associated entry in GatewayStatus.Conditions. + /// + /// The Addresses field represents a request for the address(es) on the + /// "outside of the Gateway", that traffic bound for this Gateway will use. + /// This could be the IP address or hostname of an external load balancer or + /// other networking infrastructure, or some other address that traffic will + /// be sent to. + /// + /// If no Addresses are specified, the implementation MAY schedule the + /// Gateway in an implementation-specific manner, assigning an appropriate + /// set of Addresses. + /// + /// The implementation MUST bind all Listeners to every GatewayAddress that + /// it assigns to the Gateway and add a corresponding entry in + /// GatewayStatus.Addresses. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub addresses: Option>, + /// AllowedListeners defines which ListenerSets can be attached to this Gateway. + /// The default value is to allow no ListenerSets. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedListeners" + )] + pub allowed_listeners: Option, + /// GatewayClassName used for this Gateway. This is the name of a + /// GatewayClass resource. + #[serde(rename = "gatewayClassName")] + pub gateway_class_name: String, + /// Infrastructure defines infrastructure level attributes about this Gateway instance. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub infrastructure: Option, + /// Listeners associated with this Gateway. Listeners define + /// logical endpoints that are bound on this Gateway's addresses. + /// At least one Listener MUST be specified. + /// + /// ## Distinct Listeners + /// + /// Each Listener in a set of Listeners (for example, in a single Gateway) + /// MUST be _distinct_, in that a traffic flow MUST be able to be assigned to + /// exactly one listener. (This section uses "set of Listeners" rather than + /// "Listeners in a single Gateway" because implementations MAY merge configuration + /// from multiple Gateways onto a single data plane, and these rules _also_ + /// apply in that case). + /// + /// Practically, this means that each listener in a set MUST have a unique + /// combination of Port, Protocol, and, if supported by the protocol, Hostname. + /// + /// Some combinations of port, protocol, and TLS settings are considered + /// Core support and MUST be supported by implementations based on the objects + /// they support: + /// + /// HTTPRoute + /// + /// 1. HTTPRoute, Port: 80, Protocol: HTTP + /// 2. HTTPRoute, Port: 443, Protocol: HTTPS, TLS Mode: Terminate, TLS keypair provided + /// + /// TLSRoute + /// + /// 1. TLSRoute, Port: 443, Protocol: TLS, TLS Mode: Passthrough + /// + /// "Distinct" Listeners have the following property: + /// + /// **The implementation can match inbound requests to a single distinct + /// Listener**. + /// + /// When multiple Listeners share values for fields (for + /// example, two Listeners with the same Port value), the implementation + /// can match requests to only one of the Listeners using other + /// Listener fields. + /// + /// When multiple listeners have the same value for the Protocol field, then + /// each of the Listeners with matching Protocol values MUST have different + /// values for other fields. + /// + /// The set of fields that MUST be different for a Listener differs per protocol. + /// The following rules define the rules for what fields MUST be considered for + /// Listeners to be distinct with each protocol currently defined in the + /// Gateway API spec. + /// + /// The set of listeners that all share a protocol value MUST have _different_ + /// values for _at least one_ of these fields to be distinct: + /// + /// * **HTTP, HTTPS, TLS**: Port, Hostname + /// * **TCP, UDP**: Port + /// + /// One **very** important rule to call out involves what happens when an + /// implementation: + /// + /// * Supports TCP protocol Listeners, as well as HTTP, HTTPS, or TLS protocol + /// Listeners, and + /// * sees HTTP, HTTPS, or TLS protocols with the same `port` as one with TCP + /// Protocol. + /// + /// In this case all the Listeners that share a port with the + /// TCP Listener are not distinct and so MUST NOT be accepted. + /// + /// If an implementation does not support TCP Protocol Listeners, then the + /// previous rule does not apply, and the TCP Listeners SHOULD NOT be + /// accepted. + /// + /// Note that the `tls` field is not used for determining if a listener is distinct, because + /// Listeners that _only_ differ on TLS config will still conflict in all cases. + /// + /// ### Listeners that are distinct only by Hostname + /// + /// When the Listeners are distinct based only on Hostname, inbound request + /// hostnames MUST match from the most specific to least specific Hostname + /// values to choose the correct Listener and its associated set of Routes. + /// + /// Exact matches MUST be processed before wildcard matches, and wildcard + /// matches MUST be processed before fallback (empty Hostname value) + /// matches. For example, `"foo.example.com"` takes precedence over + /// `"*.example.com"`, and `"*.example.com"` takes precedence over `""`. + /// + /// Additionally, if there are multiple wildcard entries, more specific + /// wildcard entries must be processed before less specific wildcard entries. + /// For example, `"*.foo.example.com"` takes precedence over `"*.example.com"`. + /// + /// The precise definition here is that the higher the number of dots in the + /// hostname to the right of the wildcard character, the higher the precedence. + /// + /// The wildcard character will match any number of characters _and dots_ to + /// the left, however, so `"*.example.com"` will match both + /// `"foo.bar.example.com"` _and_ `"bar.example.com"`. + /// + /// ## Handling indistinct Listeners + /// + /// If a set of Listeners contains Listeners that are not distinct, then those + /// Listeners are _Conflicted_, and the implementation MUST set the "Conflicted" + /// condition in the Listener Status to "True". + /// + /// The words "indistinct" and "conflicted" are considered equivalent for the + /// purpose of this documentation. + /// + /// Implementations MAY choose to accept a Gateway with some Conflicted + /// Listeners only if they only accept the partial Listener set that contains + /// no Conflicted Listeners. + /// + /// Specifically, an implementation MAY accept a partial Listener set subject to + /// the following rules: + /// + /// * The implementation MUST NOT pick one conflicting Listener as the winner. + /// ALL indistinct Listeners must not be accepted for processing. + /// * At least one distinct Listener MUST be present, or else the Gateway effectively + /// contains _no_ Listeners, and must be rejected from processing as a whole. + /// + /// The implementation MUST set a "ListenersNotValid" condition on the + /// Gateway Status when the Gateway contains Conflicted Listeners whether or + /// not they accept the Gateway. That Condition SHOULD clearly + /// indicate in the Message which Listeners are conflicted, and which are + /// Accepted. Additionally, the Listener status for those listeners SHOULD + /// indicate which Listeners are conflicted and not Accepted. + /// + /// ## General Listener behavior + /// + /// Note that, for all distinct Listeners, requests SHOULD match at most one Listener. + /// For example, if Listeners are defined for "foo.example.com" and "*.example.com", a + /// request to "foo.example.com" SHOULD only be routed using routes attached + /// to the "foo.example.com" Listener (and not the "*.example.com" Listener). + /// + /// This concept is known as "Listener Isolation", and it is an Extended feature + /// of Gateway API. Implementations that do not support Listener Isolation MUST + /// clearly document this, and MUST NOT claim support for the + /// `GatewayHTTPListenerIsolation` feature. + /// + /// Implementations that _do_ support Listener Isolation SHOULD claim support + /// for the Extended `GatewayHTTPListenerIsolation` feature and pass the associated + /// conformance tests. + /// + /// ## Compatible Listeners + /// + /// A Gateway's Listeners are considered _compatible_ if: + /// + /// 1. They are distinct. + /// 2. The implementation can serve them in compliance with the Addresses + /// requirement that all Listeners are available on all assigned + /// addresses. + /// + /// Compatible combinations in Extended support are expected to vary across + /// implementations. A combination that is compatible for one implementation + /// may not be compatible for another. + /// + /// For example, an implementation that cannot serve both TCP and UDP listeners + /// on the same address, or cannot mix HTTPS and generic TLS listens on the same port + /// would not consider those cases compatible, even though they are distinct. + /// + /// Implementations MAY merge separate Gateways onto a single set of + /// Addresses if all Listeners across all Gateways are compatible. + /// + /// In a future release the MinItems=1 requirement MAY be dropped. + /// + /// Support: Core + pub listeners: Vec, + /// TLS specifies frontend and backend tls configuration for entire gateway. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tls: Option, +} +/// GatewaySpecAddress describes an address that can be bound to a Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAddresses { + /// Type of the address. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// When a value is unspecified, an implementation SHOULD automatically + /// assign an address matching the requested type if possible. + /// + /// If an implementation does not support an empty value, they MUST set the + /// "Programmed" condition in status to False with a reason of "AddressNotAssigned". + /// + /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, +} +/// AllowedListeners defines which ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAllowedListeners { + /// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. + /// The default value is to allow no ListenerSets. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespaces: Option, +} +/// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAllowedListenersNamespaces { + /// From indicates where ListenerSets can attach to this Gateway. Possible + /// values are: + /// + /// * Same: Only ListenerSets in the same namespace may be attached to this Gateway. + /// * Selector: ListenerSets in namespaces selected by the selector may be attached to this Gateway. + /// * All: ListenerSets in all namespaces may be attached to this Gateway. + /// * None: Only listeners defined in the Gateway's spec are allowed + /// + /// The default value None + #[serde(default, skip_serializing_if = "Option::is_none")] + pub from: Option, + /// Selector must be specified when From is set to "Selector". In that case, + /// only ListenerSets in Namespaces matching this Selector will be selected by this + /// Gateway. This field is ignored for other values of "From". + #[serde(default, skip_serializing_if = "Option::is_none")] + pub selector: Option, +} +/// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GatewayAllowedListenersNamespacesFrom { + All, + Selector, + Same, + None, +} +/// Infrastructure defines infrastructure level attributes about this Gateway instance. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayInfrastructure { + /// Annotations that SHOULD be applied to any resources created in response to this Gateway. + /// + /// For implementations creating other Kubernetes objects, this should be the `metadata.annotations` field on resources. + /// For other implementations, this refers to any relevant (implementation specific) "annotations" concepts. + /// + /// An implementation may chose to add additional implementation-specific annotations as they see fit. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub annotations: Option>, + /// Labels that SHOULD be applied to any resources created in response to this Gateway. + /// + /// For implementations creating other Kubernetes objects, this should be the `metadata.labels` field on resources. + /// For other implementations, this refers to any relevant (implementation specific) "labels" concepts. + /// + /// An implementation may chose to add additional implementation-specific labels as they see fit. + /// + /// If an implementation maps these labels to Pods, or any other resource that would need to be recreated when labels + /// change, it SHOULD clearly warn about this behavior in documentation. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub labels: Option>, + /// ParametersRef is a reference to a resource that contains the configuration + /// parameters corresponding to the Gateway. This is optional if the + /// controller does not require any additional configuration. + /// + /// This follows the same semantics as GatewayClass's `parametersRef`, but on a per-Gateway basis + /// + /// The Gateway's GatewayClass may provide its own `parametersRef`. When both are specified, + /// the merging behavior is implementation specific. + /// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. + /// + /// If the referent cannot be found, refers to an unsupported kind, or when + /// the data within that resource is malformed, the Gateway SHOULD be + /// rejected with the "Accepted" status condition set to "False" and an + /// "InvalidParameters" reason. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parametersRef" + )] + pub parameters_ref: Option, +} +/// TLS specifies frontend and backend tls configuration for entire gateway. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTls { + /// Backend describes TLS configuration for gateway when connecting + /// to backends. + /// + /// Note that this contains only details for the Gateway as a TLS client, + /// and does _not_ imply behavior about how to choose which backend should + /// get a TLS connection. That is determined by the presence of a BackendTLSPolicy. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub backend: Option, + /// Frontend describes TLS config when client connects to Gateway. + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub frontend: Option, +} +/// Backend describes TLS configuration for gateway when connecting +/// to backends. +/// +/// Note that this contains only details for the Gateway as a TLS client, +/// and does _not_ imply behavior about how to choose which backend should +/// get a TLS connection. That is determined by the presence of a BackendTLSPolicy. +/// +/// Support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsBackend { + /// ClientCertificateRef references an object that contains a client certificate + /// and its associated private key. It can reference standard Kubernetes resources, + /// i.e., Secret, or implementation-specific custom resources. + /// + /// A ClientCertificateRef is considered invalid if: + /// + /// * It refers to a resource that cannot be resolved (e.g., the referenced resource + /// does not exist) or is misconfigured (e.g., a Secret does not contain the keys + /// named `tls.crt` and `tls.key`). In this case, the `ResolvedRefs` condition + /// on the Gateway MUST be set to False with the Reason `InvalidClientCertificateRef` + /// and the Message of the Condition MUST indicate why the reference is invalid. + /// + /// * It refers to a resource in another namespace UNLESS there is a ReferenceGrant + /// in the target namespace that allows the certificate to be attached. + /// If a ReferenceGrant does not allow this reference, the `ResolvedRefs` condition + /// on the Gateway MUST be set to False with the Reason `RefNotPermitted`. + /// + /// Implementations MAY choose to perform further validation of the certificate + /// content (e.g., checking expiry or enforcing specific formats). In such cases, + /// an implementation-specific Reason and Message MUST be set. + /// + /// Support: Core - Reference to a Kubernetes TLS Secret (with the type `kubernetes.io/tls`). + /// Support: Implementation-specific - Other resource kinds or Secrets with a + /// different type (e.g., `Opaque`). + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "clientCertificateRef" + )] + pub client_certificate_ref: Option, +} +/// Frontend describes TLS config when client connects to Gateway. +/// Support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontend { + /// Default specifies the default client certificate validation configuration + /// for all Listeners handling HTTPS traffic, unless a per-port configuration + /// is defined. + /// + /// support: Core + pub default: GatewayTlsFrontendDefault, + /// PerPort specifies tls configuration assigned per port. + /// Per port configuration is optional. Once set this configuration overrides + /// the default configuration for all Listeners handling HTTPS traffic + /// that match this port. + /// Each override port requires a unique TLS configuration. + /// + /// support: Core + #[serde(default, skip_serializing_if = "Option::is_none", rename = "perPort")] + pub per_port: Option>, +} +/// Default specifies the default client certificate validation configuration +/// for all Listeners handling HTTPS traffic, unless a per-port configuration +/// is defined. +/// +/// support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendDefault { + /// Validation holds configuration information for validating the frontend (client). + /// Setting this field will result in mutual authentication when connecting to the gateway. + /// In browsers this may result in a dialog appearing + /// that requests a user to specify the client certificate. + /// The maximum depth of a certificate chain accepted in verification is Implementation specific. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub validation: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendPerPort { + /// The Port indicates the Port Number to which the TLS configuration will be + /// applied. This configuration will be applied to all Listeners handling HTTPS + /// traffic that match this port. + /// + /// Support: Core + pub port: i32, + /// TLS store the configuration that will be applied to all Listeners handling + /// HTTPS traffic and matching given port. + /// + /// Support: Core + pub tls: GatewayTlsFrontendPerPortTls, +} +/// TLS store the configuration that will be applied to all Listeners handling +/// HTTPS traffic and matching given port. +/// +/// Support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendPerPortTls { + /// Validation holds configuration information for validating the frontend (client). + /// Setting this field will result in mutual authentication when connecting to the gateway. + /// In browsers this may result in a dialog appearing + /// that requests a user to specify the client certificate. + /// The maximum depth of a certificate chain accepted in verification is Implementation specific. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub validation: Option, +} +/// Status defines the current state of Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatus { + /// Addresses lists the network addresses that have been bound to the + /// Gateway. + /// + /// This list may differ from the addresses provided in the spec under some + /// conditions: + /// + /// * no addresses are specified, all addresses are dynamically assigned + /// * a combination of specified and dynamic addresses are assigned + /// * a specified address was unusable (e.g. already in use) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub addresses: Option>, + /// AttachedListenerSets represents the total number of ListenerSets that have been + /// successfully attached to this Gateway. + /// + /// A ListenerSet is successfully attached to a Gateway when all the following conditions are met: + /// - The ListenerSet is selected by the Gateway's AllowedListeners field + /// - The ListenerSet has a valid ParentRef selecting the Gateway + /// - The ListenerSet's status has the condition "Accepted: true" + /// + /// Uses for this field include troubleshooting AttachedListenerSets attachment and + /// measuring blast radius/impact of changes to a Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "attachedListenerSets" + )] + pub attached_listener_sets: Option, + /// Conditions describe the current conditions of the Gateway. + /// + /// Implementations should prefer to express Gateway conditions + /// using the `GatewayConditionType` and `GatewayConditionReason` + /// constants so that operators and tools can converge on a common + /// vocabulary to describe Gateway state. + /// + /// Known condition types are: + /// + /// * "Accepted" + /// * "Programmed" + /// * "Ready" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// Listeners provide status for each unique listener port defined in the Spec. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub listeners: Option>, +} +/// GatewayStatusAddress describes a network address that is bound to a Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatusAddresses { + /// Type of the address. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// Value of the address. The validity of the values will depend + /// on the type and support by the controller. + /// + /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. + pub value: String, +} diff --git a/gateway-api-with-extensions/src/standard/grpcroutes.rs b/gateway-api-with-extensions/src/standard/grpcroutes.rs new file mode 100644 index 0000000..5cb1d24 --- /dev/null +++ b/gateway-api-with-extensions/src/standard/grpcroutes.rs @@ -0,0 +1,383 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of GRPCRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "GRPCRoute", + plural = "grpcroutes" +)] +#[kube(namespaced)] +#[kube(status = "RouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct GrpcRouteSpec { + /// Hostnames defines a set of hostnames to match against the GRPC + /// Host header to select a GRPCRoute to process the request. This matches + /// the RFC 1123 definition of a hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label MUST appear by itself as the first label. + /// + /// If a hostname is specified by both the Listener and GRPCRoute, there + /// MUST be at least one intersecting hostname for the GRPCRoute to be + /// attached to the Listener. For example: + /// + /// * A Listener with `test.example.com` as the hostname matches GRPCRoutes + /// that have either not specified any hostnames, or have specified at + /// least one of `test.example.com` or `*.example.com`. + /// * A Listener with `*.example.com` as the hostname matches GRPCRoutes + /// that have either not specified any hostnames or have specified at least + /// one hostname that matches the Listener hostname. For example, + /// `test.example.com` and `*.example.com` would both match. On the other + /// hand, `example.com` and `test.example.net` would not match. + /// + /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted + /// as a suffix match. That means that a match for `*.example.com` would match + /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. + /// + /// If both the Listener and GRPCRoute have specified hostnames, any + /// GRPCRoute hostnames that do not match the Listener hostname MUST be + /// ignored. For example, if a Listener specified `*.example.com`, and the + /// GRPCRoute specified `test.example.com` and `test.example.net`, + /// `test.example.net` MUST NOT be considered for a match. + /// + /// If both the Listener and GRPCRoute have specified hostnames, and none + /// match with the criteria above, then the GRPCRoute MUST NOT be accepted by + /// the implementation. The implementation MUST raise an 'Accepted' Condition + /// with a status of `False` in the corresponding RouteParentStatus. + /// + /// If a Route (A) of type HTTPRoute or GRPCRoute is attached to a + /// Listener and that listener already has another Route (B) of the other + /// type attached and the intersection of the hostnames of A and B is + /// non-empty, then the implementation MUST accept exactly one of these two + /// routes, determined by the following criteria, in order: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// The rejected Route MUST raise an 'Accepted' condition with a status of + /// 'False' in the corresponding RouteParentStatus. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostnames: Option>, + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of GRPC matchers, filters and actions. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rules: Option>, +} +/// GRPCRouteRule defines the semantics for matching a gRPC request based on +/// conditions (matches), processing it (filters), and forwarding the request to +/// an API object (backendRefs). +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GrpcRouteRule { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. + /// + /// Failure behavior here depends on how many BackendRefs are specified and + /// how many are invalid. + /// + /// If *all* entries in BackendRefs are invalid, and there are also no filters + /// specified in this route rule, *all* traffic which matches this rule MUST + /// receive an `UNAVAILABLE` status. + /// + /// See the GRPCBackendRef definition for the rules about what makes a single + /// GRPCBackendRef invalid. + /// + /// When a GRPCBackendRef is invalid, `UNAVAILABLE` statuses MUST be returned for + /// requests that would have otherwise been routed to an invalid backend. If + /// multiple backends are specified, and some are invalid, the proportion of + /// requests that would otherwise have been routed to an invalid backend + /// MUST receive an `UNAVAILABLE` status. + /// + /// For example, if two backends are specified with equal weights, and one is + /// invalid, 50 percent of traffic MUST receive an `UNAVAILABLE` status. + /// Implementations may choose how that 50 percent is determined. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRefs" + )] + pub backend_refs: Option>, + /// Filters define the filters that are applied to requests that match + /// this rule. + /// + /// The effects of ordering of multiple behaviors are currently unspecified. + /// This can change in the future based on feedback during the alpha stage. + /// + /// Conformance-levels at this level are defined based on the type of filter: + /// + /// - ALL core filters MUST be supported by all implementations that support + /// GRPCRoute. + /// - Implementers are encouraged to support extended filters. + /// - Implementation-specific custom filters have no API guarantees across + /// implementations. + /// + /// Specifying the same filter multiple times is not supported unless explicitly + /// indicated in the filter. + /// + /// If an implementation cannot support a combination of filters, it must clearly + /// document that limitation. In cases where incompatible or unsupported + /// filters are specified and cause the `Accepted` condition to be set to status + /// `False`, implementations may use the `IncompatibleFilters` reason to specify + /// this configuration error. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Matches define conditions used for matching the rule against incoming + /// gRPC requests. Each match is independent, i.e. this rule will be matched + /// if **any** one of the matches is satisfied. + /// + /// For example, take the following matches configuration: + /// + /// ```text + /// matches: + /// - method: + /// service: foo.bar + /// headers: + /// values: + /// version: 2 + /// - method: + /// service: foo.bar.v2 + /// ``` + /// + /// For a request to match against this rule, it MUST satisfy + /// EITHER of the two conditions: + /// + /// - service of foo.bar AND contains the header `version: 2` + /// - service of foo.bar.v2 + /// + /// See the documentation for GRPCRouteMatch on how to specify multiple + /// match conditions to be ANDed together. + /// + /// If no matches are specified, the implementation MUST match every gRPC request. + /// + /// Proxy or Load Balancer routing configuration generated from GRPCRoutes + /// MUST prioritize rules based on the following criteria, continuing on + /// ties. Merging MUST not be done between GRPCRoutes and HTTPRoutes. + /// Precedence MUST be given to the rule with the largest number of: + /// + /// * Characters in a matching non-wildcard hostname. + /// * Characters in a matching hostname. + /// * Characters in a matching service. + /// * Characters in a matching method. + /// * Header matches. + /// + /// If ties still exist across multiple Routes, matching precedence MUST be + /// determined in order of the following criteria, continuing on ties: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// If ties still exist within the Route that has been given precedence, + /// matching precedence MUST be granted to the first matching rule meeting + /// the above criteria. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub matches: Option>, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} +/// GRPCBackendRef defines how a GRPCRoute forwards a gRPC request. +/// +/// Note that when a namespace different than the local namespace is specified, a +/// ReferenceGrant object is required in the referent namespace to allow that +/// namespace's owner to accept the reference. See the ReferenceGrant +/// documentation for details. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GRPCBackendReference { + /// Filters defined at this level MUST be executed if and only if the + /// request is being forwarded to the backend defined here. + /// + /// Support: Implementation-specific (For broader support of filters, use the + /// Filters field in GRPCRouteRule.) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Group is the group of the referent. For example, "gateway.networking.k8s.io". + /// When unspecified or empty string, core API group is inferred. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. For example + /// "Service". + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations SHOULD NOT + /// support ExternalName Services. + /// + /// Support: Core (Services with a type other than ExternalName) + /// + /// Support: Implementation-specific (Services with type ExternalName) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent. + pub name: String, + /// Namespace is the namespace of the backend. When unspecified, the local + /// namespace is inferred. + /// + /// Note that when a namespace different than the local namespace is specified, + /// a ReferenceGrant object is required in the referent namespace to allow that + /// namespace's owner to accept the reference. See the ReferenceGrant + /// documentation for details. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + /// Port specifies the destination port number to use for this resource. + /// Port is required when the referent is a Kubernetes Service. In this + /// case, the port number is the service port number, not the target port. + /// For other resources, destination port might be derived from the referent + /// resource or this field. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + /// Weight specifies the proportion of requests forwarded to the referenced + /// backend. This is computed as weight/(sum of all weights in this + /// BackendRefs list). For non-zero values, there may be some epsilon from + /// the exact proportion defined here depending on the precision an + /// implementation supports. Weight is not a percentage and the sum of + /// weights does not need to equal 100. + /// + /// If only one backend is specified and it has a weight greater than 0, 100% + /// of the traffic is forwarded to that backend. If weight is set to 0, no + /// traffic should be forwarded for this entry. If unspecified, weight + /// defaults to 1. + /// + /// Support for this field varies based on the context where used. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} +/// GRPCRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a gRPC request only if its service +/// is `foo` AND it contains the `version: v1` header: +/// +/// ```text +/// matches: +/// - method: +/// type: Exact +/// service: "foo" +/// - headers: +/// name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GrpcRouteMatch { + /// Headers specifies gRPC request header matchers. Multiple match values are + /// ANDed together, meaning, a request MUST match all the specified headers + /// to select the route. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub headers: Option>, + /// Method specifies a gRPC request service/method matcher. If this field is + /// not specified, all services and methods will match. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, +} +/// Method specifies a gRPC request service/method matcher. If this field is +/// not specified, all services and methods will match. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GRPCMethodMatch { + /// Value of the method to match against. If left empty or omitted, will + /// match all services. + /// + /// At least one of Service and Method MUST be a non-empty string. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, + /// Value of the service to match against. If left empty or omitted, will + /// match any service. + /// + /// At least one of Service and Method MUST be a non-empty string. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub service: Option, + /// Type specifies how to match against the service and/or method. + /// Support: Core (Exact with service and method specified) + /// + /// Support: Implementation-specific (Exact with method specified but no service specified) + /// + /// Support: Implementation-specific (RegularExpression) + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, +} diff --git a/gateway-api-with-extensions/src/standard/httproutes.rs b/gateway-api-with-extensions/src/standard/httproutes.rs new file mode 100644 index 0000000..165be1d --- /dev/null +++ b/gateway-api-with-extensions/src/standard/httproutes.rs @@ -0,0 +1,1240 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of HTTPRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "HTTPRoute", + plural = "httproutes" +)] +#[kube(namespaced)] +#[kube(status = "RouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct HttpRouteSpec { + /// Hostnames defines a set of hostnames that should match against the HTTP Host + /// header to select a HTTPRoute used to process the request. Implementations + /// MUST ignore any port value specified in the HTTP Host header while + /// performing a match and (absent of any applicable header modification + /// configuration) MUST forward this header unmodified to the backend. + /// + /// Valid values for Hostnames are determined by RFC 1123 definition of a + /// hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label must appear by itself as the first label. + /// + /// If a hostname is specified by both the Listener and HTTPRoute, there + /// must be at least one intersecting hostname for the HTTPRoute to be + /// attached to the Listener. For example: + /// + /// * A Listener with `test.example.com` as the hostname matches HTTPRoutes + /// that have either not specified any hostnames, or have specified at + /// least one of `test.example.com` or `*.example.com`. + /// * A Listener with `*.example.com` as the hostname matches HTTPRoutes + /// that have either not specified any hostnames or have specified at least + /// one hostname that matches the Listener hostname. For example, + /// `*.example.com`, `test.example.com`, and `foo.test.example.com` would + /// all match. On the other hand, `example.com` and `test.example.net` would + /// not match. + /// + /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted + /// as a suffix match. That means that a match for `*.example.com` would match + /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. + /// + /// If both the Listener and HTTPRoute have specified hostnames, any + /// HTTPRoute hostnames that do not match the Listener hostname MUST be + /// ignored. For example, if a Listener specified `*.example.com`, and the + /// HTTPRoute specified `test.example.com` and `test.example.net`, + /// `test.example.net` must not be considered for a match. + /// + /// If both the Listener and HTTPRoute have specified hostnames, and none + /// match with the criteria above, then the HTTPRoute is not accepted. The + /// implementation must raise an 'Accepted' Condition with a status of + /// `False` in the corresponding RouteParentStatus. + /// + /// In the event that multiple HTTPRoutes specify intersecting hostnames (e.g. + /// overlapping wildcard matching and exact matching hostnames), precedence must + /// be given to rules from the HTTPRoute with the largest number of: + /// + /// * Characters in a matching non-wildcard hostname. + /// * Characters in a matching hostname. + /// + /// If ties exist across multiple Routes, the matching precedence rules for + /// HTTPRouteMatches takes over. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostnames: Option>, + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of HTTP matchers, filters and actions. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rules: Option>, +} +/// HTTPRouteRule defines semantics for matching an HTTP request based on +/// conditions (matches), processing it (filters), and forwarding the request to +/// an API object (backendRefs). +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRule { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. + /// + /// Failure behavior here depends on how many BackendRefs are specified and + /// how many are invalid. + /// + /// If *all* entries in BackendRefs are invalid, and there are also no filters + /// specified in this route rule, *all* traffic which matches this rule MUST + /// receive a 500 status code. + /// + /// See the HTTPBackendRef definition for the rules about what makes a single + /// HTTPBackendRef invalid. + /// + /// When a HTTPBackendRef is invalid, 500 status codes MUST be returned for + /// requests that would have otherwise been routed to an invalid backend. If + /// multiple backends are specified, and some are invalid, the proportion of + /// requests that would otherwise have been routed to an invalid backend + /// MUST receive a 500 status code. + /// + /// For example, if two backends are specified with equal weights, and one is + /// invalid, 50 percent of traffic must receive a 500. Implementations may + /// choose how that 50 percent is determined. + /// + /// When a HTTPBackendRef refers to a Service that has no ready endpoints, + /// implementations SHOULD return a 503 for requests to that backend instead. + /// If an implementation chooses to do this, all of the above rules for 500 responses + /// MUST also apply for responses that return a 503. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRefs" + )] + pub backend_refs: Option>, + /// Filters define the filters that are applied to requests that match + /// this rule. + /// + /// Wherever possible, implementations SHOULD implement filters in the order + /// they are specified. + /// + /// Implementations MAY choose to implement this ordering strictly, rejecting + /// any combination or order of filters that cannot be supported. If implementations + /// choose a strict interpretation of filter ordering, they MUST clearly document + /// that behavior. + /// + /// To reject an invalid combination or order of filters, implementations SHOULD + /// consider the Route Rules with this configuration invalid. If all Route Rules + /// in a Route are invalid, the entire Route would be considered invalid. If only + /// a portion of Route Rules are invalid, implementations MUST set the + /// "PartiallyInvalid" condition for the Route. + /// + /// Conformance-levels at this level are defined based on the type of filter: + /// + /// - ALL core filters MUST be supported by all implementations. + /// - Implementers are encouraged to support extended filters. + /// - Implementation-specific custom filters have no API guarantees across + /// implementations. + /// + /// Specifying the same filter multiple times is not supported unless explicitly + /// indicated in the filter. + /// + /// All filters are expected to be compatible with each other except for the + /// URLRewrite and RequestRedirect filters, which may not be combined. If an + /// implementation cannot support other combinations of filters, they must clearly + /// document that limitation. In cases where incompatible or unsupported + /// filters are specified and cause the `Accepted` condition to be set to status + /// `False`, implementations may use the `IncompatibleFilters` reason to specify + /// this configuration error. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Matches define conditions used for matching the rule against incoming + /// HTTP requests. Each match is independent, i.e. this rule will be matched + /// if **any** one of the matches is satisfied. + /// + /// For example, take the following matches configuration: + /// + /// ```text + /// matches: + /// - path: + /// value: "/foo" + /// headers: + /// - name: "version" + /// value: "v2" + /// - path: + /// value: "/v2/foo" + /// ``` + /// + /// For a request to match against this rule, a request must satisfy + /// EITHER of the two conditions: + /// + /// - path prefixed with `/foo` AND contains the header `version: v2` + /// - path prefix of `/v2/foo` + /// + /// See the documentation for HTTPRouteMatch on how to specify multiple + /// match conditions that should be ANDed together. + /// + /// If no matches are specified, the default is a prefix + /// path match on "/", which has the effect of matching every + /// HTTP request. + /// + /// Proxy or Load Balancer routing configuration generated from HTTPRoutes + /// MUST prioritize matches based on the following criteria, continuing on + /// ties. Across all rules specified on applicable Routes, precedence must be + /// given to the match having: + /// + /// * "Exact" path match. + /// * "Prefix" path match with largest number of characters. + /// * Method match. + /// * Largest number of header matches. + /// * Largest number of query param matches. + /// + /// Note: The precedence of RegularExpression path matches are implementation-specific. + /// + /// If ties still exist across multiple Routes, matching precedence MUST be + /// determined in order of the following criteria, continuing on ties: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// If ties still exist within an HTTPRoute, matching precedence MUST be granted + /// to the FIRST matching rule (in list order) with a match meeting the above + /// criteria. + /// + /// When no rules matching a request have been successfully attached to the + /// parent a request is coming from, a HTTP 404 status code MUST be returned. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub matches: Option>, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + /// Timeouts defines the timeouts that can be configured for an HTTP request. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub timeouts: Option, +} +/// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. +/// +/// Note that when a namespace different than the local namespace is specified, a +/// ReferenceGrant object is required in the referent namespace to allow that +/// namespace's owner to accept the reference. See the ReferenceGrant +/// documentation for details. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HTTPBackendReference { + /// Filters defined at this level should be executed if and only if the + /// request is being forwarded to the backend defined here. + /// + /// Support: Implementation-specific (For broader support of filters, use the + /// Filters field in HTTPRouteRule.) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Group is the group of the referent. For example, "gateway.networking.k8s.io". + /// When unspecified or empty string, core API group is inferred. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. For example + /// "Service". + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations SHOULD NOT + /// support ExternalName Services. + /// + /// Support: Core (Services with a type other than ExternalName) + /// + /// Support: Implementation-specific (Services with type ExternalName) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent. + pub name: String, + /// Namespace is the namespace of the backend. When unspecified, the local + /// namespace is inferred. + /// + /// Note that when a namespace different than the local namespace is specified, + /// a ReferenceGrant object is required in the referent namespace to allow that + /// namespace's owner to accept the reference. See the ReferenceGrant + /// documentation for details. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + /// Port specifies the destination port number to use for this resource. + /// Port is required when the referent is a Kubernetes Service. In this + /// case, the port number is the service port number, not the target port. + /// For other resources, destination port might be derived from the referent + /// resource or this field. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + /// Weight specifies the proportion of requests forwarded to the referenced + /// backend. This is computed as weight/(sum of all weights in this + /// BackendRefs list). For non-zero values, there may be some epsilon from + /// the exact proportion defined here depending on the precision an + /// implementation supports. Weight is not a percentage and the sum of + /// weights does not need to equal 100. + /// + /// If only one backend is specified and it has a weight greater than 0, 100% + /// of the traffic is forwarded to that backend. If weight is set to 0, no + /// traffic should be forwarded for this entry. If unspecified, weight + /// defaults to 1. + /// + /// Support for this field varies based on the context where used. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} +/// HTTPRouteFilter defines processing steps that must be completed during the +/// request or response lifecycle. HTTPRouteFilters are meant as an extension +/// point to express processing that may be done in Gateway implementations. Some +/// examples include request or response modification, implementing +/// authentication strategies, rate-limiting, and traffic shaping. API +/// guarantee/conformance is defined based on the type of the filter. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteBackendFilter { + /// CORS defines a schema for a filter that responds to the + /// cross-origin request based on HTTP response header. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cors: Option, + /// ExtensionRef is an optional, implementation-specific extension to the + /// "filter" behavior. For example, resource "myroutefilter" in group + /// "networking.example.net"). ExtensionRef MUST NOT be used for core and + /// extended filters. + /// + /// This filter can be used multiple times within the same rule. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + /// RequestHeaderModifier defines a schema for a filter that modifies request + /// headers. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + /// RequestMirror defines a schema for a filter that mirrors requests. + /// Requests are sent to the specified destination, but responses from + /// that destination are ignored. + /// + /// This filter can be used multiple times within the same rule. Note that + /// not all implementations will be able to support mirroring to multiple + /// backends. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + /// RequestRedirect defines a schema for a filter that responds to the + /// request with an HTTP redirection. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestRedirect" + )] + pub request_redirect: Option, + /// ResponseHeaderModifier defines a schema for a filter that modifies response + /// headers. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + /// Type identifies the type of filter to apply. As with other API fields, + /// types are classified into three conformance levels: + /// + /// - Core: Filter types and their corresponding configuration defined by + /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All + /// implementations must support core filters. + /// + /// - Extended: Filter types and their corresponding configuration defined by + /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers + /// are encouraged to support extended filters. + /// + /// - Implementation-specific: Filters that are defined and supported by + /// specific vendors. + /// In the future, filters showing convergence in behavior across multiple + /// implementations will be considered for inclusion in extended or core + /// conformance levels. Filter-specific configuration for such filters + /// is specified using the ExtensionRef field. `Type` should be set to + /// "ExtensionRef" for custom filters. + /// + /// Implementers are encouraged to define custom implementation types to + /// extend the core API with implementation-specific behavior. + /// + /// If a reference to a custom filter type cannot be resolved, the filter + /// MUST NOT be skipped. Instead, requests that would have been processed by + /// that filter MUST receive a HTTP error response. + /// + /// Note that values may be added to this enum, implementations + /// must ensure that unknown values will not cause a crash. + /// + /// Unknown values here must result in the implementation setting the + /// Accepted Condition for the Route to `status: False`, with a + /// Reason of `UnsupportedValue`. + #[serde(rename = "type")] + pub r#type: HTTPFilterType, + /// URLRewrite defines a schema for a filter that modifies a request during forwarding. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "urlRewrite" + )] + pub url_rewrite: Option, +} +/// CORS defines a schema for a filter that responds to the +/// cross-origin request based on HTTP response header. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesBackendRefsFiltersCors { + /// AllowCredentials indicates whether the actual cross-origin request allows + /// to include credentials. + /// + /// When set to true, the gateway will include the `Access-Control-Allow-Credentials` + /// response header with value true (case-sensitive). + /// + /// When set to false or omitted the gateway will omit the header + /// `Access-Control-Allow-Credentials` entirely (this is the standard CORS + /// behavior). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowCredentials" + )] + pub allow_credentials: Option, + /// AllowHeaders indicates which HTTP request headers are supported for + /// accessing the requested resource. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Allow-Headers` + /// response header are separated by a comma (","). + /// + /// When the `AllowHeaders` field is configured with one or more headers, the + /// gateway must return the `Access-Control-Allow-Headers` response header + /// which value is present in the `AllowHeaders` field. + /// + /// If any header name in the `Access-Control-Request-Headers` request header + /// is not included in the list of header names specified by the response + /// header `Access-Control-Allow-Headers`, it will present an error on the + /// client side. + /// + /// If any header name in the `Access-Control-Allow-Headers` response header + /// does not recognize by the client, it will also occur an error on the + /// client side. + /// + /// A wildcard indicates that the requests with all HTTP headers are allowed. + /// If config contains the wildcard "*" in allowHeaders and the request is + /// not credentialed, the `Access-Control-Allow-Headers` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Headers from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Headers` response header. When + /// also the `AllowCredentials` field is true and `AllowHeaders` field + /// is specified with the `*` wildcard, the gateway must specify one or more + /// HTTP headers in the value of the `Access-Control-Allow-Headers` response + /// header. The value of the header `Access-Control-Allow-Headers` is same as + /// the `Access-Control-Request-Headers` header provided by the client. If + /// the header `Access-Control-Request-Headers` is not included in the + /// request, the gateway will omit the `Access-Control-Allow-Headers` + /// response header, instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowHeaders" + )] + pub allow_headers: Option>, + /// AllowMethods indicates which HTTP methods are supported for accessing the + /// requested resource. + /// + /// Valid values are any method defined by RFC9110, along with the special + /// value `*`, which represents all HTTP methods are allowed. + /// + /// Method names are case-sensitive, so these values are also case-sensitive. + /// (See + /// + /// Multiple method names in the value of the `Access-Control-Allow-Methods` + /// response header are separated by a comma (","). + /// + /// A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`. + /// (See The + /// CORS-safelisted methods are always allowed, regardless of whether they + /// are specified in the `AllowMethods` field. + /// + /// When the `AllowMethods` field is configured with one or more methods, the + /// gateway must return the `Access-Control-Allow-Methods` response header + /// which value is present in the `AllowMethods` field. + /// + /// If the HTTP method of the `Access-Control-Request-Method` request header + /// is not included in the list of methods specified by the response header + /// `Access-Control-Allow-Methods`, it will present an error on the client + /// side. + /// + /// If config contains the wildcard "*" in allowMethods and the request is + /// not credentialed, the `Access-Control-Allow-Methods` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Method from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Methods` response header. When + /// also the `AllowCredentials` field is true and `AllowMethods` field + /// specified with the `*` wildcard, the gateway must specify one HTTP method + /// in the value of the Access-Control-Allow-Methods response header. The + /// value of the header `Access-Control-Allow-Methods` is same as the + /// `Access-Control-Request-Method` header provided by the client. If the + /// header `Access-Control-Request-Method` is not included in the request, + /// the gateway will omit the `Access-Control-Allow-Methods` response header, + /// instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowMethods" + )] + pub allow_methods: Option>, + /// AllowOrigins indicates whether the response can be shared with requested + /// resource from the given `Origin`. + /// + /// The `Origin` consists of a scheme and a host, with an optional port, and + /// takes the form `://(:)`. + /// + /// Valid values for scheme are: `http` and `https`. + /// + /// Valid values for port are any integer between 1 and 65535 (the list of + /// available TCP/UDP ports). Note that, if not included, port `80` is + /// assumed for `http` scheme origins, and port `443` is assumed for `https` + /// origins. This may affect origin matching. + /// + /// The host part of the origin may contain the wildcard character `*`. These + /// wildcard characters behave as follows: + /// + /// * `*` is a greedy match to the _left_, including any number of + /// DNS labels to the left of its position. This also means that + /// `*` will include any number of period `.` characters to the + /// left of its position. + /// * A wildcard by itself matches all hosts. + /// + /// An origin value that includes _only_ the `*` character indicates requests + /// from all `Origin`s are allowed. + /// + /// When the `AllowOrigins` field is configured with multiple origins, it + /// means the server supports clients from multiple origins. If the request + /// `Origin` matches the configured allowed origins, the gateway must return + /// the given `Origin` and sets value of the header + /// `Access-Control-Allow-Origin` same as the `Origin` header provided by the + /// client. + /// + /// The status code of a successful response to a "preflight" request is + /// always an OK status (i.e., 204 or 200). + /// + /// If the request `Origin` does not match the configured allowed origins, + /// the gateway returns 204/200 response but doesn't set the relevant + /// cross-origin response headers. Alternatively, the gateway responds with + /// 403 status to the "preflight" request is denied, coupled with omitting + /// the CORS headers. The cross-origin request fails on the client side. + /// Therefore, the client doesn't attempt the actual cross-origin request. + /// + /// Conversely, if the request `Origin` matches one of the configured + /// allowed origins, the gateway sets the response header + /// `Access-Control-Allow-Origin` to the same value as the `Origin` + /// header provided by the client. + /// + /// When config has the wildcard ("*") in allowOrigins, and the request + /// is not credentialed (e.g., it is a preflight request), the + /// `Access-Control-Allow-Origin` response header either contains the + /// wildcard as well or the Origin from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Origin` response header. When + /// also the `AllowCredentials` field is true and `AllowOrigins` field + /// specified with the `*` wildcard, the gateway must return a single origin + /// in the value of the `Access-Control-Allow-Origin` response header, + /// instead of specifying the `*` wildcard. The value of the header + /// `Access-Control-Allow-Origin` is same as the `Origin` header provided by + /// the client. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowOrigins" + )] + pub allow_origins: Option>, + /// ExposeHeaders indicates which HTTP response headers can be exposed + /// to client-side scripts in response to a cross-origin request. + /// + /// A CORS-safelisted response header is an HTTP header in a CORS response + /// that it is considered safe to expose to the client scripts. + /// The CORS-safelisted response headers include the following headers: + /// `Cache-Control` + /// `Content-Language` + /// `Content-Length` + /// `Content-Type` + /// `Expires` + /// `Last-Modified` + /// `Pragma` + /// (See + /// The CORS-safelisted response headers are exposed to client by default. + /// + /// When an HTTP header name is specified using the `ExposeHeaders` field, + /// this additional header will be exposed as part of the response to the + /// client. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Expose-Headers` + /// response header are separated by a comma (","). + /// + /// A wildcard indicates that the responses with all HTTP headers are exposed + /// to clients. The `Access-Control-Expose-Headers` response header can only + /// use `*` wildcard as value when the request is not credentialed. + /// + /// When the `exposeHeaders` config field contains the "*" wildcard and + /// the request is credentialed, the gateway cannot use the `*` wildcard in + /// the `Access-Control-Expose-Headers` response header. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "exposeHeaders" + )] + pub expose_headers: Option>, + /// MaxAge indicates the duration (in seconds) for the client to cache the + /// results of a "preflight" request. + /// + /// The information provided by the `Access-Control-Allow-Methods` and + /// `Access-Control-Allow-Headers` response headers can be cached by the + /// client until the time specified by `Access-Control-Max-Age` elapses. + /// + /// The default value of `Access-Control-Max-Age` response header is 5 + /// (seconds). + /// + /// When the `MaxAge` field is unspecified, the gateway sets the response + /// header "Access-Control-Max-Age: 5" by default. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] + pub max_age: Option, +} +/// HTTPRouteFilter defines processing steps that must be completed during the +/// request or response lifecycle. HTTPRouteFilters are meant as an extension +/// point to express processing that may be done in Gateway implementations. Some +/// examples include request or response modification, implementing +/// authentication strategies, rate-limiting, and traffic shaping. API +/// guarantee/conformance is defined based on the type of the filter. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteFilter { + /// CORS defines a schema for a filter that responds to the + /// cross-origin request based on HTTP response header. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cors: Option, + /// ExtensionRef is an optional, implementation-specific extension to the + /// "filter" behavior. For example, resource "myroutefilter" in group + /// "networking.example.net"). ExtensionRef MUST NOT be used for core and + /// extended filters. + /// + /// This filter can be used multiple times within the same rule. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + /// RequestHeaderModifier defines a schema for a filter that modifies request + /// headers. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + /// RequestMirror defines a schema for a filter that mirrors requests. + /// Requests are sent to the specified destination, but responses from + /// that destination are ignored. + /// + /// This filter can be used multiple times within the same rule. Note that + /// not all implementations will be able to support mirroring to multiple + /// backends. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + /// RequestRedirect defines a schema for a filter that responds to the + /// request with an HTTP redirection. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestRedirect" + )] + pub request_redirect: Option, + /// ResponseHeaderModifier defines a schema for a filter that modifies response + /// headers. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + /// Type identifies the type of filter to apply. As with other API fields, + /// types are classified into three conformance levels: + /// + /// - Core: Filter types and their corresponding configuration defined by + /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All + /// implementations must support core filters. + /// + /// - Extended: Filter types and their corresponding configuration defined by + /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers + /// are encouraged to support extended filters. + /// + /// - Implementation-specific: Filters that are defined and supported by + /// specific vendors. + /// In the future, filters showing convergence in behavior across multiple + /// implementations will be considered for inclusion in extended or core + /// conformance levels. Filter-specific configuration for such filters + /// is specified using the ExtensionRef field. `Type` should be set to + /// "ExtensionRef" for custom filters. + /// + /// Implementers are encouraged to define custom implementation types to + /// extend the core API with implementation-specific behavior. + /// + /// If a reference to a custom filter type cannot be resolved, the filter + /// MUST NOT be skipped. Instead, requests that would have been processed by + /// that filter MUST receive a HTTP error response. + /// + /// Note that values may be added to this enum, implementations + /// must ensure that unknown values will not cause a crash. + /// + /// Unknown values here must result in the implementation setting the + /// Accepted Condition for the Route to `status: False`, with a + /// Reason of `UnsupportedValue`. + #[serde(rename = "type")] + pub r#type: HTTPFilterType, + /// URLRewrite defines a schema for a filter that modifies a request during forwarding. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "urlRewrite" + )] + pub url_rewrite: Option, +} +/// CORS defines a schema for a filter that responds to the +/// cross-origin request based on HTTP response header. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesFiltersCors { + /// AllowCredentials indicates whether the actual cross-origin request allows + /// to include credentials. + /// + /// When set to true, the gateway will include the `Access-Control-Allow-Credentials` + /// response header with value true (case-sensitive). + /// + /// When set to false or omitted the gateway will omit the header + /// `Access-Control-Allow-Credentials` entirely (this is the standard CORS + /// behavior). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowCredentials" + )] + pub allow_credentials: Option, + /// AllowHeaders indicates which HTTP request headers are supported for + /// accessing the requested resource. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Allow-Headers` + /// response header are separated by a comma (","). + /// + /// When the `AllowHeaders` field is configured with one or more headers, the + /// gateway must return the `Access-Control-Allow-Headers` response header + /// which value is present in the `AllowHeaders` field. + /// + /// If any header name in the `Access-Control-Request-Headers` request header + /// is not included in the list of header names specified by the response + /// header `Access-Control-Allow-Headers`, it will present an error on the + /// client side. + /// + /// If any header name in the `Access-Control-Allow-Headers` response header + /// does not recognize by the client, it will also occur an error on the + /// client side. + /// + /// A wildcard indicates that the requests with all HTTP headers are allowed. + /// If config contains the wildcard "*" in allowHeaders and the request is + /// not credentialed, the `Access-Control-Allow-Headers` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Headers from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Headers` response header. When + /// also the `AllowCredentials` field is true and `AllowHeaders` field + /// is specified with the `*` wildcard, the gateway must specify one or more + /// HTTP headers in the value of the `Access-Control-Allow-Headers` response + /// header. The value of the header `Access-Control-Allow-Headers` is same as + /// the `Access-Control-Request-Headers` header provided by the client. If + /// the header `Access-Control-Request-Headers` is not included in the + /// request, the gateway will omit the `Access-Control-Allow-Headers` + /// response header, instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowHeaders" + )] + pub allow_headers: Option>, + /// AllowMethods indicates which HTTP methods are supported for accessing the + /// requested resource. + /// + /// Valid values are any method defined by RFC9110, along with the special + /// value `*`, which represents all HTTP methods are allowed. + /// + /// Method names are case-sensitive, so these values are also case-sensitive. + /// (See + /// + /// Multiple method names in the value of the `Access-Control-Allow-Methods` + /// response header are separated by a comma (","). + /// + /// A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`. + /// (See The + /// CORS-safelisted methods are always allowed, regardless of whether they + /// are specified in the `AllowMethods` field. + /// + /// When the `AllowMethods` field is configured with one or more methods, the + /// gateway must return the `Access-Control-Allow-Methods` response header + /// which value is present in the `AllowMethods` field. + /// + /// If the HTTP method of the `Access-Control-Request-Method` request header + /// is not included in the list of methods specified by the response header + /// `Access-Control-Allow-Methods`, it will present an error on the client + /// side. + /// + /// If config contains the wildcard "*" in allowMethods and the request is + /// not credentialed, the `Access-Control-Allow-Methods` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Method from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Methods` response header. When + /// also the `AllowCredentials` field is true and `AllowMethods` field + /// specified with the `*` wildcard, the gateway must specify one HTTP method + /// in the value of the Access-Control-Allow-Methods response header. The + /// value of the header `Access-Control-Allow-Methods` is same as the + /// `Access-Control-Request-Method` header provided by the client. If the + /// header `Access-Control-Request-Method` is not included in the request, + /// the gateway will omit the `Access-Control-Allow-Methods` response header, + /// instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowMethods" + )] + pub allow_methods: Option>, + /// AllowOrigins indicates whether the response can be shared with requested + /// resource from the given `Origin`. + /// + /// The `Origin` consists of a scheme and a host, with an optional port, and + /// takes the form `://(:)`. + /// + /// Valid values for scheme are: `http` and `https`. + /// + /// Valid values for port are any integer between 1 and 65535 (the list of + /// available TCP/UDP ports). Note that, if not included, port `80` is + /// assumed for `http` scheme origins, and port `443` is assumed for `https` + /// origins. This may affect origin matching. + /// + /// The host part of the origin may contain the wildcard character `*`. These + /// wildcard characters behave as follows: + /// + /// * `*` is a greedy match to the _left_, including any number of + /// DNS labels to the left of its position. This also means that + /// `*` will include any number of period `.` characters to the + /// left of its position. + /// * A wildcard by itself matches all hosts. + /// + /// An origin value that includes _only_ the `*` character indicates requests + /// from all `Origin`s are allowed. + /// + /// When the `AllowOrigins` field is configured with multiple origins, it + /// means the server supports clients from multiple origins. If the request + /// `Origin` matches the configured allowed origins, the gateway must return + /// the given `Origin` and sets value of the header + /// `Access-Control-Allow-Origin` same as the `Origin` header provided by the + /// client. + /// + /// The status code of a successful response to a "preflight" request is + /// always an OK status (i.e., 204 or 200). + /// + /// If the request `Origin` does not match the configured allowed origins, + /// the gateway returns 204/200 response but doesn't set the relevant + /// cross-origin response headers. Alternatively, the gateway responds with + /// 403 status to the "preflight" request is denied, coupled with omitting + /// the CORS headers. The cross-origin request fails on the client side. + /// Therefore, the client doesn't attempt the actual cross-origin request. + /// + /// Conversely, if the request `Origin` matches one of the configured + /// allowed origins, the gateway sets the response header + /// `Access-Control-Allow-Origin` to the same value as the `Origin` + /// header provided by the client. + /// + /// When config has the wildcard ("*") in allowOrigins, and the request + /// is not credentialed (e.g., it is a preflight request), the + /// `Access-Control-Allow-Origin` response header either contains the + /// wildcard as well or the Origin from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Origin` response header. When + /// also the `AllowCredentials` field is true and `AllowOrigins` field + /// specified with the `*` wildcard, the gateway must return a single origin + /// in the value of the `Access-Control-Allow-Origin` response header, + /// instead of specifying the `*` wildcard. The value of the header + /// `Access-Control-Allow-Origin` is same as the `Origin` header provided by + /// the client. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowOrigins" + )] + pub allow_origins: Option>, + /// ExposeHeaders indicates which HTTP response headers can be exposed + /// to client-side scripts in response to a cross-origin request. + /// + /// A CORS-safelisted response header is an HTTP header in a CORS response + /// that it is considered safe to expose to the client scripts. + /// The CORS-safelisted response headers include the following headers: + /// `Cache-Control` + /// `Content-Language` + /// `Content-Length` + /// `Content-Type` + /// `Expires` + /// `Last-Modified` + /// `Pragma` + /// (See + /// The CORS-safelisted response headers are exposed to client by default. + /// + /// When an HTTP header name is specified using the `ExposeHeaders` field, + /// this additional header will be exposed as part of the response to the + /// client. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Expose-Headers` + /// response header are separated by a comma (","). + /// + /// A wildcard indicates that the responses with all HTTP headers are exposed + /// to clients. The `Access-Control-Expose-Headers` response header can only + /// use `*` wildcard as value when the request is not credentialed. + /// + /// When the `exposeHeaders` config field contains the "*" wildcard and + /// the request is credentialed, the gateway cannot use the `*` wildcard in + /// the `Access-Control-Expose-Headers` response header. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "exposeHeaders" + )] + pub expose_headers: Option>, + /// MaxAge indicates the duration (in seconds) for the client to cache the + /// results of a "preflight" request. + /// + /// The information provided by the `Access-Control-Allow-Methods` and + /// `Access-Control-Allow-Headers` response headers can be cached by the + /// client until the time specified by `Access-Control-Max-Age` elapses. + /// + /// The default value of `Access-Control-Max-Age` response header is 5 + /// (seconds). + /// + /// When the `MaxAge` field is unspecified, the gateway sets the response + /// header "Access-Control-Max-Age: 5" by default. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] + pub max_age: Option, +} +/// HTTPRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a HTTP request only if its path +/// starts with `/foo` AND it contains the `version: v1` header: +/// +/// ```text +/// match: +/// +/// path: +/// value: "/foo" +/// headers: +/// - name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RouteMatch { + /// Headers specifies HTTP request header matchers. Multiple match values are + /// ANDed together, meaning, a request must match all the specified headers + /// to select the route. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub headers: Option>, + /// Method specifies HTTP method matcher. + /// When specified, this route will be matched only if the request has the + /// specified method. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, + /// Path specifies a HTTP request path matcher. If this field is not + /// specified, a default prefix match on the "/" path is provided. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, + /// QueryParams specifies HTTP query parameter matchers. Multiple match + /// values are ANDed together, meaning, a request must match all the + /// specified query parameters to select the route. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "queryParams" + )] + pub query_params: Option>, +} +/// HTTPRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a HTTP request only if its path +/// starts with `/foo` AND it contains the `version: v1` header: +/// +/// ```text +/// match: +/// +/// path: +/// value: "/foo" +/// headers: +/// - name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HTTPMethodMatch { + #[serde(rename = "GET")] + Get, + #[serde(rename = "HEAD")] + Head, + #[serde(rename = "POST")] + Post, + #[serde(rename = "PUT")] + Put, + #[serde(rename = "DELETE")] + Delete, + #[serde(rename = "CONNECT")] + Connect, + #[serde(rename = "OPTIONS")] + Options, + #[serde(rename = "TRACE")] + Trace, + #[serde(rename = "PATCH")] + Patch, +} +/// Path specifies a HTTP request path matcher. If this field is not +/// specified, a default prefix match on the "/" path is provided. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct PathMatch { + /// Type specifies how to match against the path Value. + /// + /// Support: Core (Exact, PathPrefix) + /// + /// Support: Implementation-specific (RegularExpression) + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// Value of the HTTP path to match against. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, +} +/// Path specifies a HTTP request path matcher. If this field is not +/// specified, a default prefix match on the "/" path is provided. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HttpRouteRulesMatchesPathType { + Exact, + PathPrefix, + RegularExpression, +} +/// Timeouts defines the timeouts that can be configured for an HTTP request. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteTimeout { + /// BackendRequest specifies a timeout for an individual request from the gateway + /// to a backend. This covers the time from when the request first starts being + /// sent from the gateway to when the full response has been received from the backend. + /// + /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout + /// completely. Implementations that cannot completely disable the timeout MUST + /// instead interpret the zero duration as the longest possible value to which + /// the timeout can be set. + /// + /// An entire client HTTP transaction with a gateway, covered by the Request timeout, + /// may result in more than one call from the gateway to the destination backend, + /// for example, if automatic retries are supported. + /// + /// The value of BackendRequest must be a Gateway API Duration string as defined by + /// GEP-2257. When this field is unspecified, its behavior is implementation-specific; + /// when specified, the value of BackendRequest must be no more than the value of the + /// Request timeout (since the Request timeout encompasses the BackendRequest timeout). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRequest" + )] + pub backend_request: Option, + /// Request specifies the maximum duration for a gateway to respond to an HTTP request. + /// If the gateway has not been able to respond before this deadline is met, the gateway + /// MUST return a timeout error. + /// + /// For example, setting the `rules.timeouts.request` field to the value `10s` in an + /// `HTTPRoute` will cause a timeout if a client request is taking longer than 10 seconds + /// to complete. + /// + /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout + /// completely. Implementations that cannot completely disable the timeout MUST + /// instead interpret the zero duration as the longest possible value to which + /// the timeout can be set. + /// + /// This timeout is intended to cover as close to the whole request-response transaction + /// as possible although an implementation MAY choose to start the timeout after the entire + /// request stream has been received instead of immediately after the transaction is + /// initiated by the client. + /// + /// The value of Request is a Gateway API Duration string as defined by GEP-2257. When this + /// field is unspecified, request timeout behavior is implementation-specific. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub request: Option, +} diff --git a/gateway-api-with-extensions/src/standard/inferencepools.rs b/gateway-api-with-extensions/src/standard/inferencepools.rs new file mode 100644 index 0000000..c8d9d73 --- /dev/null +++ b/gateway-api-with-extensions/src/standard/inferencepools.rs @@ -0,0 +1,158 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of the InferencePool. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "inference.networking.k8s.io", + version = "v1", + kind = "InferencePool", + plural = "inferencepools" +)] +#[kube(namespaced)] +#[kube(status = "InferencePoolStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct InferencePoolSpec { + /// EndpointPickerRef is a reference to the Endpoint Picker extension and its + /// associated configuration. + #[serde(rename = "endpointPickerRef")] + pub endpoint_picker_ref: InferencePoolEndpointPickerRef, + /// Selector determines which Pods are members of this inference pool. + /// It matches Pods by their labels only within the same namespace; cross-namespace + /// selection is not supported. + /// + /// The structure of this LabelSelector is intentionally simple to be compatible + /// with Kubernetes Service selectors, as some implementations may translate + /// this configuration into a Service resource. + pub selector: InferencePoolSelector, + /// TargetPorts defines a list of ports that are exposed by this InferencePool. + /// Every port will be treated as a distinctive endpoint by EPP, + /// addressable as a 'podIP:portNumber' combination. + #[serde(rename = "targetPorts")] + pub target_ports: Vec, +} +/// EndpointPickerRef is a reference to the Endpoint Picker extension and its +/// associated configuration. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolEndpointPickerRef { + /// FailureMode configures how the parent handles the case when the Endpoint Picker extension + /// is non-responsive. When unspecified, defaults to "FailClose". + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "failureMode" + )] + pub failure_mode: Option, + /// Group is the group of the referent API object. When unspecified, the default value + /// is "", representing the Core API group. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. + /// + /// Required if the referent is ambiguous, e.g. service with multiple ports. + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations MUST NOT + /// support ExternalName Services. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent API object. + pub name: String, + /// Port is the port of the Endpoint Picker extension service. + /// + /// Port is required when the referent is a Kubernetes Service. In this + /// case, the port number is the service port number, not the target port. + /// For other resources, destination port might be derived from the referent + /// resource or this field. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, +} +/// EndpointPickerRef is a reference to the Endpoint Picker extension and its +/// associated configuration. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum InferencePoolEndpointPickerRefFailureMode { + FailOpen, + FailClose, +} +/// Selector determines which Pods are members of this inference pool. +/// It matches Pods by their labels only within the same namespace; cross-namespace +/// selection is not supported. +/// +/// The structure of this LabelSelector is intentionally simple to be compatible +/// with Kubernetes Service selectors, as some implementations may translate +/// this configuration into a Service resource. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolSelector { + /// MatchLabels contains a set of required {key,value} pairs. + /// An object must match every label in this map to be selected. + /// The matching logic is an AND operation on all entries. + #[serde(rename = "matchLabels")] + pub match_labels: BTreeMap, +} +/// Status defines the observed state of the InferencePool. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolStatus { + /// Parents is a list of parent resources, typically Gateways, that are associated with + /// the InferencePool, and the status of the InferencePool with respect to each parent. + /// + /// A controller that manages the InferencePool, must add an entry for each parent it manages + /// and remove the parent entry when the controller no longer considers the InferencePool to + /// be associated with that parent. + /// + /// A maximum of 32 parents will be represented in this list. When the list is empty, + /// it indicates that the InferencePool is not associated with any parents. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub parents: Option>, +} +/// ParentStatus defines the observed state of InferencePool from a Parent, i.e. Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferencePoolStatusParents { + /// Conditions is a list of status conditions that provide information about the observed + /// state of the InferencePool. This field is required to be set by the controller that + /// manages the InferencePool. + /// + /// Supported condition types are: + /// + /// * "Accepted" + /// * "ResolvedRefs" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// ControllerName is a domain/path string that indicates the name of the controller that + /// wrote this status. This corresponds with the GatewayClass controllerName field when the + /// parentRef references a Gateway kind. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are valid Kubernetes names: + /// + /// + /// + /// Controllers MAY populate this field when writing status. When populating this field, controllers + /// should ensure that entries to status populated with their ControllerName are cleaned up when they + /// are no longer necessary. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "controllerName" + )] + pub controller_name: Option, + /// ParentRef is used to identify the parent resource that this status + /// is associated with. It is used to match the InferencePool with the parent + /// resource, such as a Gateway. + #[serde(rename = "parentRef")] + pub parent_ref: Reference, +} diff --git a/gateway-api-with-extensions/src/standard/listenersets.rs b/gateway-api-with-extensions/src/standard/listenersets.rs new file mode 100644 index 0000000..15afda4 --- /dev/null +++ b/gateway-api-with-extensions/src/standard/listenersets.rs @@ -0,0 +1,76 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of ListenerSet. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "ListenerSet", + plural = "listenersets" +)] +#[kube(namespaced)] +#[kube(status = "ListenerSetStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct ListenerSetSpec { + /// Listeners associated with this ListenerSet. Listeners define + /// logical endpoints that are bound on this referenced parent Gateway's addresses. + /// + /// Listeners in a `Gateway` and their attached `ListenerSets` are concatenated + /// as a list when programming the underlying infrastructure. Each listener + /// name does not need to be unique across the Gateway and ListenerSets. + /// See ListenerEntry.Name for more details. + /// + /// Implementations MUST treat the parent Gateway as having the merged + /// list of all listeners from itself and attached ListenerSets using + /// the following precedence: + /// + /// 1. "parent" Gateway + /// 2. ListenerSet ordered by creation time (oldest first) + /// 3. ListenerSet ordered alphabetically by "{namespace}/{name}". + /// + /// An implementation MAY reject listeners by setting the ListenerEntryStatus + /// `Accepted` condition to False with the Reason `TooManyListeners` + /// + /// If a listener has a conflict, this will be reported in the + /// Status.ListenerEntryStatus setting the `Conflicted` condition to True. + /// + /// Implementations SHOULD be cautious about what information from the + /// parent or siblings are reported to avoid accidentally leaking + /// sensitive information that the child would not otherwise have access + /// to. This can include contents of secrets etc. + pub listeners: Vec, + /// ParentRef references the Gateway that the listeners are attached to. + #[serde(rename = "parentRef")] + pub parent_ref: Reference, +} +/// Status defines the current state of ListenerSet. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetStatus { + /// Conditions describe the current conditions of the ListenerSet. + /// + /// Implementations MUST express ListenerSet conditions using the + /// `ListenerSetConditionType` and `ListenerSetConditionReason` + /// constants so that operators and tools can converge on a common + /// vocabulary to describe ListenerSet state. + /// + /// Known condition types are: + /// + /// * "Accepted" + /// * "Programmed" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// Listeners provide status for each unique listener port defined in the Spec. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub listeners: Option>, +} diff --git a/gateway-api-with-extensions/src/standard/mod.rs b/gateway-api-with-extensions/src/standard/mod.rs new file mode 100644 index 0000000..14cdfb8 --- /dev/null +++ b/gateway-api-with-extensions/src/standard/mod.rs @@ -0,0 +1,13 @@ +// WARNING: generated file - manual changes will be overriden +pub mod backendtlspolicies; +pub mod common; +pub mod constants; +pub mod enum_defaults; +pub mod gatewayclasses; +pub mod gateways; +pub mod grpcroutes; +pub mod httproutes; +pub mod inferencepools; +pub mod listenersets; +pub mod referencegrants; +pub mod tlsroutes; diff --git a/gateway-api/src/apis/experimental/referencegrants.rs b/gateway-api-with-extensions/src/standard/referencegrants.rs similarity index 92% rename from gateway-api/src/apis/experimental/referencegrants.rs rename to gateway-api-with-extensions/src/standard/referencegrants.rs index a383a35..6eb6981 100644 --- a/gateway-api/src/apis/experimental/referencegrants.rs +++ b/gateway-api-with-extensions/src/standard/referencegrants.rs @@ -1,20 +1,17 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 +// WARNING: generated file - manual changes will be overriden #[allow(unused_imports)] mod prelude { - pub use kube::CustomResource; + pub use kube_derive::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } use self::prelude::*; - /// Spec defines the desired state of ReferenceGrant. #[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] #[kube( group = "gateway.networking.k8s.io", - version = "v1beta1", + version = "v1", kind = "ReferenceGrant", plural = "referencegrants" )] @@ -37,7 +34,6 @@ pub struct ReferenceGrantSpec { /// Support: Core pub to: Vec, } - /// ReferenceGrantFrom describes trusted namespaces and kinds. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct ReferenceGrantFrom { @@ -67,7 +63,6 @@ pub struct ReferenceGrantFrom { /// Support: Core pub namespace: String, } - /// ReferenceGrantTo describes what Kinds are allowed as targets of the /// references. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] diff --git a/gateway-api-with-extensions/src/standard/tlsroutes.rs b/gateway-api-with-extensions/src/standard/tlsroutes.rs new file mode 100644 index 0000000..f0f07d6 --- /dev/null +++ b/gateway-api-with-extensions/src/standard/tlsroutes.rs @@ -0,0 +1,185 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of TLSRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "TLSRoute", + plural = "tlsroutes" +)] +#[kube(namespaced)] +#[kube(status = "RouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct TlsRouteSpec { + /// Hostnames defines a set of SNI hostnames that should match against the + /// SNI attribute of TLS ClientHello message in TLS handshake. This matches + /// the RFC 1123 definition of a hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed in SNI hostnames per RFC 6066. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label must appear by itself as the first label. + pub hostnames: Vec, + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of actions. + pub rules: Vec, +} +/// TLSRouteRule is the configuration for a given rule. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TlsRouteRules { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. If unspecified or invalid (refers to a nonexistent resource or + /// a Service with no endpoints), the rule performs no forwarding; if no + /// filters are specified that would result in a response being sent, the + /// underlying implementation must actively reject request attempts to this + /// backend, by rejecting the connection. Request rejections must respect + /// weight; if an invalid backend is requested to have 80% of requests, then + /// 80% of requests must be rejected instead. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Extended + #[serde(rename = "backendRefs")] + pub backend_refs: Vec, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} +/// BackendRef defines how a Route should forward a request to a Kubernetes +/// resource. +/// +/// Note that when a namespace different than the local namespace is specified, a +/// ReferenceGrant object is required in the referent namespace to allow that +/// namespace's owner to accept the reference. See the ReferenceGrant +/// documentation for details. +/// +/// Note that when the BackendTLSPolicy object is enabled by the implementation, +/// there are some extra rules about validity to consider here. See the fields +/// where this struct is used for more information about the exact behavior. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TlsRouteRulesBackendRefs { + /// Group is the group of the referent. For example, "gateway.networking.k8s.io". + /// When unspecified or empty string, core API group is inferred. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. For example + /// "Service". + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations SHOULD NOT + /// support ExternalName Services. + /// + /// Support: Core (Services with a type other than ExternalName) + /// + /// Support: Implementation-specific (Services with type ExternalName) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent. + pub name: String, + /// Namespace is the namespace of the backend. When unspecified, the local + /// namespace is inferred. + /// + /// Note that when a namespace different than the local namespace is specified, + /// a ReferenceGrant object is required in the referent namespace to allow that + /// namespace's owner to accept the reference. See the ReferenceGrant + /// documentation for details. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + /// Port specifies the destination port number to use for this resource. + /// Port is required when the referent is a Kubernetes Service. In this + /// case, the port number is the service port number, not the target port. + /// For other resources, destination port might be derived from the referent + /// resource or this field. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + /// Weight specifies the proportion of requests forwarded to the referenced + /// backend. This is computed as weight/(sum of all weights in this + /// BackendRefs list). For non-zero values, there may be some epsilon from + /// the exact proportion defined here depending on the precision an + /// implementation supports. Weight is not a percentage and the sum of + /// weights does not need to equal 100. + /// + /// If only one backend is specified and it has a weight greater than 0, 100% + /// of the traffic is forwarded to that backend. If weight is set to 0, no + /// traffic should be forwarded for this entry. If unspecified, weight + /// defaults to 1. + /// + /// Support for this field varies based on the context where used. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} diff --git a/gateway-api/CHANGELOG.md b/gateway-api/CHANGELOG.md new file mode 100644 index 0000000..6b69549 --- /dev/null +++ b/gateway-api/CHANGELOG.md @@ -0,0 +1,42 @@ +# Changelog + +## Next + +Supports: Gateway API `v1.4.0` + +>[!IMPORTANT] +Breaking change + +### Breaking Changes + +* The structure of APIs has changed to promote the re-use of types in the generated code. The APIs are still generated with Kopium in the first step, but there is a second stage where additional task is executed to reduce and rename the Kopium-generated types. While with this approach we can significantly reduce the surface of exposed APIs, it is also a breaking change. See [issue](https://github.com/kube-rs/gateway-api-rs/issues/38) for more context. + +### Changes + +* Updated to [kube](https://github.com/kube-rs/kube) `v2.0.1` +* Updated to Gateway API `v1.4.0` + +## 0.19.0 + +Supports: Gateway API `v1.4.0` + +### Changes + +* Updated to Gateway API `v1.4.0` +* Adds support for `BackendTLSPolicy` + +## 0.18.0 + +Supports: Gateway API `v1.2.1` + +### Changes + +* Updated to [kube](https://github.com/kube-rs/kube) `v2.0.1` + +## 0.16.0 + +Supports: Gateway API `v1.2.1` + +### Changes + +Initial release. All types are generated with Kopium. diff --git a/gateway-api/Cargo.toml b/gateway-api/Cargo.toml index 81cef86..65b870c 100644 --- a/gateway-api/Cargo.toml +++ b/gateway-api/Cargo.toml @@ -7,36 +7,47 @@ keywords = ["kubernetes", "gateway-api"] homepage = "https://docs.rs/crate/gateway-api/" readme = "../README.md" repository = "https://github.com/kube-rs/gateway-api-rs" +version = "0.150.0" authors.workspace = true edition.workspace = true license.workspace = true -version.workspace = true + [dependencies] delegate.workspace = true k8s-openapi = { workspace = true, features = ["schemars"] } -kube = { workspace = true, features = ["derive"] } +kube = { workspace = true, default-features = false, features = [] } +kube-core = { workspace = true, features = ["schema"] } +kube-derive.workspace = true once_cell.workspace = true regex.workspace = true schemars.workspace = true serde_json.workspace = true serde.workspace = true serde_yaml.workspace = true +cfg-if.workspace = true -[dev-dependencies] -k8s-openapi = { workspace = true, features = ["v1_32", "schemars"] } -kube = { workspace = true, features = ["derive"] } +# [dev-dependencies] +# k8s-openapi = { workspace = true, features = ["v1_33", "schemars"] } +# kube = { workspace = true, features = ["client", "rustls-tls", "ring"] } -anyhow.workspace = true -hyper-util.workspace = true -tokio.workspace = true -tower.workspace = true -uuid.workspace = true +# anyhow.workspace = true +# hyper-util.workspace = true +# tokio.workspace = true +# tower.workspace = true +# uuid.workspace = true -[package.metadata.docs.rs] -features = ["k8s-openapi/v1_32"] [features] -default = [] -experimental = [] +default = ["standard"] +standard = [] +experimental=[] + + + +[lints.clippy] +derivable_impls = "allow" +doc_lazy_continuation = "allow" +tabs_in_doc_comments = "allow" +empty_line_after_doc_comments = "allow" diff --git a/gateway-api/examples/Cargo.toml b/gateway-api/examples/Cargo.toml index e28efe8..fb392c9 100644 --- a/gateway-api/examples/Cargo.toml +++ b/gateway-api/examples/Cargo.toml @@ -16,7 +16,6 @@ gateway-api = { path = "../" } anyhow.workspace = true hyper-util.workspace = true k8s-openapi.workspace = true -kube.workspace = true serde_json.workspace = true tokio.workspace = true tower.workspace = true @@ -25,7 +24,7 @@ tracing-subscriber.workspace = true uuid.workspace = true [features] -default = [ "k8s-openapi/v1_32" ] +default = [ "k8s-openapi/v1_33" ] [[bin]] name = "gep2257" diff --git a/gateway-api/src/apis/experimental/enum_defaults.rs b/gateway-api/src/apis/experimental/enum_defaults.rs deleted file mode 100644 index 3fee275..0000000 --- a/gateway-api/src/apis/experimental/enum_defaults.rs +++ /dev/null @@ -1,58 +0,0 @@ -// WARNING: generated file - manual changes will be overriden - -use super::httproutes::{ - HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType, HTTPRouteRulesBackendRefsFiltersType, - HTTPRouteRulesBackendRefsFiltersUrlRewritePathType, - HTTPRouteRulesFiltersRequestRedirectPathType, HTTPRouteRulesFiltersType, - HTTPRouteRulesFiltersUrlRewritePathType, -}; - -use super::grpcroutes::{GRPCRouteRulesBackendRefsFiltersType, GRPCRouteRulesFiltersType}; - -impl Default for GRPCRouteRulesBackendRefsFiltersType { - fn default() -> Self { - GRPCRouteRulesBackendRefsFiltersType::RequestHeaderModifier - } -} - -impl Default for GRPCRouteRulesFiltersType { - fn default() -> Self { - GRPCRouteRulesFiltersType::RequestHeaderModifier - } -} - -impl Default for HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType { - fn default() -> Self { - HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType::ReplaceFullPath - } -} - -impl Default for HTTPRouteRulesBackendRefsFiltersType { - fn default() -> Self { - HTTPRouteRulesBackendRefsFiltersType::RequestHeaderModifier - } -} - -impl Default for HTTPRouteRulesBackendRefsFiltersUrlRewritePathType { - fn default() -> Self { - HTTPRouteRulesBackendRefsFiltersUrlRewritePathType::ReplaceFullPath - } -} - -impl Default for HTTPRouteRulesFiltersRequestRedirectPathType { - fn default() -> Self { - HTTPRouteRulesFiltersRequestRedirectPathType::ReplaceFullPath - } -} - -impl Default for HTTPRouteRulesFiltersType { - fn default() -> Self { - HTTPRouteRulesFiltersType::RequestHeaderModifier - } -} - -impl Default for HTTPRouteRulesFiltersUrlRewritePathType { - fn default() -> Self { - HTTPRouteRulesFiltersUrlRewritePathType::ReplaceFullPath - } -} diff --git a/gateway-api/src/apis/experimental/gateways.rs b/gateway-api/src/apis/experimental/gateways.rs deleted file mode 100644 index fa590f4..0000000 --- a/gateway-api/src/apis/experimental/gateways.rs +++ /dev/null @@ -1,878 +0,0 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 - -#[allow(unused_imports)] -mod prelude { - pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube::CustomResource; - pub use schemars::JsonSchema; - pub use serde::{Deserialize, Serialize}; - pub use std::collections::BTreeMap; -} -use self::prelude::*; - -/// Spec defines the desired state of Gateway. -#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -#[kube( - group = "gateway.networking.k8s.io", - version = "v1", - kind = "Gateway", - plural = "gateways" -)] -#[kube(namespaced)] -#[kube(status = "GatewayStatus")] -#[kube(derive = "Default")] -#[kube(derive = "PartialEq")] -pub struct GatewaySpec { - /// Addresses requested for this Gateway. This is optional and behavior can - /// depend on the implementation. If a value is set in the spec and the - /// requested address is invalid or unavailable, the implementation MUST - /// indicate this in the associated entry in GatewayStatus.Addresses. - /// - /// The Addresses field represents a request for the address(es) on the - /// "outside of the Gateway", that traffic bound for this Gateway will use. - /// This could be the IP address or hostname of an external load balancer or - /// other networking infrastructure, or some other address that traffic will - /// be sent to. - /// - /// If no Addresses are specified, the implementation MAY schedule the - /// Gateway in an implementation-specific manner, assigning an appropriate - /// set of Addresses. - /// - /// The implementation MUST bind all Listeners to every GatewayAddress that - /// it assigns to the Gateway and add a corresponding entry in - /// GatewayStatus.Addresses. - /// - /// Support: Extended - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub addresses: Option>, - /// BackendTLS configures TLS settings for when this Gateway is connecting to - /// backends with TLS. - /// - /// Support: Core - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "backendTLS" - )] - pub backend_tls: Option, - /// GatewayClassName used for this Gateway. This is the name of a - /// GatewayClass resource. - #[serde(rename = "gatewayClassName")] - pub gateway_class_name: String, - /// Infrastructure defines infrastructure level attributes about this Gateway instance. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub infrastructure: Option, - /// Listeners associated with this Gateway. Listeners define - /// logical endpoints that are bound on this Gateway's addresses. - /// At least one Listener MUST be specified. - /// - /// Each Listener in a set of Listeners (for example, in a single Gateway) - /// MUST be _distinct_, in that a traffic flow MUST be able to be assigned to - /// exactly one listener. (This section uses "set of Listeners" rather than - /// "Listeners in a single Gateway" because implementations MAY merge configuration - /// from multiple Gateways onto a single data plane, and these rules _also_ - /// apply in that case). - /// - /// Practically, this means that each listener in a set MUST have a unique - /// combination of Port, Protocol, and, if supported by the protocol, Hostname. - /// - /// Some combinations of port, protocol, and TLS settings are considered - /// Core support and MUST be supported by implementations based on their - /// targeted conformance profile: - /// - /// HTTP Profile - /// - /// 1. HTTPRoute, Port: 80, Protocol: HTTP - /// 2. HTTPRoute, Port: 443, Protocol: HTTPS, TLS Mode: Terminate, TLS keypair provided - /// - /// TLS Profile - /// - /// 1. TLSRoute, Port: 443, Protocol: TLS, TLS Mode: Passthrough - /// - /// "Distinct" Listeners have the following property: - /// - /// The implementation can match inbound requests to a single distinct - /// Listener. When multiple Listeners share values for fields (for - /// example, two Listeners with the same Port value), the implementation - /// can match requests to only one of the Listeners using other - /// Listener fields. - /// - /// For example, the following Listener scenarios are distinct: - /// - /// 1. Multiple Listeners with the same Port that all use the "HTTP" - /// Protocol that all have unique Hostname values. - /// 2. Multiple Listeners with the same Port that use either the "HTTPS" or - /// "TLS" Protocol that all have unique Hostname values. - /// 3. A mixture of "TCP" and "UDP" Protocol Listeners, where no Listener - /// with the same Protocol has the same Port value. - /// - /// Some fields in the Listener struct have possible values that affect - /// whether the Listener is distinct. Hostname is particularly relevant - /// for HTTP or HTTPS protocols. - /// - /// When using the Hostname value to select between same-Port, same-Protocol - /// Listeners, the Hostname value must be different on each Listener for the - /// Listener to be distinct. - /// - /// When the Listeners are distinct based on Hostname, inbound request - /// hostnames MUST match from the most specific to least specific Hostname - /// values to choose the correct Listener and its associated set of Routes. - /// - /// Exact matches must be processed before wildcard matches, and wildcard - /// matches must be processed before fallback (empty Hostname value) - /// matches. For example, `"foo.example.com"` takes precedence over - /// `"*.example.com"`, and `"*.example.com"` takes precedence over `""`. - /// - /// Additionally, if there are multiple wildcard entries, more specific - /// wildcard entries must be processed before less specific wildcard entries. - /// For example, `"*.foo.example.com"` takes precedence over `"*.example.com"`. - /// The precise definition here is that the higher the number of dots in the - /// hostname to the right of the wildcard character, the higher the precedence. - /// - /// The wildcard character will match any number of characters _and dots_ to - /// the left, however, so `"*.example.com"` will match both - /// `"foo.bar.example.com"` _and_ `"bar.example.com"`. - /// - /// If a set of Listeners contains Listeners that are not distinct, then those - /// Listeners are Conflicted, and the implementation MUST set the "Conflicted" - /// condition in the Listener Status to "True". - /// - /// Implementations MAY choose to accept a Gateway with some Conflicted - /// Listeners only if they only accept the partial Listener set that contains - /// no Conflicted Listeners. To put this another way, implementations may - /// accept a partial Listener set only if they throw out *all* the conflicting - /// Listeners. No picking one of the conflicting listeners as the winner. - /// This also means that the Gateway must have at least one non-conflicting - /// Listener in this case, otherwise it violates the requirement that at - /// least one Listener must be present. - /// - /// The implementation MUST set a "ListenersNotValid" condition on the - /// Gateway Status when the Gateway contains Conflicted Listeners whether or - /// not they accept the Gateway. That Condition SHOULD clearly - /// indicate in the Message which Listeners are conflicted, and which are - /// Accepted. Additionally, the Listener status for those listeners SHOULD - /// indicate which Listeners are conflicted and not Accepted. - /// - /// A Gateway's Listeners are considered "compatible" if: - /// - /// 1. They are distinct. - /// 2. The implementation can serve them in compliance with the Addresses - /// requirement that all Listeners are available on all assigned - /// addresses. - /// - /// Compatible combinations in Extended support are expected to vary across - /// implementations. A combination that is compatible for one implementation - /// may not be compatible for another. - /// - /// For example, an implementation that cannot serve both TCP and UDP listeners - /// on the same address, or cannot mix HTTPS and generic TLS listens on the same port - /// would not consider those cases compatible, even though they are distinct. - /// - /// Note that requests SHOULD match at most one Listener. For example, if - /// Listeners are defined for "foo.example.com" and "*.example.com", a - /// request to "foo.example.com" SHOULD only be routed using routes attached - /// to the "foo.example.com" Listener (and not the "*.example.com" Listener). - /// This concept is known as "Listener Isolation". Implementations that do - /// not support Listener Isolation MUST clearly document this. - /// - /// Implementations MAY merge separate Gateways onto a single set of - /// Addresses if all Listeners across all Gateways are compatible. - /// - /// Support: Core - pub listeners: Vec, -} - -/// GatewayAddress describes an address that can be bound to a Gateway. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayAddresses { - /// Type of the address. - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value of the address. The validity of the values will depend - /// on the type and support by the controller. - /// - /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. - pub value: String, -} - -/// BackendTLS configures TLS settings for when this Gateway is connecting to -/// backends with TLS. -/// -/// Support: Core -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayBackendTls { - /// ClientCertificateRef is a reference to an object that contains a Client - /// Certificate and the associated private key. - /// - /// References to a resource in different namespace are invalid UNLESS there - /// is a ReferenceGrant in the target namespace that allows the certificate - /// to be attached. If a ReferenceGrant does not allow this reference, the - /// "ResolvedRefs" condition MUST be set to False for this listener with the - /// "RefNotPermitted" reason. - /// - /// ClientCertificateRef can reference to standard Kubernetes resources, i.e. - /// Secret, or implementation-specific custom resources. - /// - /// This setting can be overridden on the service level by use of BackendTLSPolicy. - /// - /// Support: Core - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "clientCertificateRef" - )] - pub client_certificate_ref: Option, -} - -/// ClientCertificateRef is a reference to an object that contains a Client -/// Certificate and the associated private key. -/// -/// References to a resource in different namespace are invalid UNLESS there -/// is a ReferenceGrant in the target namespace that allows the certificate -/// to be attached. If a ReferenceGrant does not allow this reference, the -/// "ResolvedRefs" condition MUST be set to False for this listener with the -/// "RefNotPermitted" reason. -/// -/// ClientCertificateRef can reference to standard Kubernetes resources, i.e. -/// Secret, or implementation-specific custom resources. -/// -/// This setting can be overridden on the service level by use of BackendTLSPolicy. -/// -/// Support: Core -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayBackendTlsClientCertificateRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. For example "Secret". - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the referenced object. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, -} - -/// Infrastructure defines infrastructure level attributes about this Gateway instance. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayInfrastructure { - /// Annotations that SHOULD be applied to any resources created in response to this Gateway. - /// - /// For implementations creating other Kubernetes objects, this should be the `metadata.annotations` field on resources. - /// For other implementations, this refers to any relevant (implementation specific) "annotations" concepts. - /// - /// An implementation may chose to add additional implementation-specific annotations as they see fit. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub annotations: Option>, - /// Labels that SHOULD be applied to any resources created in response to this Gateway. - /// - /// For implementations creating other Kubernetes objects, this should be the `metadata.labels` field on resources. - /// For other implementations, this refers to any relevant (implementation specific) "labels" concepts. - /// - /// An implementation may chose to add additional implementation-specific labels as they see fit. - /// - /// If an implementation maps these labels to Pods, or any other resource that would need to be recreated when labels - /// change, it SHOULD clearly warn about this behavior in documentation. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub labels: Option>, - /// ParametersRef is a reference to a resource that contains the configuration - /// parameters corresponding to the Gateway. This is optional if the - /// controller does not require any additional configuration. - /// - /// This follows the same semantics as GatewayClass's `parametersRef`, but on a per-Gateway basis - /// - /// The Gateway's GatewayClass may provide its own `parametersRef`. When both are specified, - /// the merging behavior is implementation specific. - /// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. - /// - /// Support: Implementation-specific - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "parametersRef" - )] - pub parameters_ref: Option, -} - -/// ParametersRef is a reference to a resource that contains the configuration -/// parameters corresponding to the Gateway. This is optional if the -/// controller does not require any additional configuration. -/// -/// This follows the same semantics as GatewayClass's `parametersRef`, but on a per-Gateway basis -/// -/// The Gateway's GatewayClass may provide its own `parametersRef`. When both are specified, -/// the merging behavior is implementation specific. -/// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. -/// -/// Support: Implementation-specific -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayInfrastructureParametersRef { - /// Group is the group of the referent. - pub group: String, - /// Kind is kind of the referent. - pub kind: String, - /// Name is the name of the referent. - pub name: String, -} - -/// Listener embodies the concept of a logical endpoint where a Gateway accepts -/// network connections. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListeners { - /// AllowedRoutes defines the types of routes that MAY be attached to a - /// Listener and the trusted namespaces where those Route resources MAY be - /// present. - /// - /// Although a client request may match multiple route rules, only one rule - /// may ultimately receive the request. Matching precedence MUST be - /// determined in order of the following criteria: - /// - /// * The most specific match as defined by the Route type. - /// * The oldest Route based on creation timestamp. For example, a Route with - /// a creation timestamp of "2020-09-08 01:02:03" is given precedence over - /// a Route with a creation timestamp of "2020-09-08 01:02:04". - /// * If everything else is equivalent, the Route appearing first in - /// alphabetical order (namespace/name) should be given precedence. For - /// example, foo/bar is given precedence over foo/baz. - /// - /// All valid rules within a Route attached to this Listener should be - /// implemented. Invalid Route rules can be ignored (sometimes that will mean - /// the full Route). If a Route rule transitions from valid to invalid, - /// support for that Route rule should be dropped to ensure consistency. For - /// example, even if a filter specified by a Route rule is invalid, the rest - /// of the rules within that Route should still be supported. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "allowedRoutes" - )] - pub allowed_routes: Option, - /// Hostname specifies the virtual hostname to match for protocol types that - /// define this concept. When unspecified, all hostnames are matched. This - /// field is ignored for protocols that don't require hostname based - /// matching. - /// - /// Implementations MUST apply Hostname matching appropriately for each of - /// the following protocols: - /// - /// * TLS: The Listener Hostname MUST match the SNI. - /// * HTTP: The Listener Hostname MUST match the Host header of the request. - /// * HTTPS: The Listener Hostname SHOULD match at both the TLS and HTTP - /// protocol layers as described above. If an implementation does not - /// ensure that both the SNI and Host header match the Listener hostname, - /// it MUST clearly document that. - /// - /// For HTTPRoute and TLSRoute resources, there is an interaction with the - /// `spec.hostnames` array. When both listener and route specify hostnames, - /// there MUST be an intersection between the values for a Route to be - /// accepted. For more information, refer to the Route specific Hostnames - /// documentation. - /// - /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted - /// as a suffix match. That means that a match for `*.example.com` would match - /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, - /// Name is the name of the Listener. This name MUST be unique within a - /// Gateway. - /// - /// Support: Core - pub name: String, - /// Port is the network port. Multiple listeners may use the - /// same port, subject to the Listener compatibility rules. - /// - /// Support: Core - pub port: i32, - /// Protocol specifies the network protocol this listener expects to receive. - /// - /// Support: Core - pub protocol: String, - /// TLS is the TLS configuration for the Listener. This field is required if - /// the Protocol field is "HTTPS" or "TLS". It is invalid to set this field - /// if the Protocol field is "HTTP", "TCP", or "UDP". - /// - /// The association of SNIs to Certificate defined in GatewayTLSConfig is - /// defined based on the Hostname field for this listener. - /// - /// The GatewayClass MUST use the longest matching SNI out of all - /// available certificates for any TLS handshake. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub tls: Option, -} - -/// AllowedRoutes defines the types of routes that MAY be attached to a -/// Listener and the trusted namespaces where those Route resources MAY be -/// present. -/// -/// Although a client request may match multiple route rules, only one rule -/// may ultimately receive the request. Matching precedence MUST be -/// determined in order of the following criteria: -/// -/// * The most specific match as defined by the Route type. -/// * The oldest Route based on creation timestamp. For example, a Route with -/// a creation timestamp of "2020-09-08 01:02:03" is given precedence over -/// a Route with a creation timestamp of "2020-09-08 01:02:04". -/// * If everything else is equivalent, the Route appearing first in -/// alphabetical order (namespace/name) should be given precedence. For -/// example, foo/bar is given precedence over foo/baz. -/// -/// All valid rules within a Route attached to this Listener should be -/// implemented. Invalid Route rules can be ignored (sometimes that will mean -/// the full Route). If a Route rule transitions from valid to invalid, -/// support for that Route rule should be dropped to ensure consistency. For -/// example, even if a filter specified by a Route rule is invalid, the rest -/// of the rules within that Route should still be supported. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersAllowedRoutes { - /// Kinds specifies the groups and kinds of Routes that are allowed to bind - /// to this Gateway Listener. When unspecified or empty, the kinds of Routes - /// selected are determined using the Listener protocol. - /// - /// A RouteGroupKind MUST correspond to kinds of Routes that are compatible - /// with the application protocol specified in the Listener's Protocol field. - /// If an implementation does not support or recognize this resource type, it - /// MUST set the "ResolvedRefs" condition to False for this Listener with the - /// "InvalidRouteKinds" reason. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kinds: Option>, - /// Namespaces indicates namespaces from which Routes may be attached to this - /// Listener. This is restricted to the namespace of this Gateway by default. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespaces: Option, -} - -/// RouteGroupKind indicates the group and kind of a Route resource. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersAllowedRoutesKinds { - /// Group is the group of the Route. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the kind of the Route. - pub kind: String, -} - -/// Namespaces indicates namespaces from which Routes may be attached to this -/// Listener. This is restricted to the namespace of this Gateway by default. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersAllowedRoutesNamespaces { - /// From indicates where Routes will be selected for this Gateway. Possible - /// values are: - /// - /// * All: Routes in all namespaces may be used by this Gateway. - /// * Selector: Routes in namespaces selected by the selector may be used by - /// this Gateway. - /// * Same: Only Routes in the same namespace may be used by this Gateway. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub from: Option, - /// Selector must be specified when From is set to "Selector". In that case, - /// only Routes in Namespaces matching this Selector will be selected by this - /// Gateway. This field is ignored for other values of "From". - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub selector: Option, -} - -/// Namespaces indicates namespaces from which Routes may be attached to this -/// Listener. This is restricted to the namespace of this Gateway by default. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayListenersAllowedRoutesNamespacesFrom { - All, - Selector, - Same, -} - -/// Selector must be specified when From is set to "Selector". In that case, -/// only Routes in Namespaces matching this Selector will be selected by this -/// Gateway. This field is ignored for other values of "From". -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersAllowedRoutesNamespacesSelector { - /// matchExpressions is a list of label selector requirements. The requirements are ANDed. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "matchExpressions" - )] - pub match_expressions: - Option>, - /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - /// map is equivalent to an element of matchExpressions, whose key field is "key", the - /// operator is "In", and the values array contains only "value". The requirements are ANDed. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "matchLabels" - )] - pub match_labels: Option>, -} - -/// A label selector requirement is a selector that contains values, a key, and an operator that -/// relates the key and values. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersAllowedRoutesNamespacesSelectorMatchExpressions { - /// key is the label key that the selector applies to. - pub key: String, - /// operator represents a key's relationship to a set of values. - /// Valid operators are In, NotIn, Exists and DoesNotExist. - pub operator: String, - /// values is an array of string values. If the operator is In or NotIn, - /// the values array must be non-empty. If the operator is Exists or DoesNotExist, - /// the values array must be empty. This array is replaced during a strategic - /// merge patch. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub values: Option>, -} - -/// TLS is the TLS configuration for the Listener. This field is required if -/// the Protocol field is "HTTPS" or "TLS". It is invalid to set this field -/// if the Protocol field is "HTTP", "TCP", or "UDP". -/// -/// The association of SNIs to Certificate defined in GatewayTLSConfig is -/// defined based on the Hostname field for this listener. -/// -/// The GatewayClass MUST use the longest matching SNI out of all -/// available certificates for any TLS handshake. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersTls { - /// CertificateRefs contains a series of references to Kubernetes objects that - /// contains TLS certificates and private keys. These certificates are used to - /// establish a TLS handshake for requests that match the hostname of the - /// associated listener. - /// - /// A single CertificateRef to a Kubernetes Secret has "Core" support. - /// Implementations MAY choose to support attaching multiple certificates to - /// a Listener, but this behavior is implementation-specific. - /// - /// References to a resource in different namespace are invalid UNLESS there - /// is a ReferenceGrant in the target namespace that allows the certificate - /// to be attached. If a ReferenceGrant does not allow this reference, the - /// "ResolvedRefs" condition MUST be set to False for this listener with the - /// "RefNotPermitted" reason. - /// - /// This field is required to have at least one element when the mode is set - /// to "Terminate" (default) and is optional otherwise. - /// - /// CertificateRefs can reference to standard Kubernetes resources, i.e. - /// Secret, or implementation-specific custom resources. - /// - /// Support: Core - A single reference to a Kubernetes Secret of type kubernetes.io/tls - /// - /// Support: Implementation-specific (More than one reference or other resource types) - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "certificateRefs" - )] - pub certificate_refs: Option>, - /// FrontendValidation holds configuration information for validating the frontend (client). - /// Setting this field will require clients to send a client certificate - /// required for validation during the TLS handshake. In browsers this may result in a dialog appearing - /// that requests a user to specify the client certificate. - /// The maximum depth of a certificate chain accepted in verification is Implementation specific. - /// - /// Support: Extended - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "frontendValidation" - )] - pub frontend_validation: Option, - /// Mode defines the TLS behavior for the TLS session initiated by the client. - /// There are two possible modes: - /// - /// - Terminate: The TLS session between the downstream client and the - /// Gateway is terminated at the Gateway. This mode requires certificates - /// to be specified in some way, such as populating the certificateRefs - /// field. - /// - Passthrough: The TLS session is NOT terminated by the Gateway. This - /// implies that the Gateway can't decipher the TLS stream except for - /// the ClientHello message of the TLS protocol. The certificateRefs field - /// is ignored in this mode. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub mode: Option, - /// Options are a list of key/value pairs to enable extended TLS - /// configuration for each implementation. For example, configuring the - /// minimum TLS version or supported cipher suites. - /// - /// A set of common keys MAY be defined by the API in the future. To avoid - /// any ambiguity, implementation-specific definitions MUST use - /// domain-prefixed names, such as `example.com/my-custom-option`. - /// Un-prefixed names are reserved for key names defined by Gateway API. - /// - /// Support: Implementation-specific - #[serde(default, skip_serializing_if = "Option::is_none")] - pub options: Option>, -} - -/// SecretObjectReference identifies an API object including its namespace, -/// defaulting to Secret. -/// -/// The API object must be valid in the cluster; the Group and Kind must -/// be registered in the cluster for this reference to be valid. -/// -/// References to objects with invalid Group and Kind are not valid, and must -/// be rejected by the implementation, with appropriate Conditions set -/// on the containing object. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersTlsCertificateRefs { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. For example "Secret". - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the referenced object. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, -} - -/// FrontendValidation holds configuration information for validating the frontend (client). -/// Setting this field will require clients to send a client certificate -/// required for validation during the TLS handshake. In browsers this may result in a dialog appearing -/// that requests a user to specify the client certificate. -/// The maximum depth of a certificate chain accepted in verification is Implementation specific. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersTlsFrontendValidation { - /// CACertificateRefs contains one or more references to - /// Kubernetes objects that contain TLS certificates of - /// the Certificate Authorities that can be used - /// as a trust anchor to validate the certificates presented by the client. - /// - /// A single CA certificate reference to a Kubernetes ConfigMap - /// has "Core" support. - /// Implementations MAY choose to support attaching multiple CA certificates to - /// a Listener, but this behavior is implementation-specific. - /// - /// Support: Core - A single reference to a Kubernetes ConfigMap - /// with the CA certificate in a key named `ca.crt`. - /// - /// Support: Implementation-specific (More than one reference, or other kinds - /// of resources). - /// - /// References to a resource in a different namespace are invalid UNLESS there - /// is a ReferenceGrant in the target namespace that allows the certificate - /// to be attached. If a ReferenceGrant does not allow this reference, the - /// "ResolvedRefs" condition MUST be set to False for this listener with the - /// "RefNotPermitted" reason. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "caCertificateRefs" - )] - pub ca_certificate_refs: Option>, -} - -/// ObjectReference identifies an API object including its namespace. -/// -/// The API object must be valid in the cluster; the Group and Kind must -/// be registered in the cluster for this reference to be valid. -/// -/// References to objects with invalid Group and Kind are not valid, and must -/// be rejected by the implementation, with appropriate Conditions set -/// on the containing object. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersTlsFrontendValidationCaCertificateRefs { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - pub group: String, - /// Kind is kind of the referent. For example "ConfigMap" or "Service". - pub kind: String, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the referenced object. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, -} - -/// TLS is the TLS configuration for the Listener. This field is required if -/// the Protocol field is "HTTPS" or "TLS". It is invalid to set this field -/// if the Protocol field is "HTTP", "TCP", or "UDP". -/// -/// The association of SNIs to Certificate defined in GatewayTLSConfig is -/// defined based on the Hostname field for this listener. -/// -/// The GatewayClass MUST use the longest matching SNI out of all -/// available certificates for any TLS handshake. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayListenersTlsMode { - Terminate, - Passthrough, -} - -/// Status defines the current state of Gateway. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayStatus { - /// Addresses lists the network addresses that have been bound to the - /// Gateway. - /// - /// This list may differ from the addresses provided in the spec under some - /// conditions: - /// - /// * no addresses are specified, all addresses are dynamically assigned - /// * a combination of specified and dynamic addresses are assigned - /// * a specified address was unusable (e.g. already in use) - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub addresses: Option>, - /// Conditions describe the current conditions of the Gateway. - /// - /// Implementations should prefer to express Gateway conditions - /// using the `GatewayConditionType` and `GatewayConditionReason` - /// constants so that operators and tools can converge on a common - /// vocabulary to describe Gateway state. - /// - /// Known condition types are: - /// - /// * "Accepted" - /// * "Programmed" - /// * "Ready" - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: Option>, - /// Listeners provide status for each unique listener port defined in the Spec. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub listeners: Option>, -} - -/// GatewayStatusAddress describes a network address that is bound to a Gateway. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayStatusAddresses { - /// Type of the address. - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value of the address. The validity of the values will depend - /// on the type and support by the controller. - /// - /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. - pub value: String, -} - -/// ListenerStatus is the status associated with a Listener. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayStatusListeners { - /// AttachedRoutes represents the total number of Routes that have been - /// successfully attached to this Listener. - /// - /// Successful attachment of a Route to a Listener is based solely on the - /// combination of the AllowedRoutes field on the corresponding Listener - /// and the Route's ParentRefs field. A Route is successfully attached to - /// a Listener when it is selected by the Listener's AllowedRoutes field - /// AND the Route has a valid ParentRef selecting the whole Gateway - /// resource or a specific Listener as a parent resource (more detail on - /// attachment semantics can be found in the documentation on the various - /// Route kinds ParentRefs fields). Listener or Route status does not impact - /// successful attachment, i.e. the AttachedRoutes field count MUST be set - /// for Listeners with condition Accepted: false and MUST count successfully - /// attached Routes that may themselves have Accepted: false conditions. - /// - /// Uses for this field include troubleshooting Route attachment and - /// measuring blast radius/impact of changes to a Listener. - #[serde(rename = "attachedRoutes")] - pub attached_routes: i32, - /// Conditions describe the current condition of this listener. - pub conditions: Vec, - /// Name is the name of the Listener that this status corresponds to. - pub name: String, - /// SupportedKinds is the list indicating the Kinds supported by this - /// listener. This MUST represent the kinds an implementation supports for - /// that Listener configuration. - /// - /// If kinds are specified in Spec that are not supported, they MUST NOT - /// appear in this list and an implementation MUST set the "ResolvedRefs" - /// condition to "False" with the "InvalidRouteKinds" reason. If both valid - /// and invalid Route kinds are specified, the implementation MUST - /// reference the valid Route kinds that have been specified. - #[serde(rename = "supportedKinds")] - pub supported_kinds: Vec, -} - -/// RouteGroupKind indicates the group and kind of a Route resource. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayStatusListenersSupportedKinds { - /// Group is the group of the Route. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the kind of the Route. - pub kind: String, -} diff --git a/gateway-api/src/apis/experimental/grpcroutes.rs b/gateway-api/src/apis/experimental/grpcroutes.rs deleted file mode 100644 index 5710d30..0000000 --- a/gateway-api/src/apis/experimental/grpcroutes.rs +++ /dev/null @@ -1,1794 +0,0 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 - -#[allow(unused_imports)] -mod prelude { - pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube::CustomResource; - pub use schemars::JsonSchema; - pub use serde::{Deserialize, Serialize}; -} -use self::prelude::*; - -/// Spec defines the desired state of GRPCRoute. -#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -#[kube( - group = "gateway.networking.k8s.io", - version = "v1", - kind = "GRPCRoute", - plural = "grpcroutes" -)] -#[kube(namespaced)] -#[kube(status = "GRPCRouteStatus")] -#[kube(derive = "Default")] -#[kube(derive = "PartialEq")] -pub struct GRPCRouteSpec { - /// Hostnames defines a set of hostnames to match against the GRPC - /// Host header to select a GRPCRoute to process the request. This matches - /// the RFC 1123 definition of a hostname with 2 notable exceptions: - /// - /// 1. IPs are not allowed. - /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard - /// label MUST appear by itself as the first label. - /// - /// If a hostname is specified by both the Listener and GRPCRoute, there - /// MUST be at least one intersecting hostname for the GRPCRoute to be - /// attached to the Listener. For example: - /// - /// * A Listener with `test.example.com` as the hostname matches GRPCRoutes - /// that have either not specified any hostnames, or have specified at - /// least one of `test.example.com` or `*.example.com`. - /// * A Listener with `*.example.com` as the hostname matches GRPCRoutes - /// that have either not specified any hostnames or have specified at least - /// one hostname that matches the Listener hostname. For example, - /// `test.example.com` and `*.example.com` would both match. On the other - /// hand, `example.com` and `test.example.net` would not match. - /// - /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted - /// as a suffix match. That means that a match for `*.example.com` would match - /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. - /// - /// If both the Listener and GRPCRoute have specified hostnames, any - /// GRPCRoute hostnames that do not match the Listener hostname MUST be - /// ignored. For example, if a Listener specified `*.example.com`, and the - /// GRPCRoute specified `test.example.com` and `test.example.net`, - /// `test.example.net` MUST NOT be considered for a match. - /// - /// If both the Listener and GRPCRoute have specified hostnames, and none - /// match with the criteria above, then the GRPCRoute MUST NOT be accepted by - /// the implementation. The implementation MUST raise an 'Accepted' Condition - /// with a status of `False` in the corresponding RouteParentStatus. - /// - /// If a Route (A) of type HTTPRoute or GRPCRoute is attached to a - /// Listener and that listener already has another Route (B) of the other - /// type attached and the intersection of the hostnames of A and B is - /// non-empty, then the implementation MUST accept exactly one of these two - /// routes, determined by the following criteria, in order: - /// - /// * The oldest Route based on creation timestamp. - /// * The Route appearing first in alphabetical order by - /// "{namespace}/{name}". - /// - /// The rejected Route MUST raise an 'Accepted' condition with a status of - /// 'False' in the corresponding RouteParentStatus. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostnames: Option>, - /// ParentRefs references the resources (usually Gateways) that a Route wants - /// to be attached to. Note that the referenced parent resource needs to - /// allow this for the attachment to be complete. For Gateways, that means - /// the Gateway needs to allow attachment from Routes of this kind and - /// namespace. For Services, that means the Service must either be in the same - /// namespace for a "producer" route, or the mesh implementation must support - /// and allow "consumer" routes for the referenced Service. ReferenceGrant is - /// not applicable for governing ParentRefs to Services - it is not possible to - /// create a "producer" route for a Service in a different namespace from the - /// Route. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// This API may be extended in the future to support additional kinds of parent - /// resources. - /// - /// ParentRefs must be _distinct_. This means either that: - /// - /// * They select different objects. If this is the case, then parentRef - /// entries are distinct. In terms of fields, this means that the - /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must - /// be unique across all parentRef entries in the Route. - /// * They do not select different objects, but for each optional field used, - /// each ParentRef that selects the same object must set the same set of - /// optional fields to different values. If one ParentRef sets a - /// combination of optional fields, all must set the same combination. - /// - /// Some examples: - /// - /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the - /// same object must also set `sectionName`. - /// * If one ParentRef sets `port`, all ParentRefs referencing the same - /// object must also set `port`. - /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs - /// referencing the same object must also set `sectionName` and `port`. - /// - /// It is possible to separately reference multiple distinct objects that may - /// be collapsed by an implementation. For example, some implementations may - /// choose to merge compatible Gateway Listeners together. If that is the - /// case, the list of routes attached to those resources should also be - /// merged. - /// - /// Note that for ParentRefs that cross namespace boundaries, there are specific - /// rules. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example, - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable other kinds of cross-namespace reference. - /// - /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. - /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. - /// - /// - /// - /// - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "parentRefs" - )] - pub parent_refs: Option>, - /// Rules are a list of GRPC matchers, filters and actions. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub rules: Option>, -} - -/// ParentReference identifies an API object (usually a Gateway) that can be considered -/// a parent of this resource (usually a route). There are two kinds of parent resources -/// with "Core" support: -/// -/// * Gateway (Gateway conformance profile) -/// * Service (Mesh conformance profile, ClusterIP Services only) -/// -/// This API may be extended in the future to support additional kinds of parent -/// resources. -/// -/// The API object must be valid in the cluster; the Group and Kind must -/// be registered in the cluster for this reference to be valid. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteParentRefs { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. - /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// When the parent resource is a Service, this targets a specific port in the - /// Service spec. When both Port (experimental) and SectionName are specified, - /// the name and port of the selected port must match both specified values. - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, -} - -/// GRPCRouteRule defines the semantics for matching a gRPC request based on -/// conditions (matches), processing it (filters), and forwarding the request to -/// an API object (backendRefs). -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRules { - /// BackendRefs defines the backend(s) where matching requests should be - /// sent. - /// - /// Failure behavior here depends on how many BackendRefs are specified and - /// how many are invalid. - /// - /// If *all* entries in BackendRefs are invalid, and there are also no filters - /// specified in this route rule, *all* traffic which matches this rule MUST - /// receive an `UNAVAILABLE` status. - /// - /// See the GRPCBackendRef definition for the rules about what makes a single - /// GRPCBackendRef invalid. - /// - /// When a GRPCBackendRef is invalid, `UNAVAILABLE` statuses MUST be returned for - /// requests that would have otherwise been routed to an invalid backend. If - /// multiple backends are specified, and some are invalid, the proportion of - /// requests that would otherwise have been routed to an invalid backend - /// MUST receive an `UNAVAILABLE` status. - /// - /// For example, if two backends are specified with equal weights, and one is - /// invalid, 50 percent of traffic MUST receive an `UNAVAILABLE` status. - /// Implementations may choose how that 50 percent is determined. - /// - /// Support: Core for Kubernetes Service - /// - /// Support: Implementation-specific for any other resource - /// - /// Support for weight: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "backendRefs" - )] - pub backend_refs: Option>, - /// Filters define the filters that are applied to requests that match - /// this rule. - /// - /// The effects of ordering of multiple behaviors are currently unspecified. - /// This can change in the future based on feedback during the alpha stage. - /// - /// Conformance-levels at this level are defined based on the type of filter: - /// - /// - ALL core filters MUST be supported by all implementations that support - /// GRPCRoute. - /// - Implementers are encouraged to support extended filters. - /// - Implementation-specific custom filters have no API guarantees across - /// implementations. - /// - /// Specifying the same filter multiple times is not supported unless explicitly - /// indicated in the filter. - /// - /// If an implementation can not support a combination of filters, it must clearly - /// document that limitation. In cases where incompatible or unsupported - /// filters are specified and cause the `Accepted` condition to be set to status - /// `False`, implementations may use the `IncompatibleFilters` reason to specify - /// this configuration error. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, - /// Matches define conditions used for matching the rule against incoming - /// gRPC requests. Each match is independent, i.e. this rule will be matched - /// if **any** one of the matches is satisfied. - /// - /// For example, take the following matches configuration: - /// - /// ```text - /// matches: - /// - method: - /// service: foo.bar - /// headers: - /// values: - /// version: 2 - /// - method: - /// service: foo.bar.v2 - /// ``` - /// - /// For a request to match against this rule, it MUST satisfy - /// EITHER of the two conditions: - /// - /// - service of foo.bar AND contains the header `version: 2` - /// - service of foo.bar.v2 - /// - /// See the documentation for GRPCRouteMatch on how to specify multiple - /// match conditions to be ANDed together. - /// - /// If no matches are specified, the implementation MUST match every gRPC request. - /// - /// Proxy or Load Balancer routing configuration generated from GRPCRoutes - /// MUST prioritize rules based on the following criteria, continuing on - /// ties. Merging MUST not be done between GRPCRoutes and HTTPRoutes. - /// Precedence MUST be given to the rule with the largest number of: - /// - /// * Characters in a matching non-wildcard hostname. - /// * Characters in a matching hostname. - /// * Characters in a matching service. - /// * Characters in a matching method. - /// * Header matches. - /// - /// If ties still exist across multiple Routes, matching precedence MUST be - /// determined in order of the following criteria, continuing on ties: - /// - /// * The oldest Route based on creation timestamp. - /// * The Route appearing first in alphabetical order by - /// "{namespace}/{name}". - /// - /// If ties still exist within the Route that has been given precedence, - /// matching precedence MUST be granted to the first matching rule meeting - /// the above criteria. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub matches: Option>, - /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. - /// - /// Support: Extended - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub name: Option, - /// SessionPersistence defines and configures session persistence - /// for the route rule. - /// - /// Support: Extended - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sessionPersistence" - )] - pub session_persistence: Option, -} - -/// GRPCBackendRef defines how a GRPCRoute forwards a gRPC request. -/// -/// Note that when a namespace different than the local namespace is specified, a -/// ReferenceGrant object is required in the referent namespace to allow that -/// namespace's owner to accept the reference. See the ReferenceGrant -/// documentation for details. -/// -/// -/// -/// When the BackendRef points to a Kubernetes Service, implementations SHOULD -/// honor the appProtocol field if it is set for the target Service Port. -/// -/// Implementations supporting appProtocol SHOULD recognize the Kubernetes -/// Standard Application Protocols defined in KEP-3726. -/// -/// If a Service appProtocol isn't specified, an implementation MAY infer the -/// backend protocol through its own means. Implementations MAY infer the -/// protocol from the Route type referring to the backend Service. -/// -/// If a Route is not able to send traffic to the backend using the specified -/// protocol then the backend is considered invalid. Implementations MUST set the -/// "ResolvedRefs" condition to "False" with the "UnsupportedProtocol" reason. -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefs { - /// Filters defined at this level MUST be executed if and only if the - /// request is being forwarded to the backend defined here. - /// - /// Support: Implementation-specific (For broader support of filters, use the - /// Filters field in GRPCRouteRule.) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// Weight specifies the proportion of requests forwarded to the referenced - /// backend. This is computed as weight/(sum of all weights in this - /// BackendRefs list). For non-zero values, there may be some epsilon from - /// the exact proportion defined here depending on the precision an - /// implementation supports. Weight is not a percentage and the sum of - /// weights does not need to equal 100. - /// - /// If only one backend is specified and it has a weight greater than 0, 100% - /// of the traffic is forwarded to that backend. If weight is set to 0, no - /// traffic should be forwarded for this entry. If unspecified, weight - /// defaults to 1. - /// - /// Support for this field varies based on the context where used. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub weight: Option, -} - -/// GRPCRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. GRPCRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFilters { - /// ExtensionRef is an optional, implementation-specific extension to the - /// "filter" behavior. For example, resource "myroutefilter" in group - /// "networking.example.net"). ExtensionRef MUST NOT be used for core and - /// extended filters. - /// - /// Support: Implementation-specific - /// - /// This filter can be used multiple times within the same rule. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "extensionRef" - )] - pub extension_ref: Option, - /// RequestHeaderModifier defines a schema for a filter that modifies request - /// headers. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestHeaderModifier" - )] - pub request_header_modifier: Option, - /// RequestMirror defines a schema for a filter that mirrors requests. - /// Requests are sent to the specified destination, but responses from - /// that destination are ignored. - /// - /// This filter can be used multiple times within the same rule. Note that - /// not all implementations will be able to support mirroring to multiple - /// backends. - /// - /// Support: Extended - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestMirror" - )] - pub request_mirror: Option, - /// ResponseHeaderModifier defines a schema for a filter that modifies response - /// headers. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "responseHeaderModifier" - )] - pub response_header_modifier: Option, - /// Type identifies the type of filter to apply. As with other API fields, - /// types are classified into three conformance levels: - /// - /// - Core: Filter types and their corresponding configuration defined by - /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All - /// implementations supporting GRPCRoute MUST support core filters. - /// - /// - Extended: Filter types and their corresponding configuration defined by - /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers - /// are encouraged to support extended filters. - /// - /// - Implementation-specific: Filters that are defined and supported by specific vendors. - /// In the future, filters showing convergence in behavior across multiple - /// implementations will be considered for inclusion in extended or core - /// conformance levels. Filter-specific configuration for such filters - /// is specified using the ExtensionRef field. `Type` MUST be set to - /// "ExtensionRef" for custom filters. - /// - /// Implementers are encouraged to define custom implementation types to - /// extend the core API with implementation-specific behavior. - /// - /// If a reference to a custom filter type cannot be resolved, the filter - /// MUST NOT be skipped. Instead, requests that would have been processed by - /// that filter MUST receive a HTTP error response. - /// - /// - #[serde(rename = "type")] - pub r#type: GRPCRouteRulesBackendRefsFiltersType, -} - -/// ExtensionRef is an optional, implementation-specific extension to the -/// "filter" behavior. For example, resource "myroutefilter" in group -/// "networking.example.net"). ExtensionRef MUST NOT be used for core and -/// extended filters. -/// -/// Support: Implementation-specific -/// -/// This filter can be used multiple times within the same rule. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersExtensionRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - pub group: String, - /// Kind is kind of the referent. For example "HTTPRoute" or "Service". - pub kind: String, - /// Name is the name of the referent. - pub name: String, -} - -/// RequestHeaderModifier defines a schema for a filter that modifies request -/// headers. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// RequestMirror defines a schema for a filter that mirrors requests. -/// Requests are sent to the specified destination, but responses from -/// that destination are ignored. -/// -/// This filter can be used multiple times within the same rule. Note that -/// not all implementations will be able to support mirroring to multiple -/// backends. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestMirror { - /// BackendRef references a resource where mirrored requests are sent. - /// - /// Mirrored requests must be sent only to a single destination endpoint - /// within this BackendRef, irrespective of how many endpoints are present - /// within this BackendRef. - /// - /// If the referent cannot be found, this BackendRef is invalid and must be - /// dropped from the Gateway. The controller must ensure the "ResolvedRefs" - /// condition on the Route status is set to `status: False` and not configure - /// this backend in the underlying implementation. - /// - /// If there is a cross-namespace reference to an *existing* object - /// that is not allowed by a ReferenceGrant, the controller must ensure the - /// "ResolvedRefs" condition on the Route is set to `status: False`, - /// with the "RefNotPermitted" reason and not configure this backend in the - /// underlying implementation. - /// - /// In either error case, the Message of the `ResolvedRefs` Condition - /// should be used to provide more detail about the problem. - /// - /// Support: Extended for Kubernetes Service - /// - /// Support: Implementation-specific for any other resource - #[serde(rename = "backendRef")] - pub backend_ref: GRPCRouteRulesBackendRefsFiltersRequestMirrorBackendRef, - /// Fraction represents the fraction of requests that should be - /// mirrored to BackendRef. - /// - /// Only one of Fraction or Percent may be specified. If neither field - /// is specified, 100% of requests will be mirrored. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub fraction: Option, - /// Percent represents the percentage of requests that should be - /// mirrored to BackendRef. Its minimum value is 0 (indicating 0% of - /// requests) and its maximum value is 100 (indicating 100% of requests). - /// - /// Only one of Fraction or Percent may be specified. If neither field - /// is specified, 100% of requests will be mirrored. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub percent: Option, -} - -/// BackendRef references a resource where mirrored requests are sent. -/// -/// Mirrored requests must be sent only to a single destination endpoint -/// within this BackendRef, irrespective of how many endpoints are present -/// within this BackendRef. -/// -/// If the referent cannot be found, this BackendRef is invalid and must be -/// dropped from the Gateway. The controller must ensure the "ResolvedRefs" -/// condition on the Route status is set to `status: False` and not configure -/// this backend in the underlying implementation. -/// -/// If there is a cross-namespace reference to an *existing* object -/// that is not allowed by a ReferenceGrant, the controller must ensure the -/// "ResolvedRefs" condition on the Route is set to `status: False`, -/// with the "RefNotPermitted" reason and not configure this backend in the -/// underlying implementation. -/// -/// In either error case, the Message of the `ResolvedRefs` Condition -/// should be used to provide more detail about the problem. -/// -/// Support: Extended for Kubernetes Service -/// -/// Support: Implementation-specific for any other resource -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestMirrorBackendRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, -} - -/// Fraction represents the fraction of requests that should be -/// mirrored to BackendRef. -/// -/// Only one of Fraction or Percent may be specified. If neither field -/// is specified, 100% of requests will be mirrored. -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestMirrorFraction { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub denominator: Option, - pub numerator: i32, -} - -/// ResponseHeaderModifier defines a schema for a filter that modifies response -/// headers. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersResponseHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersResponseHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersResponseHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// GRPCRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. GRPCRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCRouteRulesBackendRefsFiltersType { - ResponseHeaderModifier, - RequestHeaderModifier, - RequestMirror, - ExtensionRef, -} - -/// GRPCRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. GRPCRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFilters { - /// ExtensionRef is an optional, implementation-specific extension to the - /// "filter" behavior. For example, resource "myroutefilter" in group - /// "networking.example.net"). ExtensionRef MUST NOT be used for core and - /// extended filters. - /// - /// Support: Implementation-specific - /// - /// This filter can be used multiple times within the same rule. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "extensionRef" - )] - pub extension_ref: Option, - /// RequestHeaderModifier defines a schema for a filter that modifies request - /// headers. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestHeaderModifier" - )] - pub request_header_modifier: Option, - /// RequestMirror defines a schema for a filter that mirrors requests. - /// Requests are sent to the specified destination, but responses from - /// that destination are ignored. - /// - /// This filter can be used multiple times within the same rule. Note that - /// not all implementations will be able to support mirroring to multiple - /// backends. - /// - /// Support: Extended - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestMirror" - )] - pub request_mirror: Option, - /// ResponseHeaderModifier defines a schema for a filter that modifies response - /// headers. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "responseHeaderModifier" - )] - pub response_header_modifier: Option, - /// Type identifies the type of filter to apply. As with other API fields, - /// types are classified into three conformance levels: - /// - /// - Core: Filter types and their corresponding configuration defined by - /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All - /// implementations supporting GRPCRoute MUST support core filters. - /// - /// - Extended: Filter types and their corresponding configuration defined by - /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers - /// are encouraged to support extended filters. - /// - /// - Implementation-specific: Filters that are defined and supported by specific vendors. - /// In the future, filters showing convergence in behavior across multiple - /// implementations will be considered for inclusion in extended or core - /// conformance levels. Filter-specific configuration for such filters - /// is specified using the ExtensionRef field. `Type` MUST be set to - /// "ExtensionRef" for custom filters. - /// - /// Implementers are encouraged to define custom implementation types to - /// extend the core API with implementation-specific behavior. - /// - /// If a reference to a custom filter type cannot be resolved, the filter - /// MUST NOT be skipped. Instead, requests that would have been processed by - /// that filter MUST receive a HTTP error response. - /// - /// - #[serde(rename = "type")] - pub r#type: GRPCRouteRulesFiltersType, -} - -/// ExtensionRef is an optional, implementation-specific extension to the -/// "filter" behavior. For example, resource "myroutefilter" in group -/// "networking.example.net"). ExtensionRef MUST NOT be used for core and -/// extended filters. -/// -/// Support: Implementation-specific -/// -/// This filter can be used multiple times within the same rule. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersExtensionRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - pub group: String, - /// Kind is kind of the referent. For example "HTTPRoute" or "Service". - pub kind: String, - /// Name is the name of the referent. - pub name: String, -} - -/// RequestHeaderModifier defines a schema for a filter that modifies request -/// headers. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// RequestMirror defines a schema for a filter that mirrors requests. -/// Requests are sent to the specified destination, but responses from -/// that destination are ignored. -/// -/// This filter can be used multiple times within the same rule. Note that -/// not all implementations will be able to support mirroring to multiple -/// backends. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestMirror { - /// BackendRef references a resource where mirrored requests are sent. - /// - /// Mirrored requests must be sent only to a single destination endpoint - /// within this BackendRef, irrespective of how many endpoints are present - /// within this BackendRef. - /// - /// If the referent cannot be found, this BackendRef is invalid and must be - /// dropped from the Gateway. The controller must ensure the "ResolvedRefs" - /// condition on the Route status is set to `status: False` and not configure - /// this backend in the underlying implementation. - /// - /// If there is a cross-namespace reference to an *existing* object - /// that is not allowed by a ReferenceGrant, the controller must ensure the - /// "ResolvedRefs" condition on the Route is set to `status: False`, - /// with the "RefNotPermitted" reason and not configure this backend in the - /// underlying implementation. - /// - /// In either error case, the Message of the `ResolvedRefs` Condition - /// should be used to provide more detail about the problem. - /// - /// Support: Extended for Kubernetes Service - /// - /// Support: Implementation-specific for any other resource - #[serde(rename = "backendRef")] - pub backend_ref: GRPCRouteRulesFiltersRequestMirrorBackendRef, - /// Fraction represents the fraction of requests that should be - /// mirrored to BackendRef. - /// - /// Only one of Fraction or Percent may be specified. If neither field - /// is specified, 100% of requests will be mirrored. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub fraction: Option, - /// Percent represents the percentage of requests that should be - /// mirrored to BackendRef. Its minimum value is 0 (indicating 0% of - /// requests) and its maximum value is 100 (indicating 100% of requests). - /// - /// Only one of Fraction or Percent may be specified. If neither field - /// is specified, 100% of requests will be mirrored. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub percent: Option, -} - -/// BackendRef references a resource where mirrored requests are sent. -/// -/// Mirrored requests must be sent only to a single destination endpoint -/// within this BackendRef, irrespective of how many endpoints are present -/// within this BackendRef. -/// -/// If the referent cannot be found, this BackendRef is invalid and must be -/// dropped from the Gateway. The controller must ensure the "ResolvedRefs" -/// condition on the Route status is set to `status: False` and not configure -/// this backend in the underlying implementation. -/// -/// If there is a cross-namespace reference to an *existing* object -/// that is not allowed by a ReferenceGrant, the controller must ensure the -/// "ResolvedRefs" condition on the Route is set to `status: False`, -/// with the "RefNotPermitted" reason and not configure this backend in the -/// underlying implementation. -/// -/// In either error case, the Message of the `ResolvedRefs` Condition -/// should be used to provide more detail about the problem. -/// -/// Support: Extended for Kubernetes Service -/// -/// Support: Implementation-specific for any other resource -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestMirrorBackendRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, -} - -/// Fraction represents the fraction of requests that should be -/// mirrored to BackendRef. -/// -/// Only one of Fraction or Percent may be specified. If neither field -/// is specified, 100% of requests will be mirrored. -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestMirrorFraction { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub denominator: Option, - pub numerator: i32, -} - -/// ResponseHeaderModifier defines a schema for a filter that modifies response -/// headers. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersResponseHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersResponseHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersResponseHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// GRPCRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. GRPCRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCRouteRulesFiltersType { - ResponseHeaderModifier, - RequestHeaderModifier, - RequestMirror, - ExtensionRef, -} - -/// GRPCRouteMatch defines the predicate used to match requests to a given -/// action. Multiple match types are ANDed together, i.e. the match will -/// evaluate to true only if all conditions are satisfied. -/// -/// For example, the match below will match a gRPC request only if its service -/// is `foo` AND it contains the `version: v1` header: -/// -/// ```text -/// matches: -/// - method: -/// type: Exact -/// service: "foo" -/// headers: -/// - name: "version" -/// value "v1" -/// -/// ``` -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesMatches { - /// Headers specifies gRPC request header matchers. Multiple match values are - /// ANDed together, meaning, a request MUST match all the specified headers - /// to select the route. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub headers: Option>, - /// Method specifies a gRPC request service/method matcher. If this field is - /// not specified, all services and methods will match. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub method: Option, -} - -/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request -/// headers. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesMatchesHeaders { - /// Name is the name of the gRPC Header to be matched. - /// - /// If multiple entries specify equivalent header names, only the first - /// entry with an equivalent name MUST be considered for a match. Subsequent - /// entries with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Type specifies how to match against the value of the header. - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value is the value of the gRPC Header to be matched. - pub value: String, -} - -/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request -/// headers. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCRouteRulesMatchesHeadersType { - Exact, - RegularExpression, -} - -/// Method specifies a gRPC request service/method matcher. If this field is -/// not specified, all services and methods will match. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesMatchesMethod { - /// Value of the method to match against. If left empty or omitted, will - /// match all services. - /// - /// At least one of Service and Method MUST be a non-empty string. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub method: Option, - /// Value of the service to match against. If left empty or omitted, will - /// match any service. - /// - /// At least one of Service and Method MUST be a non-empty string. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub service: Option, - /// Type specifies how to match against the service and/or method. - /// Support: Core (Exact with service and method specified) - /// - /// Support: Implementation-specific (Exact with method specified but no service specified) - /// - /// Support: Implementation-specific (RegularExpression) - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, -} - -/// Method specifies a gRPC request service/method matcher. If this field is -/// not specified, all services and methods will match. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCRouteRulesMatchesMethodType { - Exact, - RegularExpression, -} - -/// SessionPersistence defines and configures session persistence -/// for the route rule. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesSessionPersistence { - /// AbsoluteTimeout defines the absolute timeout of the persistent - /// session. Once the AbsoluteTimeout duration has elapsed, the - /// session becomes invalid. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "absoluteTimeout" - )] - pub absolute_timeout: Option, - /// CookieConfig provides configuration settings that are specific - /// to cookie-based session persistence. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "cookieConfig" - )] - pub cookie_config: Option, - /// IdleTimeout defines the idle timeout of the persistent session. - /// Once the session has been idle for more than the specified - /// IdleTimeout duration, the session becomes invalid. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "idleTimeout" - )] - pub idle_timeout: Option, - /// SessionName defines the name of the persistent session token - /// which may be reflected in the cookie or the header. Users - /// should avoid reusing session names to prevent unintended - /// consequences, such as rejection or unpredictable behavior. - /// - /// Support: Implementation-specific - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sessionName" - )] - pub session_name: Option, - /// Type defines the type of session persistence such as through - /// the use a header or cookie. Defaults to cookie based session - /// persistence. - /// - /// Support: Core for "Cookie" type - /// - /// Support: Extended for "Header" type - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, -} - -/// CookieConfig provides configuration settings that are specific -/// to cookie-based session persistence. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesSessionPersistenceCookieConfig { - /// LifetimeType specifies whether the cookie has a permanent or - /// session-based lifetime. A permanent cookie persists until its - /// specified expiry time, defined by the Expires or Max-Age cookie - /// attributes, while a session cookie is deleted when the current - /// session ends. - /// - /// When set to "Permanent", AbsoluteTimeout indicates the - /// cookie's lifetime via the Expires or Max-Age cookie attributes - /// and is required. - /// - /// When set to "Session", AbsoluteTimeout indicates the - /// absolute lifetime of the cookie tracked by the gateway and - /// is optional. - /// - /// Support: Core for "Session" type - /// - /// Support: Extended for "Permanent" type - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "lifetimeType" - )] - pub lifetime_type: Option, -} - -/// CookieConfig provides configuration settings that are specific -/// to cookie-based session persistence. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCRouteRulesSessionPersistenceCookieConfigLifetimeType { - Permanent, - Session, -} - -/// SessionPersistence defines and configures session persistence -/// for the route rule. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCRouteRulesSessionPersistenceType { - Cookie, - Header, -} - -/// Status defines the current state of GRPCRoute. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteStatus { - /// Parents is a list of parent resources (usually Gateways) that are - /// associated with the route, and the status of the route with respect to - /// each parent. When this route attaches to a parent, the controller that - /// manages the parent must add an entry to this list when the controller - /// first sees the route and should update the entry as appropriate when the - /// route or gateway is modified. - /// - /// Note that parent references that cannot be resolved by an implementation - /// of this API will not be added to this list. Implementations of this API - /// can only populate Route status for the Gateways/parent resources they are - /// responsible for. - /// - /// A maximum of 32 Gateways will be represented in this list. An empty list - /// means the route has not been attached to any Gateway. - pub parents: Vec, -} - -/// RouteParentStatus describes the status of a route with respect to an -/// associated Parent. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteStatusParents { - /// Conditions describes the status of the route with respect to the Gateway. - /// Note that the route's availability is also subject to the Gateway's own - /// status conditions and listener status. - /// - /// If the Route's ParentRef specifies an existing Gateway that supports - /// Routes of this kind AND that Gateway's controller has sufficient access, - /// then that Gateway's controller MUST set the "Accepted" condition on the - /// Route, to indicate whether the route has been accepted or rejected by the - /// Gateway, and why. - /// - /// A Route MUST be considered "Accepted" if at least one of the Route's - /// rules is implemented by the Gateway. - /// - /// There are a number of cases where the "Accepted" condition may not be set - /// due to lack of controller visibility, that includes when: - /// - /// * The Route refers to a non-existent parent. - /// * The Route is of a type that the controller does not support. - /// * The Route is in a namespace the controller does not have access to. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: Option>, - /// ControllerName is a domain/path string that indicates the name of the - /// controller that wrote this status. This corresponds with the - /// controllerName field on GatewayClass. - /// - /// Example: "example.net/gateway-controller". - /// - /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are - /// valid Kubernetes names - /// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names). - /// - /// Controllers MUST populate this field when writing status. Controllers should ensure that - /// entries to status populated with their ControllerName are cleaned up when they are no - /// longer necessary. - #[serde(rename = "controllerName")] - pub controller_name: String, - /// ParentRef corresponds with a ParentRef in the spec that this - /// RouteParentStatus struct describes the status of. - #[serde(rename = "parentRef")] - pub parent_ref: GRPCRouteStatusParentsParentRef, -} - -/// ParentRef corresponds with a ParentRef in the spec that this -/// RouteParentStatus struct describes the status of. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteStatusParentsParentRef { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. - /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// When the parent resource is a Service, this targets a specific port in the - /// Service spec. When both Port (experimental) and SectionName are specified, - /// the name and port of the selected port must match both specified values. - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, -} diff --git a/gateway-api/src/apis/experimental/httproutes.rs b/gateway-api/src/apis/experimental/httproutes.rs deleted file mode 100644 index d5dfc8a..0000000 --- a/gateway-api/src/apis/experimental/httproutes.rs +++ /dev/null @@ -1,2598 +0,0 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 - -#[allow(unused_imports)] -mod prelude { - pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube::CustomResource; - pub use schemars::JsonSchema; - pub use serde::{Deserialize, Serialize}; -} -use self::prelude::*; - -/// Spec defines the desired state of HTTPRoute. -#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -#[kube( - group = "gateway.networking.k8s.io", - version = "v1", - kind = "HTTPRoute", - plural = "httproutes" -)] -#[kube(namespaced)] -#[kube(status = "HTTPRouteStatus")] -#[kube(derive = "Default")] -#[kube(derive = "PartialEq")] -pub struct HTTPRouteSpec { - /// Hostnames defines a set of hostnames that should match against the HTTP Host - /// header to select a HTTPRoute used to process the request. Implementations - /// MUST ignore any port value specified in the HTTP Host header while - /// performing a match and (absent of any applicable header modification - /// configuration) MUST forward this header unmodified to the backend. - /// - /// Valid values for Hostnames are determined by RFC 1123 definition of a - /// hostname with 2 notable exceptions: - /// - /// 1. IPs are not allowed. - /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard - /// label must appear by itself as the first label. - /// - /// If a hostname is specified by both the Listener and HTTPRoute, there - /// must be at least one intersecting hostname for the HTTPRoute to be - /// attached to the Listener. For example: - /// - /// * A Listener with `test.example.com` as the hostname matches HTTPRoutes - /// that have either not specified any hostnames, or have specified at - /// least one of `test.example.com` or `*.example.com`. - /// * A Listener with `*.example.com` as the hostname matches HTTPRoutes - /// that have either not specified any hostnames or have specified at least - /// one hostname that matches the Listener hostname. For example, - /// `*.example.com`, `test.example.com`, and `foo.test.example.com` would - /// all match. On the other hand, `example.com` and `test.example.net` would - /// not match. - /// - /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted - /// as a suffix match. That means that a match for `*.example.com` would match - /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. - /// - /// If both the Listener and HTTPRoute have specified hostnames, any - /// HTTPRoute hostnames that do not match the Listener hostname MUST be - /// ignored. For example, if a Listener specified `*.example.com`, and the - /// HTTPRoute specified `test.example.com` and `test.example.net`, - /// `test.example.net` must not be considered for a match. - /// - /// If both the Listener and HTTPRoute have specified hostnames, and none - /// match with the criteria above, then the HTTPRoute is not accepted. The - /// implementation must raise an 'Accepted' Condition with a status of - /// `False` in the corresponding RouteParentStatus. - /// - /// In the event that multiple HTTPRoutes specify intersecting hostnames (e.g. - /// overlapping wildcard matching and exact matching hostnames), precedence must - /// be given to rules from the HTTPRoute with the largest number of: - /// - /// * Characters in a matching non-wildcard hostname. - /// * Characters in a matching hostname. - /// - /// If ties exist across multiple Routes, the matching precedence rules for - /// HTTPRouteMatches takes over. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostnames: Option>, - /// ParentRefs references the resources (usually Gateways) that a Route wants - /// to be attached to. Note that the referenced parent resource needs to - /// allow this for the attachment to be complete. For Gateways, that means - /// the Gateway needs to allow attachment from Routes of this kind and - /// namespace. For Services, that means the Service must either be in the same - /// namespace for a "producer" route, or the mesh implementation must support - /// and allow "consumer" routes for the referenced Service. ReferenceGrant is - /// not applicable for governing ParentRefs to Services - it is not possible to - /// create a "producer" route for a Service in a different namespace from the - /// Route. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// This API may be extended in the future to support additional kinds of parent - /// resources. - /// - /// ParentRefs must be _distinct_. This means either that: - /// - /// * They select different objects. If this is the case, then parentRef - /// entries are distinct. In terms of fields, this means that the - /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must - /// be unique across all parentRef entries in the Route. - /// * They do not select different objects, but for each optional field used, - /// each ParentRef that selects the same object must set the same set of - /// optional fields to different values. If one ParentRef sets a - /// combination of optional fields, all must set the same combination. - /// - /// Some examples: - /// - /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the - /// same object must also set `sectionName`. - /// * If one ParentRef sets `port`, all ParentRefs referencing the same - /// object must also set `port`. - /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs - /// referencing the same object must also set `sectionName` and `port`. - /// - /// It is possible to separately reference multiple distinct objects that may - /// be collapsed by an implementation. For example, some implementations may - /// choose to merge compatible Gateway Listeners together. If that is the - /// case, the list of routes attached to those resources should also be - /// merged. - /// - /// Note that for ParentRefs that cross namespace boundaries, there are specific - /// rules. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example, - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable other kinds of cross-namespace reference. - /// - /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. - /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. - /// - /// - /// - /// - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "parentRefs" - )] - pub parent_refs: Option>, - /// Rules are a list of HTTP matchers, filters and actions. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub rules: Option>, -} - -/// ParentReference identifies an API object (usually a Gateway) that can be considered -/// a parent of this resource (usually a route). There are two kinds of parent resources -/// with "Core" support: -/// -/// * Gateway (Gateway conformance profile) -/// * Service (Mesh conformance profile, ClusterIP Services only) -/// -/// This API may be extended in the future to support additional kinds of parent -/// resources. -/// -/// The API object must be valid in the cluster; the Group and Kind must -/// be registered in the cluster for this reference to be valid. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteParentRefs { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. - /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// When the parent resource is a Service, this targets a specific port in the - /// Service spec. When both Port (experimental) and SectionName are specified, - /// the name and port of the selected port must match both specified values. - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, -} - -/// HTTPRouteRule defines semantics for matching an HTTP request based on -/// conditions (matches), processing it (filters), and forwarding the request to -/// an API object (backendRefs). -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRules { - /// BackendRefs defines the backend(s) where matching requests should be - /// sent. - /// - /// Failure behavior here depends on how many BackendRefs are specified and - /// how many are invalid. - /// - /// If *all* entries in BackendRefs are invalid, and there are also no filters - /// specified in this route rule, *all* traffic which matches this rule MUST - /// receive a 500 status code. - /// - /// See the HTTPBackendRef definition for the rules about what makes a single - /// HTTPBackendRef invalid. - /// - /// When a HTTPBackendRef is invalid, 500 status codes MUST be returned for - /// requests that would have otherwise been routed to an invalid backend. If - /// multiple backends are specified, and some are invalid, the proportion of - /// requests that would otherwise have been routed to an invalid backend - /// MUST receive a 500 status code. - /// - /// For example, if two backends are specified with equal weights, and one is - /// invalid, 50 percent of traffic must receive a 500. Implementations may - /// choose how that 50 percent is determined. - /// - /// When a HTTPBackendRef refers to a Service that has no ready endpoints, - /// implementations SHOULD return a 503 for requests to that backend instead. - /// If an implementation chooses to do this, all of the above rules for 500 responses - /// MUST also apply for responses that return a 503. - /// - /// Support: Core for Kubernetes Service - /// - /// Support: Extended for Kubernetes ServiceImport - /// - /// Support: Implementation-specific for any other resource - /// - /// Support for weight: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "backendRefs" - )] - pub backend_refs: Option>, - /// Filters define the filters that are applied to requests that match - /// this rule. - /// - /// Wherever possible, implementations SHOULD implement filters in the order - /// they are specified. - /// - /// Implementations MAY choose to implement this ordering strictly, rejecting - /// any combination or order of filters that can not be supported. If implementations - /// choose a strict interpretation of filter ordering, they MUST clearly document - /// that behavior. - /// - /// To reject an invalid combination or order of filters, implementations SHOULD - /// consider the Route Rules with this configuration invalid. If all Route Rules - /// in a Route are invalid, the entire Route would be considered invalid. If only - /// a portion of Route Rules are invalid, implementations MUST set the - /// "PartiallyInvalid" condition for the Route. - /// - /// Conformance-levels at this level are defined based on the type of filter: - /// - /// - ALL core filters MUST be supported by all implementations. - /// - Implementers are encouraged to support extended filters. - /// - Implementation-specific custom filters have no API guarantees across - /// implementations. - /// - /// Specifying the same filter multiple times is not supported unless explicitly - /// indicated in the filter. - /// - /// All filters are expected to be compatible with each other except for the - /// URLRewrite and RequestRedirect filters, which may not be combined. If an - /// implementation can not support other combinations of filters, they must clearly - /// document that limitation. In cases where incompatible or unsupported - /// filters are specified and cause the `Accepted` condition to be set to status - /// `False`, implementations may use the `IncompatibleFilters` reason to specify - /// this configuration error. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, - /// Matches define conditions used for matching the rule against incoming - /// HTTP requests. Each match is independent, i.e. this rule will be matched - /// if **any** one of the matches is satisfied. - /// - /// For example, take the following matches configuration: - /// - /// ```text - /// matches: - /// - path: - /// value: "/foo" - /// headers: - /// - name: "version" - /// value: "v2" - /// - path: - /// value: "/v2/foo" - /// ``` - /// - /// For a request to match against this rule, a request must satisfy - /// EITHER of the two conditions: - /// - /// - path prefixed with `/foo` AND contains the header `version: v2` - /// - path prefix of `/v2/foo` - /// - /// See the documentation for HTTPRouteMatch on how to specify multiple - /// match conditions that should be ANDed together. - /// - /// If no matches are specified, the default is a prefix - /// path match on "/", which has the effect of matching every - /// HTTP request. - /// - /// Proxy or Load Balancer routing configuration generated from HTTPRoutes - /// MUST prioritize matches based on the following criteria, continuing on - /// ties. Across all rules specified on applicable Routes, precedence must be - /// given to the match having: - /// - /// * "Exact" path match. - /// * "Prefix" path match with largest number of characters. - /// * Method match. - /// * Largest number of header matches. - /// * Largest number of query param matches. - /// - /// Note: The precedence of RegularExpression path matches are implementation-specific. - /// - /// If ties still exist across multiple Routes, matching precedence MUST be - /// determined in order of the following criteria, continuing on ties: - /// - /// * The oldest Route based on creation timestamp. - /// * The Route appearing first in alphabetical order by - /// "{namespace}/{name}". - /// - /// If ties still exist within an HTTPRoute, matching precedence MUST be granted - /// to the FIRST matching rule (in list order) with a match meeting the above - /// criteria. - /// - /// When no rules matching a request have been successfully attached to the - /// parent a request is coming from, a HTTP 404 status code MUST be returned. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub matches: Option>, - /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. - /// - /// Support: Extended - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub name: Option, - /// Retry defines the configuration for when to retry an HTTP request. - /// - /// Support: Extended - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub retry: Option, - /// SessionPersistence defines and configures session persistence - /// for the route rule. - /// - /// Support: Extended - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sessionPersistence" - )] - pub session_persistence: Option, - /// Timeouts defines the timeouts that can be configured for an HTTP request. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub timeouts: Option, -} - -/// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. -/// -/// Note that when a namespace different than the local namespace is specified, a -/// ReferenceGrant object is required in the referent namespace to allow that -/// namespace's owner to accept the reference. See the ReferenceGrant -/// documentation for details. -/// -/// -/// -/// When the BackendRef points to a Kubernetes Service, implementations SHOULD -/// honor the appProtocol field if it is set for the target Service Port. -/// -/// Implementations supporting appProtocol SHOULD recognize the Kubernetes -/// Standard Application Protocols defined in KEP-3726. -/// -/// If a Service appProtocol isn't specified, an implementation MAY infer the -/// backend protocol through its own means. Implementations MAY infer the -/// protocol from the Route type referring to the backend Service. -/// -/// If a Route is not able to send traffic to the backend using the specified -/// protocol then the backend is considered invalid. Implementations MUST set the -/// "ResolvedRefs" condition to "False" with the "UnsupportedProtocol" reason. -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefs { - /// Filters defined at this level should be executed if and only if the - /// request is being forwarded to the backend defined here. - /// - /// Support: Implementation-specific (For broader support of filters, use the - /// Filters field in HTTPRouteRule.) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// Weight specifies the proportion of requests forwarded to the referenced - /// backend. This is computed as weight/(sum of all weights in this - /// BackendRefs list). For non-zero values, there may be some epsilon from - /// the exact proportion defined here depending on the precision an - /// implementation supports. Weight is not a percentage and the sum of - /// weights does not need to equal 100. - /// - /// If only one backend is specified and it has a weight greater than 0, 100% - /// of the traffic is forwarded to that backend. If weight is set to 0, no - /// traffic should be forwarded for this entry. If unspecified, weight - /// defaults to 1. - /// - /// Support for this field varies based on the context where used. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub weight: Option, -} - -/// HTTPRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. HTTPRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFilters { - /// ExtensionRef is an optional, implementation-specific extension to the - /// "filter" behavior. For example, resource "myroutefilter" in group - /// "networking.example.net"). ExtensionRef MUST NOT be used for core and - /// extended filters. - /// - /// This filter can be used multiple times within the same rule. - /// - /// Support: Implementation-specific - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "extensionRef" - )] - pub extension_ref: Option, - /// RequestHeaderModifier defines a schema for a filter that modifies request - /// headers. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestHeaderModifier" - )] - pub request_header_modifier: Option, - /// RequestMirror defines a schema for a filter that mirrors requests. - /// Requests are sent to the specified destination, but responses from - /// that destination are ignored. - /// - /// This filter can be used multiple times within the same rule. Note that - /// not all implementations will be able to support mirroring to multiple - /// backends. - /// - /// Support: Extended - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestMirror" - )] - pub request_mirror: Option, - /// RequestRedirect defines a schema for a filter that responds to the - /// request with an HTTP redirection. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestRedirect" - )] - pub request_redirect: Option, - /// ResponseHeaderModifier defines a schema for a filter that modifies response - /// headers. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "responseHeaderModifier" - )] - pub response_header_modifier: Option, - /// Type identifies the type of filter to apply. As with other API fields, - /// types are classified into three conformance levels: - /// - /// - Core: Filter types and their corresponding configuration defined by - /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All - /// implementations must support core filters. - /// - /// - Extended: Filter types and their corresponding configuration defined by - /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers - /// are encouraged to support extended filters. - /// - /// - Implementation-specific: Filters that are defined and supported by - /// specific vendors. - /// In the future, filters showing convergence in behavior across multiple - /// implementations will be considered for inclusion in extended or core - /// conformance levels. Filter-specific configuration for such filters - /// is specified using the ExtensionRef field. `Type` should be set to - /// "ExtensionRef" for custom filters. - /// - /// Implementers are encouraged to define custom implementation types to - /// extend the core API with implementation-specific behavior. - /// - /// If a reference to a custom filter type cannot be resolved, the filter - /// MUST NOT be skipped. Instead, requests that would have been processed by - /// that filter MUST receive a HTTP error response. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesBackendRefsFiltersType, - /// URLRewrite defines a schema for a filter that modifies a request during forwarding. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "urlRewrite" - )] - pub url_rewrite: Option, -} - -/// ExtensionRef is an optional, implementation-specific extension to the -/// "filter" behavior. For example, resource "myroutefilter" in group -/// "networking.example.net"). ExtensionRef MUST NOT be used for core and -/// extended filters. -/// -/// This filter can be used multiple times within the same rule. -/// -/// Support: Implementation-specific -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersExtensionRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - pub group: String, - /// Kind is kind of the referent. For example "HTTPRoute" or "Service". - pub kind: String, - /// Name is the name of the referent. - pub name: String, -} - -/// RequestHeaderModifier defines a schema for a filter that modifies request -/// headers. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// RequestMirror defines a schema for a filter that mirrors requests. -/// Requests are sent to the specified destination, but responses from -/// that destination are ignored. -/// -/// This filter can be used multiple times within the same rule. Note that -/// not all implementations will be able to support mirroring to multiple -/// backends. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestMirror { - /// BackendRef references a resource where mirrored requests are sent. - /// - /// Mirrored requests must be sent only to a single destination endpoint - /// within this BackendRef, irrespective of how many endpoints are present - /// within this BackendRef. - /// - /// If the referent cannot be found, this BackendRef is invalid and must be - /// dropped from the Gateway. The controller must ensure the "ResolvedRefs" - /// condition on the Route status is set to `status: False` and not configure - /// this backend in the underlying implementation. - /// - /// If there is a cross-namespace reference to an *existing* object - /// that is not allowed by a ReferenceGrant, the controller must ensure the - /// "ResolvedRefs" condition on the Route is set to `status: False`, - /// with the "RefNotPermitted" reason and not configure this backend in the - /// underlying implementation. - /// - /// In either error case, the Message of the `ResolvedRefs` Condition - /// should be used to provide more detail about the problem. - /// - /// Support: Extended for Kubernetes Service - /// - /// Support: Implementation-specific for any other resource - #[serde(rename = "backendRef")] - pub backend_ref: HTTPRouteRulesBackendRefsFiltersRequestMirrorBackendRef, - /// Fraction represents the fraction of requests that should be - /// mirrored to BackendRef. - /// - /// Only one of Fraction or Percent may be specified. If neither field - /// is specified, 100% of requests will be mirrored. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub fraction: Option, - /// Percent represents the percentage of requests that should be - /// mirrored to BackendRef. Its minimum value is 0 (indicating 0% of - /// requests) and its maximum value is 100 (indicating 100% of requests). - /// - /// Only one of Fraction or Percent may be specified. If neither field - /// is specified, 100% of requests will be mirrored. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub percent: Option, -} - -/// BackendRef references a resource where mirrored requests are sent. -/// -/// Mirrored requests must be sent only to a single destination endpoint -/// within this BackendRef, irrespective of how many endpoints are present -/// within this BackendRef. -/// -/// If the referent cannot be found, this BackendRef is invalid and must be -/// dropped from the Gateway. The controller must ensure the "ResolvedRefs" -/// condition on the Route status is set to `status: False` and not configure -/// this backend in the underlying implementation. -/// -/// If there is a cross-namespace reference to an *existing* object -/// that is not allowed by a ReferenceGrant, the controller must ensure the -/// "ResolvedRefs" condition on the Route is set to `status: False`, -/// with the "RefNotPermitted" reason and not configure this backend in the -/// underlying implementation. -/// -/// In either error case, the Message of the `ResolvedRefs` Condition -/// should be used to provide more detail about the problem. -/// -/// Support: Extended for Kubernetes Service -/// -/// Support: Implementation-specific for any other resource -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestMirrorBackendRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, -} - -/// Fraction represents the fraction of requests that should be -/// mirrored to BackendRef. -/// -/// Only one of Fraction or Percent may be specified. If neither field -/// is specified, 100% of requests will be mirrored. -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestMirrorFraction { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub denominator: Option, - pub numerator: i32, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestRedirect { - /// Hostname is the hostname to be used in the value of the `Location` - /// header in the response. - /// When empty, the hostname in the `Host` header of the request is used. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, - /// Path defines parameters used to modify the path of the incoming request. - /// The modified path is then used to construct the `Location` header. When - /// empty, the request path is used as-is. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub path: Option, - /// Port is the port to be used in the value of the `Location` - /// header in the response. - /// - /// If no port is specified, the redirect port MUST be derived using the - /// following rules: - /// - /// * If redirect scheme is not-empty, the redirect port MUST be the well-known - /// port associated with the redirect scheme. Specifically "http" to port 80 - /// and "https" to port 443. If the redirect scheme does not have a - /// well-known port, the listener port of the Gateway SHOULD be used. - /// * If redirect scheme is empty, the redirect port MUST be the Gateway - /// Listener port. - /// - /// Implementations SHOULD NOT add the port number in the 'Location' - /// header in the following cases: - /// - /// * A Location header that will use HTTP (whether that is determined via - /// the Listener protocol or the Scheme field) _and_ use port 80. - /// * A Location header that will use HTTPS (whether that is determined via - /// the Listener protocol or the Scheme field) _and_ use port 443. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// Scheme is the scheme to be used in the value of the `Location` header in - /// the response. When empty, the scheme of the request is used. - /// - /// Scheme redirects can affect the port of the redirect, for more information, - /// refer to the documentation for the port field of this filter. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub scheme: Option, - /// StatusCode is the HTTP status code to be used in response. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "statusCode" - )] - pub status_code: Option, -} - -/// Path defines parameters used to modify the path of the incoming request. -/// The modified path is then used to construct the `Location` header. When -/// empty, the request path is used as-is. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestRedirectPath { - /// ReplaceFullPath specifies the value with which to replace the full path - /// of a request during a rewrite or redirect. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replaceFullPath" - )] - pub replace_full_path: Option, - /// ReplacePrefixMatch specifies the value with which to replace the prefix - /// match of a request during a rewrite or redirect. For example, a request - /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch - /// of "/xyz" would be modified to "/xyz/bar". - /// - /// Note that this matches the behavior of the PathPrefix match type. This - /// matches full path elements. A path element refers to the list of labels - /// in the path split by the `/` separator. When specified, a trailing `/` is - /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all - /// match the prefix `/abc`, but the path `/abcd` would not. - /// - /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch. - /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in - /// the implementation setting the Accepted Condition for the Route to `status: False`. - /// - /// Request Path | Prefix Match | Replace Prefix | Modified Path - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replacePrefixMatch" - )] - pub replace_prefix_match: Option, - /// Type defines the type of path modifier. Additional types may be - /// added in a future release of the API. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType, -} - -/// Path defines parameters used to modify the path of the incoming request. -/// The modified path is then used to construct the `Location` header. When -/// empty, the request path is used as-is. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType { - ReplaceFullPath, - ReplacePrefixMatch, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesBackendRefsFiltersRequestRedirectScheme { - #[serde(rename = "http")] - Http, - #[serde(rename = "https")] - Https, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesBackendRefsFiltersRequestRedirectStatusCode { - #[serde(rename = "301")] - r#_301, - #[serde(rename = "302")] - r#_302, -} - -/// ResponseHeaderModifier defines a schema for a filter that modifies response -/// headers. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersResponseHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersResponseHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersResponseHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. HTTPRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesBackendRefsFiltersType { - RequestHeaderModifier, - ResponseHeaderModifier, - RequestMirror, - RequestRedirect, - #[serde(rename = "URLRewrite")] - UrlRewrite, - ExtensionRef, -} - -/// URLRewrite defines a schema for a filter that modifies a request during forwarding. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersUrlRewrite { - /// Hostname is the value to be used to replace the Host header value during - /// forwarding. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, - /// Path defines a path rewrite. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub path: Option, -} - -/// Path defines a path rewrite. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersUrlRewritePath { - /// ReplaceFullPath specifies the value with which to replace the full path - /// of a request during a rewrite or redirect. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replaceFullPath" - )] - pub replace_full_path: Option, - /// ReplacePrefixMatch specifies the value with which to replace the prefix - /// match of a request during a rewrite or redirect. For example, a request - /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch - /// of "/xyz" would be modified to "/xyz/bar". - /// - /// Note that this matches the behavior of the PathPrefix match type. This - /// matches full path elements. A path element refers to the list of labels - /// in the path split by the `/` separator. When specified, a trailing `/` is - /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all - /// match the prefix `/abc`, but the path `/abcd` would not. - /// - /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch. - /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in - /// the implementation setting the Accepted Condition for the Route to `status: False`. - /// - /// Request Path | Prefix Match | Replace Prefix | Modified Path - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replacePrefixMatch" - )] - pub replace_prefix_match: Option, - /// Type defines the type of path modifier. Additional types may be - /// added in a future release of the API. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesBackendRefsFiltersUrlRewritePathType, -} - -/// Path defines a path rewrite. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesBackendRefsFiltersUrlRewritePathType { - ReplaceFullPath, - ReplacePrefixMatch, -} - -/// HTTPRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. HTTPRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFilters { - /// ExtensionRef is an optional, implementation-specific extension to the - /// "filter" behavior. For example, resource "myroutefilter" in group - /// "networking.example.net"). ExtensionRef MUST NOT be used for core and - /// extended filters. - /// - /// This filter can be used multiple times within the same rule. - /// - /// Support: Implementation-specific - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "extensionRef" - )] - pub extension_ref: Option, - /// RequestHeaderModifier defines a schema for a filter that modifies request - /// headers. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestHeaderModifier" - )] - pub request_header_modifier: Option, - /// RequestMirror defines a schema for a filter that mirrors requests. - /// Requests are sent to the specified destination, but responses from - /// that destination are ignored. - /// - /// This filter can be used multiple times within the same rule. Note that - /// not all implementations will be able to support mirroring to multiple - /// backends. - /// - /// Support: Extended - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestMirror" - )] - pub request_mirror: Option, - /// RequestRedirect defines a schema for a filter that responds to the - /// request with an HTTP redirection. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestRedirect" - )] - pub request_redirect: Option, - /// ResponseHeaderModifier defines a schema for a filter that modifies response - /// headers. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "responseHeaderModifier" - )] - pub response_header_modifier: Option, - /// Type identifies the type of filter to apply. As with other API fields, - /// types are classified into three conformance levels: - /// - /// - Core: Filter types and their corresponding configuration defined by - /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All - /// implementations must support core filters. - /// - /// - Extended: Filter types and their corresponding configuration defined by - /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers - /// are encouraged to support extended filters. - /// - /// - Implementation-specific: Filters that are defined and supported by - /// specific vendors. - /// In the future, filters showing convergence in behavior across multiple - /// implementations will be considered for inclusion in extended or core - /// conformance levels. Filter-specific configuration for such filters - /// is specified using the ExtensionRef field. `Type` should be set to - /// "ExtensionRef" for custom filters. - /// - /// Implementers are encouraged to define custom implementation types to - /// extend the core API with implementation-specific behavior. - /// - /// If a reference to a custom filter type cannot be resolved, the filter - /// MUST NOT be skipped. Instead, requests that would have been processed by - /// that filter MUST receive a HTTP error response. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesFiltersType, - /// URLRewrite defines a schema for a filter that modifies a request during forwarding. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "urlRewrite" - )] - pub url_rewrite: Option, -} - -/// ExtensionRef is an optional, implementation-specific extension to the -/// "filter" behavior. For example, resource "myroutefilter" in group -/// "networking.example.net"). ExtensionRef MUST NOT be used for core and -/// extended filters. -/// -/// This filter can be used multiple times within the same rule. -/// -/// Support: Implementation-specific -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersExtensionRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - pub group: String, - /// Kind is kind of the referent. For example "HTTPRoute" or "Service". - pub kind: String, - /// Name is the name of the referent. - pub name: String, -} - -/// RequestHeaderModifier defines a schema for a filter that modifies request -/// headers. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// RequestMirror defines a schema for a filter that mirrors requests. -/// Requests are sent to the specified destination, but responses from -/// that destination are ignored. -/// -/// This filter can be used multiple times within the same rule. Note that -/// not all implementations will be able to support mirroring to multiple -/// backends. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestMirror { - /// BackendRef references a resource where mirrored requests are sent. - /// - /// Mirrored requests must be sent only to a single destination endpoint - /// within this BackendRef, irrespective of how many endpoints are present - /// within this BackendRef. - /// - /// If the referent cannot be found, this BackendRef is invalid and must be - /// dropped from the Gateway. The controller must ensure the "ResolvedRefs" - /// condition on the Route status is set to `status: False` and not configure - /// this backend in the underlying implementation. - /// - /// If there is a cross-namespace reference to an *existing* object - /// that is not allowed by a ReferenceGrant, the controller must ensure the - /// "ResolvedRefs" condition on the Route is set to `status: False`, - /// with the "RefNotPermitted" reason and not configure this backend in the - /// underlying implementation. - /// - /// In either error case, the Message of the `ResolvedRefs` Condition - /// should be used to provide more detail about the problem. - /// - /// Support: Extended for Kubernetes Service - /// - /// Support: Implementation-specific for any other resource - #[serde(rename = "backendRef")] - pub backend_ref: HTTPRouteRulesFiltersRequestMirrorBackendRef, - /// Fraction represents the fraction of requests that should be - /// mirrored to BackendRef. - /// - /// Only one of Fraction or Percent may be specified. If neither field - /// is specified, 100% of requests will be mirrored. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub fraction: Option, - /// Percent represents the percentage of requests that should be - /// mirrored to BackendRef. Its minimum value is 0 (indicating 0% of - /// requests) and its maximum value is 100 (indicating 100% of requests). - /// - /// Only one of Fraction or Percent may be specified. If neither field - /// is specified, 100% of requests will be mirrored. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub percent: Option, -} - -/// BackendRef references a resource where mirrored requests are sent. -/// -/// Mirrored requests must be sent only to a single destination endpoint -/// within this BackendRef, irrespective of how many endpoints are present -/// within this BackendRef. -/// -/// If the referent cannot be found, this BackendRef is invalid and must be -/// dropped from the Gateway. The controller must ensure the "ResolvedRefs" -/// condition on the Route status is set to `status: False` and not configure -/// this backend in the underlying implementation. -/// -/// If there is a cross-namespace reference to an *existing* object -/// that is not allowed by a ReferenceGrant, the controller must ensure the -/// "ResolvedRefs" condition on the Route is set to `status: False`, -/// with the "RefNotPermitted" reason and not configure this backend in the -/// underlying implementation. -/// -/// In either error case, the Message of the `ResolvedRefs` Condition -/// should be used to provide more detail about the problem. -/// -/// Support: Extended for Kubernetes Service -/// -/// Support: Implementation-specific for any other resource -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestMirrorBackendRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, -} - -/// Fraction represents the fraction of requests that should be -/// mirrored to BackendRef. -/// -/// Only one of Fraction or Percent may be specified. If neither field -/// is specified, 100% of requests will be mirrored. -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestMirrorFraction { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub denominator: Option, - pub numerator: i32, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestRedirect { - /// Hostname is the hostname to be used in the value of the `Location` - /// header in the response. - /// When empty, the hostname in the `Host` header of the request is used. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, - /// Path defines parameters used to modify the path of the incoming request. - /// The modified path is then used to construct the `Location` header. When - /// empty, the request path is used as-is. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub path: Option, - /// Port is the port to be used in the value of the `Location` - /// header in the response. - /// - /// If no port is specified, the redirect port MUST be derived using the - /// following rules: - /// - /// * If redirect scheme is not-empty, the redirect port MUST be the well-known - /// port associated with the redirect scheme. Specifically "http" to port 80 - /// and "https" to port 443. If the redirect scheme does not have a - /// well-known port, the listener port of the Gateway SHOULD be used. - /// * If redirect scheme is empty, the redirect port MUST be the Gateway - /// Listener port. - /// - /// Implementations SHOULD NOT add the port number in the 'Location' - /// header in the following cases: - /// - /// * A Location header that will use HTTP (whether that is determined via - /// the Listener protocol or the Scheme field) _and_ use port 80. - /// * A Location header that will use HTTPS (whether that is determined via - /// the Listener protocol or the Scheme field) _and_ use port 443. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// Scheme is the scheme to be used in the value of the `Location` header in - /// the response. When empty, the scheme of the request is used. - /// - /// Scheme redirects can affect the port of the redirect, for more information, - /// refer to the documentation for the port field of this filter. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub scheme: Option, - /// StatusCode is the HTTP status code to be used in response. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "statusCode" - )] - pub status_code: Option, -} - -/// Path defines parameters used to modify the path of the incoming request. -/// The modified path is then used to construct the `Location` header. When -/// empty, the request path is used as-is. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestRedirectPath { - /// ReplaceFullPath specifies the value with which to replace the full path - /// of a request during a rewrite or redirect. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replaceFullPath" - )] - pub replace_full_path: Option, - /// ReplacePrefixMatch specifies the value with which to replace the prefix - /// match of a request during a rewrite or redirect. For example, a request - /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch - /// of "/xyz" would be modified to "/xyz/bar". - /// - /// Note that this matches the behavior of the PathPrefix match type. This - /// matches full path elements. A path element refers to the list of labels - /// in the path split by the `/` separator. When specified, a trailing `/` is - /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all - /// match the prefix `/abc`, but the path `/abcd` would not. - /// - /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch. - /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in - /// the implementation setting the Accepted Condition for the Route to `status: False`. - /// - /// Request Path | Prefix Match | Replace Prefix | Modified Path - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replacePrefixMatch" - )] - pub replace_prefix_match: Option, - /// Type defines the type of path modifier. Additional types may be - /// added in a future release of the API. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesFiltersRequestRedirectPathType, -} - -/// Path defines parameters used to modify the path of the incoming request. -/// The modified path is then used to construct the `Location` header. When -/// empty, the request path is used as-is. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesFiltersRequestRedirectPathType { - ReplaceFullPath, - ReplacePrefixMatch, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesFiltersRequestRedirectScheme { - #[serde(rename = "http")] - Http, - #[serde(rename = "https")] - Https, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesFiltersRequestRedirectStatusCode { - #[serde(rename = "301")] - r#_301, - #[serde(rename = "302")] - r#_302, -} - -/// ResponseHeaderModifier defines a schema for a filter that modifies response -/// headers. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersResponseHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersResponseHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersResponseHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. HTTPRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesFiltersType { - RequestHeaderModifier, - ResponseHeaderModifier, - RequestMirror, - RequestRedirect, - #[serde(rename = "URLRewrite")] - UrlRewrite, - ExtensionRef, -} - -/// URLRewrite defines a schema for a filter that modifies a request during forwarding. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersUrlRewrite { - /// Hostname is the value to be used to replace the Host header value during - /// forwarding. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, - /// Path defines a path rewrite. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub path: Option, -} - -/// Path defines a path rewrite. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersUrlRewritePath { - /// ReplaceFullPath specifies the value with which to replace the full path - /// of a request during a rewrite or redirect. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replaceFullPath" - )] - pub replace_full_path: Option, - /// ReplacePrefixMatch specifies the value with which to replace the prefix - /// match of a request during a rewrite or redirect. For example, a request - /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch - /// of "/xyz" would be modified to "/xyz/bar". - /// - /// Note that this matches the behavior of the PathPrefix match type. This - /// matches full path elements. A path element refers to the list of labels - /// in the path split by the `/` separator. When specified, a trailing `/` is - /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all - /// match the prefix `/abc`, but the path `/abcd` would not. - /// - /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch. - /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in - /// the implementation setting the Accepted Condition for the Route to `status: False`. - /// - /// Request Path | Prefix Match | Replace Prefix | Modified Path - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replacePrefixMatch" - )] - pub replace_prefix_match: Option, - /// Type defines the type of path modifier. Additional types may be - /// added in a future release of the API. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesFiltersUrlRewritePathType, -} - -/// Path defines a path rewrite. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesFiltersUrlRewritePathType { - ReplaceFullPath, - ReplacePrefixMatch, -} - -/// HTTPRouteMatch defines the predicate used to match requests to a given -/// action. Multiple match types are ANDed together, i.e. the match will -/// evaluate to true only if all conditions are satisfied. -/// -/// For example, the match below will match a HTTP request only if its path -/// starts with `/foo` AND it contains the `version: v1` header: -/// -/// ```text -/// match: -/// -/// path: -/// value: "/foo" -/// headers: -/// - name: "version" -/// value "v1" -/// -/// ``` -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesMatches { - /// Headers specifies HTTP request header matchers. Multiple match values are - /// ANDed together, meaning, a request must match all the specified headers - /// to select the route. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub headers: Option>, - /// Method specifies HTTP method matcher. - /// When specified, this route will be matched only if the request has the - /// specified method. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub method: Option, - /// Path specifies a HTTP request path matcher. If this field is not - /// specified, a default prefix match on the "/" path is provided. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub path: Option, - /// QueryParams specifies HTTP query parameter matchers. Multiple match - /// values are ANDed together, meaning, a request must match all the - /// specified query parameters to select the route. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "queryParams" - )] - pub query_params: Option>, -} - -/// HTTPHeaderMatch describes how to select a HTTP route by matching HTTP request -/// headers. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesMatchesHeaders { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, only the first - /// entry with an equivalent name MUST be considered for a match. Subsequent - /// entries with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - /// - /// When a header is repeated in an HTTP request, it is - /// implementation-specific behavior as to how this is represented. - /// Generally, proxies should follow the guidance from the RFC: - /// https://www.rfc-editor.org/rfc/rfc7230.html#section-3.2.2 regarding - /// processing a repeated header, with special handling for "Set-Cookie". - pub name: String, - /// Type specifies how to match against the value of the header. - /// - /// Support: Core (Exact) - /// - /// Support: Implementation-specific (RegularExpression) - /// - /// Since RegularExpression HeaderMatchType has implementation-specific - /// conformance, implementations can support POSIX, PCRE or any other dialects - /// of regular expressions. Please read the implementation's documentation to - /// determine the supported dialect. - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeaderMatch describes how to select a HTTP route by matching HTTP request -/// headers. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesMatchesHeadersType { - Exact, - RegularExpression, -} - -/// HTTPRouteMatch defines the predicate used to match requests to a given -/// action. Multiple match types are ANDed together, i.e. the match will -/// evaluate to true only if all conditions are satisfied. -/// -/// For example, the match below will match a HTTP request only if its path -/// starts with `/foo` AND it contains the `version: v1` header: -/// -/// ```text -/// match: -/// -/// path: -/// value: "/foo" -/// headers: -/// - name: "version" -/// value "v1" -/// -/// ``` -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesMatchesMethod { - #[serde(rename = "GET")] - Get, - #[serde(rename = "HEAD")] - Head, - #[serde(rename = "POST")] - Post, - #[serde(rename = "PUT")] - Put, - #[serde(rename = "DELETE")] - Delete, - #[serde(rename = "CONNECT")] - Connect, - #[serde(rename = "OPTIONS")] - Options, - #[serde(rename = "TRACE")] - Trace, - #[serde(rename = "PATCH")] - Patch, -} - -/// Path specifies a HTTP request path matcher. If this field is not -/// specified, a default prefix match on the "/" path is provided. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesMatchesPath { - /// Type specifies how to match against the path Value. - /// - /// Support: Core (Exact, PathPrefix) - /// - /// Support: Implementation-specific (RegularExpression) - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value of the HTTP path to match against. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub value: Option, -} - -/// Path specifies a HTTP request path matcher. If this field is not -/// specified, a default prefix match on the "/" path is provided. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesMatchesPathType { - Exact, - PathPrefix, - RegularExpression, -} - -/// HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP -/// query parameters. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesMatchesQueryParams { - /// Name is the name of the HTTP query param to be matched. This must be an - /// exact string match. (See - /// https://tools.ietf.org/html/rfc7230#section-2.7.3). - /// - /// If multiple entries specify equivalent query param names, only the first - /// entry with an equivalent name MUST be considered for a match. Subsequent - /// entries with an equivalent query param name MUST be ignored. - /// - /// If a query param is repeated in an HTTP request, the behavior is - /// purposely left undefined, since different data planes have different - /// capabilities. However, it is *recommended* that implementations should - /// match against the first value of the param if the data plane supports it, - /// as this behavior is expected in other load balancing contexts outside of - /// the Gateway API. - /// - /// Users SHOULD NOT route traffic based on repeated query params to guard - /// themselves against potential differences in the implementations. - pub name: String, - /// Type specifies how to match against the value of the query parameter. - /// - /// Support: Extended (Exact) - /// - /// Support: Implementation-specific (RegularExpression) - /// - /// Since RegularExpression QueryParamMatchType has Implementation-specific - /// conformance, implementations can support POSIX, PCRE or any other - /// dialects of regular expressions. Please read the implementation's - /// documentation to determine the supported dialect. - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value is the value of HTTP query param to be matched. - pub value: String, -} - -/// HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP -/// query parameters. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesMatchesQueryParamsType { - Exact, - RegularExpression, -} - -/// Retry defines the configuration for when to retry an HTTP request. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesRetry { - /// Attempts specifies the maxmimum number of times an individual request - /// from the gateway to a backend should be retried. - /// - /// If the maximum number of retries has been attempted without a successful - /// response from the backend, the Gateway MUST return an error. - /// - /// When this field is unspecified, the number of times to attempt to retry - /// a backend request is implementation-specific. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub attempts: Option, - /// Backoff specifies the minimum duration a Gateway should wait between - /// retry attempts and is represented in Gateway API Duration formatting. - /// - /// For example, setting the `rules[].retry.backoff` field to the value - /// `100ms` will cause a backend request to first be retried approximately - /// 100 milliseconds after timing out or receiving a response code configured - /// to be retryable. - /// - /// An implementation MAY use an exponential or alternative backoff strategy - /// for subsequent retry attempts, MAY cap the maximum backoff duration to - /// some amount greater than the specified minimum, and MAY add arbitrary - /// jitter to stagger requests, as long as unsuccessful backend requests are - /// not retried before the configured minimum duration. - /// - /// If a Request timeout (`rules[].timeouts.request`) is configured on the - /// route, the entire duration of the initial request and any retry attempts - /// MUST not exceed the Request timeout duration. If any retry attempts are - /// still in progress when the Request timeout duration has been reached, - /// these SHOULD be canceled if possible and the Gateway MUST immediately - /// return a timeout error. - /// - /// If a BackendRequest timeout (`rules[].timeouts.backendRequest`) is - /// configured on the route, any retry attempts which reach the configured - /// BackendRequest timeout duration without a response SHOULD be canceled if - /// possible and the Gateway should wait for at least the specified backoff - /// duration before attempting to retry the backend request again. - /// - /// If a BackendRequest timeout is _not_ configured on the route, retry - /// attempts MAY time out after an implementation default duration, or MAY - /// remain pending until a configured Request timeout or implementation - /// default duration for total request time is reached. - /// - /// When this field is unspecified, the time to wait between retry attempts - /// is implementation-specific. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub backoff: Option, - /// Codes defines the HTTP response status codes for which a backend request - /// should be retried. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub codes: Option>, -} - -/// SessionPersistence defines and configures session persistence -/// for the route rule. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesSessionPersistence { - /// AbsoluteTimeout defines the absolute timeout of the persistent - /// session. Once the AbsoluteTimeout duration has elapsed, the - /// session becomes invalid. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "absoluteTimeout" - )] - pub absolute_timeout: Option, - /// CookieConfig provides configuration settings that are specific - /// to cookie-based session persistence. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "cookieConfig" - )] - pub cookie_config: Option, - /// IdleTimeout defines the idle timeout of the persistent session. - /// Once the session has been idle for more than the specified - /// IdleTimeout duration, the session becomes invalid. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "idleTimeout" - )] - pub idle_timeout: Option, - /// SessionName defines the name of the persistent session token - /// which may be reflected in the cookie or the header. Users - /// should avoid reusing session names to prevent unintended - /// consequences, such as rejection or unpredictable behavior. - /// - /// Support: Implementation-specific - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sessionName" - )] - pub session_name: Option, - /// Type defines the type of session persistence such as through - /// the use a header or cookie. Defaults to cookie based session - /// persistence. - /// - /// Support: Core for "Cookie" type - /// - /// Support: Extended for "Header" type - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, -} - -/// CookieConfig provides configuration settings that are specific -/// to cookie-based session persistence. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesSessionPersistenceCookieConfig { - /// LifetimeType specifies whether the cookie has a permanent or - /// session-based lifetime. A permanent cookie persists until its - /// specified expiry time, defined by the Expires or Max-Age cookie - /// attributes, while a session cookie is deleted when the current - /// session ends. - /// - /// When set to "Permanent", AbsoluteTimeout indicates the - /// cookie's lifetime via the Expires or Max-Age cookie attributes - /// and is required. - /// - /// When set to "Session", AbsoluteTimeout indicates the - /// absolute lifetime of the cookie tracked by the gateway and - /// is optional. - /// - /// Support: Core for "Session" type - /// - /// Support: Extended for "Permanent" type - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "lifetimeType" - )] - pub lifetime_type: Option, -} - -/// CookieConfig provides configuration settings that are specific -/// to cookie-based session persistence. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesSessionPersistenceCookieConfigLifetimeType { - Permanent, - Session, -} - -/// SessionPersistence defines and configures session persistence -/// for the route rule. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesSessionPersistenceType { - Cookie, - Header, -} - -/// Timeouts defines the timeouts that can be configured for an HTTP request. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesTimeouts { - /// BackendRequest specifies a timeout for an individual request from the gateway - /// to a backend. This covers the time from when the request first starts being - /// sent from the gateway to when the full response has been received from the backend. - /// - /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout - /// completely. Implementations that cannot completely disable the timeout MUST - /// instead interpret the zero duration as the longest possible value to which - /// the timeout can be set. - /// - /// An entire client HTTP transaction with a gateway, covered by the Request timeout, - /// may result in more than one call from the gateway to the destination backend, - /// for example, if automatic retries are supported. - /// - /// The value of BackendRequest must be a Gateway API Duration string as defined by - /// GEP-2257. When this field is unspecified, its behavior is implementation-specific; - /// when specified, the value of BackendRequest must be no more than the value of the - /// Request timeout (since the Request timeout encompasses the BackendRequest timeout). - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "backendRequest" - )] - pub backend_request: Option, - /// Request specifies the maximum duration for a gateway to respond to an HTTP request. - /// If the gateway has not been able to respond before this deadline is met, the gateway - /// MUST return a timeout error. - /// - /// For example, setting the `rules.timeouts.request` field to the value `10s` in an - /// `HTTPRoute` will cause a timeout if a client request is taking longer than 10 seconds - /// to complete. - /// - /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout - /// completely. Implementations that cannot completely disable the timeout MUST - /// instead interpret the zero duration as the longest possible value to which - /// the timeout can be set. - /// - /// This timeout is intended to cover as close to the whole request-response transaction - /// as possible although an implementation MAY choose to start the timeout after the entire - /// request stream has been received instead of immediately after the transaction is - /// initiated by the client. - /// - /// The value of Request is a Gateway API Duration string as defined by GEP-2257. When this - /// field is unspecified, request timeout behavior is implementation-specific. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub request: Option, -} - -/// Status defines the current state of HTTPRoute. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteStatus { - /// Parents is a list of parent resources (usually Gateways) that are - /// associated with the route, and the status of the route with respect to - /// each parent. When this route attaches to a parent, the controller that - /// manages the parent must add an entry to this list when the controller - /// first sees the route and should update the entry as appropriate when the - /// route or gateway is modified. - /// - /// Note that parent references that cannot be resolved by an implementation - /// of this API will not be added to this list. Implementations of this API - /// can only populate Route status for the Gateways/parent resources they are - /// responsible for. - /// - /// A maximum of 32 Gateways will be represented in this list. An empty list - /// means the route has not been attached to any Gateway. - pub parents: Vec, -} - -/// RouteParentStatus describes the status of a route with respect to an -/// associated Parent. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteStatusParents { - /// Conditions describes the status of the route with respect to the Gateway. - /// Note that the route's availability is also subject to the Gateway's own - /// status conditions and listener status. - /// - /// If the Route's ParentRef specifies an existing Gateway that supports - /// Routes of this kind AND that Gateway's controller has sufficient access, - /// then that Gateway's controller MUST set the "Accepted" condition on the - /// Route, to indicate whether the route has been accepted or rejected by the - /// Gateway, and why. - /// - /// A Route MUST be considered "Accepted" if at least one of the Route's - /// rules is implemented by the Gateway. - /// - /// There are a number of cases where the "Accepted" condition may not be set - /// due to lack of controller visibility, that includes when: - /// - /// * The Route refers to a non-existent parent. - /// * The Route is of a type that the controller does not support. - /// * The Route is in a namespace the controller does not have access to. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: Option>, - /// ControllerName is a domain/path string that indicates the name of the - /// controller that wrote this status. This corresponds with the - /// controllerName field on GatewayClass. - /// - /// Example: "example.net/gateway-controller". - /// - /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are - /// valid Kubernetes names - /// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names). - /// - /// Controllers MUST populate this field when writing status. Controllers should ensure that - /// entries to status populated with their ControllerName are cleaned up when they are no - /// longer necessary. - #[serde(rename = "controllerName")] - pub controller_name: String, - /// ParentRef corresponds with a ParentRef in the spec that this - /// RouteParentStatus struct describes the status of. - #[serde(rename = "parentRef")] - pub parent_ref: HTTPRouteStatusParentsParentRef, -} - -/// ParentRef corresponds with a ParentRef in the spec that this -/// RouteParentStatus struct describes the status of. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteStatusParentsParentRef { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. - /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// When the parent resource is a Service, this targets a specific port in the - /// Service spec. When both Port (experimental) and SectionName are specified, - /// the name and port of the selected port must match both specified values. - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, -} diff --git a/gateway-api/src/apis/experimental/tlsroutes.rs b/gateway-api/src/apis/experimental/tlsroutes.rs deleted file mode 100644 index fed8e98..0000000 --- a/gateway-api/src/apis/experimental/tlsroutes.rs +++ /dev/null @@ -1,564 +0,0 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 - -#[allow(unused_imports)] -mod prelude { - pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube::CustomResource; - pub use schemars::JsonSchema; - pub use serde::{Deserialize, Serialize}; -} -use self::prelude::*; - -/// Spec defines the desired state of TLSRoute. -#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -#[kube( - group = "gateway.networking.k8s.io", - version = "v1alpha2", - kind = "TLSRoute", - plural = "tlsroutes" -)] -#[kube(namespaced)] -#[kube(status = "TLSRouteStatus")] -#[kube(derive = "Default")] -#[kube(derive = "PartialEq")] -pub struct TLSRouteSpec { - /// Hostnames defines a set of SNI names that should match against the - /// SNI attribute of TLS ClientHello message in TLS handshake. This matches - /// the RFC 1123 definition of a hostname with 2 notable exceptions: - /// - /// 1. IPs are not allowed in SNI names per RFC 6066. - /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard - /// label must appear by itself as the first label. - /// - /// If a hostname is specified by both the Listener and TLSRoute, there - /// must be at least one intersecting hostname for the TLSRoute to be - /// attached to the Listener. For example: - /// - /// * A Listener with `test.example.com` as the hostname matches TLSRoutes - /// that have either not specified any hostnames, or have specified at - /// least one of `test.example.com` or `*.example.com`. - /// * A Listener with `*.example.com` as the hostname matches TLSRoutes - /// that have either not specified any hostnames or have specified at least - /// one hostname that matches the Listener hostname. For example, - /// `test.example.com` and `*.example.com` would both match. On the other - /// hand, `example.com` and `test.example.net` would not match. - /// - /// If both the Listener and TLSRoute have specified hostnames, any - /// TLSRoute hostnames that do not match the Listener hostname MUST be - /// ignored. For example, if a Listener specified `*.example.com`, and the - /// TLSRoute specified `test.example.com` and `test.example.net`, - /// `test.example.net` must not be considered for a match. - /// - /// If both the Listener and TLSRoute have specified hostnames, and none - /// match with the criteria above, then the TLSRoute is not accepted. The - /// implementation must raise an 'Accepted' Condition with a status of - /// `False` in the corresponding RouteParentStatus. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostnames: Option>, - /// ParentRefs references the resources (usually Gateways) that a Route wants - /// to be attached to. Note that the referenced parent resource needs to - /// allow this for the attachment to be complete. For Gateways, that means - /// the Gateway needs to allow attachment from Routes of this kind and - /// namespace. For Services, that means the Service must either be in the same - /// namespace for a "producer" route, or the mesh implementation must support - /// and allow "consumer" routes for the referenced Service. ReferenceGrant is - /// not applicable for governing ParentRefs to Services - it is not possible to - /// create a "producer" route for a Service in a different namespace from the - /// Route. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// This API may be extended in the future to support additional kinds of parent - /// resources. - /// - /// ParentRefs must be _distinct_. This means either that: - /// - /// * They select different objects. If this is the case, then parentRef - /// entries are distinct. In terms of fields, this means that the - /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must - /// be unique across all parentRef entries in the Route. - /// * They do not select different objects, but for each optional field used, - /// each ParentRef that selects the same object must set the same set of - /// optional fields to different values. If one ParentRef sets a - /// combination of optional fields, all must set the same combination. - /// - /// Some examples: - /// - /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the - /// same object must also set `sectionName`. - /// * If one ParentRef sets `port`, all ParentRefs referencing the same - /// object must also set `port`. - /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs - /// referencing the same object must also set `sectionName` and `port`. - /// - /// It is possible to separately reference multiple distinct objects that may - /// be collapsed by an implementation. For example, some implementations may - /// choose to merge compatible Gateway Listeners together. If that is the - /// case, the list of routes attached to those resources should also be - /// merged. - /// - /// Note that for ParentRefs that cross namespace boundaries, there are specific - /// rules. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example, - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable other kinds of cross-namespace reference. - /// - /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. - /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. - /// - /// - /// - /// - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "parentRefs" - )] - pub parent_refs: Option>, - /// Rules are a list of TLS matchers and actions. - /// - /// - pub rules: Vec, -} - -/// ParentReference identifies an API object (usually a Gateway) that can be considered -/// a parent of this resource (usually a route). There are two kinds of parent resources -/// with "Core" support: -/// -/// * Gateway (Gateway conformance profile) -/// * Service (Mesh conformance profile, ClusterIP Services only) -/// -/// This API may be extended in the future to support additional kinds of parent -/// resources. -/// -/// The API object must be valid in the cluster; the Group and Kind must -/// be registered in the cluster for this reference to be valid. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TLSRouteParentRefs { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. - /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// When the parent resource is a Service, this targets a specific port in the - /// Service spec. When both Port (experimental) and SectionName are specified, - /// the name and port of the selected port must match both specified values. - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, -} - -/// TLSRouteRule is the configuration for a given rule. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TLSRouteRules { - /// BackendRefs defines the backend(s) where matching requests should be - /// sent. If unspecified or invalid (refers to a non-existent resource or - /// a Service with no endpoints), the rule performs no forwarding; if no - /// filters are specified that would result in a response being sent, the - /// underlying implementation must actively reject request attempts to this - /// backend, by rejecting the connection or returning a 500 status code. - /// Request rejections must respect weight; if an invalid backend is - /// requested to have 80% of requests, then 80% of requests must be rejected - /// instead. - /// - /// Support: Core for Kubernetes Service - /// - /// Support: Extended for Kubernetes ServiceImport - /// - /// Support: Implementation-specific for any other resource - /// - /// Support for weight: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "backendRefs" - )] - pub backend_refs: Option>, - /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub name: Option, -} - -/// BackendRef defines how a Route should forward a request to a Kubernetes -/// resource. -/// -/// Note that when a namespace different than the local namespace is specified, a -/// ReferenceGrant object is required in the referent namespace to allow that -/// namespace's owner to accept the reference. See the ReferenceGrant -/// documentation for details. -/// -/// -/// -/// When the BackendRef points to a Kubernetes Service, implementations SHOULD -/// honor the appProtocol field if it is set for the target Service Port. -/// -/// Implementations supporting appProtocol SHOULD recognize the Kubernetes -/// Standard Application Protocols defined in KEP-3726. -/// -/// If a Service appProtocol isn't specified, an implementation MAY infer the -/// backend protocol through its own means. Implementations MAY infer the -/// protocol from the Route type referring to the backend Service. -/// -/// If a Route is not able to send traffic to the backend using the specified -/// protocol then the backend is considered invalid. Implementations MUST set the -/// "ResolvedRefs" condition to "False" with the "UnsupportedProtocol" reason. -/// -/// -/// -/// Note that when the BackendTLSPolicy object is enabled by the implementation, -/// there are some extra rules about validity to consider here. See the fields -/// where this struct is used for more information about the exact behavior. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TLSRouteRulesBackendRefs { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// Weight specifies the proportion of requests forwarded to the referenced - /// backend. This is computed as weight/(sum of all weights in this - /// BackendRefs list). For non-zero values, there may be some epsilon from - /// the exact proportion defined here depending on the precision an - /// implementation supports. Weight is not a percentage and the sum of - /// weights does not need to equal 100. - /// - /// If only one backend is specified and it has a weight greater than 0, 100% - /// of the traffic is forwarded to that backend. If weight is set to 0, no - /// traffic should be forwarded for this entry. If unspecified, weight - /// defaults to 1. - /// - /// Support for this field varies based on the context where used. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub weight: Option, -} - -/// Status defines the current state of TLSRoute. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TLSRouteStatus { - /// Parents is a list of parent resources (usually Gateways) that are - /// associated with the route, and the status of the route with respect to - /// each parent. When this route attaches to a parent, the controller that - /// manages the parent must add an entry to this list when the controller - /// first sees the route and should update the entry as appropriate when the - /// route or gateway is modified. - /// - /// Note that parent references that cannot be resolved by an implementation - /// of this API will not be added to this list. Implementations of this API - /// can only populate Route status for the Gateways/parent resources they are - /// responsible for. - /// - /// A maximum of 32 Gateways will be represented in this list. An empty list - /// means the route has not been attached to any Gateway. - pub parents: Vec, -} - -/// RouteParentStatus describes the status of a route with respect to an -/// associated Parent. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TLSRouteStatusParents { - /// Conditions describes the status of the route with respect to the Gateway. - /// Note that the route's availability is also subject to the Gateway's own - /// status conditions and listener status. - /// - /// If the Route's ParentRef specifies an existing Gateway that supports - /// Routes of this kind AND that Gateway's controller has sufficient access, - /// then that Gateway's controller MUST set the "Accepted" condition on the - /// Route, to indicate whether the route has been accepted or rejected by the - /// Gateway, and why. - /// - /// A Route MUST be considered "Accepted" if at least one of the Route's - /// rules is implemented by the Gateway. - /// - /// There are a number of cases where the "Accepted" condition may not be set - /// due to lack of controller visibility, that includes when: - /// - /// * The Route refers to a non-existent parent. - /// * The Route is of a type that the controller does not support. - /// * The Route is in a namespace the controller does not have access to. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: Option>, - /// ControllerName is a domain/path string that indicates the name of the - /// controller that wrote this status. This corresponds with the - /// controllerName field on GatewayClass. - /// - /// Example: "example.net/gateway-controller". - /// - /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are - /// valid Kubernetes names - /// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names). - /// - /// Controllers MUST populate this field when writing status. Controllers should ensure that - /// entries to status populated with their ControllerName are cleaned up when they are no - /// longer necessary. - #[serde(rename = "controllerName")] - pub controller_name: String, - /// ParentRef corresponds with a ParentRef in the spec that this - /// RouteParentStatus struct describes the status of. - #[serde(rename = "parentRef")] - pub parent_ref: TLSRouteStatusParentsParentRef, -} - -/// ParentRef corresponds with a ParentRef in the spec that this -/// RouteParentStatus struct describes the status of. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TLSRouteStatusParentsParentRef { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. - /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// When the parent resource is a Service, this targets a specific port in the - /// Service spec. When both Port (experimental) and SectionName are specified, - /// the name and port of the selected port must match both specified values. - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, -} diff --git a/gateway-api/src/apis/standard/enum_defaults.rs b/gateway-api/src/apis/standard/enum_defaults.rs deleted file mode 100644 index 3fee275..0000000 --- a/gateway-api/src/apis/standard/enum_defaults.rs +++ /dev/null @@ -1,58 +0,0 @@ -// WARNING: generated file - manual changes will be overriden - -use super::httproutes::{ - HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType, HTTPRouteRulesBackendRefsFiltersType, - HTTPRouteRulesBackendRefsFiltersUrlRewritePathType, - HTTPRouteRulesFiltersRequestRedirectPathType, HTTPRouteRulesFiltersType, - HTTPRouteRulesFiltersUrlRewritePathType, -}; - -use super::grpcroutes::{GRPCRouteRulesBackendRefsFiltersType, GRPCRouteRulesFiltersType}; - -impl Default for GRPCRouteRulesBackendRefsFiltersType { - fn default() -> Self { - GRPCRouteRulesBackendRefsFiltersType::RequestHeaderModifier - } -} - -impl Default for GRPCRouteRulesFiltersType { - fn default() -> Self { - GRPCRouteRulesFiltersType::RequestHeaderModifier - } -} - -impl Default for HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType { - fn default() -> Self { - HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType::ReplaceFullPath - } -} - -impl Default for HTTPRouteRulesBackendRefsFiltersType { - fn default() -> Self { - HTTPRouteRulesBackendRefsFiltersType::RequestHeaderModifier - } -} - -impl Default for HTTPRouteRulesBackendRefsFiltersUrlRewritePathType { - fn default() -> Self { - HTTPRouteRulesBackendRefsFiltersUrlRewritePathType::ReplaceFullPath - } -} - -impl Default for HTTPRouteRulesFiltersRequestRedirectPathType { - fn default() -> Self { - HTTPRouteRulesFiltersRequestRedirectPathType::ReplaceFullPath - } -} - -impl Default for HTTPRouteRulesFiltersType { - fn default() -> Self { - HTTPRouteRulesFiltersType::RequestHeaderModifier - } -} - -impl Default for HTTPRouteRulesFiltersUrlRewritePathType { - fn default() -> Self { - HTTPRouteRulesFiltersUrlRewritePathType::ReplaceFullPath - } -} diff --git a/gateway-api/src/apis/standard/gateways.rs b/gateway-api/src/apis/standard/gateways.rs deleted file mode 100644 index 96f62a1..0000000 --- a/gateway-api/src/apis/standard/gateways.rs +++ /dev/null @@ -1,707 +0,0 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 - -#[allow(unused_imports)] -mod prelude { - pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube::CustomResource; - pub use schemars::JsonSchema; - pub use serde::{Deserialize, Serialize}; - pub use std::collections::BTreeMap; -} -use self::prelude::*; - -/// Spec defines the desired state of Gateway. -#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -#[kube( - group = "gateway.networking.k8s.io", - version = "v1", - kind = "Gateway", - plural = "gateways" -)] -#[kube(namespaced)] -#[kube(status = "GatewayStatus")] -#[kube(derive = "Default")] -#[kube(derive = "PartialEq")] -pub struct GatewaySpec { - /// Addresses requested for this Gateway. This is optional and behavior can - /// depend on the implementation. If a value is set in the spec and the - /// requested address is invalid or unavailable, the implementation MUST - /// indicate this in the associated entry in GatewayStatus.Addresses. - /// - /// The Addresses field represents a request for the address(es) on the - /// "outside of the Gateway", that traffic bound for this Gateway will use. - /// This could be the IP address or hostname of an external load balancer or - /// other networking infrastructure, or some other address that traffic will - /// be sent to. - /// - /// If no Addresses are specified, the implementation MAY schedule the - /// Gateway in an implementation-specific manner, assigning an appropriate - /// set of Addresses. - /// - /// The implementation MUST bind all Listeners to every GatewayAddress that - /// it assigns to the Gateway and add a corresponding entry in - /// GatewayStatus.Addresses. - /// - /// Support: Extended - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub addresses: Option>, - /// GatewayClassName used for this Gateway. This is the name of a - /// GatewayClass resource. - #[serde(rename = "gatewayClassName")] - pub gateway_class_name: String, - /// Infrastructure defines infrastructure level attributes about this Gateway instance. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub infrastructure: Option, - /// Listeners associated with this Gateway. Listeners define - /// logical endpoints that are bound on this Gateway's addresses. - /// At least one Listener MUST be specified. - /// - /// Each Listener in a set of Listeners (for example, in a single Gateway) - /// MUST be _distinct_, in that a traffic flow MUST be able to be assigned to - /// exactly one listener. (This section uses "set of Listeners" rather than - /// "Listeners in a single Gateway" because implementations MAY merge configuration - /// from multiple Gateways onto a single data plane, and these rules _also_ - /// apply in that case). - /// - /// Practically, this means that each listener in a set MUST have a unique - /// combination of Port, Protocol, and, if supported by the protocol, Hostname. - /// - /// Some combinations of port, protocol, and TLS settings are considered - /// Core support and MUST be supported by implementations based on their - /// targeted conformance profile: - /// - /// HTTP Profile - /// - /// 1. HTTPRoute, Port: 80, Protocol: HTTP - /// 2. HTTPRoute, Port: 443, Protocol: HTTPS, TLS Mode: Terminate, TLS keypair provided - /// - /// TLS Profile - /// - /// 1. TLSRoute, Port: 443, Protocol: TLS, TLS Mode: Passthrough - /// - /// "Distinct" Listeners have the following property: - /// - /// The implementation can match inbound requests to a single distinct - /// Listener. When multiple Listeners share values for fields (for - /// example, two Listeners with the same Port value), the implementation - /// can match requests to only one of the Listeners using other - /// Listener fields. - /// - /// For example, the following Listener scenarios are distinct: - /// - /// 1. Multiple Listeners with the same Port that all use the "HTTP" - /// Protocol that all have unique Hostname values. - /// 2. Multiple Listeners with the same Port that use either the "HTTPS" or - /// "TLS" Protocol that all have unique Hostname values. - /// 3. A mixture of "TCP" and "UDP" Protocol Listeners, where no Listener - /// with the same Protocol has the same Port value. - /// - /// Some fields in the Listener struct have possible values that affect - /// whether the Listener is distinct. Hostname is particularly relevant - /// for HTTP or HTTPS protocols. - /// - /// When using the Hostname value to select between same-Port, same-Protocol - /// Listeners, the Hostname value must be different on each Listener for the - /// Listener to be distinct. - /// - /// When the Listeners are distinct based on Hostname, inbound request - /// hostnames MUST match from the most specific to least specific Hostname - /// values to choose the correct Listener and its associated set of Routes. - /// - /// Exact matches must be processed before wildcard matches, and wildcard - /// matches must be processed before fallback (empty Hostname value) - /// matches. For example, `"foo.example.com"` takes precedence over - /// `"*.example.com"`, and `"*.example.com"` takes precedence over `""`. - /// - /// Additionally, if there are multiple wildcard entries, more specific - /// wildcard entries must be processed before less specific wildcard entries. - /// For example, `"*.foo.example.com"` takes precedence over `"*.example.com"`. - /// The precise definition here is that the higher the number of dots in the - /// hostname to the right of the wildcard character, the higher the precedence. - /// - /// The wildcard character will match any number of characters _and dots_ to - /// the left, however, so `"*.example.com"` will match both - /// `"foo.bar.example.com"` _and_ `"bar.example.com"`. - /// - /// If a set of Listeners contains Listeners that are not distinct, then those - /// Listeners are Conflicted, and the implementation MUST set the "Conflicted" - /// condition in the Listener Status to "True". - /// - /// Implementations MAY choose to accept a Gateway with some Conflicted - /// Listeners only if they only accept the partial Listener set that contains - /// no Conflicted Listeners. To put this another way, implementations may - /// accept a partial Listener set only if they throw out *all* the conflicting - /// Listeners. No picking one of the conflicting listeners as the winner. - /// This also means that the Gateway must have at least one non-conflicting - /// Listener in this case, otherwise it violates the requirement that at - /// least one Listener must be present. - /// - /// The implementation MUST set a "ListenersNotValid" condition on the - /// Gateway Status when the Gateway contains Conflicted Listeners whether or - /// not they accept the Gateway. That Condition SHOULD clearly - /// indicate in the Message which Listeners are conflicted, and which are - /// Accepted. Additionally, the Listener status for those listeners SHOULD - /// indicate which Listeners are conflicted and not Accepted. - /// - /// A Gateway's Listeners are considered "compatible" if: - /// - /// 1. They are distinct. - /// 2. The implementation can serve them in compliance with the Addresses - /// requirement that all Listeners are available on all assigned - /// addresses. - /// - /// Compatible combinations in Extended support are expected to vary across - /// implementations. A combination that is compatible for one implementation - /// may not be compatible for another. - /// - /// For example, an implementation that cannot serve both TCP and UDP listeners - /// on the same address, or cannot mix HTTPS and generic TLS listens on the same port - /// would not consider those cases compatible, even though they are distinct. - /// - /// Note that requests SHOULD match at most one Listener. For example, if - /// Listeners are defined for "foo.example.com" and "*.example.com", a - /// request to "foo.example.com" SHOULD only be routed using routes attached - /// to the "foo.example.com" Listener (and not the "*.example.com" Listener). - /// This concept is known as "Listener Isolation". Implementations that do - /// not support Listener Isolation MUST clearly document this. - /// - /// Implementations MAY merge separate Gateways onto a single set of - /// Addresses if all Listeners across all Gateways are compatible. - /// - /// Support: Core - pub listeners: Vec, -} - -/// GatewayAddress describes an address that can be bound to a Gateway. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayAddresses { - /// Type of the address. - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value of the address. The validity of the values will depend - /// on the type and support by the controller. - /// - /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. - pub value: String, -} - -/// Infrastructure defines infrastructure level attributes about this Gateway instance. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayInfrastructure { - /// Annotations that SHOULD be applied to any resources created in response to this Gateway. - /// - /// For implementations creating other Kubernetes objects, this should be the `metadata.annotations` field on resources. - /// For other implementations, this refers to any relevant (implementation specific) "annotations" concepts. - /// - /// An implementation may chose to add additional implementation-specific annotations as they see fit. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub annotations: Option>, - /// Labels that SHOULD be applied to any resources created in response to this Gateway. - /// - /// For implementations creating other Kubernetes objects, this should be the `metadata.labels` field on resources. - /// For other implementations, this refers to any relevant (implementation specific) "labels" concepts. - /// - /// An implementation may chose to add additional implementation-specific labels as they see fit. - /// - /// If an implementation maps these labels to Pods, or any other resource that would need to be recreated when labels - /// change, it SHOULD clearly warn about this behavior in documentation. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub labels: Option>, - /// ParametersRef is a reference to a resource that contains the configuration - /// parameters corresponding to the Gateway. This is optional if the - /// controller does not require any additional configuration. - /// - /// This follows the same semantics as GatewayClass's `parametersRef`, but on a per-Gateway basis - /// - /// The Gateway's GatewayClass may provide its own `parametersRef`. When both are specified, - /// the merging behavior is implementation specific. - /// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. - /// - /// Support: Implementation-specific - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "parametersRef" - )] - pub parameters_ref: Option, -} - -/// ParametersRef is a reference to a resource that contains the configuration -/// parameters corresponding to the Gateway. This is optional if the -/// controller does not require any additional configuration. -/// -/// This follows the same semantics as GatewayClass's `parametersRef`, but on a per-Gateway basis -/// -/// The Gateway's GatewayClass may provide its own `parametersRef`. When both are specified, -/// the merging behavior is implementation specific. -/// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. -/// -/// Support: Implementation-specific -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayInfrastructureParametersRef { - /// Group is the group of the referent. - pub group: String, - /// Kind is kind of the referent. - pub kind: String, - /// Name is the name of the referent. - pub name: String, -} - -/// Listener embodies the concept of a logical endpoint where a Gateway accepts -/// network connections. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListeners { - /// AllowedRoutes defines the types of routes that MAY be attached to a - /// Listener and the trusted namespaces where those Route resources MAY be - /// present. - /// - /// Although a client request may match multiple route rules, only one rule - /// may ultimately receive the request. Matching precedence MUST be - /// determined in order of the following criteria: - /// - /// * The most specific match as defined by the Route type. - /// * The oldest Route based on creation timestamp. For example, a Route with - /// a creation timestamp of "2020-09-08 01:02:03" is given precedence over - /// a Route with a creation timestamp of "2020-09-08 01:02:04". - /// * If everything else is equivalent, the Route appearing first in - /// alphabetical order (namespace/name) should be given precedence. For - /// example, foo/bar is given precedence over foo/baz. - /// - /// All valid rules within a Route attached to this Listener should be - /// implemented. Invalid Route rules can be ignored (sometimes that will mean - /// the full Route). If a Route rule transitions from valid to invalid, - /// support for that Route rule should be dropped to ensure consistency. For - /// example, even if a filter specified by a Route rule is invalid, the rest - /// of the rules within that Route should still be supported. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "allowedRoutes" - )] - pub allowed_routes: Option, - /// Hostname specifies the virtual hostname to match for protocol types that - /// define this concept. When unspecified, all hostnames are matched. This - /// field is ignored for protocols that don't require hostname based - /// matching. - /// - /// Implementations MUST apply Hostname matching appropriately for each of - /// the following protocols: - /// - /// * TLS: The Listener Hostname MUST match the SNI. - /// * HTTP: The Listener Hostname MUST match the Host header of the request. - /// * HTTPS: The Listener Hostname SHOULD match at both the TLS and HTTP - /// protocol layers as described above. If an implementation does not - /// ensure that both the SNI and Host header match the Listener hostname, - /// it MUST clearly document that. - /// - /// For HTTPRoute and TLSRoute resources, there is an interaction with the - /// `spec.hostnames` array. When both listener and route specify hostnames, - /// there MUST be an intersection between the values for a Route to be - /// accepted. For more information, refer to the Route specific Hostnames - /// documentation. - /// - /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted - /// as a suffix match. That means that a match for `*.example.com` would match - /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, - /// Name is the name of the Listener. This name MUST be unique within a - /// Gateway. - /// - /// Support: Core - pub name: String, - /// Port is the network port. Multiple listeners may use the - /// same port, subject to the Listener compatibility rules. - /// - /// Support: Core - pub port: i32, - /// Protocol specifies the network protocol this listener expects to receive. - /// - /// Support: Core - pub protocol: String, - /// TLS is the TLS configuration for the Listener. This field is required if - /// the Protocol field is "HTTPS" or "TLS". It is invalid to set this field - /// if the Protocol field is "HTTP", "TCP", or "UDP". - /// - /// The association of SNIs to Certificate defined in GatewayTLSConfig is - /// defined based on the Hostname field for this listener. - /// - /// The GatewayClass MUST use the longest matching SNI out of all - /// available certificates for any TLS handshake. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub tls: Option, -} - -/// AllowedRoutes defines the types of routes that MAY be attached to a -/// Listener and the trusted namespaces where those Route resources MAY be -/// present. -/// -/// Although a client request may match multiple route rules, only one rule -/// may ultimately receive the request. Matching precedence MUST be -/// determined in order of the following criteria: -/// -/// * The most specific match as defined by the Route type. -/// * The oldest Route based on creation timestamp. For example, a Route with -/// a creation timestamp of "2020-09-08 01:02:03" is given precedence over -/// a Route with a creation timestamp of "2020-09-08 01:02:04". -/// * If everything else is equivalent, the Route appearing first in -/// alphabetical order (namespace/name) should be given precedence. For -/// example, foo/bar is given precedence over foo/baz. -/// -/// All valid rules within a Route attached to this Listener should be -/// implemented. Invalid Route rules can be ignored (sometimes that will mean -/// the full Route). If a Route rule transitions from valid to invalid, -/// support for that Route rule should be dropped to ensure consistency. For -/// example, even if a filter specified by a Route rule is invalid, the rest -/// of the rules within that Route should still be supported. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersAllowedRoutes { - /// Kinds specifies the groups and kinds of Routes that are allowed to bind - /// to this Gateway Listener. When unspecified or empty, the kinds of Routes - /// selected are determined using the Listener protocol. - /// - /// A RouteGroupKind MUST correspond to kinds of Routes that are compatible - /// with the application protocol specified in the Listener's Protocol field. - /// If an implementation does not support or recognize this resource type, it - /// MUST set the "ResolvedRefs" condition to False for this Listener with the - /// "InvalidRouteKinds" reason. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kinds: Option>, - /// Namespaces indicates namespaces from which Routes may be attached to this - /// Listener. This is restricted to the namespace of this Gateway by default. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespaces: Option, -} - -/// RouteGroupKind indicates the group and kind of a Route resource. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersAllowedRoutesKinds { - /// Group is the group of the Route. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the kind of the Route. - pub kind: String, -} - -/// Namespaces indicates namespaces from which Routes may be attached to this -/// Listener. This is restricted to the namespace of this Gateway by default. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersAllowedRoutesNamespaces { - /// From indicates where Routes will be selected for this Gateway. Possible - /// values are: - /// - /// * All: Routes in all namespaces may be used by this Gateway. - /// * Selector: Routes in namespaces selected by the selector may be used by - /// this Gateway. - /// * Same: Only Routes in the same namespace may be used by this Gateway. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub from: Option, - /// Selector must be specified when From is set to "Selector". In that case, - /// only Routes in Namespaces matching this Selector will be selected by this - /// Gateway. This field is ignored for other values of "From". - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub selector: Option, -} - -/// Namespaces indicates namespaces from which Routes may be attached to this -/// Listener. This is restricted to the namespace of this Gateway by default. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayListenersAllowedRoutesNamespacesFrom { - All, - Selector, - Same, -} - -/// Selector must be specified when From is set to "Selector". In that case, -/// only Routes in Namespaces matching this Selector will be selected by this -/// Gateway. This field is ignored for other values of "From". -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersAllowedRoutesNamespacesSelector { - /// matchExpressions is a list of label selector requirements. The requirements are ANDed. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "matchExpressions" - )] - pub match_expressions: - Option>, - /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - /// map is equivalent to an element of matchExpressions, whose key field is "key", the - /// operator is "In", and the values array contains only "value". The requirements are ANDed. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "matchLabels" - )] - pub match_labels: Option>, -} - -/// A label selector requirement is a selector that contains values, a key, and an operator that -/// relates the key and values. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersAllowedRoutesNamespacesSelectorMatchExpressions { - /// key is the label key that the selector applies to. - pub key: String, - /// operator represents a key's relationship to a set of values. - /// Valid operators are In, NotIn, Exists and DoesNotExist. - pub operator: String, - /// values is an array of string values. If the operator is In or NotIn, - /// the values array must be non-empty. If the operator is Exists or DoesNotExist, - /// the values array must be empty. This array is replaced during a strategic - /// merge patch. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub values: Option>, -} - -/// TLS is the TLS configuration for the Listener. This field is required if -/// the Protocol field is "HTTPS" or "TLS". It is invalid to set this field -/// if the Protocol field is "HTTP", "TCP", or "UDP". -/// -/// The association of SNIs to Certificate defined in GatewayTLSConfig is -/// defined based on the Hostname field for this listener. -/// -/// The GatewayClass MUST use the longest matching SNI out of all -/// available certificates for any TLS handshake. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersTls { - /// CertificateRefs contains a series of references to Kubernetes objects that - /// contains TLS certificates and private keys. These certificates are used to - /// establish a TLS handshake for requests that match the hostname of the - /// associated listener. - /// - /// A single CertificateRef to a Kubernetes Secret has "Core" support. - /// Implementations MAY choose to support attaching multiple certificates to - /// a Listener, but this behavior is implementation-specific. - /// - /// References to a resource in different namespace are invalid UNLESS there - /// is a ReferenceGrant in the target namespace that allows the certificate - /// to be attached. If a ReferenceGrant does not allow this reference, the - /// "ResolvedRefs" condition MUST be set to False for this listener with the - /// "RefNotPermitted" reason. - /// - /// This field is required to have at least one element when the mode is set - /// to "Terminate" (default) and is optional otherwise. - /// - /// CertificateRefs can reference to standard Kubernetes resources, i.e. - /// Secret, or implementation-specific custom resources. - /// - /// Support: Core - A single reference to a Kubernetes Secret of type kubernetes.io/tls - /// - /// Support: Implementation-specific (More than one reference or other resource types) - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "certificateRefs" - )] - pub certificate_refs: Option>, - /// Mode defines the TLS behavior for the TLS session initiated by the client. - /// There are two possible modes: - /// - /// - Terminate: The TLS session between the downstream client and the - /// Gateway is terminated at the Gateway. This mode requires certificates - /// to be specified in some way, such as populating the certificateRefs - /// field. - /// - Passthrough: The TLS session is NOT terminated by the Gateway. This - /// implies that the Gateway can't decipher the TLS stream except for - /// the ClientHello message of the TLS protocol. The certificateRefs field - /// is ignored in this mode. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub mode: Option, - /// Options are a list of key/value pairs to enable extended TLS - /// configuration for each implementation. For example, configuring the - /// minimum TLS version or supported cipher suites. - /// - /// A set of common keys MAY be defined by the API in the future. To avoid - /// any ambiguity, implementation-specific definitions MUST use - /// domain-prefixed names, such as `example.com/my-custom-option`. - /// Un-prefixed names are reserved for key names defined by Gateway API. - /// - /// Support: Implementation-specific - #[serde(default, skip_serializing_if = "Option::is_none")] - pub options: Option>, -} - -/// SecretObjectReference identifies an API object including its namespace, -/// defaulting to Secret. -/// -/// The API object must be valid in the cluster; the Group and Kind must -/// be registered in the cluster for this reference to be valid. -/// -/// References to objects with invalid Group and Kind are not valid, and must -/// be rejected by the implementation, with appropriate Conditions set -/// on the containing object. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersTlsCertificateRefs { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. For example "Secret". - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the referenced object. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, -} - -/// TLS is the TLS configuration for the Listener. This field is required if -/// the Protocol field is "HTTPS" or "TLS". It is invalid to set this field -/// if the Protocol field is "HTTP", "TCP", or "UDP". -/// -/// The association of SNIs to Certificate defined in GatewayTLSConfig is -/// defined based on the Hostname field for this listener. -/// -/// The GatewayClass MUST use the longest matching SNI out of all -/// available certificates for any TLS handshake. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayListenersTlsMode { - Terminate, - Passthrough, -} - -/// Status defines the current state of Gateway. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayStatus { - /// Addresses lists the network addresses that have been bound to the - /// Gateway. - /// - /// This list may differ from the addresses provided in the spec under some - /// conditions: - /// - /// * no addresses are specified, all addresses are dynamically assigned - /// * a combination of specified and dynamic addresses are assigned - /// * a specified address was unusable (e.g. already in use) - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub addresses: Option>, - /// Conditions describe the current conditions of the Gateway. - /// - /// Implementations should prefer to express Gateway conditions - /// using the `GatewayConditionType` and `GatewayConditionReason` - /// constants so that operators and tools can converge on a common - /// vocabulary to describe Gateway state. - /// - /// Known condition types are: - /// - /// * "Accepted" - /// * "Programmed" - /// * "Ready" - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: Option>, - /// Listeners provide status for each unique listener port defined in the Spec. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub listeners: Option>, -} - -/// GatewayStatusAddress describes a network address that is bound to a Gateway. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayStatusAddresses { - /// Type of the address. - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value of the address. The validity of the values will depend - /// on the type and support by the controller. - /// - /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. - pub value: String, -} - -/// ListenerStatus is the status associated with a Listener. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayStatusListeners { - /// AttachedRoutes represents the total number of Routes that have been - /// successfully attached to this Listener. - /// - /// Successful attachment of a Route to a Listener is based solely on the - /// combination of the AllowedRoutes field on the corresponding Listener - /// and the Route's ParentRefs field. A Route is successfully attached to - /// a Listener when it is selected by the Listener's AllowedRoutes field - /// AND the Route has a valid ParentRef selecting the whole Gateway - /// resource or a specific Listener as a parent resource (more detail on - /// attachment semantics can be found in the documentation on the various - /// Route kinds ParentRefs fields). Listener or Route status does not impact - /// successful attachment, i.e. the AttachedRoutes field count MUST be set - /// for Listeners with condition Accepted: false and MUST count successfully - /// attached Routes that may themselves have Accepted: false conditions. - /// - /// Uses for this field include troubleshooting Route attachment and - /// measuring blast radius/impact of changes to a Listener. - #[serde(rename = "attachedRoutes")] - pub attached_routes: i32, - /// Conditions describe the current condition of this listener. - pub conditions: Vec, - /// Name is the name of the Listener that this status corresponds to. - pub name: String, - /// SupportedKinds is the list indicating the Kinds supported by this - /// listener. This MUST represent the kinds an implementation supports for - /// that Listener configuration. - /// - /// If kinds are specified in Spec that are not supported, they MUST NOT - /// appear in this list and an implementation MUST set the "ResolvedRefs" - /// condition to "False" with the "InvalidRouteKinds" reason. If both valid - /// and invalid Route kinds are specified, the implementation MUST - /// reference the valid Route kinds that have been specified. - #[serde(rename = "supportedKinds")] - pub supported_kinds: Vec, -} - -/// RouteGroupKind indicates the group and kind of a Route resource. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayStatusListenersSupportedKinds { - /// Group is the group of the Route. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the kind of the Route. - pub kind: String, -} diff --git a/gateway-api/src/apis/standard/grpcroutes.rs b/gateway-api/src/apis/standard/grpcroutes.rs deleted file mode 100644 index 60949b7..0000000 --- a/gateway-api/src/apis/standard/grpcroutes.rs +++ /dev/null @@ -1,1556 +0,0 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 - -#[allow(unused_imports)] -mod prelude { - pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube::CustomResource; - pub use schemars::JsonSchema; - pub use serde::{Deserialize, Serialize}; -} -use self::prelude::*; - -/// Spec defines the desired state of GRPCRoute. -#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -#[kube( - group = "gateway.networking.k8s.io", - version = "v1", - kind = "GRPCRoute", - plural = "grpcroutes" -)] -#[kube(namespaced)] -#[kube(status = "GRPCRouteStatus")] -#[kube(derive = "Default")] -#[kube(derive = "PartialEq")] -pub struct GRPCRouteSpec { - /// Hostnames defines a set of hostnames to match against the GRPC - /// Host header to select a GRPCRoute to process the request. This matches - /// the RFC 1123 definition of a hostname with 2 notable exceptions: - /// - /// 1. IPs are not allowed. - /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard - /// label MUST appear by itself as the first label. - /// - /// If a hostname is specified by both the Listener and GRPCRoute, there - /// MUST be at least one intersecting hostname for the GRPCRoute to be - /// attached to the Listener. For example: - /// - /// * A Listener with `test.example.com` as the hostname matches GRPCRoutes - /// that have either not specified any hostnames, or have specified at - /// least one of `test.example.com` or `*.example.com`. - /// * A Listener with `*.example.com` as the hostname matches GRPCRoutes - /// that have either not specified any hostnames or have specified at least - /// one hostname that matches the Listener hostname. For example, - /// `test.example.com` and `*.example.com` would both match. On the other - /// hand, `example.com` and `test.example.net` would not match. - /// - /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted - /// as a suffix match. That means that a match for `*.example.com` would match - /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. - /// - /// If both the Listener and GRPCRoute have specified hostnames, any - /// GRPCRoute hostnames that do not match the Listener hostname MUST be - /// ignored. For example, if a Listener specified `*.example.com`, and the - /// GRPCRoute specified `test.example.com` and `test.example.net`, - /// `test.example.net` MUST NOT be considered for a match. - /// - /// If both the Listener and GRPCRoute have specified hostnames, and none - /// match with the criteria above, then the GRPCRoute MUST NOT be accepted by - /// the implementation. The implementation MUST raise an 'Accepted' Condition - /// with a status of `False` in the corresponding RouteParentStatus. - /// - /// If a Route (A) of type HTTPRoute or GRPCRoute is attached to a - /// Listener and that listener already has another Route (B) of the other - /// type attached and the intersection of the hostnames of A and B is - /// non-empty, then the implementation MUST accept exactly one of these two - /// routes, determined by the following criteria, in order: - /// - /// * The oldest Route based on creation timestamp. - /// * The Route appearing first in alphabetical order by - /// "{namespace}/{name}". - /// - /// The rejected Route MUST raise an 'Accepted' condition with a status of - /// 'False' in the corresponding RouteParentStatus. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostnames: Option>, - /// ParentRefs references the resources (usually Gateways) that a Route wants - /// to be attached to. Note that the referenced parent resource needs to - /// allow this for the attachment to be complete. For Gateways, that means - /// the Gateway needs to allow attachment from Routes of this kind and - /// namespace. For Services, that means the Service must either be in the same - /// namespace for a "producer" route, or the mesh implementation must support - /// and allow "consumer" routes for the referenced Service. ReferenceGrant is - /// not applicable for governing ParentRefs to Services - it is not possible to - /// create a "producer" route for a Service in a different namespace from the - /// Route. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// This API may be extended in the future to support additional kinds of parent - /// resources. - /// - /// ParentRefs must be _distinct_. This means either that: - /// - /// * They select different objects. If this is the case, then parentRef - /// entries are distinct. In terms of fields, this means that the - /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must - /// be unique across all parentRef entries in the Route. - /// * They do not select different objects, but for each optional field used, - /// each ParentRef that selects the same object must set the same set of - /// optional fields to different values. If one ParentRef sets a - /// combination of optional fields, all must set the same combination. - /// - /// Some examples: - /// - /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the - /// same object must also set `sectionName`. - /// * If one ParentRef sets `port`, all ParentRefs referencing the same - /// object must also set `port`. - /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs - /// referencing the same object must also set `sectionName` and `port`. - /// - /// It is possible to separately reference multiple distinct objects that may - /// be collapsed by an implementation. For example, some implementations may - /// choose to merge compatible Gateway Listeners together. If that is the - /// case, the list of routes attached to those resources should also be - /// merged. - /// - /// Note that for ParentRefs that cross namespace boundaries, there are specific - /// rules. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example, - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable other kinds of cross-namespace reference. - /// - /// - /// - /// - /// - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "parentRefs" - )] - pub parent_refs: Option>, - /// Rules are a list of GRPC matchers, filters and actions. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub rules: Option>, -} - -/// ParentReference identifies an API object (usually a Gateway) that can be considered -/// a parent of this resource (usually a route). There are two kinds of parent resources -/// with "Core" support: -/// -/// * Gateway (Gateway conformance profile) -/// * Service (Mesh conformance profile, ClusterIP Services only) -/// -/// This API may be extended in the future to support additional kinds of parent -/// resources. -/// -/// The API object must be valid in the cluster; the Group and Kind must -/// be registered in the cluster for this reference to be valid. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteParentRefs { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, -} - -/// GRPCRouteRule defines the semantics for matching a gRPC request based on -/// conditions (matches), processing it (filters), and forwarding the request to -/// an API object (backendRefs). -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRules { - /// BackendRefs defines the backend(s) where matching requests should be - /// sent. - /// - /// Failure behavior here depends on how many BackendRefs are specified and - /// how many are invalid. - /// - /// If *all* entries in BackendRefs are invalid, and there are also no filters - /// specified in this route rule, *all* traffic which matches this rule MUST - /// receive an `UNAVAILABLE` status. - /// - /// See the GRPCBackendRef definition for the rules about what makes a single - /// GRPCBackendRef invalid. - /// - /// When a GRPCBackendRef is invalid, `UNAVAILABLE` statuses MUST be returned for - /// requests that would have otherwise been routed to an invalid backend. If - /// multiple backends are specified, and some are invalid, the proportion of - /// requests that would otherwise have been routed to an invalid backend - /// MUST receive an `UNAVAILABLE` status. - /// - /// For example, if two backends are specified with equal weights, and one is - /// invalid, 50 percent of traffic MUST receive an `UNAVAILABLE` status. - /// Implementations may choose how that 50 percent is determined. - /// - /// Support: Core for Kubernetes Service - /// - /// Support: Implementation-specific for any other resource - /// - /// Support for weight: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "backendRefs" - )] - pub backend_refs: Option>, - /// Filters define the filters that are applied to requests that match - /// this rule. - /// - /// The effects of ordering of multiple behaviors are currently unspecified. - /// This can change in the future based on feedback during the alpha stage. - /// - /// Conformance-levels at this level are defined based on the type of filter: - /// - /// - ALL core filters MUST be supported by all implementations that support - /// GRPCRoute. - /// - Implementers are encouraged to support extended filters. - /// - Implementation-specific custom filters have no API guarantees across - /// implementations. - /// - /// Specifying the same filter multiple times is not supported unless explicitly - /// indicated in the filter. - /// - /// If an implementation can not support a combination of filters, it must clearly - /// document that limitation. In cases where incompatible or unsupported - /// filters are specified and cause the `Accepted` condition to be set to status - /// `False`, implementations may use the `IncompatibleFilters` reason to specify - /// this configuration error. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, - /// Matches define conditions used for matching the rule against incoming - /// gRPC requests. Each match is independent, i.e. this rule will be matched - /// if **any** one of the matches is satisfied. - /// - /// For example, take the following matches configuration: - /// - /// ```text - /// matches: - /// - method: - /// service: foo.bar - /// headers: - /// values: - /// version: 2 - /// - method: - /// service: foo.bar.v2 - /// ``` - /// - /// For a request to match against this rule, it MUST satisfy - /// EITHER of the two conditions: - /// - /// - service of foo.bar AND contains the header `version: 2` - /// - service of foo.bar.v2 - /// - /// See the documentation for GRPCRouteMatch on how to specify multiple - /// match conditions to be ANDed together. - /// - /// If no matches are specified, the implementation MUST match every gRPC request. - /// - /// Proxy or Load Balancer routing configuration generated from GRPCRoutes - /// MUST prioritize rules based on the following criteria, continuing on - /// ties. Merging MUST not be done between GRPCRoutes and HTTPRoutes. - /// Precedence MUST be given to the rule with the largest number of: - /// - /// * Characters in a matching non-wildcard hostname. - /// * Characters in a matching hostname. - /// * Characters in a matching service. - /// * Characters in a matching method. - /// * Header matches. - /// - /// If ties still exist across multiple Routes, matching precedence MUST be - /// determined in order of the following criteria, continuing on ties: - /// - /// * The oldest Route based on creation timestamp. - /// * The Route appearing first in alphabetical order by - /// "{namespace}/{name}". - /// - /// If ties still exist within the Route that has been given precedence, - /// matching precedence MUST be granted to the first matching rule meeting - /// the above criteria. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub matches: Option>, -} - -/// GRPCBackendRef defines how a GRPCRoute forwards a gRPC request. -/// -/// Note that when a namespace different than the local namespace is specified, a -/// ReferenceGrant object is required in the referent namespace to allow that -/// namespace's owner to accept the reference. See the ReferenceGrant -/// documentation for details. -/// -/// -/// -/// When the BackendRef points to a Kubernetes Service, implementations SHOULD -/// honor the appProtocol field if it is set for the target Service Port. -/// -/// Implementations supporting appProtocol SHOULD recognize the Kubernetes -/// Standard Application Protocols defined in KEP-3726. -/// -/// If a Service appProtocol isn't specified, an implementation MAY infer the -/// backend protocol through its own means. Implementations MAY infer the -/// protocol from the Route type referring to the backend Service. -/// -/// If a Route is not able to send traffic to the backend using the specified -/// protocol then the backend is considered invalid. Implementations MUST set the -/// "ResolvedRefs" condition to "False" with the "UnsupportedProtocol" reason. -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefs { - /// Filters defined at this level MUST be executed if and only if the - /// request is being forwarded to the backend defined here. - /// - /// Support: Implementation-specific (For broader support of filters, use the - /// Filters field in GRPCRouteRule.) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// Weight specifies the proportion of requests forwarded to the referenced - /// backend. This is computed as weight/(sum of all weights in this - /// BackendRefs list). For non-zero values, there may be some epsilon from - /// the exact proportion defined here depending on the precision an - /// implementation supports. Weight is not a percentage and the sum of - /// weights does not need to equal 100. - /// - /// If only one backend is specified and it has a weight greater than 0, 100% - /// of the traffic is forwarded to that backend. If weight is set to 0, no - /// traffic should be forwarded for this entry. If unspecified, weight - /// defaults to 1. - /// - /// Support for this field varies based on the context where used. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub weight: Option, -} - -/// GRPCRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. GRPCRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFilters { - /// ExtensionRef is an optional, implementation-specific extension to the - /// "filter" behavior. For example, resource "myroutefilter" in group - /// "networking.example.net"). ExtensionRef MUST NOT be used for core and - /// extended filters. - /// - /// Support: Implementation-specific - /// - /// This filter can be used multiple times within the same rule. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "extensionRef" - )] - pub extension_ref: Option, - /// RequestHeaderModifier defines a schema for a filter that modifies request - /// headers. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestHeaderModifier" - )] - pub request_header_modifier: Option, - /// RequestMirror defines a schema for a filter that mirrors requests. - /// Requests are sent to the specified destination, but responses from - /// that destination are ignored. - /// - /// This filter can be used multiple times within the same rule. Note that - /// not all implementations will be able to support mirroring to multiple - /// backends. - /// - /// Support: Extended - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestMirror" - )] - pub request_mirror: Option, - /// ResponseHeaderModifier defines a schema for a filter that modifies response - /// headers. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "responseHeaderModifier" - )] - pub response_header_modifier: Option, - /// Type identifies the type of filter to apply. As with other API fields, - /// types are classified into three conformance levels: - /// - /// - Core: Filter types and their corresponding configuration defined by - /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All - /// implementations supporting GRPCRoute MUST support core filters. - /// - /// - Extended: Filter types and their corresponding configuration defined by - /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers - /// are encouraged to support extended filters. - /// - /// - Implementation-specific: Filters that are defined and supported by specific vendors. - /// In the future, filters showing convergence in behavior across multiple - /// implementations will be considered for inclusion in extended or core - /// conformance levels. Filter-specific configuration for such filters - /// is specified using the ExtensionRef field. `Type` MUST be set to - /// "ExtensionRef" for custom filters. - /// - /// Implementers are encouraged to define custom implementation types to - /// extend the core API with implementation-specific behavior. - /// - /// If a reference to a custom filter type cannot be resolved, the filter - /// MUST NOT be skipped. Instead, requests that would have been processed by - /// that filter MUST receive a HTTP error response. - /// - /// - #[serde(rename = "type")] - pub r#type: GRPCRouteRulesBackendRefsFiltersType, -} - -/// ExtensionRef is an optional, implementation-specific extension to the -/// "filter" behavior. For example, resource "myroutefilter" in group -/// "networking.example.net"). ExtensionRef MUST NOT be used for core and -/// extended filters. -/// -/// Support: Implementation-specific -/// -/// This filter can be used multiple times within the same rule. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersExtensionRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - pub group: String, - /// Kind is kind of the referent. For example "HTTPRoute" or "Service". - pub kind: String, - /// Name is the name of the referent. - pub name: String, -} - -/// RequestHeaderModifier defines a schema for a filter that modifies request -/// headers. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// RequestMirror defines a schema for a filter that mirrors requests. -/// Requests are sent to the specified destination, but responses from -/// that destination are ignored. -/// -/// This filter can be used multiple times within the same rule. Note that -/// not all implementations will be able to support mirroring to multiple -/// backends. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestMirror { - /// BackendRef references a resource where mirrored requests are sent. - /// - /// Mirrored requests must be sent only to a single destination endpoint - /// within this BackendRef, irrespective of how many endpoints are present - /// within this BackendRef. - /// - /// If the referent cannot be found, this BackendRef is invalid and must be - /// dropped from the Gateway. The controller must ensure the "ResolvedRefs" - /// condition on the Route status is set to `status: False` and not configure - /// this backend in the underlying implementation. - /// - /// If there is a cross-namespace reference to an *existing* object - /// that is not allowed by a ReferenceGrant, the controller must ensure the - /// "ResolvedRefs" condition on the Route is set to `status: False`, - /// with the "RefNotPermitted" reason and not configure this backend in the - /// underlying implementation. - /// - /// In either error case, the Message of the `ResolvedRefs` Condition - /// should be used to provide more detail about the problem. - /// - /// Support: Extended for Kubernetes Service - /// - /// Support: Implementation-specific for any other resource - #[serde(rename = "backendRef")] - pub backend_ref: GRPCRouteRulesBackendRefsFiltersRequestMirrorBackendRef, -} - -/// BackendRef references a resource where mirrored requests are sent. -/// -/// Mirrored requests must be sent only to a single destination endpoint -/// within this BackendRef, irrespective of how many endpoints are present -/// within this BackendRef. -/// -/// If the referent cannot be found, this BackendRef is invalid and must be -/// dropped from the Gateway. The controller must ensure the "ResolvedRefs" -/// condition on the Route status is set to `status: False` and not configure -/// this backend in the underlying implementation. -/// -/// If there is a cross-namespace reference to an *existing* object -/// that is not allowed by a ReferenceGrant, the controller must ensure the -/// "ResolvedRefs" condition on the Route is set to `status: False`, -/// with the "RefNotPermitted" reason and not configure this backend in the -/// underlying implementation. -/// -/// In either error case, the Message of the `ResolvedRefs` Condition -/// should be used to provide more detail about the problem. -/// -/// Support: Extended for Kubernetes Service -/// -/// Support: Implementation-specific for any other resource -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestMirrorBackendRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, -} - -/// ResponseHeaderModifier defines a schema for a filter that modifies response -/// headers. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersResponseHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersResponseHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersResponseHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// GRPCRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. GRPCRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCRouteRulesBackendRefsFiltersType { - ResponseHeaderModifier, - RequestHeaderModifier, - RequestMirror, - ExtensionRef, -} - -/// GRPCRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. GRPCRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFilters { - /// ExtensionRef is an optional, implementation-specific extension to the - /// "filter" behavior. For example, resource "myroutefilter" in group - /// "networking.example.net"). ExtensionRef MUST NOT be used for core and - /// extended filters. - /// - /// Support: Implementation-specific - /// - /// This filter can be used multiple times within the same rule. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "extensionRef" - )] - pub extension_ref: Option, - /// RequestHeaderModifier defines a schema for a filter that modifies request - /// headers. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestHeaderModifier" - )] - pub request_header_modifier: Option, - /// RequestMirror defines a schema for a filter that mirrors requests. - /// Requests are sent to the specified destination, but responses from - /// that destination are ignored. - /// - /// This filter can be used multiple times within the same rule. Note that - /// not all implementations will be able to support mirroring to multiple - /// backends. - /// - /// Support: Extended - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestMirror" - )] - pub request_mirror: Option, - /// ResponseHeaderModifier defines a schema for a filter that modifies response - /// headers. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "responseHeaderModifier" - )] - pub response_header_modifier: Option, - /// Type identifies the type of filter to apply. As with other API fields, - /// types are classified into three conformance levels: - /// - /// - Core: Filter types and their corresponding configuration defined by - /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All - /// implementations supporting GRPCRoute MUST support core filters. - /// - /// - Extended: Filter types and their corresponding configuration defined by - /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers - /// are encouraged to support extended filters. - /// - /// - Implementation-specific: Filters that are defined and supported by specific vendors. - /// In the future, filters showing convergence in behavior across multiple - /// implementations will be considered for inclusion in extended or core - /// conformance levels. Filter-specific configuration for such filters - /// is specified using the ExtensionRef field. `Type` MUST be set to - /// "ExtensionRef" for custom filters. - /// - /// Implementers are encouraged to define custom implementation types to - /// extend the core API with implementation-specific behavior. - /// - /// If a reference to a custom filter type cannot be resolved, the filter - /// MUST NOT be skipped. Instead, requests that would have been processed by - /// that filter MUST receive a HTTP error response. - /// - /// - #[serde(rename = "type")] - pub r#type: GRPCRouteRulesFiltersType, -} - -/// ExtensionRef is an optional, implementation-specific extension to the -/// "filter" behavior. For example, resource "myroutefilter" in group -/// "networking.example.net"). ExtensionRef MUST NOT be used for core and -/// extended filters. -/// -/// Support: Implementation-specific -/// -/// This filter can be used multiple times within the same rule. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersExtensionRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - pub group: String, - /// Kind is kind of the referent. For example "HTTPRoute" or "Service". - pub kind: String, - /// Name is the name of the referent. - pub name: String, -} - -/// RequestHeaderModifier defines a schema for a filter that modifies request -/// headers. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// RequestMirror defines a schema for a filter that mirrors requests. -/// Requests are sent to the specified destination, but responses from -/// that destination are ignored. -/// -/// This filter can be used multiple times within the same rule. Note that -/// not all implementations will be able to support mirroring to multiple -/// backends. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestMirror { - /// BackendRef references a resource where mirrored requests are sent. - /// - /// Mirrored requests must be sent only to a single destination endpoint - /// within this BackendRef, irrespective of how many endpoints are present - /// within this BackendRef. - /// - /// If the referent cannot be found, this BackendRef is invalid and must be - /// dropped from the Gateway. The controller must ensure the "ResolvedRefs" - /// condition on the Route status is set to `status: False` and not configure - /// this backend in the underlying implementation. - /// - /// If there is a cross-namespace reference to an *existing* object - /// that is not allowed by a ReferenceGrant, the controller must ensure the - /// "ResolvedRefs" condition on the Route is set to `status: False`, - /// with the "RefNotPermitted" reason and not configure this backend in the - /// underlying implementation. - /// - /// In either error case, the Message of the `ResolvedRefs` Condition - /// should be used to provide more detail about the problem. - /// - /// Support: Extended for Kubernetes Service - /// - /// Support: Implementation-specific for any other resource - #[serde(rename = "backendRef")] - pub backend_ref: GRPCRouteRulesFiltersRequestMirrorBackendRef, -} - -/// BackendRef references a resource where mirrored requests are sent. -/// -/// Mirrored requests must be sent only to a single destination endpoint -/// within this BackendRef, irrespective of how many endpoints are present -/// within this BackendRef. -/// -/// If the referent cannot be found, this BackendRef is invalid and must be -/// dropped from the Gateway. The controller must ensure the "ResolvedRefs" -/// condition on the Route status is set to `status: False` and not configure -/// this backend in the underlying implementation. -/// -/// If there is a cross-namespace reference to an *existing* object -/// that is not allowed by a ReferenceGrant, the controller must ensure the -/// "ResolvedRefs" condition on the Route is set to `status: False`, -/// with the "RefNotPermitted" reason and not configure this backend in the -/// underlying implementation. -/// -/// In either error case, the Message of the `ResolvedRefs` Condition -/// should be used to provide more detail about the problem. -/// -/// Support: Extended for Kubernetes Service -/// -/// Support: Implementation-specific for any other resource -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestMirrorBackendRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, -} - -/// ResponseHeaderModifier defines a schema for a filter that modifies response -/// headers. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersResponseHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersResponseHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersResponseHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// GRPCRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. GRPCRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCRouteRulesFiltersType { - ResponseHeaderModifier, - RequestHeaderModifier, - RequestMirror, - ExtensionRef, -} - -/// GRPCRouteMatch defines the predicate used to match requests to a given -/// action. Multiple match types are ANDed together, i.e. the match will -/// evaluate to true only if all conditions are satisfied. -/// -/// For example, the match below will match a gRPC request only if its service -/// is `foo` AND it contains the `version: v1` header: -/// -/// ```text -/// matches: -/// - method: -/// type: Exact -/// service: "foo" -/// headers: -/// - name: "version" -/// value "v1" -/// -/// ``` -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesMatches { - /// Headers specifies gRPC request header matchers. Multiple match values are - /// ANDed together, meaning, a request MUST match all the specified headers - /// to select the route. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub headers: Option>, - /// Method specifies a gRPC request service/method matcher. If this field is - /// not specified, all services and methods will match. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub method: Option, -} - -/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request -/// headers. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesMatchesHeaders { - /// Name is the name of the gRPC Header to be matched. - /// - /// If multiple entries specify equivalent header names, only the first - /// entry with an equivalent name MUST be considered for a match. Subsequent - /// entries with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Type specifies how to match against the value of the header. - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value is the value of the gRPC Header to be matched. - pub value: String, -} - -/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request -/// headers. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCRouteRulesMatchesHeadersType { - Exact, - RegularExpression, -} - -/// Method specifies a gRPC request service/method matcher. If this field is -/// not specified, all services and methods will match. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesMatchesMethod { - /// Value of the method to match against. If left empty or omitted, will - /// match all services. - /// - /// At least one of Service and Method MUST be a non-empty string. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub method: Option, - /// Value of the service to match against. If left empty or omitted, will - /// match any service. - /// - /// At least one of Service and Method MUST be a non-empty string. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub service: Option, - /// Type specifies how to match against the service and/or method. - /// Support: Core (Exact with service and method specified) - /// - /// Support: Implementation-specific (Exact with method specified but no service specified) - /// - /// Support: Implementation-specific (RegularExpression) - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, -} - -/// Method specifies a gRPC request service/method matcher. If this field is -/// not specified, all services and methods will match. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCRouteRulesMatchesMethodType { - Exact, - RegularExpression, -} - -/// Status defines the current state of GRPCRoute. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteStatus { - /// Parents is a list of parent resources (usually Gateways) that are - /// associated with the route, and the status of the route with respect to - /// each parent. When this route attaches to a parent, the controller that - /// manages the parent must add an entry to this list when the controller - /// first sees the route and should update the entry as appropriate when the - /// route or gateway is modified. - /// - /// Note that parent references that cannot be resolved by an implementation - /// of this API will not be added to this list. Implementations of this API - /// can only populate Route status for the Gateways/parent resources they are - /// responsible for. - /// - /// A maximum of 32 Gateways will be represented in this list. An empty list - /// means the route has not been attached to any Gateway. - pub parents: Vec, -} - -/// RouteParentStatus describes the status of a route with respect to an -/// associated Parent. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteStatusParents { - /// Conditions describes the status of the route with respect to the Gateway. - /// Note that the route's availability is also subject to the Gateway's own - /// status conditions and listener status. - /// - /// If the Route's ParentRef specifies an existing Gateway that supports - /// Routes of this kind AND that Gateway's controller has sufficient access, - /// then that Gateway's controller MUST set the "Accepted" condition on the - /// Route, to indicate whether the route has been accepted or rejected by the - /// Gateway, and why. - /// - /// A Route MUST be considered "Accepted" if at least one of the Route's - /// rules is implemented by the Gateway. - /// - /// There are a number of cases where the "Accepted" condition may not be set - /// due to lack of controller visibility, that includes when: - /// - /// * The Route refers to a non-existent parent. - /// * The Route is of a type that the controller does not support. - /// * The Route is in a namespace the controller does not have access to. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: Option>, - /// ControllerName is a domain/path string that indicates the name of the - /// controller that wrote this status. This corresponds with the - /// controllerName field on GatewayClass. - /// - /// Example: "example.net/gateway-controller". - /// - /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are - /// valid Kubernetes names - /// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names). - /// - /// Controllers MUST populate this field when writing status. Controllers should ensure that - /// entries to status populated with their ControllerName are cleaned up when they are no - /// longer necessary. - #[serde(rename = "controllerName")] - pub controller_name: String, - /// ParentRef corresponds with a ParentRef in the spec that this - /// RouteParentStatus struct describes the status of. - #[serde(rename = "parentRef")] - pub parent_ref: GRPCRouteStatusParentsParentRef, -} - -/// ParentRef corresponds with a ParentRef in the spec that this -/// RouteParentStatus struct describes the status of. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteStatusParentsParentRef { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, -} diff --git a/gateway-api/src/apis/standard/httproutes.rs b/gateway-api/src/apis/standard/httproutes.rs deleted file mode 100644 index 978a747..0000000 --- a/gateway-api/src/apis/standard/httproutes.rs +++ /dev/null @@ -1,2288 +0,0 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 - -#[allow(unused_imports)] -mod prelude { - pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube::CustomResource; - pub use schemars::JsonSchema; - pub use serde::{Deserialize, Serialize}; -} -use self::prelude::*; - -/// Spec defines the desired state of HTTPRoute. -#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -#[kube( - group = "gateway.networking.k8s.io", - version = "v1", - kind = "HTTPRoute", - plural = "httproutes" -)] -#[kube(namespaced)] -#[kube(status = "HTTPRouteStatus")] -#[kube(derive = "Default")] -#[kube(derive = "PartialEq")] -pub struct HTTPRouteSpec { - /// Hostnames defines a set of hostnames that should match against the HTTP Host - /// header to select a HTTPRoute used to process the request. Implementations - /// MUST ignore any port value specified in the HTTP Host header while - /// performing a match and (absent of any applicable header modification - /// configuration) MUST forward this header unmodified to the backend. - /// - /// Valid values for Hostnames are determined by RFC 1123 definition of a - /// hostname with 2 notable exceptions: - /// - /// 1. IPs are not allowed. - /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard - /// label must appear by itself as the first label. - /// - /// If a hostname is specified by both the Listener and HTTPRoute, there - /// must be at least one intersecting hostname for the HTTPRoute to be - /// attached to the Listener. For example: - /// - /// * A Listener with `test.example.com` as the hostname matches HTTPRoutes - /// that have either not specified any hostnames, or have specified at - /// least one of `test.example.com` or `*.example.com`. - /// * A Listener with `*.example.com` as the hostname matches HTTPRoutes - /// that have either not specified any hostnames or have specified at least - /// one hostname that matches the Listener hostname. For example, - /// `*.example.com`, `test.example.com`, and `foo.test.example.com` would - /// all match. On the other hand, `example.com` and `test.example.net` would - /// not match. - /// - /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted - /// as a suffix match. That means that a match for `*.example.com` would match - /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. - /// - /// If both the Listener and HTTPRoute have specified hostnames, any - /// HTTPRoute hostnames that do not match the Listener hostname MUST be - /// ignored. For example, if a Listener specified `*.example.com`, and the - /// HTTPRoute specified `test.example.com` and `test.example.net`, - /// `test.example.net` must not be considered for a match. - /// - /// If both the Listener and HTTPRoute have specified hostnames, and none - /// match with the criteria above, then the HTTPRoute is not accepted. The - /// implementation must raise an 'Accepted' Condition with a status of - /// `False` in the corresponding RouteParentStatus. - /// - /// In the event that multiple HTTPRoutes specify intersecting hostnames (e.g. - /// overlapping wildcard matching and exact matching hostnames), precedence must - /// be given to rules from the HTTPRoute with the largest number of: - /// - /// * Characters in a matching non-wildcard hostname. - /// * Characters in a matching hostname. - /// - /// If ties exist across multiple Routes, the matching precedence rules for - /// HTTPRouteMatches takes over. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostnames: Option>, - /// ParentRefs references the resources (usually Gateways) that a Route wants - /// to be attached to. Note that the referenced parent resource needs to - /// allow this for the attachment to be complete. For Gateways, that means - /// the Gateway needs to allow attachment from Routes of this kind and - /// namespace. For Services, that means the Service must either be in the same - /// namespace for a "producer" route, or the mesh implementation must support - /// and allow "consumer" routes for the referenced Service. ReferenceGrant is - /// not applicable for governing ParentRefs to Services - it is not possible to - /// create a "producer" route for a Service in a different namespace from the - /// Route. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// This API may be extended in the future to support additional kinds of parent - /// resources. - /// - /// ParentRefs must be _distinct_. This means either that: - /// - /// * They select different objects. If this is the case, then parentRef - /// entries are distinct. In terms of fields, this means that the - /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must - /// be unique across all parentRef entries in the Route. - /// * They do not select different objects, but for each optional field used, - /// each ParentRef that selects the same object must set the same set of - /// optional fields to different values. If one ParentRef sets a - /// combination of optional fields, all must set the same combination. - /// - /// Some examples: - /// - /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the - /// same object must also set `sectionName`. - /// * If one ParentRef sets `port`, all ParentRefs referencing the same - /// object must also set `port`. - /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs - /// referencing the same object must also set `sectionName` and `port`. - /// - /// It is possible to separately reference multiple distinct objects that may - /// be collapsed by an implementation. For example, some implementations may - /// choose to merge compatible Gateway Listeners together. If that is the - /// case, the list of routes attached to those resources should also be - /// merged. - /// - /// Note that for ParentRefs that cross namespace boundaries, there are specific - /// rules. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example, - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable other kinds of cross-namespace reference. - /// - /// - /// - /// - /// - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "parentRefs" - )] - pub parent_refs: Option>, - /// Rules are a list of HTTP matchers, filters and actions. - /// - /// - #[serde(default, skip_serializing_if = "Option::is_none")] - pub rules: Option>, -} - -/// ParentReference identifies an API object (usually a Gateway) that can be considered -/// a parent of this resource (usually a route). There are two kinds of parent resources -/// with "Core" support: -/// -/// * Gateway (Gateway conformance profile) -/// * Service (Mesh conformance profile, ClusterIP Services only) -/// -/// This API may be extended in the future to support additional kinds of parent -/// resources. -/// -/// The API object must be valid in the cluster; the Group and Kind must -/// be registered in the cluster for this reference to be valid. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteParentRefs { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, -} - -/// HTTPRouteRule defines semantics for matching an HTTP request based on -/// conditions (matches), processing it (filters), and forwarding the request to -/// an API object (backendRefs). -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRules { - /// BackendRefs defines the backend(s) where matching requests should be - /// sent. - /// - /// Failure behavior here depends on how many BackendRefs are specified and - /// how many are invalid. - /// - /// If *all* entries in BackendRefs are invalid, and there are also no filters - /// specified in this route rule, *all* traffic which matches this rule MUST - /// receive a 500 status code. - /// - /// See the HTTPBackendRef definition for the rules about what makes a single - /// HTTPBackendRef invalid. - /// - /// When a HTTPBackendRef is invalid, 500 status codes MUST be returned for - /// requests that would have otherwise been routed to an invalid backend. If - /// multiple backends are specified, and some are invalid, the proportion of - /// requests that would otherwise have been routed to an invalid backend - /// MUST receive a 500 status code. - /// - /// For example, if two backends are specified with equal weights, and one is - /// invalid, 50 percent of traffic must receive a 500. Implementations may - /// choose how that 50 percent is determined. - /// - /// When a HTTPBackendRef refers to a Service that has no ready endpoints, - /// implementations SHOULD return a 503 for requests to that backend instead. - /// If an implementation chooses to do this, all of the above rules for 500 responses - /// MUST also apply for responses that return a 503. - /// - /// Support: Core for Kubernetes Service - /// - /// Support: Extended for Kubernetes ServiceImport - /// - /// Support: Implementation-specific for any other resource - /// - /// Support for weight: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "backendRefs" - )] - pub backend_refs: Option>, - /// Filters define the filters that are applied to requests that match - /// this rule. - /// - /// Wherever possible, implementations SHOULD implement filters in the order - /// they are specified. - /// - /// Implementations MAY choose to implement this ordering strictly, rejecting - /// any combination or order of filters that can not be supported. If implementations - /// choose a strict interpretation of filter ordering, they MUST clearly document - /// that behavior. - /// - /// To reject an invalid combination or order of filters, implementations SHOULD - /// consider the Route Rules with this configuration invalid. If all Route Rules - /// in a Route are invalid, the entire Route would be considered invalid. If only - /// a portion of Route Rules are invalid, implementations MUST set the - /// "PartiallyInvalid" condition for the Route. - /// - /// Conformance-levels at this level are defined based on the type of filter: - /// - /// - ALL core filters MUST be supported by all implementations. - /// - Implementers are encouraged to support extended filters. - /// - Implementation-specific custom filters have no API guarantees across - /// implementations. - /// - /// Specifying the same filter multiple times is not supported unless explicitly - /// indicated in the filter. - /// - /// All filters are expected to be compatible with each other except for the - /// URLRewrite and RequestRedirect filters, which may not be combined. If an - /// implementation can not support other combinations of filters, they must clearly - /// document that limitation. In cases where incompatible or unsupported - /// filters are specified and cause the `Accepted` condition to be set to status - /// `False`, implementations may use the `IncompatibleFilters` reason to specify - /// this configuration error. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, - /// Matches define conditions used for matching the rule against incoming - /// HTTP requests. Each match is independent, i.e. this rule will be matched - /// if **any** one of the matches is satisfied. - /// - /// For example, take the following matches configuration: - /// - /// ```text - /// matches: - /// - path: - /// value: "/foo" - /// headers: - /// - name: "version" - /// value: "v2" - /// - path: - /// value: "/v2/foo" - /// ``` - /// - /// For a request to match against this rule, a request must satisfy - /// EITHER of the two conditions: - /// - /// - path prefixed with `/foo` AND contains the header `version: v2` - /// - path prefix of `/v2/foo` - /// - /// See the documentation for HTTPRouteMatch on how to specify multiple - /// match conditions that should be ANDed together. - /// - /// If no matches are specified, the default is a prefix - /// path match on "/", which has the effect of matching every - /// HTTP request. - /// - /// Proxy or Load Balancer routing configuration generated from HTTPRoutes - /// MUST prioritize matches based on the following criteria, continuing on - /// ties. Across all rules specified on applicable Routes, precedence must be - /// given to the match having: - /// - /// * "Exact" path match. - /// * "Prefix" path match with largest number of characters. - /// * Method match. - /// * Largest number of header matches. - /// * Largest number of query param matches. - /// - /// Note: The precedence of RegularExpression path matches are implementation-specific. - /// - /// If ties still exist across multiple Routes, matching precedence MUST be - /// determined in order of the following criteria, continuing on ties: - /// - /// * The oldest Route based on creation timestamp. - /// * The Route appearing first in alphabetical order by - /// "{namespace}/{name}". - /// - /// If ties still exist within an HTTPRoute, matching precedence MUST be granted - /// to the FIRST matching rule (in list order) with a match meeting the above - /// criteria. - /// - /// When no rules matching a request have been successfully attached to the - /// parent a request is coming from, a HTTP 404 status code MUST be returned. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub matches: Option>, - /// Timeouts defines the timeouts that can be configured for an HTTP request. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub timeouts: Option, -} - -/// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. -/// -/// Note that when a namespace different than the local namespace is specified, a -/// ReferenceGrant object is required in the referent namespace to allow that -/// namespace's owner to accept the reference. See the ReferenceGrant -/// documentation for details. -/// -/// -/// -/// When the BackendRef points to a Kubernetes Service, implementations SHOULD -/// honor the appProtocol field if it is set for the target Service Port. -/// -/// Implementations supporting appProtocol SHOULD recognize the Kubernetes -/// Standard Application Protocols defined in KEP-3726. -/// -/// If a Service appProtocol isn't specified, an implementation MAY infer the -/// backend protocol through its own means. Implementations MAY infer the -/// protocol from the Route type referring to the backend Service. -/// -/// If a Route is not able to send traffic to the backend using the specified -/// protocol then the backend is considered invalid. Implementations MUST set the -/// "ResolvedRefs" condition to "False" with the "UnsupportedProtocol" reason. -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefs { - /// Filters defined at this level should be executed if and only if the - /// request is being forwarded to the backend defined here. - /// - /// Support: Implementation-specific (For broader support of filters, use the - /// Filters field in HTTPRouteRule.) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// Weight specifies the proportion of requests forwarded to the referenced - /// backend. This is computed as weight/(sum of all weights in this - /// BackendRefs list). For non-zero values, there may be some epsilon from - /// the exact proportion defined here depending on the precision an - /// implementation supports. Weight is not a percentage and the sum of - /// weights does not need to equal 100. - /// - /// If only one backend is specified and it has a weight greater than 0, 100% - /// of the traffic is forwarded to that backend. If weight is set to 0, no - /// traffic should be forwarded for this entry. If unspecified, weight - /// defaults to 1. - /// - /// Support for this field varies based on the context where used. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub weight: Option, -} - -/// HTTPRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. HTTPRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFilters { - /// ExtensionRef is an optional, implementation-specific extension to the - /// "filter" behavior. For example, resource "myroutefilter" in group - /// "networking.example.net"). ExtensionRef MUST NOT be used for core and - /// extended filters. - /// - /// This filter can be used multiple times within the same rule. - /// - /// Support: Implementation-specific - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "extensionRef" - )] - pub extension_ref: Option, - /// RequestHeaderModifier defines a schema for a filter that modifies request - /// headers. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestHeaderModifier" - )] - pub request_header_modifier: Option, - /// RequestMirror defines a schema for a filter that mirrors requests. - /// Requests are sent to the specified destination, but responses from - /// that destination are ignored. - /// - /// This filter can be used multiple times within the same rule. Note that - /// not all implementations will be able to support mirroring to multiple - /// backends. - /// - /// Support: Extended - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestMirror" - )] - pub request_mirror: Option, - /// RequestRedirect defines a schema for a filter that responds to the - /// request with an HTTP redirection. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestRedirect" - )] - pub request_redirect: Option, - /// ResponseHeaderModifier defines a schema for a filter that modifies response - /// headers. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "responseHeaderModifier" - )] - pub response_header_modifier: Option, - /// Type identifies the type of filter to apply. As with other API fields, - /// types are classified into three conformance levels: - /// - /// - Core: Filter types and their corresponding configuration defined by - /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All - /// implementations must support core filters. - /// - /// - Extended: Filter types and their corresponding configuration defined by - /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers - /// are encouraged to support extended filters. - /// - /// - Implementation-specific: Filters that are defined and supported by - /// specific vendors. - /// In the future, filters showing convergence in behavior across multiple - /// implementations will be considered for inclusion in extended or core - /// conformance levels. Filter-specific configuration for such filters - /// is specified using the ExtensionRef field. `Type` should be set to - /// "ExtensionRef" for custom filters. - /// - /// Implementers are encouraged to define custom implementation types to - /// extend the core API with implementation-specific behavior. - /// - /// If a reference to a custom filter type cannot be resolved, the filter - /// MUST NOT be skipped. Instead, requests that would have been processed by - /// that filter MUST receive a HTTP error response. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesBackendRefsFiltersType, - /// URLRewrite defines a schema for a filter that modifies a request during forwarding. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "urlRewrite" - )] - pub url_rewrite: Option, -} - -/// ExtensionRef is an optional, implementation-specific extension to the -/// "filter" behavior. For example, resource "myroutefilter" in group -/// "networking.example.net"). ExtensionRef MUST NOT be used for core and -/// extended filters. -/// -/// This filter can be used multiple times within the same rule. -/// -/// Support: Implementation-specific -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersExtensionRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - pub group: String, - /// Kind is kind of the referent. For example "HTTPRoute" or "Service". - pub kind: String, - /// Name is the name of the referent. - pub name: String, -} - -/// RequestHeaderModifier defines a schema for a filter that modifies request -/// headers. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// RequestMirror defines a schema for a filter that mirrors requests. -/// Requests are sent to the specified destination, but responses from -/// that destination are ignored. -/// -/// This filter can be used multiple times within the same rule. Note that -/// not all implementations will be able to support mirroring to multiple -/// backends. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestMirror { - /// BackendRef references a resource where mirrored requests are sent. - /// - /// Mirrored requests must be sent only to a single destination endpoint - /// within this BackendRef, irrespective of how many endpoints are present - /// within this BackendRef. - /// - /// If the referent cannot be found, this BackendRef is invalid and must be - /// dropped from the Gateway. The controller must ensure the "ResolvedRefs" - /// condition on the Route status is set to `status: False` and not configure - /// this backend in the underlying implementation. - /// - /// If there is a cross-namespace reference to an *existing* object - /// that is not allowed by a ReferenceGrant, the controller must ensure the - /// "ResolvedRefs" condition on the Route is set to `status: False`, - /// with the "RefNotPermitted" reason and not configure this backend in the - /// underlying implementation. - /// - /// In either error case, the Message of the `ResolvedRefs` Condition - /// should be used to provide more detail about the problem. - /// - /// Support: Extended for Kubernetes Service - /// - /// Support: Implementation-specific for any other resource - #[serde(rename = "backendRef")] - pub backend_ref: HTTPRouteRulesBackendRefsFiltersRequestMirrorBackendRef, -} - -/// BackendRef references a resource where mirrored requests are sent. -/// -/// Mirrored requests must be sent only to a single destination endpoint -/// within this BackendRef, irrespective of how many endpoints are present -/// within this BackendRef. -/// -/// If the referent cannot be found, this BackendRef is invalid and must be -/// dropped from the Gateway. The controller must ensure the "ResolvedRefs" -/// condition on the Route status is set to `status: False` and not configure -/// this backend in the underlying implementation. -/// -/// If there is a cross-namespace reference to an *existing* object -/// that is not allowed by a ReferenceGrant, the controller must ensure the -/// "ResolvedRefs" condition on the Route is set to `status: False`, -/// with the "RefNotPermitted" reason and not configure this backend in the -/// underlying implementation. -/// -/// In either error case, the Message of the `ResolvedRefs` Condition -/// should be used to provide more detail about the problem. -/// -/// Support: Extended for Kubernetes Service -/// -/// Support: Implementation-specific for any other resource -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestMirrorBackendRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestRedirect { - /// Hostname is the hostname to be used in the value of the `Location` - /// header in the response. - /// When empty, the hostname in the `Host` header of the request is used. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, - /// Path defines parameters used to modify the path of the incoming request. - /// The modified path is then used to construct the `Location` header. When - /// empty, the request path is used as-is. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub path: Option, - /// Port is the port to be used in the value of the `Location` - /// header in the response. - /// - /// If no port is specified, the redirect port MUST be derived using the - /// following rules: - /// - /// * If redirect scheme is not-empty, the redirect port MUST be the well-known - /// port associated with the redirect scheme. Specifically "http" to port 80 - /// and "https" to port 443. If the redirect scheme does not have a - /// well-known port, the listener port of the Gateway SHOULD be used. - /// * If redirect scheme is empty, the redirect port MUST be the Gateway - /// Listener port. - /// - /// Implementations SHOULD NOT add the port number in the 'Location' - /// header in the following cases: - /// - /// * A Location header that will use HTTP (whether that is determined via - /// the Listener protocol or the Scheme field) _and_ use port 80. - /// * A Location header that will use HTTPS (whether that is determined via - /// the Listener protocol or the Scheme field) _and_ use port 443. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// Scheme is the scheme to be used in the value of the `Location` header in - /// the response. When empty, the scheme of the request is used. - /// - /// Scheme redirects can affect the port of the redirect, for more information, - /// refer to the documentation for the port field of this filter. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub scheme: Option, - /// StatusCode is the HTTP status code to be used in response. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "statusCode" - )] - pub status_code: Option, -} - -/// Path defines parameters used to modify the path of the incoming request. -/// The modified path is then used to construct the `Location` header. When -/// empty, the request path is used as-is. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestRedirectPath { - /// ReplaceFullPath specifies the value with which to replace the full path - /// of a request during a rewrite or redirect. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replaceFullPath" - )] - pub replace_full_path: Option, - /// ReplacePrefixMatch specifies the value with which to replace the prefix - /// match of a request during a rewrite or redirect. For example, a request - /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch - /// of "/xyz" would be modified to "/xyz/bar". - /// - /// Note that this matches the behavior of the PathPrefix match type. This - /// matches full path elements. A path element refers to the list of labels - /// in the path split by the `/` separator. When specified, a trailing `/` is - /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all - /// match the prefix `/abc`, but the path `/abcd` would not. - /// - /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch. - /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in - /// the implementation setting the Accepted Condition for the Route to `status: False`. - /// - /// Request Path | Prefix Match | Replace Prefix | Modified Path - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replacePrefixMatch" - )] - pub replace_prefix_match: Option, - /// Type defines the type of path modifier. Additional types may be - /// added in a future release of the API. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType, -} - -/// Path defines parameters used to modify the path of the incoming request. -/// The modified path is then used to construct the `Location` header. When -/// empty, the request path is used as-is. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType { - ReplaceFullPath, - ReplacePrefixMatch, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesBackendRefsFiltersRequestRedirectScheme { - #[serde(rename = "http")] - Http, - #[serde(rename = "https")] - Https, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesBackendRefsFiltersRequestRedirectStatusCode { - #[serde(rename = "301")] - r#_301, - #[serde(rename = "302")] - r#_302, -} - -/// ResponseHeaderModifier defines a schema for a filter that modifies response -/// headers. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersResponseHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersResponseHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersResponseHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. HTTPRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesBackendRefsFiltersType { - RequestHeaderModifier, - ResponseHeaderModifier, - RequestMirror, - RequestRedirect, - #[serde(rename = "URLRewrite")] - UrlRewrite, - ExtensionRef, -} - -/// URLRewrite defines a schema for a filter that modifies a request during forwarding. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersUrlRewrite { - /// Hostname is the value to be used to replace the Host header value during - /// forwarding. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, - /// Path defines a path rewrite. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub path: Option, -} - -/// Path defines a path rewrite. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersUrlRewritePath { - /// ReplaceFullPath specifies the value with which to replace the full path - /// of a request during a rewrite or redirect. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replaceFullPath" - )] - pub replace_full_path: Option, - /// ReplacePrefixMatch specifies the value with which to replace the prefix - /// match of a request during a rewrite or redirect. For example, a request - /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch - /// of "/xyz" would be modified to "/xyz/bar". - /// - /// Note that this matches the behavior of the PathPrefix match type. This - /// matches full path elements. A path element refers to the list of labels - /// in the path split by the `/` separator. When specified, a trailing `/` is - /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all - /// match the prefix `/abc`, but the path `/abcd` would not. - /// - /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch. - /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in - /// the implementation setting the Accepted Condition for the Route to `status: False`. - /// - /// Request Path | Prefix Match | Replace Prefix | Modified Path - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replacePrefixMatch" - )] - pub replace_prefix_match: Option, - /// Type defines the type of path modifier. Additional types may be - /// added in a future release of the API. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesBackendRefsFiltersUrlRewritePathType, -} - -/// Path defines a path rewrite. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesBackendRefsFiltersUrlRewritePathType { - ReplaceFullPath, - ReplacePrefixMatch, -} - -/// HTTPRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. HTTPRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFilters { - /// ExtensionRef is an optional, implementation-specific extension to the - /// "filter" behavior. For example, resource "myroutefilter" in group - /// "networking.example.net"). ExtensionRef MUST NOT be used for core and - /// extended filters. - /// - /// This filter can be used multiple times within the same rule. - /// - /// Support: Implementation-specific - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "extensionRef" - )] - pub extension_ref: Option, - /// RequestHeaderModifier defines a schema for a filter that modifies request - /// headers. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestHeaderModifier" - )] - pub request_header_modifier: Option, - /// RequestMirror defines a schema for a filter that mirrors requests. - /// Requests are sent to the specified destination, but responses from - /// that destination are ignored. - /// - /// This filter can be used multiple times within the same rule. Note that - /// not all implementations will be able to support mirroring to multiple - /// backends. - /// - /// Support: Extended - /// - /// - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestMirror" - )] - pub request_mirror: Option, - /// RequestRedirect defines a schema for a filter that responds to the - /// request with an HTTP redirection. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "requestRedirect" - )] - pub request_redirect: Option, - /// ResponseHeaderModifier defines a schema for a filter that modifies response - /// headers. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "responseHeaderModifier" - )] - pub response_header_modifier: Option, - /// Type identifies the type of filter to apply. As with other API fields, - /// types are classified into three conformance levels: - /// - /// - Core: Filter types and their corresponding configuration defined by - /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All - /// implementations must support core filters. - /// - /// - Extended: Filter types and their corresponding configuration defined by - /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers - /// are encouraged to support extended filters. - /// - /// - Implementation-specific: Filters that are defined and supported by - /// specific vendors. - /// In the future, filters showing convergence in behavior across multiple - /// implementations will be considered for inclusion in extended or core - /// conformance levels. Filter-specific configuration for such filters - /// is specified using the ExtensionRef field. `Type` should be set to - /// "ExtensionRef" for custom filters. - /// - /// Implementers are encouraged to define custom implementation types to - /// extend the core API with implementation-specific behavior. - /// - /// If a reference to a custom filter type cannot be resolved, the filter - /// MUST NOT be skipped. Instead, requests that would have been processed by - /// that filter MUST receive a HTTP error response. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesFiltersType, - /// URLRewrite defines a schema for a filter that modifies a request during forwarding. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "urlRewrite" - )] - pub url_rewrite: Option, -} - -/// ExtensionRef is an optional, implementation-specific extension to the -/// "filter" behavior. For example, resource "myroutefilter" in group -/// "networking.example.net"). ExtensionRef MUST NOT be used for core and -/// extended filters. -/// -/// This filter can be used multiple times within the same rule. -/// -/// Support: Implementation-specific -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersExtensionRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - pub group: String, - /// Kind is kind of the referent. For example "HTTPRoute" or "Service". - pub kind: String, - /// Name is the name of the referent. - pub name: String, -} - -/// RequestHeaderModifier defines a schema for a filter that modifies request -/// headers. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// RequestMirror defines a schema for a filter that mirrors requests. -/// Requests are sent to the specified destination, but responses from -/// that destination are ignored. -/// -/// This filter can be used multiple times within the same rule. Note that -/// not all implementations will be able to support mirroring to multiple -/// backends. -/// -/// Support: Extended -/// -/// -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestMirror { - /// BackendRef references a resource where mirrored requests are sent. - /// - /// Mirrored requests must be sent only to a single destination endpoint - /// within this BackendRef, irrespective of how many endpoints are present - /// within this BackendRef. - /// - /// If the referent cannot be found, this BackendRef is invalid and must be - /// dropped from the Gateway. The controller must ensure the "ResolvedRefs" - /// condition on the Route status is set to `status: False` and not configure - /// this backend in the underlying implementation. - /// - /// If there is a cross-namespace reference to an *existing* object - /// that is not allowed by a ReferenceGrant, the controller must ensure the - /// "ResolvedRefs" condition on the Route is set to `status: False`, - /// with the "RefNotPermitted" reason and not configure this backend in the - /// underlying implementation. - /// - /// In either error case, the Message of the `ResolvedRefs` Condition - /// should be used to provide more detail about the problem. - /// - /// Support: Extended for Kubernetes Service - /// - /// Support: Implementation-specific for any other resource - #[serde(rename = "backendRef")] - pub backend_ref: HTTPRouteRulesFiltersRequestMirrorBackendRef, -} - -/// BackendRef references a resource where mirrored requests are sent. -/// -/// Mirrored requests must be sent only to a single destination endpoint -/// within this BackendRef, irrespective of how many endpoints are present -/// within this BackendRef. -/// -/// If the referent cannot be found, this BackendRef is invalid and must be -/// dropped from the Gateway. The controller must ensure the "ResolvedRefs" -/// condition on the Route status is set to `status: False` and not configure -/// this backend in the underlying implementation. -/// -/// If there is a cross-namespace reference to an *existing* object -/// that is not allowed by a ReferenceGrant, the controller must ensure the -/// "ResolvedRefs" condition on the Route is set to `status: False`, -/// with the "RefNotPermitted" reason and not configure this backend in the -/// underlying implementation. -/// -/// In either error case, the Message of the `ResolvedRefs` Condition -/// should be used to provide more detail about the problem. -/// -/// Support: Extended for Kubernetes Service -/// -/// Support: Implementation-specific for any other resource -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestMirrorBackendRef { - /// Group is the group of the referent. For example, "gateway.networking.k8s.io". - /// When unspecified or empty string, core API group is inferred. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is the Kubernetes resource kind of the referent. For example - /// "Service". - /// - /// Defaults to "Service" when not specified. - /// - /// ExternalName services can refer to CNAME DNS records that may live - /// outside of the cluster and as such are difficult to reason about in - /// terms of conformance. They also may not be safe to forward to (see - /// CVE-2021-25740 for more information). Implementations SHOULD NOT - /// support ExternalName Services. - /// - /// Support: Core (Services with a type other than ExternalName) - /// - /// Support: Implementation-specific (Services with type ExternalName) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the backend. When unspecified, the local - /// namespace is inferred. - /// - /// Note that when a namespace different than the local namespace is specified, - /// a ReferenceGrant object is required in the referent namespace to allow that - /// namespace's owner to accept the reference. See the ReferenceGrant - /// documentation for details. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port specifies the destination port number to use for this resource. - /// Port is required when the referent is a Kubernetes Service. In this - /// case, the port number is the service port number, not the target port. - /// For other resources, destination port might be derived from the referent - /// resource or this field. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestRedirect { - /// Hostname is the hostname to be used in the value of the `Location` - /// header in the response. - /// When empty, the hostname in the `Host` header of the request is used. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, - /// Path defines parameters used to modify the path of the incoming request. - /// The modified path is then used to construct the `Location` header. When - /// empty, the request path is used as-is. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub path: Option, - /// Port is the port to be used in the value of the `Location` - /// header in the response. - /// - /// If no port is specified, the redirect port MUST be derived using the - /// following rules: - /// - /// * If redirect scheme is not-empty, the redirect port MUST be the well-known - /// port associated with the redirect scheme. Specifically "http" to port 80 - /// and "https" to port 443. If the redirect scheme does not have a - /// well-known port, the listener port of the Gateway SHOULD be used. - /// * If redirect scheme is empty, the redirect port MUST be the Gateway - /// Listener port. - /// - /// Implementations SHOULD NOT add the port number in the 'Location' - /// header in the following cases: - /// - /// * A Location header that will use HTTP (whether that is determined via - /// the Listener protocol or the Scheme field) _and_ use port 80. - /// * A Location header that will use HTTPS (whether that is determined via - /// the Listener protocol or the Scheme field) _and_ use port 443. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// Scheme is the scheme to be used in the value of the `Location` header in - /// the response. When empty, the scheme of the request is used. - /// - /// Scheme redirects can affect the port of the redirect, for more information, - /// refer to the documentation for the port field of this filter. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub scheme: Option, - /// StatusCode is the HTTP status code to be used in response. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "statusCode" - )] - pub status_code: Option, -} - -/// Path defines parameters used to modify the path of the incoming request. -/// The modified path is then used to construct the `Location` header. When -/// empty, the request path is used as-is. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestRedirectPath { - /// ReplaceFullPath specifies the value with which to replace the full path - /// of a request during a rewrite or redirect. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replaceFullPath" - )] - pub replace_full_path: Option, - /// ReplacePrefixMatch specifies the value with which to replace the prefix - /// match of a request during a rewrite or redirect. For example, a request - /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch - /// of "/xyz" would be modified to "/xyz/bar". - /// - /// Note that this matches the behavior of the PathPrefix match type. This - /// matches full path elements. A path element refers to the list of labels - /// in the path split by the `/` separator. When specified, a trailing `/` is - /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all - /// match the prefix `/abc`, but the path `/abcd` would not. - /// - /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch. - /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in - /// the implementation setting the Accepted Condition for the Route to `status: False`. - /// - /// Request Path | Prefix Match | Replace Prefix | Modified Path - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replacePrefixMatch" - )] - pub replace_prefix_match: Option, - /// Type defines the type of path modifier. Additional types may be - /// added in a future release of the API. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesFiltersRequestRedirectPathType, -} - -/// Path defines parameters used to modify the path of the incoming request. -/// The modified path is then used to construct the `Location` header. When -/// empty, the request path is used as-is. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesFiltersRequestRedirectPathType { - ReplaceFullPath, - ReplacePrefixMatch, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesFiltersRequestRedirectScheme { - #[serde(rename = "http")] - Http, - #[serde(rename = "https")] - Https, -} - -/// RequestRedirect defines a schema for a filter that responds to the -/// request with an HTTP redirection. -/// -/// Support: Core -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesFiltersRequestRedirectStatusCode { - #[serde(rename = "301")] - r#_301, - #[serde(rename = "302")] - r#_302, -} - -/// ResponseHeaderModifier defines a schema for a filter that modifies response -/// headers. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersResponseHeaderModifier { - /// Add adds the given header(s) (name, value) to the request - /// before the action. It appends to any existing values associated - /// with the header name. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// add: - /// - name: "my-header" - /// value: "bar,baz" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: foo,bar,baz - #[serde(default, skip_serializing_if = "Option::is_none")] - pub add: Option>, - /// Remove the given header(s) from the HTTP request before the action. The - /// value of Remove is a list of HTTP header names. Note that the header - /// names are case-insensitive (see - /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2). - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header1: foo - /// my-header2: bar - /// my-header3: baz - /// - /// Config: - /// remove: ["my-header1", "my-header3"] - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header2: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub remove: Option>, - /// Set overwrites the request with the given header (name, value) - /// before the action. - /// - /// Input: - /// GET /foo HTTP/1.1 - /// my-header: foo - /// - /// Config: - /// set: - /// - name: "my-header" - /// value: "bar" - /// - /// Output: - /// GET /foo HTTP/1.1 - /// my-header: bar - #[serde(default, skip_serializing_if = "Option::is_none")] - pub set: Option>, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersResponseHeaderModifierAdd { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersResponseHeaderModifierSet { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, the first entry with - /// an equivalent name MUST be considered for a match. Subsequent entries - /// with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - pub name: String, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPRouteFilter defines processing steps that must be completed during the -/// request or response lifecycle. HTTPRouteFilters are meant as an extension -/// point to express processing that may be done in Gateway implementations. Some -/// examples include request or response modification, implementing -/// authentication strategies, rate-limiting, and traffic shaping. API -/// guarantee/conformance is defined based on the type of the filter. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesFiltersType { - RequestHeaderModifier, - ResponseHeaderModifier, - RequestMirror, - RequestRedirect, - #[serde(rename = "URLRewrite")] - UrlRewrite, - ExtensionRef, -} - -/// URLRewrite defines a schema for a filter that modifies a request during forwarding. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersUrlRewrite { - /// Hostname is the value to be used to replace the Host header value during - /// forwarding. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, - /// Path defines a path rewrite. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub path: Option, -} - -/// Path defines a path rewrite. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersUrlRewritePath { - /// ReplaceFullPath specifies the value with which to replace the full path - /// of a request during a rewrite or redirect. - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replaceFullPath" - )] - pub replace_full_path: Option, - /// ReplacePrefixMatch specifies the value with which to replace the prefix - /// match of a request during a rewrite or redirect. For example, a request - /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch - /// of "/xyz" would be modified to "/xyz/bar". - /// - /// Note that this matches the behavior of the PathPrefix match type. This - /// matches full path elements. A path element refers to the list of labels - /// in the path split by the `/` separator. When specified, a trailing `/` is - /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all - /// match the prefix `/abc`, but the path `/abcd` would not. - /// - /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch. - /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in - /// the implementation setting the Accepted Condition for the Route to `status: False`. - /// - /// Request Path | Prefix Match | Replace Prefix | Modified Path - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "replacePrefixMatch" - )] - pub replace_prefix_match: Option, - /// Type defines the type of path modifier. Additional types may be - /// added in a future release of the API. - /// - /// Note that values may be added to this enum, implementations - /// must ensure that unknown values will not cause a crash. - /// - /// Unknown values here must result in the implementation setting the - /// Accepted Condition for the Route to `status: False`, with a - /// Reason of `UnsupportedValue`. - #[serde(rename = "type")] - pub r#type: HTTPRouteRulesFiltersUrlRewritePathType, -} - -/// Path defines a path rewrite. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesFiltersUrlRewritePathType { - ReplaceFullPath, - ReplacePrefixMatch, -} - -/// HTTPRouteMatch defines the predicate used to match requests to a given -/// action. Multiple match types are ANDed together, i.e. the match will -/// evaluate to true only if all conditions are satisfied. -/// -/// For example, the match below will match a HTTP request only if its path -/// starts with `/foo` AND it contains the `version: v1` header: -/// -/// ```text -/// match: -/// -/// path: -/// value: "/foo" -/// headers: -/// - name: "version" -/// value "v1" -/// -/// ``` -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesMatches { - /// Headers specifies HTTP request header matchers. Multiple match values are - /// ANDed together, meaning, a request must match all the specified headers - /// to select the route. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub headers: Option>, - /// Method specifies HTTP method matcher. - /// When specified, this route will be matched only if the request has the - /// specified method. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub method: Option, - /// Path specifies a HTTP request path matcher. If this field is not - /// specified, a default prefix match on the "/" path is provided. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub path: Option, - /// QueryParams specifies HTTP query parameter matchers. Multiple match - /// values are ANDed together, meaning, a request must match all the - /// specified query parameters to select the route. - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "queryParams" - )] - pub query_params: Option>, -} - -/// HTTPHeaderMatch describes how to select a HTTP route by matching HTTP request -/// headers. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesMatchesHeaders { - /// Name is the name of the HTTP Header to be matched. Name matching MUST be - /// case insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2). - /// - /// If multiple entries specify equivalent header names, only the first - /// entry with an equivalent name MUST be considered for a match. Subsequent - /// entries with an equivalent header name MUST be ignored. Due to the - /// case-insensitivity of header names, "foo" and "Foo" are considered - /// equivalent. - /// - /// When a header is repeated in an HTTP request, it is - /// implementation-specific behavior as to how this is represented. - /// Generally, proxies should follow the guidance from the RFC: - /// https://www.rfc-editor.org/rfc/rfc7230.html#section-3.2.2 regarding - /// processing a repeated header, with special handling for "Set-Cookie". - pub name: String, - /// Type specifies how to match against the value of the header. - /// - /// Support: Core (Exact) - /// - /// Support: Implementation-specific (RegularExpression) - /// - /// Since RegularExpression HeaderMatchType has implementation-specific - /// conformance, implementations can support POSIX, PCRE or any other dialects - /// of regular expressions. Please read the implementation's documentation to - /// determine the supported dialect. - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value is the value of HTTP Header to be matched. - pub value: String, -} - -/// HTTPHeaderMatch describes how to select a HTTP route by matching HTTP request -/// headers. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesMatchesHeadersType { - Exact, - RegularExpression, -} - -/// HTTPRouteMatch defines the predicate used to match requests to a given -/// action. Multiple match types are ANDed together, i.e. the match will -/// evaluate to true only if all conditions are satisfied. -/// -/// For example, the match below will match a HTTP request only if its path -/// starts with `/foo` AND it contains the `version: v1` header: -/// -/// ```text -/// match: -/// -/// path: -/// value: "/foo" -/// headers: -/// - name: "version" -/// value "v1" -/// -/// ``` -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesMatchesMethod { - #[serde(rename = "GET")] - Get, - #[serde(rename = "HEAD")] - Head, - #[serde(rename = "POST")] - Post, - #[serde(rename = "PUT")] - Put, - #[serde(rename = "DELETE")] - Delete, - #[serde(rename = "CONNECT")] - Connect, - #[serde(rename = "OPTIONS")] - Options, - #[serde(rename = "TRACE")] - Trace, - #[serde(rename = "PATCH")] - Patch, -} - -/// Path specifies a HTTP request path matcher. If this field is not -/// specified, a default prefix match on the "/" path is provided. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesMatchesPath { - /// Type specifies how to match against the path Value. - /// - /// Support: Core (Exact, PathPrefix) - /// - /// Support: Implementation-specific (RegularExpression) - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value of the HTTP path to match against. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub value: Option, -} - -/// Path specifies a HTTP request path matcher. If this field is not -/// specified, a default prefix match on the "/" path is provided. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesMatchesPathType { - Exact, - PathPrefix, - RegularExpression, -} - -/// HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP -/// query parameters. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesMatchesQueryParams { - /// Name is the name of the HTTP query param to be matched. This must be an - /// exact string match. (See - /// https://tools.ietf.org/html/rfc7230#section-2.7.3). - /// - /// If multiple entries specify equivalent query param names, only the first - /// entry with an equivalent name MUST be considered for a match. Subsequent - /// entries with an equivalent query param name MUST be ignored. - /// - /// If a query param is repeated in an HTTP request, the behavior is - /// purposely left undefined, since different data planes have different - /// capabilities. However, it is *recommended* that implementations should - /// match against the first value of the param if the data plane supports it, - /// as this behavior is expected in other load balancing contexts outside of - /// the Gateway API. - /// - /// Users SHOULD NOT route traffic based on repeated query params to guard - /// themselves against potential differences in the implementations. - pub name: String, - /// Type specifies how to match against the value of the query parameter. - /// - /// Support: Extended (Exact) - /// - /// Support: Implementation-specific (RegularExpression) - /// - /// Since RegularExpression QueryParamMatchType has Implementation-specific - /// conformance, implementations can support POSIX, PCRE or any other - /// dialects of regular expressions. Please read the implementation's - /// documentation to determine the supported dialect. - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - /// Value is the value of HTTP query param to be matched. - pub value: String, -} - -/// HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP -/// query parameters. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesMatchesQueryParamsType { - Exact, - RegularExpression, -} - -/// Timeouts defines the timeouts that can be configured for an HTTP request. -/// -/// Support: Extended -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesTimeouts { - /// BackendRequest specifies a timeout for an individual request from the gateway - /// to a backend. This covers the time from when the request first starts being - /// sent from the gateway to when the full response has been received from the backend. - /// - /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout - /// completely. Implementations that cannot completely disable the timeout MUST - /// instead interpret the zero duration as the longest possible value to which - /// the timeout can be set. - /// - /// An entire client HTTP transaction with a gateway, covered by the Request timeout, - /// may result in more than one call from the gateway to the destination backend, - /// for example, if automatic retries are supported. - /// - /// The value of BackendRequest must be a Gateway API Duration string as defined by - /// GEP-2257. When this field is unspecified, its behavior is implementation-specific; - /// when specified, the value of BackendRequest must be no more than the value of the - /// Request timeout (since the Request timeout encompasses the BackendRequest timeout). - /// - /// Support: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "backendRequest" - )] - pub backend_request: Option, - /// Request specifies the maximum duration for a gateway to respond to an HTTP request. - /// If the gateway has not been able to respond before this deadline is met, the gateway - /// MUST return a timeout error. - /// - /// For example, setting the `rules.timeouts.request` field to the value `10s` in an - /// `HTTPRoute` will cause a timeout if a client request is taking longer than 10 seconds - /// to complete. - /// - /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout - /// completely. Implementations that cannot completely disable the timeout MUST - /// instead interpret the zero duration as the longest possible value to which - /// the timeout can be set. - /// - /// This timeout is intended to cover as close to the whole request-response transaction - /// as possible although an implementation MAY choose to start the timeout after the entire - /// request stream has been received instead of immediately after the transaction is - /// initiated by the client. - /// - /// The value of Request is a Gateway API Duration string as defined by GEP-2257. When this - /// field is unspecified, request timeout behavior is implementation-specific. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub request: Option, -} - -/// Status defines the current state of HTTPRoute. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteStatus { - /// Parents is a list of parent resources (usually Gateways) that are - /// associated with the route, and the status of the route with respect to - /// each parent. When this route attaches to a parent, the controller that - /// manages the parent must add an entry to this list when the controller - /// first sees the route and should update the entry as appropriate when the - /// route or gateway is modified. - /// - /// Note that parent references that cannot be resolved by an implementation - /// of this API will not be added to this list. Implementations of this API - /// can only populate Route status for the Gateways/parent resources they are - /// responsible for. - /// - /// A maximum of 32 Gateways will be represented in this list. An empty list - /// means the route has not been attached to any Gateway. - pub parents: Vec, -} - -/// RouteParentStatus describes the status of a route with respect to an -/// associated Parent. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteStatusParents { - /// Conditions describes the status of the route with respect to the Gateway. - /// Note that the route's availability is also subject to the Gateway's own - /// status conditions and listener status. - /// - /// If the Route's ParentRef specifies an existing Gateway that supports - /// Routes of this kind AND that Gateway's controller has sufficient access, - /// then that Gateway's controller MUST set the "Accepted" condition on the - /// Route, to indicate whether the route has been accepted or rejected by the - /// Gateway, and why. - /// - /// A Route MUST be considered "Accepted" if at least one of the Route's - /// rules is implemented by the Gateway. - /// - /// There are a number of cases where the "Accepted" condition may not be set - /// due to lack of controller visibility, that includes when: - /// - /// * The Route refers to a non-existent parent. - /// * The Route is of a type that the controller does not support. - /// * The Route is in a namespace the controller does not have access to. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: Option>, - /// ControllerName is a domain/path string that indicates the name of the - /// controller that wrote this status. This corresponds with the - /// controllerName field on GatewayClass. - /// - /// Example: "example.net/gateway-controller". - /// - /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are - /// valid Kubernetes names - /// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names). - /// - /// Controllers MUST populate this field when writing status. Controllers should ensure that - /// entries to status populated with their ControllerName are cleaned up when they are no - /// longer necessary. - #[serde(rename = "controllerName")] - pub controller_name: String, - /// ParentRef corresponds with a ParentRef in the spec that this - /// RouteParentStatus struct describes the status of. - #[serde(rename = "parentRef")] - pub parent_ref: HTTPRouteStatusParentsParentRef, -} - -/// ParentRef corresponds with a ParentRef in the spec that this -/// RouteParentStatus struct describes the status of. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteStatusParentsParentRef { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, -} diff --git a/gateway-api/src/apis/standard/mod.rs b/gateway-api/src/apis/standard/mod.rs deleted file mode 100644 index 5111225..0000000 --- a/gateway-api/src/apis/standard/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -// WARNING! generated file do not edit -pub mod constants; -mod enum_defaults; -pub mod gatewayclasses; -pub mod gateways; -pub mod grpcroutes; -pub mod httproutes; -pub mod referencegrants; diff --git a/gateway-api/src/duration.rs b/gateway-api/src/duration.rs index 699bee9..087b0e8 100644 --- a/gateway-api/src/duration.rs +++ b/gateway-api/src/duration.rs @@ -8,10 +8,10 @@ //! Go's `time.ParseDuration`, with additional restrictions: negative //! durations, units smaller than millisecond, and floating point are not //! allowed, and durations are limited to four components of no more than five -//! digits each. See https://gateway-api.sigs.k8s.io/geps/gep-2257 for the +//! digits each. See for the //! complete specification. -use kube::core::Duration as k8sDuration; +use kube_core::Duration as k8sDuration; use once_cell::sync::Lazy; use regex::Regex; use std::fmt; @@ -24,7 +24,7 @@ use std::time::Duration as stdDuration; /// obey GEP-2257. It is based on `std::time::Duration` and uses /// `kube::core::Duration` for the heavy lifting of parsing. /// -/// See https://gateway-api.sigs.k8s.io/geps/gep-2257 for the complete +/// See for the complete /// specification. /// /// Per GEP-2257, when parsing a `gateway_api::Duration` from a string, the @@ -70,7 +70,7 @@ const MAX_DURATION_MS: u128 = (((99999 * 3600) + (59 * 60) + 59) * 1_000) + 999; pub fn is_valid(duration: stdDuration) -> Result<(), String> { // Check nanoseconds to see if we have sub-millisecond precision in // this duration. - if duration.subsec_nanos() % 1_000_000 != 0 { + if !duration.subsec_nanos().is_multiple_of(1_000_000) { return Err("Cannot express sub-millisecond precision in GEP-2257".to_string()); } @@ -389,13 +389,12 @@ impl FromStr for Duration { // This Lazy Regex::new should never ever fail, given that the regex // is a compile-time constant. But just in case..... static RE: Lazy = Lazy::new(|| { - Regex::new(GEP2257_PATTERN).expect( - format!( + Regex::new(GEP2257_PATTERN).unwrap_or_else(|_| { + panic!( r#"GEP2257 regex "{}" did not compile (this is a bug!)"#, GEP2257_PATTERN ) - .as_str(), - ) + }) }); // If the string doesn't match the regex, it's invalid. diff --git a/gateway-api/src/experimental/backendtlspolicies.rs b/gateway-api/src/experimental/backendtlspolicies.rs new file mode 100644 index 0000000..10c7b7e --- /dev/null +++ b/gateway-api/src/experimental/backendtlspolicies.rs @@ -0,0 +1,354 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of BackendTLSPolicy. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "BackendTLSPolicy", + plural = "backendtlspolicies" +)] +#[kube(namespaced)] +#[kube(status = "BackendTlsPolicyStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct BackendTlsPolicySpec { + /// Options are a list of key/value pairs to enable extended TLS + /// configuration for each implementation. For example, configuring the + /// minimum TLS version or supported cipher suites. + /// + /// A set of common keys MAY be defined by the API in the future. To avoid + /// any ambiguity, implementation-specific definitions MUST use + /// domain-prefixed names, such as `example.com/my-custom-option`. + /// Un-prefixed names are reserved for key names defined by Gateway API. + /// + /// Support: Implementation-specific + #[serde(default, skip_serializing_if = "Option::is_none")] + pub options: Option>, + /// TargetRefs identifies an API object to apply the policy to. + /// Note that this config applies to the entire referenced resource + /// by default, but this default may change in the future to provide + /// a more granular application of the policy. + /// + /// TargetRefs must be _distinct_. This means either that: + /// + /// * They select different targets. If this is the case, then targetRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, and `name` must + /// be unique across all targetRef entries in the BackendTLSPolicy. + /// * They select different sectionNames in the same target. + /// + /// When more than one BackendTLSPolicy selects the same target and + /// sectionName, implementations MUST determine precedence using the + /// following criteria, continuing on ties: + /// + /// * The older policy by creation timestamp takes precedence. For + /// example, a policy with a creation timestamp of "2021-07-15 + /// 01:02:03" MUST be given precedence over a policy with a + /// creation timestamp of "2021-07-15 01:02:04". + /// * The policy appearing first in alphabetical order by {namespace}/{name}. + /// For example, a policy named `foo/bar` is given precedence over a + /// policy named `foo/baz`. + /// + /// For any BackendTLSPolicy that does not take precedence, the + /// implementation MUST ensure the `Accepted` Condition is set to + /// `status: False`, with Reason `Conflicted`. + /// + /// Implementations SHOULD NOT support more than one targetRef at this + /// time. Although the API technically allows for this, the current guidance + /// for conflict resolution and status handling is lacking. Until that can be + /// clarified in a future release, the safest approach is to support a single + /// targetRef. + /// + /// Support Levels: + /// + /// * Extended: Kubernetes Service referenced by HTTPRoute backendRefs. + /// + /// * Implementation-Specific: Services not connected via HTTPRoute, and any + /// other kind of backend. Implementations MAY use BackendTLSPolicy for: + /// - Services not referenced by any Route (e.g., infrastructure services) + /// - Gateway feature backends (e.g., ExternalAuth, rate-limiting services) + /// - Service mesh workload-to-service communication + /// - Other resource types beyond Service + /// + /// Implementations SHOULD aim to ensure that BackendTLSPolicy behavior is consistent, + /// even outside of the extended HTTPRoute -(backendRef) -> Service path. + /// They SHOULD clearly document how BackendTLSPolicy is interpreted in these + /// scenarios, including: + /// - Which resources beyond Service are supported + /// - How the policy is discovered and applied + /// - Any implementation-specific semantics or restrictions + /// + /// Note that this config applies to the entire referenced resource + /// by default, but this default may change in the future to provide + /// a more granular application of the policy. + #[serde(rename = "targetRefs")] + pub target_refs: Vec, + /// Validation contains backend TLS validation configuration. + pub validation: BackendTlsPolicyValidation, +} +/// LocalPolicyTargetReferenceWithSectionName identifies an API object to apply a +/// direct policy to. This should be used as part of Policy resources that can +/// target single resources. For more information on how this policy attachment +/// mode works, and a sample Policy resource, refer to the policy attachment +/// documentation for Gateway API. +/// +/// Note: This should only be used for direct policy attachment when references +/// to SectionName are actually needed. In all other cases, +/// LocalPolicyTargetReference should be used. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyTargetRefs { + /// Group is the group of the target resource. + pub group: String, + /// Kind is kind of the target resource. + pub kind: String, + /// Name is the name of the target resource. + pub name: String, + /// SectionName is the name of a section within the target resource. When + /// unspecified, this targetRef targets the entire resource. In the following + /// resources, SectionName is interpreted as the following: + /// + /// * Gateway: Listener name + /// * HTTPRoute: HTTPRouteRule name + /// * Service: Port name + /// + /// If a SectionName is specified, but does not exist on the targeted object, + /// the Policy must fail to attach, and the policy implementation should record + /// a `ResolvedRefs` or similar Condition in the Policy's status. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sectionName" + )] + pub section_name: Option, +} +/// Validation contains backend TLS validation configuration. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyValidation { + /// CACertificateRefs contains one or more references to Kubernetes objects that + /// contain a PEM-encoded TLS CA certificate bundle, which is used to + /// validate a TLS handshake between the Gateway and backend Pod. + /// + /// If CACertificateRefs is empty or unspecified, then WellKnownCACertificates must be + /// specified. Only one of CACertificateRefs or WellKnownCACertificates may be specified, + /// not both. If CACertificateRefs is empty or unspecified, the configuration for + /// WellKnownCACertificates MUST be honored instead if supported by the implementation. + /// + /// A CACertificateRef is invalid if: + /// + /// * It refers to a resource that cannot be resolved (e.g., the referenced resource + /// does not exist) or is misconfigured (e.g., a ConfigMap does not contain a key + /// named `ca.crt`). In this case, the Reason must be set to `InvalidCACertificateRef` + /// and the Message of the Condition must indicate which reference is invalid and why. + /// + /// * It refers to an unknown or unsupported kind of resource. In this case, the Reason + /// must be set to `InvalidKind` and the Message of the Condition must explain which + /// kind of resource is unknown or unsupported. + /// + /// * It refers to a resource in another namespace. This may change in future + /// spec updates. + /// + /// Implementations MAY choose to perform further validation of the certificate + /// content (e.g., checking expiry or enforcing specific formats). In such cases, + /// an implementation-specific Reason and Message must be set for the invalid reference. + /// + /// In all cases, the implementation MUST ensure the `ResolvedRefs` Condition on + /// the BackendTLSPolicy is set to `status: False`, with a Reason and Message + /// that indicate the cause of the error. Connections using an invalid + /// CACertificateRef MUST fail, and the client MUST receive an HTTP 5xx error + /// response. If ALL CACertificateRefs are invalid, the implementation MUST also + /// ensure the `Accepted` Condition on the BackendTLSPolicy is set to + /// `status: False`, with a Reason `NoValidCACertificate`. + /// + /// A single CACertificateRef to a Kubernetes ConfigMap kind has "Core" support. + /// Implementations MAY choose to support attaching multiple certificates to + /// a backend, but this behavior is implementation-specific. + /// + /// Support: Core - An optional single reference to a Kubernetes ConfigMap, + /// with the CA certificate in a key named `ca.crt`. + /// + /// Support: Implementation-specific - More than one reference, other kinds + /// of resources, or a single reference that includes multiple certificates. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "caCertificateRefs" + )] + pub ca_certificate_refs: Option>, + /// Hostname is used for two purposes in the connection between Gateways and + /// backends: + /// + /// 1. Hostname MUST be used as the SNI to connect to the backend (RFC 6066). + /// 2. Hostname MUST be used for authentication and MUST match the certificate + /// served by the matching backend, unless SubjectAltNames is specified. + /// 3. If SubjectAltNames are specified, Hostname can be used for certificate selection + /// but MUST NOT be used for authentication. If you want to use the value + /// of the Hostname field for authentication, you MUST add it to the SubjectAltNames list. + /// + /// Support: Core + pub hostname: String, + /// SubjectAltNames contains one or more Subject Alternative Names. + /// When specified the certificate served from the backend MUST + /// have at least one Subject Alternate Name matching one of the specified SubjectAltNames. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "subjectAltNames" + )] + pub subject_alt_names: Option>, + /// WellKnownCACertificates specifies whether a well-known set of CA certificates + /// may be used in the TLS handshake between the gateway and backend pod. + /// + /// If WellKnownCACertificates is unspecified or empty (""), then CACertificateRefs + /// must be specified with at least one entry for a valid configuration. Only one of + /// CACertificateRefs or WellKnownCACertificates may be specified, not both. + /// If an implementation does not support the WellKnownCACertificates field, or + /// the supplied value is not recognized, the implementation MUST ensure the + /// `Accepted` Condition on the BackendTLSPolicy is set to `status: False`, with + /// a Reason `Invalid`. + /// + /// Valid values include: + /// * "System" - indicates that well-known system CA certificates should be used. + /// + /// Implementations MAY define their own sets of CA certificates. Such definitions + /// MUST use an implementation-specific, prefixed name, such as + /// `mycompany.com/my-custom-ca-certificates`. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "wellKnownCACertificates" + )] + pub well_known_ca_certificates: Option, +} +/// SubjectAltName represents Subject Alternative Name. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyValidationSubjectAltNames { + /// Hostname contains Subject Alternative Name specified in DNS name format. + /// Required when Type is set to Hostname, ignored otherwise. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + /// Type determines the format of the Subject Alternative Name. Always required. + /// + /// Support: Core + #[serde(rename = "type")] + pub r#type: BackendTlsPolicyValidationSubjectAltNamesType, + /// URI contains Subject Alternative Name specified in a full URI format. + /// It MUST include both a scheme (e.g., "http" or "ftp") and a scheme-specific-part. + /// Common values include SPIFFE IDs like "spiffe://mycluster.example.com/ns/myns/sa/svc1sa". + /// Required when Type is set to URI, ignored otherwise. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub uri: Option, +} +/// SubjectAltName represents Subject Alternative Name. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum BackendTlsPolicyValidationSubjectAltNamesType { + Hostname, + #[serde(rename = "URI")] + Uri, +} +/// Status defines the current state of BackendTLSPolicy. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyStatus { + /// Ancestors is a list of ancestor resources (usually Gateways) that are + /// associated with the policy, and the status of the policy with respect to + /// each ancestor. When this policy attaches to a parent, the controller that + /// manages the parent and the ancestors MUST add an entry to this list when + /// the controller first sees the policy and SHOULD update the entry as + /// appropriate when the relevant ancestor is modified. + /// + /// Note that choosing the relevant ancestor is left to the Policy designers; + /// an important part of Policy design is designing the right object level at + /// which to namespace this status. + /// + /// Note also that implementations MUST ONLY populate ancestor status for + /// the Ancestor resources they are responsible for. Implementations MUST + /// use the ControllerName field to uniquely identify the entries in this list + /// that they are responsible for. + /// + /// Note that to achieve this, the list of PolicyAncestorStatus structs + /// MUST be treated as a map with a composite key, made up of the AncestorRef + /// and ControllerName fields combined. + /// + /// A maximum of 16 ancestors will be represented in this list. An empty list + /// means the Policy is not relevant for any ancestors. + /// + /// If this slice is full, implementations MUST NOT add further entries. + /// Instead they MUST consider the policy unimplementable and signal that + /// on any related resources such as the ancestor that would be referenced + /// here. For example, if this list was full on BackendTLSPolicy, no + /// additional Gateways would be able to reference the Service targeted by + /// the BackendTLSPolicy. + pub ancestors: Vec, +} +/// PolicyAncestorStatus describes the status of a route with respect to an +/// associated Ancestor. +/// +/// Ancestors refer to objects that are either the Target of a policy or above it +/// in terms of object hierarchy. For example, if a policy targets a Service, the +/// Policy's Ancestors are, in order, the Service, the HTTPRoute, the Gateway, and +/// the GatewayClass. Almost always, in this hierarchy, the Gateway will be the most +/// useful object to place Policy status on, so we recommend that implementations +/// SHOULD use Gateway as the PolicyAncestorStatus object unless the designers +/// have a _very_ good reason otherwise. +/// +/// In the context of policy attachment, the Ancestor is used to distinguish which +/// resource results in a distinct application of this policy. For example, if a policy +/// targets a Service, it may have a distinct result per attached Gateway. +/// +/// Policies targeting the same resource may have different effects depending on the +/// ancestors of those resources. For example, different Gateways targeting the same +/// Service may have different capabilities, especially if they have different underlying +/// implementations. +/// +/// For example, in BackendTLSPolicy, the Policy attaches to a Service that is +/// used as a backend in a HTTPRoute that is itself attached to a Gateway. +/// In this case, the relevant object for status is the Gateway, and that is the +/// ancestor object referred to in this status. +/// +/// Note that a parent is also an ancestor, so for objects where the parent is the +/// relevant object for status, this struct SHOULD still be used. +/// +/// This struct is intended to be used in a slice that's effectively a map, +/// with a composite key made up of the AncestorRef and the ControllerName. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyStatusAncestors { + /// AncestorRef corresponds with a ParentRef in the spec that this + /// PolicyAncestorStatus struct describes the status of. + #[serde(rename = "ancestorRef")] + pub ancestor_ref: ParentReference, + /// Conditions describes the status of the Policy with respect to the given Ancestor. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, +} diff --git a/gateway-api/src/experimental/common.rs b/gateway-api/src/experimental/common.rs new file mode 100644 index 0000000..e3ea674 --- /dev/null +++ b/gateway-api/src/experimental/common.rs @@ -0,0 +1,441 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum AllowedRoutesNamespacesFrom { + All, + Selector, + Same, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum CookieConfigLifetimeType { + Permanent, + Session, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum DefaultGateway { + All, + None, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum ExternalAuthProtocol { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "GRPC")] + Grpc, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GRPCFilterType { + ResponseHeaderModifier, + RequestHeaderModifier, + RequestMirror, + ExtensionRef, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HTTPFilterType { + RequestHeaderModifier, + ResponseHeaderModifier, + RequestMirror, + RequestRedirect, + #[serde(rename = "URLRewrite")] + UrlRewrite, + ExtensionRef, + #[serde(rename = "CORS")] + Cors, + ExternalAuth, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HeaderMatchType { + Exact, + RegularExpression, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RedirectStatusCode { + #[serde(rename = "301")] + r#_301, + #[serde(rename = "302")] + r#_302, + #[serde(rename = "303")] + r#_303, + #[serde(rename = "307")] + r#_307, + #[serde(rename = "308")] + r#_308, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RequestOperationType { + ReplaceFullPath, + ReplacePrefixMatch, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RequestRedirectScheme { + #[serde(rename = "http")] + Http, + #[serde(rename = "https")] + Https, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum SessionPersistenceType { + Cookie, + Header, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum TlsMode { + Terminate, + Passthrough, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum TlsValidationMode { + AllowValidOnly, + AllowInsecureFallback, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendObjectReference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ExtensionParametersReference { + pub group: String, + pub kind: String, + pub name: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ExternalAuthGrpc { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedHeaders" + )] + pub allowed_headers: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ExternalAuthHttp { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedHeaders" + )] + pub allowed_headers: Option>, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedResponseHeaders" + )] + pub allowed_response_headers: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ForwardBody { + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxSize")] + pub max_size: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayParametersRef { + pub group: String, + pub kind: String, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HTTPHeader { + pub name: String, + pub value: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Kind { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + pub kind: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct MatchExpressions { + pub key: String, + pub operator: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub values: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ParentReference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sectionName" + )] + pub section_name: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Reference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestMirrorFraction { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub denominator: Option, + pub numerator: i32, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TcpRouteRulesBackendRefs { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ExternalAuthFilter { + #[serde(rename = "backendRef")] + pub backend_ref: BackendObjectReference, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "forwardBody" + )] + pub forward_body: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub grpc: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub http: Option, + pub protocol: ExternalAuthProtocol, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct FrontendTlsValidation { + #[serde(rename = "caCertificateRefs")] + pub ca_certificate_refs: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HeaderMatch { + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + pub value: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HeaderModifier { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub add: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub remove: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub set: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerTls { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "certificateRefs" + )] + pub certificate_refs: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub options: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct NamespaceSelector { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "matchExpressions" + )] + pub match_expressions: Option>, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "matchLabels" + )] + pub match_labels: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct PersistenceCookieConfig { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "lifetimeType" + )] + pub lifetime_type: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestMirror { + #[serde(rename = "backendRef")] + pub backend_ref: BackendObjectReference, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub fraction: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub percent: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestRedirectPath { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "replaceFullPath" + )] + pub replace_full_path: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "replacePrefixMatch" + )] + pub replace_prefix_match: Option, + #[serde(rename = "type")] + pub r#type: RequestOperationType, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct AllowedRoutesNamespaces { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub from: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub selector: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct FilterRequestRedirect { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub scheme: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "statusCode" + )] + pub status_code: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct FrontendTls { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub validation: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GrpcRouteFilter { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + #[serde(rename = "type")] + pub r#type: GRPCFilterType, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteUrlRewrite { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct SessionPersistence { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "absoluteTimeout" + )] + pub absolute_timeout: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "cookieConfig" + )] + pub cookie_config: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "idleTimeout" + )] + pub idle_timeout: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sessionName" + )] + pub session_name: Option, + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct AllowedRoutes { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kinds: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespaces: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Listeners { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedRoutes" + )] + pub allowed_routes: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + pub name: String, + pub port: i32, + pub protocol: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tls: Option, +} diff --git a/gateway-api/src/apis/standard/constants.rs b/gateway-api/src/experimental/constants.rs similarity index 74% rename from gateway-api/src/apis/standard/constants.rs rename to gateway-api/src/experimental/constants.rs index 2605e44..8995c8a 100644 --- a/gateway-api/src/apis/standard/constants.rs +++ b/gateway-api/src/experimental/constants.rs @@ -3,14 +3,13 @@ #[derive(Debug, PartialEq, Eq)] pub enum GatewayClassConditionType { Accepted, + SupportedVersion, } - impl std::fmt::Display for GatewayClassConditionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum GatewayClassConditionReason { Accepted, @@ -18,27 +17,25 @@ pub enum GatewayClassConditionReason { Pending, Unsupported, Waiting, + SupportedVersion, + UnsupportedVersion, } - impl std::fmt::Display for GatewayClassConditionReason { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum GatewayConditionType { Programmed, Accepted, Ready, } - impl std::fmt::Display for GatewayConditionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum GatewayConditionReason { Programmed, @@ -54,13 +51,11 @@ pub enum GatewayConditionReason { Ready, ListenersNotReady, } - impl std::fmt::Display for GatewayConditionReason { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum ListenerConditionType { Conflicted, @@ -69,13 +64,11 @@ pub enum ListenerConditionType { Programmed, Ready, } - impl std::fmt::Display for ListenerConditionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum ListenerConditionReason { HostnameConflict, @@ -93,9 +86,35 @@ pub enum ListenerConditionReason { Pending, Ready, } - impl std::fmt::Display for ListenerConditionReason { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self) } } +#[derive(Debug, PartialEq, Eq)] +pub enum RouteConditionType { + Accepted, + ResolvedRefs, +} +impl std::fmt::Display for RouteConditionType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum RouteConditionReason { + Accepted, + NotAllowedByListeners, + NoMatchingListenerHostname, + UnsupportedValue, + Pending, + ResolvedRefs, + RefNotPermitted, + InvalidKind, + BackendNotFound, +} +impl std::fmt::Display for RouteConditionReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} diff --git a/gateway-api/src/experimental/enum_defaults.rs b/gateway-api/src/experimental/enum_defaults.rs new file mode 100644 index 0000000..56bd29d --- /dev/null +++ b/gateway-api/src/experimental/enum_defaults.rs @@ -0,0 +1,116 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +pub mod prelude { + + pub use super::super::backendtlspolicies::*; + pub use super::super::gatewayclasses::*; + pub use super::super::gateways::*; + pub use super::super::grpcroutes::*; + pub use super::super::httproutes::*; + pub use super::super::listenersets::*; + pub use super::super::referencegrants::*; + pub use super::super::tcproutes::*; + pub use super::super::tlsroutes::*; + pub use super::super::udproutes::*; + + pub use super::super::common::*; +} +use prelude::*; +impl Default for AllowedRoutesNamespacesFrom { + fn default() -> Self { + AllowedRoutesNamespacesFrom::Same + } +} + +impl Default for BackendTlsPolicyValidationSubjectAltNamesType { + fn default() -> Self { + BackendTlsPolicyValidationSubjectAltNamesType::Hostname + } +} + +impl Default for CookieConfigLifetimeType { + fn default() -> Self { + CookieConfigLifetimeType::Session + } +} + +impl Default for ExternalAuthProtocol { + fn default() -> Self { + ExternalAuthProtocol::Http + } +} + +impl Default for GRPCFilterType { + fn default() -> Self { + GRPCFilterType::RequestHeaderModifier + } +} + +impl Default for GatewayAllowedListenersNamespacesFrom { + fn default() -> Self { + GatewayAllowedListenersNamespacesFrom::Same + } +} + +impl Default for HTTPFilterType { + fn default() -> Self { + HTTPFilterType::RequestHeaderModifier + } +} + +impl Default for HTTPMethodMatch { + fn default() -> Self { + HTTPMethodMatch::Get + } +} + +impl Default for HeaderMatchType { + fn default() -> Self { + HeaderMatchType::Exact + } +} + +impl Default for HttpRouteRulesMatchesPathType { + fn default() -> Self { + HttpRouteRulesMatchesPathType::Exact + } +} + +impl Default for RedirectStatusCode { + fn default() -> Self { + RedirectStatusCode::r#_301 + } +} + +impl Default for RequestOperationType { + fn default() -> Self { + RequestOperationType::ReplaceFullPath + } +} + +impl Default for RequestRedirectScheme { + fn default() -> Self { + RequestRedirectScheme::Https + } +} + +impl Default for SessionPersistenceType { + fn default() -> Self { + SessionPersistenceType::Cookie + } +} + +impl Default for TlsMode { + fn default() -> Self { + TlsMode::Terminate + } +} + +impl Default for TlsValidationMode { + fn default() -> Self { + TlsValidationMode::AllowValidOnly + } +} + +use crate::experimental::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType; diff --git a/gateway-api/src/apis/standard/gatewayclasses.rs b/gateway-api/src/experimental/gatewayclasses.rs similarity index 63% rename from gateway-api/src/apis/standard/gatewayclasses.rs rename to gateway-api/src/experimental/gatewayclasses.rs index 7cde0c9..2c224a1 100644 --- a/gateway-api/src/apis/standard/gatewayclasses.rs +++ b/gateway-api/src/experimental/gatewayclasses.rs @@ -1,16 +1,14 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 +// WARNING: generated file - manual changes will be overriden +use super::common::*; #[allow(unused_imports)] mod prelude { pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube::CustomResource; + pub use kube_derive::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } use self::prelude::*; - /// Spec defines the desired state of GatewayClass. #[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] #[kube( @@ -59,42 +57,8 @@ pub struct GatewayClassSpec { skip_serializing_if = "Option::is_none", rename = "parametersRef" )] - pub parameters_ref: Option, -} - -/// ParametersRef is a reference to a resource that contains the configuration -/// parameters corresponding to the GatewayClass. This is optional if the -/// controller does not require any additional configuration. -/// -/// ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap, -/// or an implementation-specific custom resource. The resource can be -/// cluster-scoped or namespace-scoped. -/// -/// If the referent cannot be found, refers to an unsupported kind, or when -/// the data within that resource is malformed, the GatewayClass SHOULD be -/// rejected with the "Accepted" status condition set to "False" and an -/// "InvalidParameters" reason. -/// -/// A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, -/// the merging behavior is implementation specific. -/// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. -/// -/// Support: Implementation-specific -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayClassParametersRef { - /// Group is the group of the referent. - pub group: String, - /// Kind is kind of the referent. - pub kind: String, - /// Name is the name of the referent. - pub name: String, - /// Namespace is the namespace of the referent. - /// This field is required when referring to a Namespace-scoped resource and - /// MUST be unset when referring to a Cluster-scoped resource. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, + pub parameters_ref: Option, } - /// Status defines the current state of GatewayClass. /// /// Implementations MUST populate status on all GatewayClass resources which @@ -108,4 +72,18 @@ pub struct GatewayClassStatus { /// of GatewayClassConditionType for the type of each Condition. #[serde(default, skip_serializing_if = "Option::is_none")] pub conditions: Option>, + /// SupportedFeatures is the set of features the GatewayClass support. + /// It MUST be sorted in ascending alphabetical order by the Name key. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "supportedFeatures" + )] + pub supported_features: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayClassStatusSupportedFeatures { + /// FeatureName is used to describe distinct features that are covered by + /// conformance tests. + pub name: String, } diff --git a/gateway-api/src/experimental/gateways.rs b/gateway-api/src/experimental/gateways.rs new file mode 100644 index 0000000..0741959 --- /dev/null +++ b/gateway-api/src/experimental/gateways.rs @@ -0,0 +1,561 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of Gateway. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "Gateway", + plural = "gateways" +)] +#[kube(namespaced)] +#[kube(status = "GatewayStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct GatewaySpec { + /// Addresses requested for this Gateway. This is optional and behavior can + /// depend on the implementation. If a value is set in the spec and the + /// requested address is invalid or unavailable, the implementation MUST + /// indicate this in an associated entry in GatewayStatus.Conditions. + /// + /// The Addresses field represents a request for the address(es) on the + /// "outside of the Gateway", that traffic bound for this Gateway will use. + /// This could be the IP address or hostname of an external load balancer or + /// other networking infrastructure, or some other address that traffic will + /// be sent to. + /// + /// If no Addresses are specified, the implementation MAY schedule the + /// Gateway in an implementation-specific manner, assigning an appropriate + /// set of Addresses. + /// + /// The implementation MUST bind all Listeners to every GatewayAddress that + /// it assigns to the Gateway and add a corresponding entry in + /// GatewayStatus.Addresses. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub addresses: Option>, + /// AllowedListeners defines which ListenerSets can be attached to this Gateway. + /// The default value is to allow no ListenerSets. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedListeners" + )] + pub allowed_listeners: Option, + /// DefaultScope, when set, configures the Gateway as a default Gateway, + /// meaning it will dynamically and implicitly have Routes (e.g. HTTPRoute) + /// attached to it, according to the scope configured here. + /// + /// If unset (the default) or set to None, the Gateway will not act as a + /// default Gateway; if set, the Gateway will claim any Route with a + /// matching scope set in its UseDefaultGateway field, subject to the usual + /// rules about which routes the Gateway can attach to. + /// + /// Think carefully before using this functionality! While the normal rules + /// about which Route can apply are still enforced, it is simply easier for + /// the wrong Route to be accidentally attached to this Gateway in this + /// configuration. If the Gateway operator is not also the operator in + /// control of the scope (e.g. namespace) with tight controls and checks on + /// what kind of workloads and Routes get added in that scope, we strongly + /// recommend not using this just because it seems convenient, and instead + /// stick to direct Route attachment. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "defaultScope" + )] + pub default_scope: Option, + /// GatewayClassName used for this Gateway. This is the name of a + /// GatewayClass resource. + #[serde(rename = "gatewayClassName")] + pub gateway_class_name: String, + /// Infrastructure defines infrastructure level attributes about this Gateway instance. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub infrastructure: Option, + /// Listeners associated with this Gateway. Listeners define + /// logical endpoints that are bound on this Gateway's addresses. + /// At least one Listener MUST be specified. + /// + /// ## Distinct Listeners + /// + /// Each Listener in a set of Listeners (for example, in a single Gateway) + /// MUST be _distinct_, in that a traffic flow MUST be able to be assigned to + /// exactly one listener. (This section uses "set of Listeners" rather than + /// "Listeners in a single Gateway" because implementations MAY merge configuration + /// from multiple Gateways onto a single data plane, and these rules _also_ + /// apply in that case). + /// + /// Practically, this means that each listener in a set MUST have a unique + /// combination of Port, Protocol, and, if supported by the protocol, Hostname. + /// + /// Some combinations of port, protocol, and TLS settings are considered + /// Core support and MUST be supported by implementations based on the objects + /// they support: + /// + /// HTTPRoute + /// + /// 1. HTTPRoute, Port: 80, Protocol: HTTP + /// 2. HTTPRoute, Port: 443, Protocol: HTTPS, TLS Mode: Terminate, TLS keypair provided + /// + /// TLSRoute + /// + /// 1. TLSRoute, Port: 443, Protocol: TLS, TLS Mode: Passthrough + /// + /// "Distinct" Listeners have the following property: + /// + /// **The implementation can match inbound requests to a single distinct + /// Listener**. + /// + /// When multiple Listeners share values for fields (for + /// example, two Listeners with the same Port value), the implementation + /// can match requests to only one of the Listeners using other + /// Listener fields. + /// + /// When multiple listeners have the same value for the Protocol field, then + /// each of the Listeners with matching Protocol values MUST have different + /// values for other fields. + /// + /// The set of fields that MUST be different for a Listener differs per protocol. + /// The following rules define the rules for what fields MUST be considered for + /// Listeners to be distinct with each protocol currently defined in the + /// Gateway API spec. + /// + /// The set of listeners that all share a protocol value MUST have _different_ + /// values for _at least one_ of these fields to be distinct: + /// + /// * **HTTP, HTTPS, TLS**: Port, Hostname + /// * **TCP, UDP**: Port + /// + /// One **very** important rule to call out involves what happens when an + /// implementation: + /// + /// * Supports TCP protocol Listeners, as well as HTTP, HTTPS, or TLS protocol + /// Listeners, and + /// * sees HTTP, HTTPS, or TLS protocols with the same `port` as one with TCP + /// Protocol. + /// + /// In this case all the Listeners that share a port with the + /// TCP Listener are not distinct and so MUST NOT be accepted. + /// + /// If an implementation does not support TCP Protocol Listeners, then the + /// previous rule does not apply, and the TCP Listeners SHOULD NOT be + /// accepted. + /// + /// Note that the `tls` field is not used for determining if a listener is distinct, because + /// Listeners that _only_ differ on TLS config will still conflict in all cases. + /// + /// ### Listeners that are distinct only by Hostname + /// + /// When the Listeners are distinct based only on Hostname, inbound request + /// hostnames MUST match from the most specific to least specific Hostname + /// values to choose the correct Listener and its associated set of Routes. + /// + /// Exact matches MUST be processed before wildcard matches, and wildcard + /// matches MUST be processed before fallback (empty Hostname value) + /// matches. For example, `"foo.example.com"` takes precedence over + /// `"*.example.com"`, and `"*.example.com"` takes precedence over `""`. + /// + /// Additionally, if there are multiple wildcard entries, more specific + /// wildcard entries must be processed before less specific wildcard entries. + /// For example, `"*.foo.example.com"` takes precedence over `"*.example.com"`. + /// + /// The precise definition here is that the higher the number of dots in the + /// hostname to the right of the wildcard character, the higher the precedence. + /// + /// The wildcard character will match any number of characters _and dots_ to + /// the left, however, so `"*.example.com"` will match both + /// `"foo.bar.example.com"` _and_ `"bar.example.com"`. + /// + /// ## Handling indistinct Listeners + /// + /// If a set of Listeners contains Listeners that are not distinct, then those + /// Listeners are _Conflicted_, and the implementation MUST set the "Conflicted" + /// condition in the Listener Status to "True". + /// + /// The words "indistinct" and "conflicted" are considered equivalent for the + /// purpose of this documentation. + /// + /// Implementations MAY choose to accept a Gateway with some Conflicted + /// Listeners only if they only accept the partial Listener set that contains + /// no Conflicted Listeners. + /// + /// Specifically, an implementation MAY accept a partial Listener set subject to + /// the following rules: + /// + /// * The implementation MUST NOT pick one conflicting Listener as the winner. + /// ALL indistinct Listeners must not be accepted for processing. + /// * At least one distinct Listener MUST be present, or else the Gateway effectively + /// contains _no_ Listeners, and must be rejected from processing as a whole. + /// + /// The implementation MUST set a "ListenersNotValid" condition on the + /// Gateway Status when the Gateway contains Conflicted Listeners whether or + /// not they accept the Gateway. That Condition SHOULD clearly + /// indicate in the Message which Listeners are conflicted, and which are + /// Accepted. Additionally, the Listener status for those listeners SHOULD + /// indicate which Listeners are conflicted and not Accepted. + /// + /// ## General Listener behavior + /// + /// Note that, for all distinct Listeners, requests SHOULD match at most one Listener. + /// For example, if Listeners are defined for "foo.example.com" and "*.example.com", a + /// request to "foo.example.com" SHOULD only be routed using routes attached + /// to the "foo.example.com" Listener (and not the "*.example.com" Listener). + /// + /// This concept is known as "Listener Isolation", and it is an Extended feature + /// of Gateway API. Implementations that do not support Listener Isolation MUST + /// clearly document this, and MUST NOT claim support for the + /// `GatewayHTTPListenerIsolation` feature. + /// + /// Implementations that _do_ support Listener Isolation SHOULD claim support + /// for the Extended `GatewayHTTPListenerIsolation` feature and pass the associated + /// conformance tests. + /// + /// ## Compatible Listeners + /// + /// A Gateway's Listeners are considered _compatible_ if: + /// + /// 1. They are distinct. + /// 2. The implementation can serve them in compliance with the Addresses + /// requirement that all Listeners are available on all assigned + /// addresses. + /// + /// Compatible combinations in Extended support are expected to vary across + /// implementations. A combination that is compatible for one implementation + /// may not be compatible for another. + /// + /// For example, an implementation that cannot serve both TCP and UDP listeners + /// on the same address, or cannot mix HTTPS and generic TLS listens on the same port + /// would not consider those cases compatible, even though they are distinct. + /// + /// Implementations MAY merge separate Gateways onto a single set of + /// Addresses if all Listeners across all Gateways are compatible. + /// + /// In a future release the MinItems=1 requirement MAY be dropped. + /// + /// Support: Core + pub listeners: Vec, + /// TLS specifies frontend and backend tls configuration for entire gateway. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tls: Option, +} +/// GatewaySpecAddress describes an address that can be bound to a Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAddresses { + /// Type of the address. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// When a value is unspecified, an implementation SHOULD automatically + /// assign an address matching the requested type if possible. + /// + /// If an implementation does not support an empty value, they MUST set the + /// "Programmed" condition in status to False with a reason of "AddressNotAssigned". + /// + /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, +} +/// AllowedListeners defines which ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAllowedListeners { + /// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. + /// The default value is to allow no ListenerSets. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespaces: Option, +} +/// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAllowedListenersNamespaces { + /// From indicates where ListenerSets can attach to this Gateway. Possible + /// values are: + /// + /// * Same: Only ListenerSets in the same namespace may be attached to this Gateway. + /// * Selector: ListenerSets in namespaces selected by the selector may be attached to this Gateway. + /// * All: ListenerSets in all namespaces may be attached to this Gateway. + /// * None: Only listeners defined in the Gateway's spec are allowed + /// + /// The default value None + #[serde(default, skip_serializing_if = "Option::is_none")] + pub from: Option, + /// Selector must be specified when From is set to "Selector". In that case, + /// only ListenerSets in Namespaces matching this Selector will be selected by this + /// Gateway. This field is ignored for other values of "From". + #[serde(default, skip_serializing_if = "Option::is_none")] + pub selector: Option, +} +/// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GatewayAllowedListenersNamespacesFrom { + All, + Selector, + Same, + None, +} +/// Infrastructure defines infrastructure level attributes about this Gateway instance. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayInfrastructure { + /// Annotations that SHOULD be applied to any resources created in response to this Gateway. + /// + /// For implementations creating other Kubernetes objects, this should be the `metadata.annotations` field on resources. + /// For other implementations, this refers to any relevant (implementation specific) "annotations" concepts. + /// + /// An implementation may chose to add additional implementation-specific annotations as they see fit. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub annotations: Option>, + /// Labels that SHOULD be applied to any resources created in response to this Gateway. + /// + /// For implementations creating other Kubernetes objects, this should be the `metadata.labels` field on resources. + /// For other implementations, this refers to any relevant (implementation specific) "labels" concepts. + /// + /// An implementation may chose to add additional implementation-specific labels as they see fit. + /// + /// If an implementation maps these labels to Pods, or any other resource that would need to be recreated when labels + /// change, it SHOULD clearly warn about this behavior in documentation. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub labels: Option>, + /// ParametersRef is a reference to a resource that contains the configuration + /// parameters corresponding to the Gateway. This is optional if the + /// controller does not require any additional configuration. + /// + /// This follows the same semantics as GatewayClass's `parametersRef`, but on a per-Gateway basis + /// + /// The Gateway's GatewayClass may provide its own `parametersRef`. When both are specified, + /// the merging behavior is implementation specific. + /// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. + /// + /// If the referent cannot be found, refers to an unsupported kind, or when + /// the data within that resource is malformed, the Gateway SHOULD be + /// rejected with the "Accepted" status condition set to "False" and an + /// "InvalidParameters" reason. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parametersRef" + )] + pub parameters_ref: Option, +} +/// TLS specifies frontend and backend tls configuration for entire gateway. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTls { + /// Backend describes TLS configuration for gateway when connecting + /// to backends. + /// + /// Note that this contains only details for the Gateway as a TLS client, + /// and does _not_ imply behavior about how to choose which backend should + /// get a TLS connection. That is determined by the presence of a BackendTLSPolicy. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub backend: Option, + /// Frontend describes TLS config when client connects to Gateway. + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub frontend: Option, +} +/// Backend describes TLS configuration for gateway when connecting +/// to backends. +/// +/// Note that this contains only details for the Gateway as a TLS client, +/// and does _not_ imply behavior about how to choose which backend should +/// get a TLS connection. That is determined by the presence of a BackendTLSPolicy. +/// +/// Support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsBackend { + /// ClientCertificateRef references an object that contains a client certificate + /// and its associated private key. It can reference standard Kubernetes resources, + /// i.e., Secret, or implementation-specific custom resources. + /// + /// A ClientCertificateRef is considered invalid if: + /// + /// * It refers to a resource that cannot be resolved (e.g., the referenced resource + /// does not exist) or is misconfigured (e.g., a Secret does not contain the keys + /// named `tls.crt` and `tls.key`). In this case, the `ResolvedRefs` condition + /// on the Gateway MUST be set to False with the Reason `InvalidClientCertificateRef` + /// and the Message of the Condition MUST indicate why the reference is invalid. + /// + /// * It refers to a resource in another namespace UNLESS there is a ReferenceGrant + /// in the target namespace that allows the certificate to be attached. + /// If a ReferenceGrant does not allow this reference, the `ResolvedRefs` condition + /// on the Gateway MUST be set to False with the Reason `RefNotPermitted`. + /// + /// Implementations MAY choose to perform further validation of the certificate + /// content (e.g., checking expiry or enforcing specific formats). In such cases, + /// an implementation-specific Reason and Message MUST be set. + /// + /// Support: Core - Reference to a Kubernetes TLS Secret (with the type `kubernetes.io/tls`). + /// Support: Implementation-specific - Other resource kinds or Secrets with a + /// different type (e.g., `Opaque`). + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "clientCertificateRef" + )] + pub client_certificate_ref: Option, +} +/// Frontend describes TLS config when client connects to Gateway. +/// Support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontend { + /// Default specifies the default client certificate validation configuration + /// for all Listeners handling HTTPS traffic, unless a per-port configuration + /// is defined. + /// + /// support: Core + pub default: FrontendTls, + /// PerPort specifies tls configuration assigned per port. + /// Per port configuration is optional. Once set this configuration overrides + /// the default configuration for all Listeners handling HTTPS traffic + /// that match this port. + /// Each override port requires a unique TLS configuration. + /// + /// support: Core + #[serde(default, skip_serializing_if = "Option::is_none", rename = "perPort")] + pub per_port: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendPerPort { + /// The Port indicates the Port Number to which the TLS configuration will be + /// applied. This configuration will be applied to all Listeners handling HTTPS + /// traffic that match this port. + /// + /// Support: Core + pub port: i32, + /// TLS store the configuration that will be applied to all Listeners handling + /// HTTPS traffic and matching given port. + /// + /// Support: Core + pub tls: FrontendTls, +} +/// Status defines the current state of Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatus { + /// Addresses lists the network addresses that have been bound to the + /// Gateway. + /// + /// This list may differ from the addresses provided in the spec under some + /// conditions: + /// + /// * no addresses are specified, all addresses are dynamically assigned + /// * a combination of specified and dynamic addresses are assigned + /// * a specified address was unusable (e.g. already in use) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub addresses: Option>, + /// AttachedListenerSets represents the total number of ListenerSets that have been + /// successfully attached to this Gateway. + /// + /// A ListenerSet is successfully attached to a Gateway when all the following conditions are met: + /// - The ListenerSet is selected by the Gateway's AllowedListeners field + /// - The ListenerSet has a valid ParentRef selecting the Gateway + /// - The ListenerSet's status has the condition "Accepted: true" + /// + /// Uses for this field include troubleshooting AttachedListenerSets attachment and + /// measuring blast radius/impact of changes to a Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "attachedListenerSets" + )] + pub attached_listener_sets: Option, + /// Conditions describe the current conditions of the Gateway. + /// + /// Implementations should prefer to express Gateway conditions + /// using the `GatewayConditionType` and `GatewayConditionReason` + /// constants so that operators and tools can converge on a common + /// vocabulary to describe Gateway state. + /// + /// Known condition types are: + /// + /// * "Accepted" + /// * "Programmed" + /// * "Ready" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// Listeners provide status for each unique listener port defined in the Spec. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub listeners: Option>, +} +/// GatewayStatusAddress describes a network address that is bound to a Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatusAddresses { + /// Type of the address. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// Value of the address. The validity of the values will depend + /// on the type and support by the controller. + /// + /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. + pub value: String, +} +/// ListenerStatus is the status associated with a Listener. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatusListeners { + /// AttachedRoutes represents the total number of Routes that have been + /// successfully attached to this Listener. + /// + /// Successful attachment of a Route to a Listener is based solely on the + /// combination of the AllowedRoutes field on the corresponding Listener + /// and the Route's ParentRefs field. A Route is successfully attached to + /// a Listener when it is selected by the Listener's AllowedRoutes field + /// AND the Route has a valid ParentRef selecting the whole Gateway + /// resource or a specific Listener as a parent resource (more detail on + /// attachment semantics can be found in the documentation on the various + /// Route kinds ParentRefs fields). Listener or Route status does not impact + /// successful attachment, i.e. the AttachedRoutes field count MUST be set + /// for Listeners, even if the Accepted condition of an individual Listener is set + /// to "False". The AttachedRoutes number represents the number of Routes with + /// the Accepted condition set to "True" that have been attached to this Listener. + /// Routes with any other value for the Accepted condition MUST NOT be included + /// in this count. + /// + /// Uses for this field include troubleshooting Route attachment and + /// measuring blast radius/impact of changes to a Listener. + #[serde(rename = "attachedRoutes")] + pub attached_routes: i32, + /// Conditions describe the current condition of this listener. + pub conditions: Vec, + /// Name is the name of the Listener that this status corresponds to. + pub name: String, + /// SupportedKinds is the list indicating the Kinds supported by this + /// listener. This MUST represent the kinds supported by an implementation for + /// that Listener configuration. + /// + /// If kinds are specified in Spec that are not supported, they MUST NOT + /// appear in this list and an implementation MUST set the "ResolvedRefs" + /// condition to "False" with the "InvalidRouteKinds" reason. If both valid + /// and invalid Route kinds are specified, the implementation MUST + /// reference the valid Route kinds that have been specified. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "supportedKinds" + )] + pub supported_kinds: Option>, +} diff --git a/gateway-api/src/apis/experimental/tcproutes.rs b/gateway-api/src/experimental/grpcroutes.rs similarity index 50% rename from gateway-api/src/apis/experimental/tcproutes.rs rename to gateway-api/src/experimental/grpcroutes.rs index 9342e6b..51ee5d8 100644 --- a/gateway-api/src/apis/experimental/tcproutes.rs +++ b/gateway-api/src/experimental/grpcroutes.rs @@ -1,29 +1,79 @@ -// WARNING: generated by kopium - manual changes will be overwritten -// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - -// kopium version: 0.21.2 +// WARNING: generated file - manual changes will be overriden +use super::common::*; #[allow(unused_imports)] mod prelude { pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube::CustomResource; + pub use kube_derive::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } use self::prelude::*; - -/// Spec defines the desired state of TCPRoute. +/// Spec defines the desired state of GRPCRoute. #[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] #[kube( group = "gateway.networking.k8s.io", - version = "v1alpha2", - kind = "TCPRoute", - plural = "tcproutes" + version = "v1", + kind = "GRPCRoute", + plural = "grpcroutes" )] #[kube(namespaced)] -#[kube(status = "TCPRouteStatus")] +#[kube(status = "GrpcRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct TCPRouteSpec { +pub struct GrpcRouteSpec { + /// Hostnames defines a set of hostnames to match against the GRPC + /// Host header to select a GRPCRoute to process the request. This matches + /// the RFC 1123 definition of a hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label MUST appear by itself as the first label. + /// + /// If a hostname is specified by both the Listener and GRPCRoute, there + /// MUST be at least one intersecting hostname for the GRPCRoute to be + /// attached to the Listener. For example: + /// + /// * A Listener with `test.example.com` as the hostname matches GRPCRoutes + /// that have either not specified any hostnames, or have specified at + /// least one of `test.example.com` or `*.example.com`. + /// * A Listener with `*.example.com` as the hostname matches GRPCRoutes + /// that have either not specified any hostnames or have specified at least + /// one hostname that matches the Listener hostname. For example, + /// `test.example.com` and `*.example.com` would both match. On the other + /// hand, `example.com` and `test.example.net` would not match. + /// + /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted + /// as a suffix match. That means that a match for `*.example.com` would match + /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. + /// + /// If both the Listener and GRPCRoute have specified hostnames, any + /// GRPCRoute hostnames that do not match the Listener hostname MUST be + /// ignored. For example, if a Listener specified `*.example.com`, and the + /// GRPCRoute specified `test.example.com` and `test.example.net`, + /// `test.example.net` MUST NOT be considered for a match. + /// + /// If both the Listener and GRPCRoute have specified hostnames, and none + /// match with the criteria above, then the GRPCRoute MUST NOT be accepted by + /// the implementation. The implementation MUST raise an 'Accepted' Condition + /// with a status of `False` in the corresponding RouteParentStatus. + /// + /// If a Route (A) of type HTTPRoute or GRPCRoute is attached to a + /// Listener and that listener already has another Route (B) of the other + /// type attached and the intersection of the hostnames of A and B is + /// non-empty, then the implementation MUST accept exactly one of these two + /// routes, determined by the following criteria, in order: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// The rejected Route MUST raise an 'Accepted' condition with a status of + /// 'False' in the corresponding RouteParentStatus. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostnames: Option>, /// ParentRefs references the resources (usually Gateways) that a Route wants /// to be attached to. Note that the referenced parent resource needs to /// allow this for the attachment to be complete. For Gateways, that means @@ -85,187 +135,173 @@ pub struct TCPRouteSpec { /// connections originating from the same namespace as the Route, for which /// the intended destination of the connections are a Service targeted as a /// ParentRef of the Route. - /// - /// - /// - /// - /// - /// #[serde( default, skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, - /// Rules are a list of TCP matchers and actions. - /// - /// - pub rules: Vec, + pub parent_refs: Option>, + /// Rules are a list of GRPC matchers, filters and actions. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rules: Option>, + /// UseDefaultGateways indicates the default Gateway scope to use for this + /// Route. If unset (the default) or set to None, the Route will not be + /// attached to any default Gateway; if set, it will be attached to any + /// default Gateway supporting the named scope, subject to the usual rules + /// about which Routes a Gateway is allowed to claim. + /// + /// Think carefully before using this functionality! The set of default + /// Gateways supporting the requested scope can change over time without + /// any notice to the Route author, and in many situations it will not be + /// appropriate to request a default Gateway for a given Route -- for + /// example, a Route with specific security requirements should almost + /// certainly not use a default Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "useDefaultGateways" + )] + pub use_default_gateways: Option, } - -/// ParentReference identifies an API object (usually a Gateway) that can be considered -/// a parent of this resource (usually a route). There are two kinds of parent resources -/// with "Core" support: -/// -/// * Gateway (Gateway conformance profile) -/// * Service (Mesh conformance profile, ClusterIP Services only) -/// -/// This API may be extended in the future to support additional kinds of parent -/// resources. -/// -/// The API object must be valid in the cluster; the Group and Kind must -/// be registered in the cluster for this reference to be valid. +/// GRPCRouteRule defines the semantics for matching a gRPC request based on +/// conditions (matches), processing it (filters), and forwarding the request to +/// an API object (backendRefs). #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TCPRouteParentRefs { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) +pub struct GrpcRouteRule { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. + /// Failure behavior here depends on how many BackendRefs are specified and + /// how many are invalid. /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. + /// If *all* entries in BackendRefs are invalid, and there are also no filters + /// specified in this route rule, *all* traffic which matches this rule MUST + /// receive an `UNAVAILABLE` status. /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. + /// See the GRPCBackendRef definition for the rules about what makes a single + /// GRPCBackendRef invalid. /// + /// When a GRPCBackendRef is invalid, `UNAVAILABLE` statuses MUST be returned for + /// requests that would have otherwise been routed to an invalid backend. If + /// multiple backends are specified, and some are invalid, the proportion of + /// requests that would otherwise have been routed to an invalid backend + /// MUST receive an `UNAVAILABLE` status. /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. + /// For example, if two backends are specified with equal weights, and one is + /// invalid, 50 percent of traffic MUST receive an `UNAVAILABLE` status. + /// Implementations may choose how that 50 percent is determined. /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. + /// Support: Core for Kubernetes Service /// + /// Support: Implementation-specific for any other resource /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. + /// Support for weight: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRefs" + )] + pub backend_refs: Option>, + /// Filters define the filters that are applied to requests that match + /// this rule. /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. + /// The effects of ordering of multiple behaviors are currently unspecified. + /// This can change in the future based on feedback during the alpha stage. /// + /// Conformance-levels at this level are defined based on the type of filter: /// - /// When the parent resource is a Service, this targets a specific port in the - /// Service spec. When both Port (experimental) and SectionName are specified, - /// the name and port of the selected port must match both specified values. + /// - ALL core filters MUST be supported by all implementations that support + /// GRPCRoute. + /// - Implementers are encouraged to support extended filters. + /// - Implementation-specific custom filters have no API guarantees across + /// implementations. /// + /// Specifying the same filter multiple times is not supported unless explicitly + /// indicated in the filter. /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. + /// If an implementation cannot support a combination of filters, it must clearly + /// document that limitation. In cases where incompatible or unsupported + /// filters are specified and cause the `Accepted` condition to be set to status + /// `False`, implementations may use the `IncompatibleFilters` reason to specify + /// this configuration error. /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Matches define conditions used for matching the rule against incoming + /// gRPC requests. Each match is independent, i.e. this rule will be matched + /// if **any** one of the matches is satisfied. + /// + /// For example, take the following matches configuration: + /// + /// ```text + /// matches: + /// - method: + /// service: foo.bar + /// headers: + /// values: + /// version: 2 + /// - method: + /// service: foo.bar.v2 + /// ``` + /// + /// For a request to match against this rule, it MUST satisfy + /// EITHER of the two conditions: + /// + /// - service of foo.bar AND contains the header `version: 2` + /// - service of foo.bar.v2 + /// + /// See the documentation for GRPCRouteMatch on how to specify multiple + /// match conditions to be ANDed together. + /// + /// If no matches are specified, the implementation MUST match every gRPC request. + /// + /// Proxy or Load Balancer routing configuration generated from GRPCRoutes + /// MUST prioritize rules based on the following criteria, continuing on + /// ties. Merging MUST not be done between GRPCRoutes and HTTPRoutes. + /// Precedence MUST be given to the rule with the largest number of: + /// + /// * Characters in a matching non-wildcard hostname. + /// * Characters in a matching hostname. + /// * Characters in a matching service. + /// * Characters in a matching method. + /// * Header matches. + /// + /// If ties still exist across multiple Routes, matching precedence MUST be + /// determined in order of the following criteria, continuing on ties: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// If ties still exist within the Route that has been given precedence, + /// matching precedence MUST be granted to the first matching rule meeting + /// the above criteria. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub matches: Option>, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. /// /// Support: Extended #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. + pub name: Option, + /// SessionPersistence defines and configures session persistence + /// for the route rule. /// - /// Support: Core + /// Support: Extended #[serde( default, skip_serializing_if = "Option::is_none", - rename = "sectionName" + rename = "sessionPersistence" )] - pub section_name: Option, + pub session_persistence: Option, } - -/// TCPRouteRule is the configuration for a given rule. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TCPRouteRules { - /// BackendRefs defines the backend(s) where matching requests should be - /// sent. If unspecified or invalid (refers to a non-existent resource or a - /// Service with no endpoints), the underlying implementation MUST actively - /// reject connection attempts to this backend. Connection rejections must - /// respect weight; if an invalid backend is requested to have 80% of - /// connections, then 80% of connections must be rejected instead. - /// - /// Support: Core for Kubernetes Service - /// - /// Support: Extended for Kubernetes ServiceImport - /// - /// Support: Implementation-specific for any other resource - /// - /// Support for weight: Extended - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "backendRefs" - )] - pub backend_refs: Option>, - /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub name: Option, -} - -/// BackendRef defines how a Route should forward a request to a Kubernetes -/// resource. +/// GRPCBackendRef defines how a GRPCRoute forwards a gRPC request. /// /// Note that when a namespace different than the local namespace is specified, a /// ReferenceGrant object is required in the referent namespace to allow that /// namespace's owner to accept the reference. See the ReferenceGrant /// documentation for details. /// -/// /// /// When the BackendRef points to a Kubernetes Service, implementations SHOULD /// honor the appProtocol field if it is set for the target Service Port. @@ -280,14 +316,15 @@ pub struct TCPRouteRules { /// If a Route is not able to send traffic to the backend using the specified /// protocol then the backend is considered invalid. Implementations MUST set the /// "ResolvedRefs" condition to "False" with the "UnsupportedProtocol" reason. -/// -/// -/// -/// Note that when the BackendTLSPolicy object is enabled by the implementation, -/// there are some extra rules about validity to consider here. See the fields -/// where this struct is used for more information about the exact behavior. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TCPRouteRulesBackendRefs { +pub struct GRPCBackendReference { + /// Filters defined at this level MUST be executed if and only if the + /// request is being forwarded to the backend defined here. + /// + /// Support: Implementation-specific (For broader support of filters, use the + /// Filters field in GRPCRouteRule.) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, /// Group is the group of the referent. For example, "gateway.networking.k8s.io". /// When unspecified or empty string, core API group is inferred. #[serde(default, skip_serializing_if = "Option::is_none")] @@ -344,10 +381,63 @@ pub struct TCPRouteRulesBackendRefs { #[serde(default, skip_serializing_if = "Option::is_none")] pub weight: Option, } - -/// Status defines the current state of TCPRoute. +/// GRPCRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a gRPC request only if its service +/// is `foo` AND it contains the `version: v1` header: +/// +/// ```text +/// matches: +/// - method: +/// type: Exact +/// service: "foo" +/// - headers: +/// name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GrpcRouteMatch { + /// Headers specifies gRPC request header matchers. Multiple match values are + /// ANDed together, meaning, a request MUST match all the specified headers + /// to select the route. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub headers: Option>, + /// Method specifies a gRPC request service/method matcher. If this field is + /// not specified, all services and methods will match. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, +} +/// Method specifies a gRPC request service/method matcher. If this field is +/// not specified, all services and methods will match. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GRPCMethodMatch { + /// Value of the method to match against. If left empty or omitted, will + /// match all services. + /// + /// At least one of Service and Method MUST be a non-empty string. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, + /// Value of the service to match against. If left empty or omitted, will + /// match any service. + /// + /// At least one of Service and Method MUST be a non-empty string. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub service: Option, + /// Type specifies how to match against the service and/or method. + /// Support: Core (Exact with service and method specified) + /// + /// Support: Implementation-specific (Exact with method specified but no service specified) + /// + /// Support: Implementation-specific (RegularExpression) + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, +} +/// Status defines the current state of GRPCRoute. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TCPRouteStatus { +pub struct GrpcRouteStatus { /// Parents is a list of parent resources (usually Gateways) that are /// associated with the route, and the status of the route with respect to /// each parent. When this route attaches to a parent, the controller that @@ -362,13 +452,12 @@ pub struct TCPRouteStatus { /// /// A maximum of 32 Gateways will be represented in this list. An empty list /// means the route has not been attached to any Gateway. - pub parents: Vec, + pub parents: Vec, } - /// RouteParentStatus describes the status of a route with respect to an /// associated Parent. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TCPRouteStatusParents { +pub struct GrpcRouteStatusParents { /// Conditions describes the status of the route with respect to the Gateway. /// Note that the route's availability is also subject to the Gateway's own /// status conditions and listener status. @@ -385,11 +474,10 @@ pub struct TCPRouteStatusParents { /// There are a number of cases where the "Accepted" condition may not be set /// due to lack of controller visibility, that includes when: /// - /// * The Route refers to a non-existent parent. + /// * The Route refers to a nonexistent parent. /// * The Route is of a type that the controller does not support. - /// * The Route is in a namespace the controller does not have access to. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: Option>, + /// * The Route is in a namespace to which the controller does not have access. + pub conditions: Vec, /// ControllerName is a domain/path string that indicates the name of the /// controller that wrote this status. This corresponds with the /// controllerName field on GatewayClass. @@ -398,7 +486,7 @@ pub struct TCPRouteStatusParents { /// /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are /// valid Kubernetes names - /// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names). + /// ( /// /// Controllers MUST populate this field when writing status. Controllers should ensure that /// entries to status populated with their ControllerName are cleaned up when they are no @@ -408,119 +496,5 @@ pub struct TCPRouteStatusParents { /// ParentRef corresponds with a ParentRef in the spec that this /// RouteParentStatus struct describes the status of. #[serde(rename = "parentRef")] - pub parent_ref: TCPRouteStatusParentsParentRef, -} - -/// ParentRef corresponds with a ParentRef in the spec that this -/// RouteParentStatus struct describes the status of. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TCPRouteStatusParentsParentRef { - /// Group is the group of the referent. - /// When unspecified, "gateway.networking.k8s.io" is inferred. - /// To set the core API group (such as for a "Service" kind referent), - /// Group must be explicitly set to "" (empty string). - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. - /// - /// There are two kinds of parent resources with "Core" support: - /// - /// * Gateway (Gateway conformance profile) - /// * Service (Mesh conformance profile, ClusterIP Services only) - /// - /// Support for other resources is Implementation-Specific. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - /// - /// Support: Core - pub name: String, - /// Namespace is the namespace of the referent. When unspecified, this refers - /// to the local namespace of the Route. - /// - /// Note that there are specific rules for ParentRefs which cross namespace - /// boundaries. Cross-namespace references are only valid if they are explicitly - /// allowed by something in the namespace they are referring to. For example: - /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a - /// generic way to enable any other kind of cross-namespace reference. - /// - /// - /// ParentRefs from a Route to a Service in the same namespace are "producer" - /// routes, which apply default routing rules to inbound connections from - /// any namespace to the Service. - /// - /// ParentRefs from a Route to a Service in a different namespace are - /// "consumer" routes, and these routing rules are only applied to outbound - /// connections originating from the same namespace as the Route, for which - /// the intended destination of the connections are a Service targeted as a - /// ParentRef of the Route. - /// - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, - /// Port is the network port this Route targets. It can be interpreted - /// differently based on the type of parent resource. - /// - /// When the parent resource is a Gateway, this targets all listeners - /// listening on the specified port that also support this kind of Route(and - /// select this Route). It's not recommended to set `Port` unless the - /// networking behaviors specified in a Route must apply to a specific port - /// as opposed to a listener(s) whose port(s) may be changed. When both Port - /// and SectionName are specified, the name and port of the selected listener - /// must match both specified values. - /// - /// - /// When the parent resource is a Service, this targets a specific port in the - /// Service spec. When both Port (experimental) and SectionName are specified, - /// the name and port of the selected port must match both specified values. - /// - /// - /// Implementations MAY choose to support other parent resources. - /// Implementations supporting other types of parent resources MUST clearly - /// document how/if Port is interpreted. - /// - /// For the purpose of status, an attachment is considered successful as - /// long as the parent resource accepts it partially. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment - /// from the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, - /// the Route MUST be considered detached from the Gateway. - /// - /// Support: Extended - #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, - /// SectionName is the name of a section within the target resource. In the - /// following resources, SectionName is interpreted as the following: - /// - /// * Gateway: Listener name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// * Service: Port name. When both Port (experimental) and SectionName - /// are specified, the name and port of the selected listener must match - /// both specified values. - /// - /// Implementations MAY choose to support attaching Routes to other resources. - /// If that is the case, they MUST clearly document how SectionName is - /// interpreted. - /// - /// When unspecified (empty string), this will reference the entire resource. - /// For the purpose of status, an attachment is considered successful if at - /// least one section in the parent resource accepts it. For example, Gateway - /// listeners can restrict which Routes can attach to them by Route kind, - /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from - /// the referencing Route, the Route MUST be considered successfully - /// attached. If no Gateway listeners accept attachment from this Route, the - /// Route MUST be considered detached from the Gateway. - /// - /// Support: Core - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, + pub parent_ref: ParentReference, } diff --git a/gateway-api/src/experimental/httproutes.rs b/gateway-api/src/experimental/httproutes.rs new file mode 100644 index 0000000..d8a98c8 --- /dev/null +++ b/gateway-api/src/experimental/httproutes.rs @@ -0,0 +1,1452 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of HTTPRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "HTTPRoute", + plural = "httproutes" +)] +#[kube(namespaced)] +#[kube(status = "HttpRouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct HttpRouteSpec { + /// Hostnames defines a set of hostnames that should match against the HTTP Host + /// header to select a HTTPRoute used to process the request. Implementations + /// MUST ignore any port value specified in the HTTP Host header while + /// performing a match and (absent of any applicable header modification + /// configuration) MUST forward this header unmodified to the backend. + /// + /// Valid values for Hostnames are determined by RFC 1123 definition of a + /// hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label must appear by itself as the first label. + /// + /// If a hostname is specified by both the Listener and HTTPRoute, there + /// must be at least one intersecting hostname for the HTTPRoute to be + /// attached to the Listener. For example: + /// + /// * A Listener with `test.example.com` as the hostname matches HTTPRoutes + /// that have either not specified any hostnames, or have specified at + /// least one of `test.example.com` or `*.example.com`. + /// * A Listener with `*.example.com` as the hostname matches HTTPRoutes + /// that have either not specified any hostnames or have specified at least + /// one hostname that matches the Listener hostname. For example, + /// `*.example.com`, `test.example.com`, and `foo.test.example.com` would + /// all match. On the other hand, `example.com` and `test.example.net` would + /// not match. + /// + /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted + /// as a suffix match. That means that a match for `*.example.com` would match + /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. + /// + /// If both the Listener and HTTPRoute have specified hostnames, any + /// HTTPRoute hostnames that do not match the Listener hostname MUST be + /// ignored. For example, if a Listener specified `*.example.com`, and the + /// HTTPRoute specified `test.example.com` and `test.example.net`, + /// `test.example.net` must not be considered for a match. + /// + /// If both the Listener and HTTPRoute have specified hostnames, and none + /// match with the criteria above, then the HTTPRoute is not accepted. The + /// implementation must raise an 'Accepted' Condition with a status of + /// `False` in the corresponding RouteParentStatus. + /// + /// In the event that multiple HTTPRoutes specify intersecting hostnames (e.g. + /// overlapping wildcard matching and exact matching hostnames), precedence must + /// be given to rules from the HTTPRoute with the largest number of: + /// + /// * Characters in a matching non-wildcard hostname. + /// * Characters in a matching hostname. + /// + /// If ties exist across multiple Routes, the matching precedence rules for + /// HTTPRouteMatches takes over. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostnames: Option>, + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + /// + /// + /// ParentRefs from a Route to a Service in the same namespace are "producer" + /// routes, which apply default routing rules to inbound connections from + /// any namespace to the Service. + /// + /// ParentRefs from a Route to a Service in a different namespace are + /// "consumer" routes, and these routing rules are only applied to outbound + /// connections originating from the same namespace as the Route, for which + /// the intended destination of the connections are a Service targeted as a + /// ParentRef of the Route. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of HTTP matchers, filters and actions. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rules: Option>, + /// UseDefaultGateways indicates the default Gateway scope to use for this + /// Route. If unset (the default) or set to None, the Route will not be + /// attached to any default Gateway; if set, it will be attached to any + /// default Gateway supporting the named scope, subject to the usual rules + /// about which Routes a Gateway is allowed to claim. + /// + /// Think carefully before using this functionality! The set of default + /// Gateways supporting the requested scope can change over time without + /// any notice to the Route author, and in many situations it will not be + /// appropriate to request a default Gateway for a given Route -- for + /// example, a Route with specific security requirements should almost + /// certainly not use a default Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "useDefaultGateways" + )] + pub use_default_gateways: Option, +} +/// HTTPRouteRule defines semantics for matching an HTTP request based on +/// conditions (matches), processing it (filters), and forwarding the request to +/// an API object (backendRefs). +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRule { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. + /// + /// Failure behavior here depends on how many BackendRefs are specified and + /// how many are invalid. + /// + /// If *all* entries in BackendRefs are invalid, and there are also no filters + /// specified in this route rule, *all* traffic which matches this rule MUST + /// receive a 500 status code. + /// + /// See the HTTPBackendRef definition for the rules about what makes a single + /// HTTPBackendRef invalid. + /// + /// When a HTTPBackendRef is invalid, 500 status codes MUST be returned for + /// requests that would have otherwise been routed to an invalid backend. If + /// multiple backends are specified, and some are invalid, the proportion of + /// requests that would otherwise have been routed to an invalid backend + /// MUST receive a 500 status code. + /// + /// For example, if two backends are specified with equal weights, and one is + /// invalid, 50 percent of traffic must receive a 500. Implementations may + /// choose how that 50 percent is determined. + /// + /// When a HTTPBackendRef refers to a Service that has no ready endpoints, + /// implementations SHOULD return a 503 for requests to that backend instead. + /// If an implementation chooses to do this, all of the above rules for 500 responses + /// MUST also apply for responses that return a 503. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRefs" + )] + pub backend_refs: Option>, + /// Filters define the filters that are applied to requests that match + /// this rule. + /// + /// Wherever possible, implementations SHOULD implement filters in the order + /// they are specified. + /// + /// Implementations MAY choose to implement this ordering strictly, rejecting + /// any combination or order of filters that cannot be supported. If implementations + /// choose a strict interpretation of filter ordering, they MUST clearly document + /// that behavior. + /// + /// To reject an invalid combination or order of filters, implementations SHOULD + /// consider the Route Rules with this configuration invalid. If all Route Rules + /// in a Route are invalid, the entire Route would be considered invalid. If only + /// a portion of Route Rules are invalid, implementations MUST set the + /// "PartiallyInvalid" condition for the Route. + /// + /// Conformance-levels at this level are defined based on the type of filter: + /// + /// - ALL core filters MUST be supported by all implementations. + /// - Implementers are encouraged to support extended filters. + /// - Implementation-specific custom filters have no API guarantees across + /// implementations. + /// + /// Specifying the same filter multiple times is not supported unless explicitly + /// indicated in the filter. + /// + /// All filters are expected to be compatible with each other except for the + /// URLRewrite and RequestRedirect filters, which may not be combined. If an + /// implementation cannot support other combinations of filters, they must clearly + /// document that limitation. In cases where incompatible or unsupported + /// filters are specified and cause the `Accepted` condition to be set to status + /// `False`, implementations may use the `IncompatibleFilters` reason to specify + /// this configuration error. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Matches define conditions used for matching the rule against incoming + /// HTTP requests. Each match is independent, i.e. this rule will be matched + /// if **any** one of the matches is satisfied. + /// + /// For example, take the following matches configuration: + /// + /// ```text + /// matches: + /// - path: + /// value: "/foo" + /// headers: + /// - name: "version" + /// value: "v2" + /// - path: + /// value: "/v2/foo" + /// ``` + /// + /// For a request to match against this rule, a request must satisfy + /// EITHER of the two conditions: + /// + /// - path prefixed with `/foo` AND contains the header `version: v2` + /// - path prefix of `/v2/foo` + /// + /// See the documentation for HTTPRouteMatch on how to specify multiple + /// match conditions that should be ANDed together. + /// + /// If no matches are specified, the default is a prefix + /// path match on "/", which has the effect of matching every + /// HTTP request. + /// + /// Proxy or Load Balancer routing configuration generated from HTTPRoutes + /// MUST prioritize matches based on the following criteria, continuing on + /// ties. Across all rules specified on applicable Routes, precedence must be + /// given to the match having: + /// + /// * "Exact" path match. + /// * "Prefix" path match with largest number of characters. + /// * Method match. + /// * Largest number of header matches. + /// * Largest number of query param matches. + /// + /// Note: The precedence of RegularExpression path matches are implementation-specific. + /// + /// If ties still exist across multiple Routes, matching precedence MUST be + /// determined in order of the following criteria, continuing on ties: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// If ties still exist within an HTTPRoute, matching precedence MUST be granted + /// to the FIRST matching rule (in list order) with a match meeting the above + /// criteria. + /// + /// When no rules matching a request have been successfully attached to the + /// parent a request is coming from, a HTTP 404 status code MUST be returned. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub matches: Option>, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + /// Retry defines the configuration for when to retry an HTTP request. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub retry: Option, + /// SessionPersistence defines and configures session persistence + /// for the route rule. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sessionPersistence" + )] + pub session_persistence: Option, + /// Timeouts defines the timeouts that can be configured for an HTTP request. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub timeouts: Option, +} +/// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. +/// +/// Note that when a namespace different than the local namespace is specified, a +/// ReferenceGrant object is required in the referent namespace to allow that +/// namespace's owner to accept the reference. See the ReferenceGrant +/// documentation for details. +/// +/// +/// When the BackendRef points to a Kubernetes Service, implementations SHOULD +/// honor the appProtocol field if it is set for the target Service Port. +/// +/// Implementations supporting appProtocol SHOULD recognize the Kubernetes +/// Standard Application Protocols defined in KEP-3726. +/// +/// If a Service appProtocol isn't specified, an implementation MAY infer the +/// backend protocol through its own means. Implementations MAY infer the +/// protocol from the Route type referring to the backend Service. +/// +/// If a Route is not able to send traffic to the backend using the specified +/// protocol then the backend is considered invalid. Implementations MUST set the +/// "ResolvedRefs" condition to "False" with the "UnsupportedProtocol" reason. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HTTPBackendReference { + /// Filters defined at this level should be executed if and only if the + /// request is being forwarded to the backend defined here. + /// + /// Support: Implementation-specific (For broader support of filters, use the + /// Filters field in HTTPRouteRule.) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Group is the group of the referent. For example, "gateway.networking.k8s.io". + /// When unspecified or empty string, core API group is inferred. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. For example + /// "Service". + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations SHOULD NOT + /// support ExternalName Services. + /// + /// Support: Core (Services with a type other than ExternalName) + /// + /// Support: Implementation-specific (Services with type ExternalName) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent. + pub name: String, + /// Namespace is the namespace of the backend. When unspecified, the local + /// namespace is inferred. + /// + /// Note that when a namespace different than the local namespace is specified, + /// a ReferenceGrant object is required in the referent namespace to allow that + /// namespace's owner to accept the reference. See the ReferenceGrant + /// documentation for details. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + /// Port specifies the destination port number to use for this resource. + /// Port is required when the referent is a Kubernetes Service. In this + /// case, the port number is the service port number, not the target port. + /// For other resources, destination port might be derived from the referent + /// resource or this field. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + /// Weight specifies the proportion of requests forwarded to the referenced + /// backend. This is computed as weight/(sum of all weights in this + /// BackendRefs list). For non-zero values, there may be some epsilon from + /// the exact proportion defined here depending on the precision an + /// implementation supports. Weight is not a percentage and the sum of + /// weights does not need to equal 100. + /// + /// If only one backend is specified and it has a weight greater than 0, 100% + /// of the traffic is forwarded to that backend. If weight is set to 0, no + /// traffic should be forwarded for this entry. If unspecified, weight + /// defaults to 1. + /// + /// Support for this field varies based on the context where used. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} +/// HTTPRouteFilter defines processing steps that must be completed during the +/// request or response lifecycle. HTTPRouteFilters are meant as an extension +/// point to express processing that may be done in Gateway implementations. Some +/// examples include request or response modification, implementing +/// authentication strategies, rate-limiting, and traffic shaping. API +/// guarantee/conformance is defined based on the type of the filter. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteBackendFilter { + /// CORS defines a schema for a filter that responds to the + /// cross-origin request based on HTTP response header. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cors: Option, + /// ExtensionRef is an optional, implementation-specific extension to the + /// "filter" behavior. For example, resource "myroutefilter" in group + /// "networking.example.net"). ExtensionRef MUST NOT be used for core and + /// extended filters. + /// + /// This filter can be used multiple times within the same rule. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + /// ExternalAuth configures settings related to sending request details + /// to an external auth service. The external service MUST authenticate + /// the request, and MAY authorize the request as well. + /// + /// If there is any problem communicating with the external service, + /// this filter MUST fail closed. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "externalAuth" + )] + pub external_auth: Option, + /// RequestHeaderModifier defines a schema for a filter that modifies request + /// headers. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + /// RequestMirror defines a schema for a filter that mirrors requests. + /// Requests are sent to the specified destination, but responses from + /// that destination are ignored. + /// + /// This filter can be used multiple times within the same rule. Note that + /// not all implementations will be able to support mirroring to multiple + /// backends. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + /// RequestRedirect defines a schema for a filter that responds to the + /// request with an HTTP redirection. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestRedirect" + )] + pub request_redirect: Option, + /// ResponseHeaderModifier defines a schema for a filter that modifies response + /// headers. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + /// Type identifies the type of filter to apply. As with other API fields, + /// types are classified into three conformance levels: + /// + /// - Core: Filter types and their corresponding configuration defined by + /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All + /// implementations must support core filters. + /// + /// - Extended: Filter types and their corresponding configuration defined by + /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers + /// are encouraged to support extended filters. + /// + /// - Implementation-specific: Filters that are defined and supported by + /// specific vendors. + /// In the future, filters showing convergence in behavior across multiple + /// implementations will be considered for inclusion in extended or core + /// conformance levels. Filter-specific configuration for such filters + /// is specified using the ExtensionRef field. `Type` should be set to + /// "ExtensionRef" for custom filters. + /// + /// Implementers are encouraged to define custom implementation types to + /// extend the core API with implementation-specific behavior. + /// + /// If a reference to a custom filter type cannot be resolved, the filter + /// MUST NOT be skipped. Instead, requests that would have been processed by + /// that filter MUST receive a HTTP error response. + /// + /// Note that values may be added to this enum, implementations + /// must ensure that unknown values will not cause a crash. + /// + /// Unknown values here must result in the implementation setting the + /// Accepted Condition for the Route to `status: False`, with a + /// Reason of `UnsupportedValue`. + #[serde(rename = "type")] + pub r#type: HTTPFilterType, + /// URLRewrite defines a schema for a filter that modifies a request during forwarding. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "urlRewrite" + )] + pub url_rewrite: Option, +} +/// CORS defines a schema for a filter that responds to the +/// cross-origin request based on HTTP response header. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesBackendRefsFiltersCors { + /// AllowCredentials indicates whether the actual cross-origin request allows + /// to include credentials. + /// + /// When set to true, the gateway will include the `Access-Control-Allow-Credentials` + /// response header with value true (case-sensitive). + /// + /// When set to false or omitted the gateway will omit the header + /// `Access-Control-Allow-Credentials` entirely (this is the standard CORS + /// behavior). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowCredentials" + )] + pub allow_credentials: Option, + /// AllowHeaders indicates which HTTP request headers are supported for + /// accessing the requested resource. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Allow-Headers` + /// response header are separated by a comma (","). + /// + /// When the `AllowHeaders` field is configured with one or more headers, the + /// gateway must return the `Access-Control-Allow-Headers` response header + /// which value is present in the `AllowHeaders` field. + /// + /// If any header name in the `Access-Control-Request-Headers` request header + /// is not included in the list of header names specified by the response + /// header `Access-Control-Allow-Headers`, it will present an error on the + /// client side. + /// + /// If any header name in the `Access-Control-Allow-Headers` response header + /// does not recognize by the client, it will also occur an error on the + /// client side. + /// + /// A wildcard indicates that the requests with all HTTP headers are allowed. + /// If config contains the wildcard "*" in allowHeaders and the request is + /// not credentialed, the `Access-Control-Allow-Headers` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Headers from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Headers` response header. When + /// also the `AllowCredentials` field is true and `AllowHeaders` field + /// is specified with the `*` wildcard, the gateway must specify one or more + /// HTTP headers in the value of the `Access-Control-Allow-Headers` response + /// header. The value of the header `Access-Control-Allow-Headers` is same as + /// the `Access-Control-Request-Headers` header provided by the client. If + /// the header `Access-Control-Request-Headers` is not included in the + /// request, the gateway will omit the `Access-Control-Allow-Headers` + /// response header, instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowHeaders" + )] + pub allow_headers: Option>, + /// AllowMethods indicates which HTTP methods are supported for accessing the + /// requested resource. + /// + /// Valid values are any method defined by RFC9110, along with the special + /// value `*`, which represents all HTTP methods are allowed. + /// + /// Method names are case-sensitive, so these values are also case-sensitive. + /// (See + /// + /// Multiple method names in the value of the `Access-Control-Allow-Methods` + /// response header are separated by a comma (","). + /// + /// A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`. + /// (See The + /// CORS-safelisted methods are always allowed, regardless of whether they + /// are specified in the `AllowMethods` field. + /// + /// When the `AllowMethods` field is configured with one or more methods, the + /// gateway must return the `Access-Control-Allow-Methods` response header + /// which value is present in the `AllowMethods` field. + /// + /// If the HTTP method of the `Access-Control-Request-Method` request header + /// is not included in the list of methods specified by the response header + /// `Access-Control-Allow-Methods`, it will present an error on the client + /// side. + /// + /// If config contains the wildcard "*" in allowMethods and the request is + /// not credentialed, the `Access-Control-Allow-Methods` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Method from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Methods` response header. When + /// also the `AllowCredentials` field is true and `AllowMethods` field + /// specified with the `*` wildcard, the gateway must specify one HTTP method + /// in the value of the Access-Control-Allow-Methods response header. The + /// value of the header `Access-Control-Allow-Methods` is same as the + /// `Access-Control-Request-Method` header provided by the client. If the + /// header `Access-Control-Request-Method` is not included in the request, + /// the gateway will omit the `Access-Control-Allow-Methods` response header, + /// instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowMethods" + )] + pub allow_methods: Option>, + /// AllowOrigins indicates whether the response can be shared with requested + /// resource from the given `Origin`. + /// + /// The `Origin` consists of a scheme and a host, with an optional port, and + /// takes the form `://(:)`. + /// + /// Valid values for scheme are: `http` and `https`. + /// + /// Valid values for port are any integer between 1 and 65535 (the list of + /// available TCP/UDP ports). Note that, if not included, port `80` is + /// assumed for `http` scheme origins, and port `443` is assumed for `https` + /// origins. This may affect origin matching. + /// + /// The host part of the origin may contain the wildcard character `*`. These + /// wildcard characters behave as follows: + /// + /// * `*` is a greedy match to the _left_, including any number of + /// DNS labels to the left of its position. This also means that + /// `*` will include any number of period `.` characters to the + /// left of its position. + /// * A wildcard by itself matches all hosts. + /// + /// An origin value that includes _only_ the `*` character indicates requests + /// from all `Origin`s are allowed. + /// + /// When the `AllowOrigins` field is configured with multiple origins, it + /// means the server supports clients from multiple origins. If the request + /// `Origin` matches the configured allowed origins, the gateway must return + /// the given `Origin` and sets value of the header + /// `Access-Control-Allow-Origin` same as the `Origin` header provided by the + /// client. + /// + /// The status code of a successful response to a "preflight" request is + /// always an OK status (i.e., 204 or 200). + /// + /// If the request `Origin` does not match the configured allowed origins, + /// the gateway returns 204/200 response but doesn't set the relevant + /// cross-origin response headers. Alternatively, the gateway responds with + /// 403 status to the "preflight" request is denied, coupled with omitting + /// the CORS headers. The cross-origin request fails on the client side. + /// Therefore, the client doesn't attempt the actual cross-origin request. + /// + /// Conversely, if the request `Origin` matches one of the configured + /// allowed origins, the gateway sets the response header + /// `Access-Control-Allow-Origin` to the same value as the `Origin` + /// header provided by the client. + /// + /// When config has the wildcard ("*") in allowOrigins, and the request + /// is not credentialed (e.g., it is a preflight request), the + /// `Access-Control-Allow-Origin` response header either contains the + /// wildcard as well or the Origin from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Origin` response header. When + /// also the `AllowCredentials` field is true and `AllowOrigins` field + /// specified with the `*` wildcard, the gateway must return a single origin + /// in the value of the `Access-Control-Allow-Origin` response header, + /// instead of specifying the `*` wildcard. The value of the header + /// `Access-Control-Allow-Origin` is same as the `Origin` header provided by + /// the client. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowOrigins" + )] + pub allow_origins: Option>, + /// ExposeHeaders indicates which HTTP response headers can be exposed + /// to client-side scripts in response to a cross-origin request. + /// + /// A CORS-safelisted response header is an HTTP header in a CORS response + /// that it is considered safe to expose to the client scripts. + /// The CORS-safelisted response headers include the following headers: + /// `Cache-Control` + /// `Content-Language` + /// `Content-Length` + /// `Content-Type` + /// `Expires` + /// `Last-Modified` + /// `Pragma` + /// (See + /// The CORS-safelisted response headers are exposed to client by default. + /// + /// When an HTTP header name is specified using the `ExposeHeaders` field, + /// this additional header will be exposed as part of the response to the + /// client. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Expose-Headers` + /// response header are separated by a comma (","). + /// + /// A wildcard indicates that the responses with all HTTP headers are exposed + /// to clients. The `Access-Control-Expose-Headers` response header can only + /// use `*` wildcard as value when the request is not credentialed. + /// + /// When the `exposeHeaders` config field contains the "*" wildcard and + /// the request is credentialed, the gateway cannot use the `*` wildcard in + /// the `Access-Control-Expose-Headers` response header. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "exposeHeaders" + )] + pub expose_headers: Option>, + /// MaxAge indicates the duration (in seconds) for the client to cache the + /// results of a "preflight" request. + /// + /// The information provided by the `Access-Control-Allow-Methods` and + /// `Access-Control-Allow-Headers` response headers can be cached by the + /// client until the time specified by `Access-Control-Max-Age` elapses. + /// + /// The default value of `Access-Control-Max-Age` response header is 5 + /// (seconds). + /// + /// When the `MaxAge` field is unspecified, the gateway sets the response + /// header "Access-Control-Max-Age: 5" by default. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] + pub max_age: Option, +} +/// HTTPRouteFilter defines processing steps that must be completed during the +/// request or response lifecycle. HTTPRouteFilters are meant as an extension +/// point to express processing that may be done in Gateway implementations. Some +/// examples include request or response modification, implementing +/// authentication strategies, rate-limiting, and traffic shaping. API +/// guarantee/conformance is defined based on the type of the filter. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteFilter { + /// CORS defines a schema for a filter that responds to the + /// cross-origin request based on HTTP response header. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cors: Option, + /// ExtensionRef is an optional, implementation-specific extension to the + /// "filter" behavior. For example, resource "myroutefilter" in group + /// "networking.example.net"). ExtensionRef MUST NOT be used for core and + /// extended filters. + /// + /// This filter can be used multiple times within the same rule. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + /// ExternalAuth configures settings related to sending request details + /// to an external auth service. The external service MUST authenticate + /// the request, and MAY authorize the request as well. + /// + /// If there is any problem communicating with the external service, + /// this filter MUST fail closed. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "externalAuth" + )] + pub external_auth: Option, + /// RequestHeaderModifier defines a schema for a filter that modifies request + /// headers. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + /// RequestMirror defines a schema for a filter that mirrors requests. + /// Requests are sent to the specified destination, but responses from + /// that destination are ignored. + /// + /// This filter can be used multiple times within the same rule. Note that + /// not all implementations will be able to support mirroring to multiple + /// backends. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + /// RequestRedirect defines a schema for a filter that responds to the + /// request with an HTTP redirection. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestRedirect" + )] + pub request_redirect: Option, + /// ResponseHeaderModifier defines a schema for a filter that modifies response + /// headers. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + /// Type identifies the type of filter to apply. As with other API fields, + /// types are classified into three conformance levels: + /// + /// - Core: Filter types and their corresponding configuration defined by + /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All + /// implementations must support core filters. + /// + /// - Extended: Filter types and their corresponding configuration defined by + /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers + /// are encouraged to support extended filters. + /// + /// - Implementation-specific: Filters that are defined and supported by + /// specific vendors. + /// In the future, filters showing convergence in behavior across multiple + /// implementations will be considered for inclusion in extended or core + /// conformance levels. Filter-specific configuration for such filters + /// is specified using the ExtensionRef field. `Type` should be set to + /// "ExtensionRef" for custom filters. + /// + /// Implementers are encouraged to define custom implementation types to + /// extend the core API with implementation-specific behavior. + /// + /// If a reference to a custom filter type cannot be resolved, the filter + /// MUST NOT be skipped. Instead, requests that would have been processed by + /// that filter MUST receive a HTTP error response. + /// + /// Note that values may be added to this enum, implementations + /// must ensure that unknown values will not cause a crash. + /// + /// Unknown values here must result in the implementation setting the + /// Accepted Condition for the Route to `status: False`, with a + /// Reason of `UnsupportedValue`. + #[serde(rename = "type")] + pub r#type: HTTPFilterType, + /// URLRewrite defines a schema for a filter that modifies a request during forwarding. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "urlRewrite" + )] + pub url_rewrite: Option, +} +/// CORS defines a schema for a filter that responds to the +/// cross-origin request based on HTTP response header. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesFiltersCors { + /// AllowCredentials indicates whether the actual cross-origin request allows + /// to include credentials. + /// + /// When set to true, the gateway will include the `Access-Control-Allow-Credentials` + /// response header with value true (case-sensitive). + /// + /// When set to false or omitted the gateway will omit the header + /// `Access-Control-Allow-Credentials` entirely (this is the standard CORS + /// behavior). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowCredentials" + )] + pub allow_credentials: Option, + /// AllowHeaders indicates which HTTP request headers are supported for + /// accessing the requested resource. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Allow-Headers` + /// response header are separated by a comma (","). + /// + /// When the `AllowHeaders` field is configured with one or more headers, the + /// gateway must return the `Access-Control-Allow-Headers` response header + /// which value is present in the `AllowHeaders` field. + /// + /// If any header name in the `Access-Control-Request-Headers` request header + /// is not included in the list of header names specified by the response + /// header `Access-Control-Allow-Headers`, it will present an error on the + /// client side. + /// + /// If any header name in the `Access-Control-Allow-Headers` response header + /// does not recognize by the client, it will also occur an error on the + /// client side. + /// + /// A wildcard indicates that the requests with all HTTP headers are allowed. + /// If config contains the wildcard "*" in allowHeaders and the request is + /// not credentialed, the `Access-Control-Allow-Headers` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Headers from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Headers` response header. When + /// also the `AllowCredentials` field is true and `AllowHeaders` field + /// is specified with the `*` wildcard, the gateway must specify one or more + /// HTTP headers in the value of the `Access-Control-Allow-Headers` response + /// header. The value of the header `Access-Control-Allow-Headers` is same as + /// the `Access-Control-Request-Headers` header provided by the client. If + /// the header `Access-Control-Request-Headers` is not included in the + /// request, the gateway will omit the `Access-Control-Allow-Headers` + /// response header, instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowHeaders" + )] + pub allow_headers: Option>, + /// AllowMethods indicates which HTTP methods are supported for accessing the + /// requested resource. + /// + /// Valid values are any method defined by RFC9110, along with the special + /// value `*`, which represents all HTTP methods are allowed. + /// + /// Method names are case-sensitive, so these values are also case-sensitive. + /// (See + /// + /// Multiple method names in the value of the `Access-Control-Allow-Methods` + /// response header are separated by a comma (","). + /// + /// A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`. + /// (See The + /// CORS-safelisted methods are always allowed, regardless of whether they + /// are specified in the `AllowMethods` field. + /// + /// When the `AllowMethods` field is configured with one or more methods, the + /// gateway must return the `Access-Control-Allow-Methods` response header + /// which value is present in the `AllowMethods` field. + /// + /// If the HTTP method of the `Access-Control-Request-Method` request header + /// is not included in the list of methods specified by the response header + /// `Access-Control-Allow-Methods`, it will present an error on the client + /// side. + /// + /// If config contains the wildcard "*" in allowMethods and the request is + /// not credentialed, the `Access-Control-Allow-Methods` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Method from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Methods` response header. When + /// also the `AllowCredentials` field is true and `AllowMethods` field + /// specified with the `*` wildcard, the gateway must specify one HTTP method + /// in the value of the Access-Control-Allow-Methods response header. The + /// value of the header `Access-Control-Allow-Methods` is same as the + /// `Access-Control-Request-Method` header provided by the client. If the + /// header `Access-Control-Request-Method` is not included in the request, + /// the gateway will omit the `Access-Control-Allow-Methods` response header, + /// instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowMethods" + )] + pub allow_methods: Option>, + /// AllowOrigins indicates whether the response can be shared with requested + /// resource from the given `Origin`. + /// + /// The `Origin` consists of a scheme and a host, with an optional port, and + /// takes the form `://(:)`. + /// + /// Valid values for scheme are: `http` and `https`. + /// + /// Valid values for port are any integer between 1 and 65535 (the list of + /// available TCP/UDP ports). Note that, if not included, port `80` is + /// assumed for `http` scheme origins, and port `443` is assumed for `https` + /// origins. This may affect origin matching. + /// + /// The host part of the origin may contain the wildcard character `*`. These + /// wildcard characters behave as follows: + /// + /// * `*` is a greedy match to the _left_, including any number of + /// DNS labels to the left of its position. This also means that + /// `*` will include any number of period `.` characters to the + /// left of its position. + /// * A wildcard by itself matches all hosts. + /// + /// An origin value that includes _only_ the `*` character indicates requests + /// from all `Origin`s are allowed. + /// + /// When the `AllowOrigins` field is configured with multiple origins, it + /// means the server supports clients from multiple origins. If the request + /// `Origin` matches the configured allowed origins, the gateway must return + /// the given `Origin` and sets value of the header + /// `Access-Control-Allow-Origin` same as the `Origin` header provided by the + /// client. + /// + /// The status code of a successful response to a "preflight" request is + /// always an OK status (i.e., 204 or 200). + /// + /// If the request `Origin` does not match the configured allowed origins, + /// the gateway returns 204/200 response but doesn't set the relevant + /// cross-origin response headers. Alternatively, the gateway responds with + /// 403 status to the "preflight" request is denied, coupled with omitting + /// the CORS headers. The cross-origin request fails on the client side. + /// Therefore, the client doesn't attempt the actual cross-origin request. + /// + /// Conversely, if the request `Origin` matches one of the configured + /// allowed origins, the gateway sets the response header + /// `Access-Control-Allow-Origin` to the same value as the `Origin` + /// header provided by the client. + /// + /// When config has the wildcard ("*") in allowOrigins, and the request + /// is not credentialed (e.g., it is a preflight request), the + /// `Access-Control-Allow-Origin` response header either contains the + /// wildcard as well or the Origin from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Origin` response header. When + /// also the `AllowCredentials` field is true and `AllowOrigins` field + /// specified with the `*` wildcard, the gateway must return a single origin + /// in the value of the `Access-Control-Allow-Origin` response header, + /// instead of specifying the `*` wildcard. The value of the header + /// `Access-Control-Allow-Origin` is same as the `Origin` header provided by + /// the client. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowOrigins" + )] + pub allow_origins: Option>, + /// ExposeHeaders indicates which HTTP response headers can be exposed + /// to client-side scripts in response to a cross-origin request. + /// + /// A CORS-safelisted response header is an HTTP header in a CORS response + /// that it is considered safe to expose to the client scripts. + /// The CORS-safelisted response headers include the following headers: + /// `Cache-Control` + /// `Content-Language` + /// `Content-Length` + /// `Content-Type` + /// `Expires` + /// `Last-Modified` + /// `Pragma` + /// (See + /// The CORS-safelisted response headers are exposed to client by default. + /// + /// When an HTTP header name is specified using the `ExposeHeaders` field, + /// this additional header will be exposed as part of the response to the + /// client. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Expose-Headers` + /// response header are separated by a comma (","). + /// + /// A wildcard indicates that the responses with all HTTP headers are exposed + /// to clients. The `Access-Control-Expose-Headers` response header can only + /// use `*` wildcard as value when the request is not credentialed. + /// + /// When the `exposeHeaders` config field contains the "*" wildcard and + /// the request is credentialed, the gateway cannot use the `*` wildcard in + /// the `Access-Control-Expose-Headers` response header. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "exposeHeaders" + )] + pub expose_headers: Option>, + /// MaxAge indicates the duration (in seconds) for the client to cache the + /// results of a "preflight" request. + /// + /// The information provided by the `Access-Control-Allow-Methods` and + /// `Access-Control-Allow-Headers` response headers can be cached by the + /// client until the time specified by `Access-Control-Max-Age` elapses. + /// + /// The default value of `Access-Control-Max-Age` response header is 5 + /// (seconds). + /// + /// When the `MaxAge` field is unspecified, the gateway sets the response + /// header "Access-Control-Max-Age: 5" by default. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] + pub max_age: Option, +} +/// HTTPRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a HTTP request only if its path +/// starts with `/foo` AND it contains the `version: v1` header: +/// +/// ```text +/// match: +/// +/// path: +/// value: "/foo" +/// headers: +/// - name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RouteMatch { + /// Headers specifies HTTP request header matchers. Multiple match values are + /// ANDed together, meaning, a request must match all the specified headers + /// to select the route. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub headers: Option>, + /// Method specifies HTTP method matcher. + /// When specified, this route will be matched only if the request has the + /// specified method. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, + /// Path specifies a HTTP request path matcher. If this field is not + /// specified, a default prefix match on the "/" path is provided. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, + /// QueryParams specifies HTTP query parameter matchers. Multiple match + /// values are ANDed together, meaning, a request must match all the + /// specified query parameters to select the route. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "queryParams" + )] + pub query_params: Option>, +} +/// HTTPRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a HTTP request only if its path +/// starts with `/foo` AND it contains the `version: v1` header: +/// +/// ```text +/// match: +/// +/// path: +/// value: "/foo" +/// headers: +/// - name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HTTPMethodMatch { + #[serde(rename = "GET")] + Get, + #[serde(rename = "HEAD")] + Head, + #[serde(rename = "POST")] + Post, + #[serde(rename = "PUT")] + Put, + #[serde(rename = "DELETE")] + Delete, + #[serde(rename = "CONNECT")] + Connect, + #[serde(rename = "OPTIONS")] + Options, + #[serde(rename = "TRACE")] + Trace, + #[serde(rename = "PATCH")] + Patch, +} +/// Path specifies a HTTP request path matcher. If this field is not +/// specified, a default prefix match on the "/" path is provided. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct PathMatch { + /// Type specifies how to match against the path Value. + /// + /// Support: Core (Exact, PathPrefix) + /// + /// Support: Implementation-specific (RegularExpression) + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// Value of the HTTP path to match against. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, +} +/// Path specifies a HTTP request path matcher. If this field is not +/// specified, a default prefix match on the "/" path is provided. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HttpRouteRulesMatchesPathType { + Exact, + PathPrefix, + RegularExpression, +} +/// Retry defines the configuration for when to retry an HTTP request. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesRetry { + /// Attempts specifies the maximum number of times an individual request + /// from the gateway to a backend should be retried. + /// + /// If the maximum number of retries has been attempted without a successful + /// response from the backend, the Gateway MUST return an error. + /// + /// When this field is unspecified, the number of times to attempt to retry + /// a backend request is implementation-specific. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub attempts: Option, + /// Backoff specifies the minimum duration a Gateway should wait between + /// retry attempts and is represented in Gateway API Duration formatting. + /// + /// For example, setting the `rules[].retry.backoff` field to the value + /// `100ms` will cause a backend request to first be retried approximately + /// 100 milliseconds after timing out or receiving a response code configured + /// to be retriable. + /// + /// An implementation MAY use an exponential or alternative backoff strategy + /// for subsequent retry attempts, MAY cap the maximum backoff duration to + /// some amount greater than the specified minimum, and MAY add arbitrary + /// jitter to stagger requests, as long as unsuccessful backend requests are + /// not retried before the configured minimum duration. + /// + /// If a Request timeout (`rules[].timeouts.request`) is configured on the + /// route, the entire duration of the initial request and any retry attempts + /// MUST not exceed the Request timeout duration. If any retry attempts are + /// still in progress when the Request timeout duration has been reached, + /// these SHOULD be canceled if possible and the Gateway MUST immediately + /// return a timeout error. + /// + /// If a BackendRequest timeout (`rules[].timeouts.backendRequest`) is + /// configured on the route, any retry attempts which reach the configured + /// BackendRequest timeout duration without a response SHOULD be canceled if + /// possible and the Gateway should wait for at least the specified backoff + /// duration before attempting to retry the backend request again. + /// + /// If a BackendRequest timeout is _not_ configured on the route, retry + /// attempts MAY time out after an implementation default duration, or MAY + /// remain pending until a configured Request timeout or implementation + /// default duration for total request time is reached. + /// + /// When this field is unspecified, the time to wait between retry attempts + /// is implementation-specific. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub backoff: Option, + /// Codes defines the HTTP response status codes for which a backend request + /// should be retried. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub codes: Option>, +} +/// Timeouts defines the timeouts that can be configured for an HTTP request. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteTimeout { + /// BackendRequest specifies a timeout for an individual request from the gateway + /// to a backend. This covers the time from when the request first starts being + /// sent from the gateway to when the full response has been received from the backend. + /// + /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout + /// completely. Implementations that cannot completely disable the timeout MUST + /// instead interpret the zero duration as the longest possible value to which + /// the timeout can be set. + /// + /// An entire client HTTP transaction with a gateway, covered by the Request timeout, + /// may result in more than one call from the gateway to the destination backend, + /// for example, if automatic retries are supported. + /// + /// The value of BackendRequest must be a Gateway API Duration string as defined by + /// GEP-2257. When this field is unspecified, its behavior is implementation-specific; + /// when specified, the value of BackendRequest must be no more than the value of the + /// Request timeout (since the Request timeout encompasses the BackendRequest timeout). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRequest" + )] + pub backend_request: Option, + /// Request specifies the maximum duration for a gateway to respond to an HTTP request. + /// If the gateway has not been able to respond before this deadline is met, the gateway + /// MUST return a timeout error. + /// + /// For example, setting the `rules.timeouts.request` field to the value `10s` in an + /// `HTTPRoute` will cause a timeout if a client request is taking longer than 10 seconds + /// to complete. + /// + /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout + /// completely. Implementations that cannot completely disable the timeout MUST + /// instead interpret the zero duration as the longest possible value to which + /// the timeout can be set. + /// + /// This timeout is intended to cover as close to the whole request-response transaction + /// as possible although an implementation MAY choose to start the timeout after the entire + /// request stream has been received instead of immediately after the transaction is + /// initiated by the client. + /// + /// The value of Request is a Gateway API Duration string as defined by GEP-2257. When this + /// field is unspecified, request timeout behavior is implementation-specific. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub request: Option, +} +/// Status defines the current state of HTTPRoute. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteStatus { + /// Parents is a list of parent resources (usually Gateways) that are + /// associated with the route, and the status of the route with respect to + /// each parent. When this route attaches to a parent, the controller that + /// manages the parent must add an entry to this list when the controller + /// first sees the route and should update the entry as appropriate when the + /// route or gateway is modified. + /// + /// Note that parent references that cannot be resolved by an implementation + /// of this API will not be added to this list. Implementations of this API + /// can only populate Route status for the Gateways/parent resources they are + /// responsible for. + /// + /// A maximum of 32 Gateways will be represented in this list. An empty list + /// means the route has not been attached to any Gateway. + pub parents: Vec, +} +/// RouteParentStatus describes the status of a route with respect to an +/// associated Parent. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteStatusParents { + /// Conditions describes the status of the route with respect to the Gateway. + /// Note that the route's availability is also subject to the Gateway's own + /// status conditions and listener status. + /// + /// If the Route's ParentRef specifies an existing Gateway that supports + /// Routes of this kind AND that Gateway's controller has sufficient access, + /// then that Gateway's controller MUST set the "Accepted" condition on the + /// Route, to indicate whether the route has been accepted or rejected by the + /// Gateway, and why. + /// + /// A Route MUST be considered "Accepted" if at least one of the Route's + /// rules is implemented by the Gateway. + /// + /// There are a number of cases where the "Accepted" condition may not be set + /// due to lack of controller visibility, that includes when: + /// + /// * The Route refers to a nonexistent parent. + /// * The Route is of a type that the controller does not support. + /// * The Route is in a namespace to which the controller does not have access. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, + /// ParentRef corresponds with a ParentRef in the spec that this + /// RouteParentStatus struct describes the status of. + #[serde(rename = "parentRef")] + pub parent_ref: ParentReference, +} diff --git a/gateway-api/src/experimental/listenersets.rs b/gateway-api/src/experimental/listenersets.rs new file mode 100644 index 0000000..4dfbec8 --- /dev/null +++ b/gateway-api/src/experimental/listenersets.rs @@ -0,0 +1,121 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of ListenerSet. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "ListenerSet", + plural = "listenersets" +)] +#[kube(namespaced)] +#[kube(status = "ListenerSetStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct ListenerSetSpec { + /// Listeners associated with this ListenerSet. Listeners define + /// logical endpoints that are bound on this referenced parent Gateway's addresses. + /// + /// Listeners in a `Gateway` and their attached `ListenerSets` are concatenated + /// as a list when programming the underlying infrastructure. Each listener + /// name does not need to be unique across the Gateway and ListenerSets. + /// See ListenerEntry.Name for more details. + /// + /// Implementations MUST treat the parent Gateway as having the merged + /// list of all listeners from itself and attached ListenerSets using + /// the following precedence: + /// + /// 1. "parent" Gateway + /// 2. ListenerSet ordered by creation time (oldest first) + /// 3. ListenerSet ordered alphabetically by "{namespace}/{name}". + /// + /// An implementation MAY reject listeners by setting the ListenerEntryStatus + /// `Accepted` condition to False with the Reason `TooManyListeners` + /// + /// If a listener has a conflict, this will be reported in the + /// Status.ListenerEntryStatus setting the `Conflicted` condition to True. + /// + /// Implementations SHOULD be cautious about what information from the + /// parent or siblings are reported to avoid accidentally leaking + /// sensitive information that the child would not otherwise have access + /// to. This can include contents of secrets etc. + pub listeners: Vec, + /// ParentRef references the Gateway that the listeners are attached to. + #[serde(rename = "parentRef")] + pub parent_ref: Reference, +} +/// Status defines the current state of ListenerSet. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetStatus { + /// Conditions describe the current conditions of the ListenerSet. + /// + /// Implementations MUST express ListenerSet conditions using the + /// `ListenerSetConditionType` and `ListenerSetConditionReason` + /// constants so that operators and tools can converge on a common + /// vocabulary to describe ListenerSet state. + /// + /// Known condition types are: + /// + /// * "Accepted" + /// * "Programmed" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// Listeners provide status for each unique listener port defined in the Spec. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub listeners: Option>, +} +/// ListenerStatus is the status associated with a Listener. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetStatusListeners { + /// AttachedRoutes represents the total number of Routes that have been + /// successfully attached to this Listener. + /// + /// Successful attachment of a Route to a Listener is based solely on the + /// combination of the AllowedRoutes field on the corresponding Listener + /// and the Route's ParentRefs field. A Route is successfully attached to + /// a Listener when it is selected by the Listener's AllowedRoutes field + /// AND the Route has a valid ParentRef selecting the whole Gateway + /// resource or a specific Listener as a parent resource (more detail on + /// attachment semantics can be found in the documentation on the various + /// Route kinds ParentRefs fields). Listener status does not impact + /// successful attachment, i.e. the AttachedRoutes field count MUST be set + /// for Listeners, even if the Accepted condition of an individual Listener is set + /// to "False". The AttachedRoutes number represents the number of Routes with + /// the Accepted condition set to "True" that have been attached to this Listener. + /// Routes with any other value for the Accepted condition MUST NOT be included + /// in this count. + /// + /// Uses for this field include troubleshooting Route attachment and + /// measuring blast radius/impact of changes to a Listener. + #[serde(rename = "attachedRoutes")] + pub attached_routes: i32, + /// Conditions describe the current condition of this listener. + pub conditions: Vec, + /// Name is the name of the Listener that this status corresponds to. + pub name: String, + /// SupportedKinds is the list indicating the Kinds supported by this + /// listener. This MUST represent the kinds supported by an implementation for + /// that Listener configuration. + /// + /// If kinds are specified in Spec that are not supported, they MUST NOT + /// appear in this list and an implementation MUST set the "ResolvedRefs" + /// condition to "False" with the "InvalidRouteKinds" reason. If both valid + /// and invalid Route kinds are specified, the implementation MUST + /// reference the valid Route kinds that have been specified. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "supportedKinds" + )] + pub supported_kinds: Option>, +} diff --git a/gateway-api/src/apis/experimental/mod.rs b/gateway-api/src/experimental/mod.rs similarity index 54% rename from gateway-api/src/apis/experimental/mod.rs rename to gateway-api/src/experimental/mod.rs index 2c13095..a13a089 100644 --- a/gateway-api/src/apis/experimental/mod.rs +++ b/gateway-api/src/experimental/mod.rs @@ -1,10 +1,13 @@ -// WARNING! generated file do not edit +// WARNING: generated file - manual changes will be overriden +pub mod backendtlspolicies; +pub mod common; pub mod constants; -mod enum_defaults; +pub mod enum_defaults; pub mod gatewayclasses; pub mod gateways; pub mod grpcroutes; pub mod httproutes; +pub mod listenersets; pub mod referencegrants; pub mod tcproutes; pub mod tlsroutes; diff --git a/gateway-api/src/experimental/referencegrants.rs b/gateway-api/src/experimental/referencegrants.rs new file mode 100644 index 0000000..6eb6981 --- /dev/null +++ b/gateway-api/src/experimental/referencegrants.rs @@ -0,0 +1,87 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +mod prelude { + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of ReferenceGrant. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "ReferenceGrant", + plural = "referencegrants" +)] +#[kube(namespaced)] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct ReferenceGrantSpec { + /// From describes the trusted namespaces and kinds that can reference the + /// resources described in "To". Each entry in this list MUST be considered + /// to be an additional place that references can be valid from, or to put + /// this another way, entries MUST be combined using OR. + /// + /// Support: Core + pub from: Vec, + /// To describes the resources that may be referenced by the resources + /// described in "From". Each entry in this list MUST be considered to be an + /// additional place that references can be valid to, or to put this another + /// way, entries MUST be combined using OR. + /// + /// Support: Core + pub to: Vec, +} +/// ReferenceGrantFrom describes trusted namespaces and kinds. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ReferenceGrantFrom { + /// Group is the group of the referent. + /// When empty, the Kubernetes core API group is inferred. + /// + /// Support: Core + pub group: String, + /// Kind is the kind of the referent. Although implementations may support + /// additional resources, the following types are part of the "Core" + /// support level for this field. + /// + /// When used to permit a SecretObjectReference: + /// + /// * Gateway + /// + /// When used to permit a BackendObjectReference: + /// + /// * GRPCRoute + /// * HTTPRoute + /// * TCPRoute + /// * TLSRoute + /// * UDPRoute + pub kind: String, + /// Namespace is the namespace of the referent. + /// + /// Support: Core + pub namespace: String, +} +/// ReferenceGrantTo describes what Kinds are allowed as targets of the +/// references. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ReferenceGrantTo { + /// Group is the group of the referent. + /// When empty, the Kubernetes core API group is inferred. + /// + /// Support: Core + pub group: String, + /// Kind is the kind of the referent. Although implementations may support + /// additional resources, the following types are part of the "Core" + /// support level for this field: + /// + /// * Secret when used to permit a SecretObjectReference + /// * Service when used to permit a BackendObjectReference + pub kind: String, + /// Name is the name of the referent. When unspecified, this policy + /// refers to all resources of the specified Group and Kind in the local + /// namespace. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} diff --git a/gateway-api/src/experimental/tcproutes.rs b/gateway-api/src/experimental/tcproutes.rs new file mode 100644 index 0000000..29652be --- /dev/null +++ b/gateway-api/src/experimental/tcproutes.rs @@ -0,0 +1,200 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of TCPRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1alpha2", + kind = "TCPRoute", + plural = "tcproutes" +)] +#[kube(namespaced)] +#[kube(status = "TcpRouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct TcpRouteSpec { + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + /// + /// + /// ParentRefs from a Route to a Service in the same namespace are "producer" + /// routes, which apply default routing rules to inbound connections from + /// any namespace to the Service. + /// + /// ParentRefs from a Route to a Service in a different namespace are + /// "consumer" routes, and these routing rules are only applied to outbound + /// connections originating from the same namespace as the Route, for which + /// the intended destination of the connections are a Service targeted as a + /// ParentRef of the Route. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of TCP matchers and actions. + pub rules: Vec, + /// UseDefaultGateways indicates the default Gateway scope to use for this + /// Route. If unset (the default) or set to None, the Route will not be + /// attached to any default Gateway; if set, it will be attached to any + /// default Gateway supporting the named scope, subject to the usual rules + /// about which Routes a Gateway is allowed to claim. + /// + /// Think carefully before using this functionality! The set of default + /// Gateways supporting the requested scope can change over time without + /// any notice to the Route author, and in many situations it will not be + /// appropriate to request a default Gateway for a given Route -- for + /// example, a Route with specific security requirements should almost + /// certainly not use a default Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "useDefaultGateways" + )] + pub use_default_gateways: Option, +} +/// TCPRouteRule is the configuration for a given rule. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TcpRouteRules { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. If unspecified or invalid (refers to a nonexistent resource or a + /// Service with no endpoints), the underlying implementation MUST actively + /// reject connection attempts to this backend. Connection rejections must + /// respect weight; if an invalid backend is requested to have 80% of + /// connections, then 80% of connections must be rejected instead. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Extended + #[serde(rename = "backendRefs")] + pub backend_refs: Vec, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} +/// Status defines the current state of TCPRoute. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TcpRouteStatus { + /// Parents is a list of parent resources (usually Gateways) that are + /// associated with the route, and the status of the route with respect to + /// each parent. When this route attaches to a parent, the controller that + /// manages the parent must add an entry to this list when the controller + /// first sees the route and should update the entry as appropriate when the + /// route or gateway is modified. + /// + /// Note that parent references that cannot be resolved by an implementation + /// of this API will not be added to this list. Implementations of this API + /// can only populate Route status for the Gateways/parent resources they are + /// responsible for. + /// + /// A maximum of 32 Gateways will be represented in this list. An empty list + /// means the route has not been attached to any Gateway. + pub parents: Vec, +} +/// RouteParentStatus describes the status of a route with respect to an +/// associated Parent. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TcpRouteStatusParents { + /// Conditions describes the status of the route with respect to the Gateway. + /// Note that the route's availability is also subject to the Gateway's own + /// status conditions and listener status. + /// + /// If the Route's ParentRef specifies an existing Gateway that supports + /// Routes of this kind AND that Gateway's controller has sufficient access, + /// then that Gateway's controller MUST set the "Accepted" condition on the + /// Route, to indicate whether the route has been accepted or rejected by the + /// Gateway, and why. + /// + /// A Route MUST be considered "Accepted" if at least one of the Route's + /// rules is implemented by the Gateway. + /// + /// There are a number of cases where the "Accepted" condition may not be set + /// due to lack of controller visibility, that includes when: + /// + /// * The Route refers to a nonexistent parent. + /// * The Route is of a type that the controller does not support. + /// * The Route is in a namespace to which the controller does not have access. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, + /// ParentRef corresponds with a ParentRef in the spec that this + /// RouteParentStatus struct describes the status of. + #[serde(rename = "parentRef")] + pub parent_ref: ParentReference, +} diff --git a/gateway-api/src/experimental/tlsroutes.rs b/gateway-api/src/experimental/tlsroutes.rs new file mode 100644 index 0000000..d9dc1af --- /dev/null +++ b/gateway-api/src/experimental/tlsroutes.rs @@ -0,0 +1,208 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of TLSRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "TLSRoute", + plural = "tlsroutes" +)] +#[kube(namespaced)] +#[kube(status = "TlsRouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct TlsRouteSpec { + /// Hostnames defines a set of SNI hostnames that should match against the + /// SNI attribute of TLS ClientHello message in TLS handshake. This matches + /// the RFC 1123 definition of a hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed in SNI hostnames per RFC 6066. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label must appear by itself as the first label. + pub hostnames: Vec, + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + /// + /// + /// ParentRefs from a Route to a Service in the same namespace are "producer" + /// routes, which apply default routing rules to inbound connections from + /// any namespace to the Service. + /// + /// ParentRefs from a Route to a Service in a different namespace are + /// "consumer" routes, and these routing rules are only applied to outbound + /// connections originating from the same namespace as the Route, for which + /// the intended destination of the connections are a Service targeted as a + /// ParentRef of the Route. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of actions. + pub rules: Vec, + /// UseDefaultGateways indicates the default Gateway scope to use for this + /// Route. If unset (the default) or set to None, the Route will not be + /// attached to any default Gateway; if set, it will be attached to any + /// default Gateway supporting the named scope, subject to the usual rules + /// about which Routes a Gateway is allowed to claim. + /// + /// Think carefully before using this functionality! The set of default + /// Gateways supporting the requested scope can change over time without + /// any notice to the Route author, and in many situations it will not be + /// appropriate to request a default Gateway for a given Route -- for + /// example, a Route with specific security requirements should almost + /// certainly not use a default Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "useDefaultGateways" + )] + pub use_default_gateways: Option, +} +/// TLSRouteRule is the configuration for a given rule. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TlsRouteRules { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. If unspecified or invalid (refers to a nonexistent resource or + /// a Service with no endpoints), the rule performs no forwarding; if no + /// filters are specified that would result in a response being sent, the + /// underlying implementation must actively reject request attempts to this + /// backend, by rejecting the connection. Request rejections must respect + /// weight; if an invalid backend is requested to have 80% of requests, then + /// 80% of requests must be rejected instead. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Extended + #[serde(rename = "backendRefs")] + pub backend_refs: Vec, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} +/// Status defines the current state of TLSRoute. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TlsRouteStatus { + /// Parents is a list of parent resources (usually Gateways) that are + /// associated with the route, and the status of the route with respect to + /// each parent. When this route attaches to a parent, the controller that + /// manages the parent must add an entry to this list when the controller + /// first sees the route and should update the entry as appropriate when the + /// route or gateway is modified. + /// + /// Note that parent references that cannot be resolved by an implementation + /// of this API will not be added to this list. Implementations of this API + /// can only populate Route status for the Gateways/parent resources they are + /// responsible for. + /// + /// A maximum of 32 Gateways will be represented in this list. An empty list + /// means the route has not been attached to any Gateway. + pub parents: Vec, +} +/// RouteParentStatus describes the status of a route with respect to an +/// associated Parent. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TlsRouteStatusParents { + /// Conditions describes the status of the route with respect to the Gateway. + /// Note that the route's availability is also subject to the Gateway's own + /// status conditions and listener status. + /// + /// If the Route's ParentRef specifies an existing Gateway that supports + /// Routes of this kind AND that Gateway's controller has sufficient access, + /// then that Gateway's controller MUST set the "Accepted" condition on the + /// Route, to indicate whether the route has been accepted or rejected by the + /// Gateway, and why. + /// + /// A Route MUST be considered "Accepted" if at least one of the Route's + /// rules is implemented by the Gateway. + /// + /// There are a number of cases where the "Accepted" condition may not be set + /// due to lack of controller visibility, that includes when: + /// + /// * The Route refers to a nonexistent parent. + /// * The Route is of a type that the controller does not support. + /// * The Route is in a namespace to which the controller does not have access. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, + /// ParentRef corresponds with a ParentRef in the spec that this + /// RouteParentStatus struct describes the status of. + #[serde(rename = "parentRef")] + pub parent_ref: ParentReference, +} diff --git a/gateway-api/src/experimental/udproutes.rs b/gateway-api/src/experimental/udproutes.rs new file mode 100644 index 0000000..0d0c996 --- /dev/null +++ b/gateway-api/src/experimental/udproutes.rs @@ -0,0 +1,200 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of UDPRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1alpha2", + kind = "UDPRoute", + plural = "udproutes" +)] +#[kube(namespaced)] +#[kube(status = "UdpRouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct UdpRouteSpec { + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + /// + /// + /// ParentRefs from a Route to a Service in the same namespace are "producer" + /// routes, which apply default routing rules to inbound connections from + /// any namespace to the Service. + /// + /// ParentRefs from a Route to a Service in a different namespace are + /// "consumer" routes, and these routing rules are only applied to outbound + /// connections originating from the same namespace as the Route, for which + /// the intended destination of the connections are a Service targeted as a + /// ParentRef of the Route. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of UDP matchers and actions. + pub rules: Vec, + /// UseDefaultGateways indicates the default Gateway scope to use for this + /// Route. If unset (the default) or set to None, the Route will not be + /// attached to any default Gateway; if set, it will be attached to any + /// default Gateway supporting the named scope, subject to the usual rules + /// about which Routes a Gateway is allowed to claim. + /// + /// Think carefully before using this functionality! The set of default + /// Gateways supporting the requested scope can change over time without + /// any notice to the Route author, and in many situations it will not be + /// appropriate to request a default Gateway for a given Route -- for + /// example, a Route with specific security requirements should almost + /// certainly not use a default Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "useDefaultGateways" + )] + pub use_default_gateways: Option, +} +/// UDPRouteRule is the configuration for a given rule. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct UdpRouteRules { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. If unspecified or invalid (refers to a nonexistent resource or a + /// Service with no endpoints), the underlying implementation MUST actively + /// reject connection attempts to this backend. Packet drops must + /// respect weight; if an invalid backend is requested to have 80% of + /// the packets, then 80% of packets must be dropped instead. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Extended + #[serde(rename = "backendRefs")] + pub backend_refs: Vec, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} +/// Status defines the current state of UDPRoute. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct UdpRouteStatus { + /// Parents is a list of parent resources (usually Gateways) that are + /// associated with the route, and the status of the route with respect to + /// each parent. When this route attaches to a parent, the controller that + /// manages the parent must add an entry to this list when the controller + /// first sees the route and should update the entry as appropriate when the + /// route or gateway is modified. + /// + /// Note that parent references that cannot be resolved by an implementation + /// of this API will not be added to this list. Implementations of this API + /// can only populate Route status for the Gateways/parent resources they are + /// responsible for. + /// + /// A maximum of 32 Gateways will be represented in this list. An empty list + /// means the route has not been attached to any Gateway. + pub parents: Vec, +} +/// RouteParentStatus describes the status of a route with respect to an +/// associated Parent. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct UdpRouteStatusParents { + /// Conditions describes the status of the route with respect to the Gateway. + /// Note that the route's availability is also subject to the Gateway's own + /// status conditions and listener status. + /// + /// If the Route's ParentRef specifies an existing Gateway that supports + /// Routes of this kind AND that Gateway's controller has sufficient access, + /// then that Gateway's controller MUST set the "Accepted" condition on the + /// Route, to indicate whether the route has been accepted or rejected by the + /// Gateway, and why. + /// + /// A Route MUST be considered "Accepted" if at least one of the Route's + /// rules is implemented by the Gateway. + /// + /// There are a number of cases where the "Accepted" condition may not be set + /// due to lack of controller visibility, that includes when: + /// + /// * The Route refers to a nonexistent parent. + /// * The Route is of a type that the controller does not support. + /// * The Route is in a namespace to which the controller does not have access. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, + /// ParentRef corresponds with a ParentRef in the spec that this + /// RouteParentStatus struct describes the status of. + #[serde(rename = "parentRef")] + pub parent_ref: ParentReference, +} diff --git a/gateway-api/src/lib.rs b/gateway-api/src/lib.rs index 492d60b..43696e7 100644 --- a/gateway-api/src/lib.rs +++ b/gateway-api/src/lib.rs @@ -1,20 +1,25 @@ pub mod duration; pub use duration::Duration; -pub mod apis; -pub use apis::standard::*; -#[cfg(feature = "experimental")] -pub use apis::experimental; +cfg_if::cfg_if! { + if #[cfg(feature = "experimental")] { + mod experimental; + pub use experimental::*; + } else { + mod standard; + pub use standard::*; + } +} #[cfg(test)] mod tests { use std::process::Command; - use anyhow::Error; + use anyhow::{Error, Ok}; use hyper_util::client::legacy::Client as HTTPClient; use hyper_util::rt::TokioExecutor; use k8s_openapi::apimachinery::pkg::apis::meta::v1::{Condition, Time}; - use k8s_openapi::chrono::Utc; + use k8s_openapi::jiff::Timestamp; use kube::Client as KubeClient; use kube::api::{Patch, PatchParams, PostParams}; use kube::config::{KubeConfigOptions, Kubeconfig}; @@ -25,25 +30,30 @@ mod tests { use tower::ServiceBuilder; use uuid::Uuid; + use crate::common::{ParentReference, ParentRouteStatus, RouteStatus}; use crate::{ + common::GatewayStatusListeners, constants::{ GatewayConditionReason, GatewayConditionType, ListenerConditionReason, - ListenerConditionType, + ListenerConditionType, RouteConditionReason, RouteConditionType, }, gatewayclasses::{GatewayClass, GatewayClassSpec}, - gateways::{ - Gateway, GatewaySpec, GatewayStatus, GatewayStatusAddresses, GatewayStatusListeners, - }, + gateways::{Gateway, GatewayListeners, GatewaySpec, GatewayStatus, GatewayStatusAddresses}, + grpcroutes::GrpcRouteSpec, + httproutes::HttpRouteSpec, + referencegrants::{ReferenceGrantFrom, ReferenceGrantSpec, ReferenceGrantTo}, }; + const DEFAULT_GATEWAY_API_VERSION: &str = "v1.5.0"; + // ------------------------------------------------------------------------- // Tests // ------------------------------------------------------------------------- #[ignore] #[tokio::test] - async fn deploy_gateway() -> Result<(), Error> { - let (client, cluster) = get_client().await?; + async fn test_deploy_resources() -> Result<(), Error> { + let (client, cluster) = get_client(false).await?; let info = client.apiserver_version().await?; println!( @@ -51,10 +61,40 @@ mod tests { cluster.name, info.git_version ); + test_resource_deployment(client).await?; + + println!("cleaning up kind cluster {}", cluster.name); + + Ok(()) + } + + #[ignore] + #[tokio::test] + async fn test_deploy_resources_upstream_crds() -> Result<(), Error> { + let (client, cluster) = get_client(true).await?; + let info = client.apiserver_version().await?; + + println!( + "kind cluster {} is running, server version: {}", + cluster.name, info.git_version + ); + + test_resource_deployment(client).await?; + + println!("cleaning up kind cluster {}", cluster.name); + + Ok(()) + } + + // ------------------------------------------------------------------------- + // Test Resources + // ------------------------------------------------------------------------- + + async fn test_resource_deployment(client: kube::Client) -> Result<(), Error> { let mut gwc = GatewayClass { metadata: ObjectMeta::default(), spec: GatewayClassSpec { - controller_name: "test-controller".to_string(), + controller_name: "example.com/gateway-controller".to_string(), description: None, parameters_ref: None, }, @@ -75,7 +115,18 @@ mod tests { .metadata .name .ok_or(Error::msg("could not find GatewayClass name"))?, - ..Default::default() + listeners: vec![GatewayListeners { + name: "http".to_string(), + port: 80, + protocol: "HTTP".to_string(), + hostname: None, + allowed_routes: None, + tls: None, + }], + addresses: None, + infrastructure: None, + allowed_listeners: None, + tls: None, }, status: None, }; @@ -87,31 +138,36 @@ mod tests { assert!(gw.metadata.name.is_some()); assert!(gw.metadata.uid.is_some()); - let mut gw_status = GatewayStatus::default(); - gw_status.addresses = Some(vec![GatewayStatusAddresses::default()]); - gw_status.listeners = Some(vec![GatewayStatusListeners { - name: "tcp".into(), - attached_routes: 0, - supported_kinds: vec![], - conditions: vec![Condition { - last_transition_time: Time(Utc::now()), + let gw_status = GatewayStatus { + addresses: Some(vec![GatewayStatusAddresses { + r#type: Some("IPAddress".to_string()), + value: "10.0.0.1".to_string(), + }]), + listeners: Some(vec![GatewayStatusListeners { + name: "http".into(), + attached_routes: 0, + supported_kinds: None, + conditions: vec![Condition { + last_transition_time: Time(Timestamp::now()), + message: "testing gateway".to_string(), + observed_generation: Some(1), + reason: ListenerConditionReason::Programmed.to_string(), + status: "True".to_string(), + type_: ListenerConditionType::Programmed.to_string(), + }], + }]), + conditions: Some(vec![Condition { + last_transition_time: Time(Timestamp::now()), message: "testing gateway".to_string(), observed_generation: Some(1), - reason: ListenerConditionReason::Programmed.to_string(), + reason: GatewayConditionReason::Programmed.to_string(), status: "True".to_string(), - type_: ListenerConditionType::Programmed.to_string(), - }], - }]); - gw_status.conditions = Some(vec![Condition { - last_transition_time: Time(Utc::now()), - message: "testing gateway".to_string(), - observed_generation: Some(1), - reason: GatewayConditionReason::Programmed.to_string(), - status: "True".to_string(), - type_: GatewayConditionType::Programmed.to_string(), - }]); - - gw = Api::default_namespaced(client) + type_: GatewayConditionType::Programmed.to_string(), + }]), + attached_listener_sets: None, + }; + + gw = Api::default_namespaced(client.clone()) .patch_status( gw.metadata.name.clone().unwrap().as_str(), &PatchParams::default(), @@ -126,6 +182,162 @@ mod tests { assert!(gw.status.clone().unwrap().listeners.is_some()); assert!(gw.status.clone().unwrap().conditions.is_some()); + let mut http_route = crate::httproutes::HTTPRoute { + metadata: ObjectMeta::default(), + spec: HttpRouteSpec { + hostnames: Some(vec!["example.com".to_string()]), + parent_refs: Some(vec![ParentReference { + group: Some("gateway.networking.k8s.io".to_string()), + kind: Some("Gateway".to_string()), + namespace: Some("default".to_string()), + name: gw.metadata.name.clone().unwrap(), + section_name: None, + port: None, + }]), + rules: Some(vec![]), + }, + status: None, + }; + http_route.metadata.name = Some("test-http-route".to_string()); + http_route = Api::default_namespaced(client.clone()) + .create(&PostParams::default(), &http_route) + .await?; + + assert!(http_route.metadata.name.is_some()); + assert!(http_route.metadata.uid.is_some()); + assert!(http_route.spec.hostnames.is_some()); + assert!(http_route.spec.parent_refs.is_some()); + + let http_route_status = RouteStatus { + parents: vec![ParentRouteStatus { + parent_ref: ParentReference { + group: Some("gateway.networking.k8s.io".to_string()), + kind: Some("Gateway".to_string()), + namespace: Some("default".to_string()), + name: gw.metadata.name.clone().unwrap(), + section_name: None, + port: None, + }, + controller_name: "example.com/gateway-controller".to_string(), + conditions: vec![Condition { + last_transition_time: Time(Timestamp::now()), + message: "testing http route".to_string(), + observed_generation: Some(1), + reason: RouteConditionReason::Accepted.to_string(), + status: "True".to_string(), + type_: RouteConditionType::Accepted.to_string(), + }], + }], + }; + + http_route = Api::default_namespaced(client.clone()) + .patch_status( + http_route.metadata.name.clone().unwrap().as_str(), + &PatchParams::default(), + &Patch::Merge(json!({ + "status": Some(http_route_status) + })), + ) + .await?; + + assert!(http_route.status.is_some()); + assert!(!http_route.status.clone().unwrap().parents.is_empty()); + + let mut grpc_route = crate::grpcroutes::GRPCRoute { + metadata: ObjectMeta::default(), + spec: GrpcRouteSpec { + hostnames: Some(vec!["grpc.example.com".to_string()]), + parent_refs: Some(vec![ParentReference { + group: Some("gateway.networking.k8s.io".to_string()), + kind: Some("Gateway".to_string()), + namespace: Some("default".to_string()), + name: gw.metadata.name.clone().unwrap(), + section_name: None, + port: None, + }]), + rules: Some(vec![]), + }, + status: None, + }; + grpc_route.metadata.name = Some("test-grpc-route".to_string()); + grpc_route = Api::default_namespaced(client.clone()) + .create(&PostParams::default(), &grpc_route) + .await?; + + assert!(grpc_route.metadata.name.is_some()); + assert!(grpc_route.metadata.uid.is_some()); + assert!(grpc_route.spec.hostnames.is_some()); + assert!(grpc_route.spec.parent_refs.is_some()); + + let grpc_route_status = RouteStatus { + parents: vec![ParentRouteStatus { + parent_ref: ParentReference { + group: Some("gateway.networking.k8s.io".to_string()), + kind: Some("Gateway".to_string()), + namespace: Some("default".to_string()), + name: gw.metadata.name.clone().unwrap(), + section_name: None, + port: None, + }, + controller_name: "example.com/gateway-controller".to_string(), + conditions: vec![Condition { + last_transition_time: Time(Timestamp::now()), + message: "testing grpc route".to_string(), + observed_generation: Some(1), + reason: RouteConditionReason::Accepted.to_string(), + status: "True".to_string(), + type_: RouteConditionType::Accepted.to_string(), + }], + }], + }; + + grpc_route = Api::default_namespaced(client.clone()) + .patch_status( + grpc_route.metadata.name.clone().unwrap().as_str(), + &PatchParams::default(), + &Patch::Merge(json!({ + "status": Some(grpc_route_status) + })), + ) + .await?; + + assert!(grpc_route.status.is_some()); + assert!(!grpc_route.status.clone().unwrap().parents.is_empty()); + + let mut ref_grant = crate::referencegrants::ReferenceGrant { + metadata: ObjectMeta::default(), + spec: ReferenceGrantSpec { + from: vec![ReferenceGrantFrom { + group: "gateway.networking.k8s.io".to_string(), + kind: "HTTPRoute".to_string(), + namespace: "default".to_string(), + }], + to: vec![ReferenceGrantTo { + group: "".to_string(), + kind: "Service".to_string(), + name: Some("backend-service".to_string()), + }], + }, + }; + ref_grant.metadata.name = Some("test-reference-grant".to_string()); + ref_grant = Api::default_namespaced(client.clone()) + .create(&PostParams::default(), &ref_grant) + .await?; + + assert!(ref_grant.metadata.name.is_some()); + assert!(ref_grant.metadata.uid.is_some()); + assert!(!ref_grant.spec.from.is_empty()); + assert_eq!(ref_grant.spec.from[0].group, "gateway.networking.k8s.io"); + assert_eq!(ref_grant.spec.from[0].kind, "HTTPRoute"); + assert_eq!(ref_grant.spec.from[0].namespace, "default"); + assert!(!ref_grant.spec.to.is_empty()); + assert_eq!(ref_grant.spec.to[0].group, ""); + assert_eq!(ref_grant.spec.to[0].kind, "Service"); + assert_eq!( + ref_grant.spec.to[0].name, + Some("backend-service".to_string()) + ); + Ok(()) } @@ -139,14 +351,13 @@ mod tests { impl Drop for Cluster { fn drop(&mut self) { - match delete_kind_cluster(&self.name) { - Err(err) => panic!("failed to cleanup kind cluster {}: {}", self.name, err), - Ok(()) => {} + if let Err(err) = delete_kind_cluster(&self.name) { + panic!("failed to cleanup kind cluster {}: {}", self.name, err) } } } - async fn get_client() -> Result<(kube::Client, Cluster), Error> { + async fn get_client(upstream: bool) -> Result<(kube::Client, Cluster), Error> { let cluster = create_kind_cluster()?; let kubeconfig_yaml = get_kind_kubeconfig(&cluster.name)?; let kubeconfig = Kubeconfig::from_yaml(&kubeconfig_yaml)?; @@ -163,11 +374,56 @@ mod tests { let client = KubeClient::new(service, config.default_namespace); - deploy_crds(client.clone()).await?; + if upstream { + deploy_crds_upstream(&cluster.name).await?; + } else { + deploy_crds(client.clone()).await?; + } Ok((client, cluster)) } + async fn deploy_crds_upstream(cluster_name: &str) -> Result<(), Error> { + let version = std::env::var("GATEWAY_API_VERSION") + .unwrap_or_else(|_| DEFAULT_GATEWAY_API_VERSION.to_string()); + + let semver_pattern = regex::Regex::new(r"^v?\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$") + .map_err(|e| Error::msg(format!("Failed to compile regex: {}", e)))?; + if !semver_pattern.is_match(&version) { + return Err(Error::msg(format!( + "GATEWAY_API_VERSION '{}' is not a valid semver version", + version + ))); + } + + let kubeconfig_yaml = get_kind_kubeconfig(cluster_name)?; + let temp_dir = std::env::temp_dir(); + let kubeconfig_path = temp_dir.join(format!("kubeconfig-{}", cluster_name)); + std::fs::write(&kubeconfig_path, kubeconfig_yaml)?; + + let url = format!( + "https://github.com/kubernetes-sigs/gateway-api/releases/download/{}/standard-install.yaml", + version + ); + + let output = Command::new("kubectl") + .arg("--kubeconfig") + .arg(&kubeconfig_path) + .arg("apply") + .arg("-f") + .arg(&url) + .output()?; + + if !output.status.success() { + return Err(Error::msg(format!( + "Failed to apply CRDs: {}", + String::from_utf8_lossy(&output.stderr) + ))); + } + + Ok(()) + } + async fn deploy_crds(client: kube::Client) -> Result<(), Error> { let mut gwc_crd = GatewayClass::crd(); gwc_crd.metadata.annotations = Some(std::collections::BTreeMap::from([( @@ -189,6 +445,36 @@ mod tests { .create(&PostParams::default(), &gw_crd) .await?; + let mut http_route_crd = crate::httproutes::HTTPRoute::crd(); + http_route_crd.metadata.annotations = Some(std::collections::BTreeMap::from([( + "api-approved.kubernetes.io".to_string(), + "https://github.com/kubernetes/enhancements/pull/1111".to_string(), + )])); + + Api::all(client.clone()) + .create(&PostParams::default(), &http_route_crd) + .await?; + + let mut grpc_route_crd = crate::grpcroutes::GRPCRoute::crd(); + grpc_route_crd.metadata.annotations = Some(std::collections::BTreeMap::from([( + "api-approved.kubernetes.io".to_string(), + "https://github.com/kubernetes/enhancements/pull/1111".to_string(), + )])); + + Api::all(client.clone()) + .create(&PostParams::default(), &grpc_route_crd) + .await?; + + let mut ref_grant_crd = crate::referencegrants::ReferenceGrant::crd(); + ref_grant_crd.metadata.annotations = Some(std::collections::BTreeMap::from([( + "api-approved.kubernetes.io".to_string(), + "https://github.com/kubernetes/enhancements/pull/1111".to_string(), + )])); + + Api::all(client.clone()) + .create(&PostParams::default(), &ref_grant_crd) + .await?; + Ok(()) } diff --git a/gateway-api/src/mod.rs b/gateway-api/src/mod.rs new file mode 100644 index 0000000..7651e9f --- /dev/null +++ b/gateway-api/src/mod.rs @@ -0,0 +1,2 @@ +pub mod experimental; +pub mod standard; diff --git a/gateway-api/src/standard/backendtlspolicies.rs b/gateway-api/src/standard/backendtlspolicies.rs new file mode 100644 index 0000000..10c7b7e --- /dev/null +++ b/gateway-api/src/standard/backendtlspolicies.rs @@ -0,0 +1,354 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of BackendTLSPolicy. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "BackendTLSPolicy", + plural = "backendtlspolicies" +)] +#[kube(namespaced)] +#[kube(status = "BackendTlsPolicyStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct BackendTlsPolicySpec { + /// Options are a list of key/value pairs to enable extended TLS + /// configuration for each implementation. For example, configuring the + /// minimum TLS version or supported cipher suites. + /// + /// A set of common keys MAY be defined by the API in the future. To avoid + /// any ambiguity, implementation-specific definitions MUST use + /// domain-prefixed names, such as `example.com/my-custom-option`. + /// Un-prefixed names are reserved for key names defined by Gateway API. + /// + /// Support: Implementation-specific + #[serde(default, skip_serializing_if = "Option::is_none")] + pub options: Option>, + /// TargetRefs identifies an API object to apply the policy to. + /// Note that this config applies to the entire referenced resource + /// by default, but this default may change in the future to provide + /// a more granular application of the policy. + /// + /// TargetRefs must be _distinct_. This means either that: + /// + /// * They select different targets. If this is the case, then targetRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, and `name` must + /// be unique across all targetRef entries in the BackendTLSPolicy. + /// * They select different sectionNames in the same target. + /// + /// When more than one BackendTLSPolicy selects the same target and + /// sectionName, implementations MUST determine precedence using the + /// following criteria, continuing on ties: + /// + /// * The older policy by creation timestamp takes precedence. For + /// example, a policy with a creation timestamp of "2021-07-15 + /// 01:02:03" MUST be given precedence over a policy with a + /// creation timestamp of "2021-07-15 01:02:04". + /// * The policy appearing first in alphabetical order by {namespace}/{name}. + /// For example, a policy named `foo/bar` is given precedence over a + /// policy named `foo/baz`. + /// + /// For any BackendTLSPolicy that does not take precedence, the + /// implementation MUST ensure the `Accepted` Condition is set to + /// `status: False`, with Reason `Conflicted`. + /// + /// Implementations SHOULD NOT support more than one targetRef at this + /// time. Although the API technically allows for this, the current guidance + /// for conflict resolution and status handling is lacking. Until that can be + /// clarified in a future release, the safest approach is to support a single + /// targetRef. + /// + /// Support Levels: + /// + /// * Extended: Kubernetes Service referenced by HTTPRoute backendRefs. + /// + /// * Implementation-Specific: Services not connected via HTTPRoute, and any + /// other kind of backend. Implementations MAY use BackendTLSPolicy for: + /// - Services not referenced by any Route (e.g., infrastructure services) + /// - Gateway feature backends (e.g., ExternalAuth, rate-limiting services) + /// - Service mesh workload-to-service communication + /// - Other resource types beyond Service + /// + /// Implementations SHOULD aim to ensure that BackendTLSPolicy behavior is consistent, + /// even outside of the extended HTTPRoute -(backendRef) -> Service path. + /// They SHOULD clearly document how BackendTLSPolicy is interpreted in these + /// scenarios, including: + /// - Which resources beyond Service are supported + /// - How the policy is discovered and applied + /// - Any implementation-specific semantics or restrictions + /// + /// Note that this config applies to the entire referenced resource + /// by default, but this default may change in the future to provide + /// a more granular application of the policy. + #[serde(rename = "targetRefs")] + pub target_refs: Vec, + /// Validation contains backend TLS validation configuration. + pub validation: BackendTlsPolicyValidation, +} +/// LocalPolicyTargetReferenceWithSectionName identifies an API object to apply a +/// direct policy to. This should be used as part of Policy resources that can +/// target single resources. For more information on how this policy attachment +/// mode works, and a sample Policy resource, refer to the policy attachment +/// documentation for Gateway API. +/// +/// Note: This should only be used for direct policy attachment when references +/// to SectionName are actually needed. In all other cases, +/// LocalPolicyTargetReference should be used. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyTargetRefs { + /// Group is the group of the target resource. + pub group: String, + /// Kind is kind of the target resource. + pub kind: String, + /// Name is the name of the target resource. + pub name: String, + /// SectionName is the name of a section within the target resource. When + /// unspecified, this targetRef targets the entire resource. In the following + /// resources, SectionName is interpreted as the following: + /// + /// * Gateway: Listener name + /// * HTTPRoute: HTTPRouteRule name + /// * Service: Port name + /// + /// If a SectionName is specified, but does not exist on the targeted object, + /// the Policy must fail to attach, and the policy implementation should record + /// a `ResolvedRefs` or similar Condition in the Policy's status. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sectionName" + )] + pub section_name: Option, +} +/// Validation contains backend TLS validation configuration. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyValidation { + /// CACertificateRefs contains one or more references to Kubernetes objects that + /// contain a PEM-encoded TLS CA certificate bundle, which is used to + /// validate a TLS handshake between the Gateway and backend Pod. + /// + /// If CACertificateRefs is empty or unspecified, then WellKnownCACertificates must be + /// specified. Only one of CACertificateRefs or WellKnownCACertificates may be specified, + /// not both. If CACertificateRefs is empty or unspecified, the configuration for + /// WellKnownCACertificates MUST be honored instead if supported by the implementation. + /// + /// A CACertificateRef is invalid if: + /// + /// * It refers to a resource that cannot be resolved (e.g., the referenced resource + /// does not exist) or is misconfigured (e.g., a ConfigMap does not contain a key + /// named `ca.crt`). In this case, the Reason must be set to `InvalidCACertificateRef` + /// and the Message of the Condition must indicate which reference is invalid and why. + /// + /// * It refers to an unknown or unsupported kind of resource. In this case, the Reason + /// must be set to `InvalidKind` and the Message of the Condition must explain which + /// kind of resource is unknown or unsupported. + /// + /// * It refers to a resource in another namespace. This may change in future + /// spec updates. + /// + /// Implementations MAY choose to perform further validation of the certificate + /// content (e.g., checking expiry or enforcing specific formats). In such cases, + /// an implementation-specific Reason and Message must be set for the invalid reference. + /// + /// In all cases, the implementation MUST ensure the `ResolvedRefs` Condition on + /// the BackendTLSPolicy is set to `status: False`, with a Reason and Message + /// that indicate the cause of the error. Connections using an invalid + /// CACertificateRef MUST fail, and the client MUST receive an HTTP 5xx error + /// response. If ALL CACertificateRefs are invalid, the implementation MUST also + /// ensure the `Accepted` Condition on the BackendTLSPolicy is set to + /// `status: False`, with a Reason `NoValidCACertificate`. + /// + /// A single CACertificateRef to a Kubernetes ConfigMap kind has "Core" support. + /// Implementations MAY choose to support attaching multiple certificates to + /// a backend, but this behavior is implementation-specific. + /// + /// Support: Core - An optional single reference to a Kubernetes ConfigMap, + /// with the CA certificate in a key named `ca.crt`. + /// + /// Support: Implementation-specific - More than one reference, other kinds + /// of resources, or a single reference that includes multiple certificates. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "caCertificateRefs" + )] + pub ca_certificate_refs: Option>, + /// Hostname is used for two purposes in the connection between Gateways and + /// backends: + /// + /// 1. Hostname MUST be used as the SNI to connect to the backend (RFC 6066). + /// 2. Hostname MUST be used for authentication and MUST match the certificate + /// served by the matching backend, unless SubjectAltNames is specified. + /// 3. If SubjectAltNames are specified, Hostname can be used for certificate selection + /// but MUST NOT be used for authentication. If you want to use the value + /// of the Hostname field for authentication, you MUST add it to the SubjectAltNames list. + /// + /// Support: Core + pub hostname: String, + /// SubjectAltNames contains one or more Subject Alternative Names. + /// When specified the certificate served from the backend MUST + /// have at least one Subject Alternate Name matching one of the specified SubjectAltNames. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "subjectAltNames" + )] + pub subject_alt_names: Option>, + /// WellKnownCACertificates specifies whether a well-known set of CA certificates + /// may be used in the TLS handshake between the gateway and backend pod. + /// + /// If WellKnownCACertificates is unspecified or empty (""), then CACertificateRefs + /// must be specified with at least one entry for a valid configuration. Only one of + /// CACertificateRefs or WellKnownCACertificates may be specified, not both. + /// If an implementation does not support the WellKnownCACertificates field, or + /// the supplied value is not recognized, the implementation MUST ensure the + /// `Accepted` Condition on the BackendTLSPolicy is set to `status: False`, with + /// a Reason `Invalid`. + /// + /// Valid values include: + /// * "System" - indicates that well-known system CA certificates should be used. + /// + /// Implementations MAY define their own sets of CA certificates. Such definitions + /// MUST use an implementation-specific, prefixed name, such as + /// `mycompany.com/my-custom-ca-certificates`. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "wellKnownCACertificates" + )] + pub well_known_ca_certificates: Option, +} +/// SubjectAltName represents Subject Alternative Name. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyValidationSubjectAltNames { + /// Hostname contains Subject Alternative Name specified in DNS name format. + /// Required when Type is set to Hostname, ignored otherwise. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + /// Type determines the format of the Subject Alternative Name. Always required. + /// + /// Support: Core + #[serde(rename = "type")] + pub r#type: BackendTlsPolicyValidationSubjectAltNamesType, + /// URI contains Subject Alternative Name specified in a full URI format. + /// It MUST include both a scheme (e.g., "http" or "ftp") and a scheme-specific-part. + /// Common values include SPIFFE IDs like "spiffe://mycluster.example.com/ns/myns/sa/svc1sa". + /// Required when Type is set to URI, ignored otherwise. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub uri: Option, +} +/// SubjectAltName represents Subject Alternative Name. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum BackendTlsPolicyValidationSubjectAltNamesType { + Hostname, + #[serde(rename = "URI")] + Uri, +} +/// Status defines the current state of BackendTLSPolicy. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyStatus { + /// Ancestors is a list of ancestor resources (usually Gateways) that are + /// associated with the policy, and the status of the policy with respect to + /// each ancestor. When this policy attaches to a parent, the controller that + /// manages the parent and the ancestors MUST add an entry to this list when + /// the controller first sees the policy and SHOULD update the entry as + /// appropriate when the relevant ancestor is modified. + /// + /// Note that choosing the relevant ancestor is left to the Policy designers; + /// an important part of Policy design is designing the right object level at + /// which to namespace this status. + /// + /// Note also that implementations MUST ONLY populate ancestor status for + /// the Ancestor resources they are responsible for. Implementations MUST + /// use the ControllerName field to uniquely identify the entries in this list + /// that they are responsible for. + /// + /// Note that to achieve this, the list of PolicyAncestorStatus structs + /// MUST be treated as a map with a composite key, made up of the AncestorRef + /// and ControllerName fields combined. + /// + /// A maximum of 16 ancestors will be represented in this list. An empty list + /// means the Policy is not relevant for any ancestors. + /// + /// If this slice is full, implementations MUST NOT add further entries. + /// Instead they MUST consider the policy unimplementable and signal that + /// on any related resources such as the ancestor that would be referenced + /// here. For example, if this list was full on BackendTLSPolicy, no + /// additional Gateways would be able to reference the Service targeted by + /// the BackendTLSPolicy. + pub ancestors: Vec, +} +/// PolicyAncestorStatus describes the status of a route with respect to an +/// associated Ancestor. +/// +/// Ancestors refer to objects that are either the Target of a policy or above it +/// in terms of object hierarchy. For example, if a policy targets a Service, the +/// Policy's Ancestors are, in order, the Service, the HTTPRoute, the Gateway, and +/// the GatewayClass. Almost always, in this hierarchy, the Gateway will be the most +/// useful object to place Policy status on, so we recommend that implementations +/// SHOULD use Gateway as the PolicyAncestorStatus object unless the designers +/// have a _very_ good reason otherwise. +/// +/// In the context of policy attachment, the Ancestor is used to distinguish which +/// resource results in a distinct application of this policy. For example, if a policy +/// targets a Service, it may have a distinct result per attached Gateway. +/// +/// Policies targeting the same resource may have different effects depending on the +/// ancestors of those resources. For example, different Gateways targeting the same +/// Service may have different capabilities, especially if they have different underlying +/// implementations. +/// +/// For example, in BackendTLSPolicy, the Policy attaches to a Service that is +/// used as a backend in a HTTPRoute that is itself attached to a Gateway. +/// In this case, the relevant object for status is the Gateway, and that is the +/// ancestor object referred to in this status. +/// +/// Note that a parent is also an ancestor, so for objects where the parent is the +/// relevant object for status, this struct SHOULD still be used. +/// +/// This struct is intended to be used in a slice that's effectively a map, +/// with a composite key made up of the AncestorRef and the ControllerName. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendTlsPolicyStatusAncestors { + /// AncestorRef corresponds with a ParentRef in the spec that this + /// PolicyAncestorStatus struct describes the status of. + #[serde(rename = "ancestorRef")] + pub ancestor_ref: ParentReference, + /// Conditions describes the status of the Policy with respect to the given Ancestor. + pub conditions: Vec, + /// ControllerName is a domain/path string that indicates the name of the + /// controller that wrote this status. This corresponds with the + /// controllerName field on GatewayClass. + /// + /// Example: "example.net/gateway-controller". + /// + /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are + /// valid Kubernetes names + /// ( + /// + /// Controllers MUST populate this field when writing status. Controllers should ensure that + /// entries to status populated with their ControllerName are cleaned up when they are no + /// longer necessary. + #[serde(rename = "controllerName")] + pub controller_name: String, +} diff --git a/gateway-api/src/standard/common.rs b/gateway-api/src/standard/common.rs new file mode 100644 index 0000000..7eb3f0c --- /dev/null +++ b/gateway-api/src/standard/common.rs @@ -0,0 +1,339 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum AllowedRoutesNamespacesFrom { + All, + Selector, + Same, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GRPCFilterType { + ResponseHeaderModifier, + RequestHeaderModifier, + RequestMirror, + ExtensionRef, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HTTPFilterType { + RequestHeaderModifier, + ResponseHeaderModifier, + RequestMirror, + RequestRedirect, + #[serde(rename = "URLRewrite")] + UrlRewrite, + ExtensionRef, + #[serde(rename = "CORS")] + Cors, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HeaderMatchType { + Exact, + RegularExpression, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RedirectStatusCode { + #[serde(rename = "301")] + r#_301, + #[serde(rename = "302")] + r#_302, + #[serde(rename = "303")] + r#_303, + #[serde(rename = "307")] + r#_307, + #[serde(rename = "308")] + r#_308, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RequestOperationType { + ReplaceFullPath, + ReplacePrefixMatch, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RequestRedirectScheme { + #[serde(rename = "http")] + Http, + #[serde(rename = "https")] + Https, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum TlsMode { + Terminate, + Passthrough, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum TlsValidationMode { + AllowValidOnly, + AllowInsecureFallback, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendObjectReference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ExtensionParametersReference { + pub group: String, + pub kind: String, + pub name: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayParametersRef { + pub group: String, + pub kind: String, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HTTPHeader { + pub name: String, + pub value: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Kind { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + pub kind: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct MatchExpressions { + pub key: String, + pub operator: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub values: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ParentReference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "sectionName" + )] + pub section_name: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Reference { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestMirrorFraction { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub denominator: Option, + pub numerator: i32, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendDefaultValidation { + #[serde(rename = "caCertificateRefs")] + pub ca_certificate_refs: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HeaderMatch { + pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + pub value: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HeaderModifier { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub add: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub remove: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub set: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerStatus { + #[serde(rename = "attachedRoutes")] + pub attached_routes: i32, + pub conditions: Vec, + pub name: String, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "supportedKinds" + )] + pub supported_kinds: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerTls { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "certificateRefs" + )] + pub certificate_refs: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub options: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct NamespaceSelector { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "matchExpressions" + )] + pub match_expressions: Option>, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "matchLabels" + )] + pub match_labels: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ParentRouteStatus { + pub conditions: Vec, + #[serde(rename = "controllerName")] + pub controller_name: String, + #[serde(rename = "parentRef")] + pub parent_ref: ParentReference, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestMirror { + #[serde(rename = "backendRef")] + pub backend_ref: BackendObjectReference, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub fraction: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub percent: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestRedirectPath { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "replaceFullPath" + )] + pub replace_full_path: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "replacePrefixMatch" + )] + pub replace_prefix_match: Option, + #[serde(rename = "type")] + pub r#type: RequestOperationType, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct AllowedRoutesNamespaces { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub from: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub selector: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct FilterRequestRedirect { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub scheme: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "statusCode" + )] + pub status_code: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GrpcRouteFilter { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + #[serde(rename = "type")] + pub r#type: GRPCFilterType, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteUrlRewrite { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RouteStatus { + pub parents: Vec, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct AllowedRoutes { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kinds: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespaces: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Listeners { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedRoutes" + )] + pub allowed_routes: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostname: Option, + pub name: String, + pub port: i32, + pub protocol: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tls: Option, +} diff --git a/gateway-api/src/standard/constants.rs b/gateway-api/src/standard/constants.rs new file mode 100644 index 0000000..bf2a178 --- /dev/null +++ b/gateway-api/src/standard/constants.rs @@ -0,0 +1,121 @@ +// WARNING: generated file - manual changes will be overriden + +#[derive(Debug, PartialEq, Eq)] +pub enum GatewayClassConditionType { + Accepted, +} +impl std::fmt::Display for GatewayClassConditionType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum GatewayClassConditionReason { + Accepted, + InvalidParameters, + Pending, + Unsupported, + Waiting, +} +impl std::fmt::Display for GatewayClassConditionReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum GatewayConditionType { + Programmed, + Accepted, + Ready, +} +impl std::fmt::Display for GatewayConditionType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum GatewayConditionReason { + Programmed, + Invalid, + NoResources, + AddressNotAssigned, + AddressNotUsable, + Accepted, + ListenersNotValid, + Pending, + UnsupportedAddress, + InvalidParameters, + Ready, + ListenersNotReady, +} +impl std::fmt::Display for GatewayConditionReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum ListenerConditionType { + Conflicted, + Accepted, + ResolvedRefs, + Programmed, + Ready, +} +impl std::fmt::Display for ListenerConditionType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum ListenerConditionReason { + HostnameConflict, + ProtocolConflict, + NoConflicts, + Accepted, + PortUnavailable, + UnsupportedProtocol, + ResolvedRefs, + InvalidCertificateRef, + InvalidRouteKinds, + RefNotPermitted, + Programmed, + Invalid, + Pending, + Ready, +} +impl std::fmt::Display for ListenerConditionReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum RouteConditionType { + Accepted, + ResolvedRefs, + PartiallyInvalid, +} +impl std::fmt::Display for RouteConditionType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +#[derive(Debug, PartialEq, Eq)] +pub enum RouteConditionReason { + Accepted, + NotAllowedByListeners, + NoMatchingListenerHostname, + NoMatchingParent, + UnsupportedValue, + Pending, + IncompatibleFilters, + ResolvedRefs, + RefNotPermitted, + InvalidKind, + BackendNotFound, + UnsupportedProtocol, +} +impl std::fmt::Display for RouteConditionReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} diff --git a/gateway-api/src/standard/enum_defaults.rs b/gateway-api/src/standard/enum_defaults.rs new file mode 100644 index 0000000..50c1dc2 --- /dev/null +++ b/gateway-api/src/standard/enum_defaults.rs @@ -0,0 +1,96 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +pub mod prelude { + + pub use super::super::backendtlspolicies::*; + pub use super::super::gatewayclasses::*; + pub use super::super::gateways::*; + pub use super::super::grpcroutes::*; + pub use super::super::httproutes::*; + pub use super::super::listenersets::*; + pub use super::super::referencegrants::*; + pub use super::super::tlsroutes::*; + + pub use super::super::common::*; +} +use prelude::*; +impl Default for AllowedRoutesNamespacesFrom { + fn default() -> Self { + AllowedRoutesNamespacesFrom::Same + } +} + +impl Default for BackendTlsPolicyValidationSubjectAltNamesType { + fn default() -> Self { + BackendTlsPolicyValidationSubjectAltNamesType::Hostname + } +} + +impl Default for GRPCFilterType { + fn default() -> Self { + GRPCFilterType::RequestHeaderModifier + } +} + +impl Default for GatewayAllowedListenersNamespacesFrom { + fn default() -> Self { + GatewayAllowedListenersNamespacesFrom::Same + } +} + +impl Default for HTTPFilterType { + fn default() -> Self { + HTTPFilterType::RequestHeaderModifier + } +} + +impl Default for HTTPMethodMatch { + fn default() -> Self { + HTTPMethodMatch::Get + } +} + +impl Default for HeaderMatchType { + fn default() -> Self { + HeaderMatchType::Exact + } +} + +impl Default for HttpRouteRulesMatchesPathType { + fn default() -> Self { + HttpRouteRulesMatchesPathType::Exact + } +} + +impl Default for RedirectStatusCode { + fn default() -> Self { + RedirectStatusCode::r#_301 + } +} + +impl Default for RequestOperationType { + fn default() -> Self { + RequestOperationType::ReplaceFullPath + } +} + +impl Default for RequestRedirectScheme { + fn default() -> Self { + RequestRedirectScheme::Https + } +} + +impl Default for TlsMode { + fn default() -> Self { + TlsMode::Terminate + } +} + +impl Default for TlsValidationMode { + fn default() -> Self { + TlsValidationMode::AllowValidOnly + } +} + +use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType; diff --git a/gateway-api/src/standard/gatewayclasses.rs b/gateway-api/src/standard/gatewayclasses.rs new file mode 100644 index 0000000..2c224a1 --- /dev/null +++ b/gateway-api/src/standard/gatewayclasses.rs @@ -0,0 +1,89 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of GatewayClass. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "GatewayClass", + plural = "gatewayclasses" +)] +#[kube(status = "GatewayClassStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct GatewayClassSpec { + /// ControllerName is the name of the controller that is managing Gateways of + /// this class. The value of this field MUST be a domain prefixed path. + /// + /// Example: "example.net/gateway-controller". + /// + /// This field is not mutable and cannot be empty. + /// + /// Support: Core + #[serde(rename = "controllerName")] + pub controller_name: String, + /// Description helps describe a GatewayClass with more details. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + /// ParametersRef is a reference to a resource that contains the configuration + /// parameters corresponding to the GatewayClass. This is optional if the + /// controller does not require any additional configuration. + /// + /// ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap, + /// or an implementation-specific custom resource. The resource can be + /// cluster-scoped or namespace-scoped. + /// + /// If the referent cannot be found, refers to an unsupported kind, or when + /// the data within that resource is malformed, the GatewayClass SHOULD be + /// rejected with the "Accepted" status condition set to "False" and an + /// "InvalidParameters" reason. + /// + /// A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, + /// the merging behavior is implementation specific. + /// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parametersRef" + )] + pub parameters_ref: Option, +} +/// Status defines the current state of GatewayClass. +/// +/// Implementations MUST populate status on all GatewayClass resources which +/// specify their controller name. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayClassStatus { + /// Conditions is the current status from the controller for + /// this GatewayClass. + /// + /// Controllers should prefer to publish conditions using values + /// of GatewayClassConditionType for the type of each Condition. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// SupportedFeatures is the set of features the GatewayClass support. + /// It MUST be sorted in ascending alphabetical order by the Name key. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "supportedFeatures" + )] + pub supported_features: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayClassStatusSupportedFeatures { + /// FeatureName is used to describe distinct features that are covered by + /// conformance tests. + pub name: String, +} diff --git a/gateway-api/src/standard/gateways.rs b/gateway-api/src/standard/gateways.rs new file mode 100644 index 0000000..8d967c5 --- /dev/null +++ b/gateway-api/src/standard/gateways.rs @@ -0,0 +1,526 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of Gateway. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "Gateway", + plural = "gateways" +)] +#[kube(namespaced)] +#[kube(status = "GatewayStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct GatewaySpec { + /// Addresses requested for this Gateway. This is optional and behavior can + /// depend on the implementation. If a value is set in the spec and the + /// requested address is invalid or unavailable, the implementation MUST + /// indicate this in an associated entry in GatewayStatus.Conditions. + /// + /// The Addresses field represents a request for the address(es) on the + /// "outside of the Gateway", that traffic bound for this Gateway will use. + /// This could be the IP address or hostname of an external load balancer or + /// other networking infrastructure, or some other address that traffic will + /// be sent to. + /// + /// If no Addresses are specified, the implementation MAY schedule the + /// Gateway in an implementation-specific manner, assigning an appropriate + /// set of Addresses. + /// + /// The implementation MUST bind all Listeners to every GatewayAddress that + /// it assigns to the Gateway and add a corresponding entry in + /// GatewayStatus.Addresses. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub addresses: Option>, + /// AllowedListeners defines which ListenerSets can be attached to this Gateway. + /// The default value is to allow no ListenerSets. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowedListeners" + )] + pub allowed_listeners: Option, + /// GatewayClassName used for this Gateway. This is the name of a + /// GatewayClass resource. + #[serde(rename = "gatewayClassName")] + pub gateway_class_name: String, + /// Infrastructure defines infrastructure level attributes about this Gateway instance. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub infrastructure: Option, + /// Listeners associated with this Gateway. Listeners define + /// logical endpoints that are bound on this Gateway's addresses. + /// At least one Listener MUST be specified. + /// + /// ## Distinct Listeners + /// + /// Each Listener in a set of Listeners (for example, in a single Gateway) + /// MUST be _distinct_, in that a traffic flow MUST be able to be assigned to + /// exactly one listener. (This section uses "set of Listeners" rather than + /// "Listeners in a single Gateway" because implementations MAY merge configuration + /// from multiple Gateways onto a single data plane, and these rules _also_ + /// apply in that case). + /// + /// Practically, this means that each listener in a set MUST have a unique + /// combination of Port, Protocol, and, if supported by the protocol, Hostname. + /// + /// Some combinations of port, protocol, and TLS settings are considered + /// Core support and MUST be supported by implementations based on the objects + /// they support: + /// + /// HTTPRoute + /// + /// 1. HTTPRoute, Port: 80, Protocol: HTTP + /// 2. HTTPRoute, Port: 443, Protocol: HTTPS, TLS Mode: Terminate, TLS keypair provided + /// + /// TLSRoute + /// + /// 1. TLSRoute, Port: 443, Protocol: TLS, TLS Mode: Passthrough + /// + /// "Distinct" Listeners have the following property: + /// + /// **The implementation can match inbound requests to a single distinct + /// Listener**. + /// + /// When multiple Listeners share values for fields (for + /// example, two Listeners with the same Port value), the implementation + /// can match requests to only one of the Listeners using other + /// Listener fields. + /// + /// When multiple listeners have the same value for the Protocol field, then + /// each of the Listeners with matching Protocol values MUST have different + /// values for other fields. + /// + /// The set of fields that MUST be different for a Listener differs per protocol. + /// The following rules define the rules for what fields MUST be considered for + /// Listeners to be distinct with each protocol currently defined in the + /// Gateway API spec. + /// + /// The set of listeners that all share a protocol value MUST have _different_ + /// values for _at least one_ of these fields to be distinct: + /// + /// * **HTTP, HTTPS, TLS**: Port, Hostname + /// * **TCP, UDP**: Port + /// + /// One **very** important rule to call out involves what happens when an + /// implementation: + /// + /// * Supports TCP protocol Listeners, as well as HTTP, HTTPS, or TLS protocol + /// Listeners, and + /// * sees HTTP, HTTPS, or TLS protocols with the same `port` as one with TCP + /// Protocol. + /// + /// In this case all the Listeners that share a port with the + /// TCP Listener are not distinct and so MUST NOT be accepted. + /// + /// If an implementation does not support TCP Protocol Listeners, then the + /// previous rule does not apply, and the TCP Listeners SHOULD NOT be + /// accepted. + /// + /// Note that the `tls` field is not used for determining if a listener is distinct, because + /// Listeners that _only_ differ on TLS config will still conflict in all cases. + /// + /// ### Listeners that are distinct only by Hostname + /// + /// When the Listeners are distinct based only on Hostname, inbound request + /// hostnames MUST match from the most specific to least specific Hostname + /// values to choose the correct Listener and its associated set of Routes. + /// + /// Exact matches MUST be processed before wildcard matches, and wildcard + /// matches MUST be processed before fallback (empty Hostname value) + /// matches. For example, `"foo.example.com"` takes precedence over + /// `"*.example.com"`, and `"*.example.com"` takes precedence over `""`. + /// + /// Additionally, if there are multiple wildcard entries, more specific + /// wildcard entries must be processed before less specific wildcard entries. + /// For example, `"*.foo.example.com"` takes precedence over `"*.example.com"`. + /// + /// The precise definition here is that the higher the number of dots in the + /// hostname to the right of the wildcard character, the higher the precedence. + /// + /// The wildcard character will match any number of characters _and dots_ to + /// the left, however, so `"*.example.com"` will match both + /// `"foo.bar.example.com"` _and_ `"bar.example.com"`. + /// + /// ## Handling indistinct Listeners + /// + /// If a set of Listeners contains Listeners that are not distinct, then those + /// Listeners are _Conflicted_, and the implementation MUST set the "Conflicted" + /// condition in the Listener Status to "True". + /// + /// The words "indistinct" and "conflicted" are considered equivalent for the + /// purpose of this documentation. + /// + /// Implementations MAY choose to accept a Gateway with some Conflicted + /// Listeners only if they only accept the partial Listener set that contains + /// no Conflicted Listeners. + /// + /// Specifically, an implementation MAY accept a partial Listener set subject to + /// the following rules: + /// + /// * The implementation MUST NOT pick one conflicting Listener as the winner. + /// ALL indistinct Listeners must not be accepted for processing. + /// * At least one distinct Listener MUST be present, or else the Gateway effectively + /// contains _no_ Listeners, and must be rejected from processing as a whole. + /// + /// The implementation MUST set a "ListenersNotValid" condition on the + /// Gateway Status when the Gateway contains Conflicted Listeners whether or + /// not they accept the Gateway. That Condition SHOULD clearly + /// indicate in the Message which Listeners are conflicted, and which are + /// Accepted. Additionally, the Listener status for those listeners SHOULD + /// indicate which Listeners are conflicted and not Accepted. + /// + /// ## General Listener behavior + /// + /// Note that, for all distinct Listeners, requests SHOULD match at most one Listener. + /// For example, if Listeners are defined for "foo.example.com" and "*.example.com", a + /// request to "foo.example.com" SHOULD only be routed using routes attached + /// to the "foo.example.com" Listener (and not the "*.example.com" Listener). + /// + /// This concept is known as "Listener Isolation", and it is an Extended feature + /// of Gateway API. Implementations that do not support Listener Isolation MUST + /// clearly document this, and MUST NOT claim support for the + /// `GatewayHTTPListenerIsolation` feature. + /// + /// Implementations that _do_ support Listener Isolation SHOULD claim support + /// for the Extended `GatewayHTTPListenerIsolation` feature and pass the associated + /// conformance tests. + /// + /// ## Compatible Listeners + /// + /// A Gateway's Listeners are considered _compatible_ if: + /// + /// 1. They are distinct. + /// 2. The implementation can serve them in compliance with the Addresses + /// requirement that all Listeners are available on all assigned + /// addresses. + /// + /// Compatible combinations in Extended support are expected to vary across + /// implementations. A combination that is compatible for one implementation + /// may not be compatible for another. + /// + /// For example, an implementation that cannot serve both TCP and UDP listeners + /// on the same address, or cannot mix HTTPS and generic TLS listens on the same port + /// would not consider those cases compatible, even though they are distinct. + /// + /// Implementations MAY merge separate Gateways onto a single set of + /// Addresses if all Listeners across all Gateways are compatible. + /// + /// In a future release the MinItems=1 requirement MAY be dropped. + /// + /// Support: Core + pub listeners: Vec, + /// TLS specifies frontend and backend tls configuration for entire gateway. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tls: Option, +} +/// GatewaySpecAddress describes an address that can be bound to a Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAddresses { + /// Type of the address. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// When a value is unspecified, an implementation SHOULD automatically + /// assign an address matching the requested type if possible. + /// + /// If an implementation does not support an empty value, they MUST set the + /// "Programmed" condition in status to False with a reason of "AddressNotAssigned". + /// + /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, +} +/// AllowedListeners defines which ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAllowedListeners { + /// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. + /// The default value is to allow no ListenerSets. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespaces: Option, +} +/// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAllowedListenersNamespaces { + /// From indicates where ListenerSets can attach to this Gateway. Possible + /// values are: + /// + /// * Same: Only ListenerSets in the same namespace may be attached to this Gateway. + /// * Selector: ListenerSets in namespaces selected by the selector may be attached to this Gateway. + /// * All: ListenerSets in all namespaces may be attached to this Gateway. + /// * None: Only listeners defined in the Gateway's spec are allowed + /// + /// The default value None + #[serde(default, skip_serializing_if = "Option::is_none")] + pub from: Option, + /// Selector must be specified when From is set to "Selector". In that case, + /// only ListenerSets in Namespaces matching this Selector will be selected by this + /// Gateway. This field is ignored for other values of "From". + #[serde(default, skip_serializing_if = "Option::is_none")] + pub selector: Option, +} +/// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. +/// The default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GatewayAllowedListenersNamespacesFrom { + All, + Selector, + Same, + None, +} +/// Infrastructure defines infrastructure level attributes about this Gateway instance. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayInfrastructure { + /// Annotations that SHOULD be applied to any resources created in response to this Gateway. + /// + /// For implementations creating other Kubernetes objects, this should be the `metadata.annotations` field on resources. + /// For other implementations, this refers to any relevant (implementation specific) "annotations" concepts. + /// + /// An implementation may chose to add additional implementation-specific annotations as they see fit. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub annotations: Option>, + /// Labels that SHOULD be applied to any resources created in response to this Gateway. + /// + /// For implementations creating other Kubernetes objects, this should be the `metadata.labels` field on resources. + /// For other implementations, this refers to any relevant (implementation specific) "labels" concepts. + /// + /// An implementation may chose to add additional implementation-specific labels as they see fit. + /// + /// If an implementation maps these labels to Pods, or any other resource that would need to be recreated when labels + /// change, it SHOULD clearly warn about this behavior in documentation. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub labels: Option>, + /// ParametersRef is a reference to a resource that contains the configuration + /// parameters corresponding to the Gateway. This is optional if the + /// controller does not require any additional configuration. + /// + /// This follows the same semantics as GatewayClass's `parametersRef`, but on a per-Gateway basis + /// + /// The Gateway's GatewayClass may provide its own `parametersRef`. When both are specified, + /// the merging behavior is implementation specific. + /// It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. + /// + /// If the referent cannot be found, refers to an unsupported kind, or when + /// the data within that resource is malformed, the Gateway SHOULD be + /// rejected with the "Accepted" status condition set to "False" and an + /// "InvalidParameters" reason. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parametersRef" + )] + pub parameters_ref: Option, +} +/// TLS specifies frontend and backend tls configuration for entire gateway. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTls { + /// Backend describes TLS configuration for gateway when connecting + /// to backends. + /// + /// Note that this contains only details for the Gateway as a TLS client, + /// and does _not_ imply behavior about how to choose which backend should + /// get a TLS connection. That is determined by the presence of a BackendTLSPolicy. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub backend: Option, + /// Frontend describes TLS config when client connects to Gateway. + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub frontend: Option, +} +/// Backend describes TLS configuration for gateway when connecting +/// to backends. +/// +/// Note that this contains only details for the Gateway as a TLS client, +/// and does _not_ imply behavior about how to choose which backend should +/// get a TLS connection. That is determined by the presence of a BackendTLSPolicy. +/// +/// Support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsBackend { + /// ClientCertificateRef references an object that contains a client certificate + /// and its associated private key. It can reference standard Kubernetes resources, + /// i.e., Secret, or implementation-specific custom resources. + /// + /// A ClientCertificateRef is considered invalid if: + /// + /// * It refers to a resource that cannot be resolved (e.g., the referenced resource + /// does not exist) or is misconfigured (e.g., a Secret does not contain the keys + /// named `tls.crt` and `tls.key`). In this case, the `ResolvedRefs` condition + /// on the Gateway MUST be set to False with the Reason `InvalidClientCertificateRef` + /// and the Message of the Condition MUST indicate why the reference is invalid. + /// + /// * It refers to a resource in another namespace UNLESS there is a ReferenceGrant + /// in the target namespace that allows the certificate to be attached. + /// If a ReferenceGrant does not allow this reference, the `ResolvedRefs` condition + /// on the Gateway MUST be set to False with the Reason `RefNotPermitted`. + /// + /// Implementations MAY choose to perform further validation of the certificate + /// content (e.g., checking expiry or enforcing specific formats). In such cases, + /// an implementation-specific Reason and Message MUST be set. + /// + /// Support: Core - Reference to a Kubernetes TLS Secret (with the type `kubernetes.io/tls`). + /// Support: Implementation-specific - Other resource kinds or Secrets with a + /// different type (e.g., `Opaque`). + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "clientCertificateRef" + )] + pub client_certificate_ref: Option, +} +/// Frontend describes TLS config when client connects to Gateway. +/// Support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontend { + /// Default specifies the default client certificate validation configuration + /// for all Listeners handling HTTPS traffic, unless a per-port configuration + /// is defined. + /// + /// support: Core + pub default: GatewayTlsFrontendDefault, + /// PerPort specifies tls configuration assigned per port. + /// Per port configuration is optional. Once set this configuration overrides + /// the default configuration for all Listeners handling HTTPS traffic + /// that match this port. + /// Each override port requires a unique TLS configuration. + /// + /// support: Core + #[serde(default, skip_serializing_if = "Option::is_none", rename = "perPort")] + pub per_port: Option>, +} +/// Default specifies the default client certificate validation configuration +/// for all Listeners handling HTTPS traffic, unless a per-port configuration +/// is defined. +/// +/// support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendDefault { + /// Validation holds configuration information for validating the frontend (client). + /// Setting this field will result in mutual authentication when connecting to the gateway. + /// In browsers this may result in a dialog appearing + /// that requests a user to specify the client certificate. + /// The maximum depth of a certificate chain accepted in verification is Implementation specific. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub validation: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendPerPort { + /// The Port indicates the Port Number to which the TLS configuration will be + /// applied. This configuration will be applied to all Listeners handling HTTPS + /// traffic that match this port. + /// + /// Support: Core + pub port: i32, + /// TLS store the configuration that will be applied to all Listeners handling + /// HTTPS traffic and matching given port. + /// + /// Support: Core + pub tls: GatewayTlsFrontendPerPortTls, +} +/// TLS store the configuration that will be applied to all Listeners handling +/// HTTPS traffic and matching given port. +/// +/// Support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendPerPortTls { + /// Validation holds configuration information for validating the frontend (client). + /// Setting this field will result in mutual authentication when connecting to the gateway. + /// In browsers this may result in a dialog appearing + /// that requests a user to specify the client certificate. + /// The maximum depth of a certificate chain accepted in verification is Implementation specific. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub validation: Option, +} +/// Status defines the current state of Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatus { + /// Addresses lists the network addresses that have been bound to the + /// Gateway. + /// + /// This list may differ from the addresses provided in the spec under some + /// conditions: + /// + /// * no addresses are specified, all addresses are dynamically assigned + /// * a combination of specified and dynamic addresses are assigned + /// * a specified address was unusable (e.g. already in use) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub addresses: Option>, + /// AttachedListenerSets represents the total number of ListenerSets that have been + /// successfully attached to this Gateway. + /// + /// A ListenerSet is successfully attached to a Gateway when all the following conditions are met: + /// - The ListenerSet is selected by the Gateway's AllowedListeners field + /// - The ListenerSet has a valid ParentRef selecting the Gateway + /// - The ListenerSet's status has the condition "Accepted: true" + /// + /// Uses for this field include troubleshooting AttachedListenerSets attachment and + /// measuring blast radius/impact of changes to a Gateway. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "attachedListenerSets" + )] + pub attached_listener_sets: Option, + /// Conditions describe the current conditions of the Gateway. + /// + /// Implementations should prefer to express Gateway conditions + /// using the `GatewayConditionType` and `GatewayConditionReason` + /// constants so that operators and tools can converge on a common + /// vocabulary to describe Gateway state. + /// + /// Known condition types are: + /// + /// * "Accepted" + /// * "Programmed" + /// * "Ready" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// Listeners provide status for each unique listener port defined in the Spec. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub listeners: Option>, +} +/// GatewayStatusAddress describes a network address that is bound to a Gateway. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatusAddresses { + /// Type of the address. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// Value of the address. The validity of the values will depend + /// on the type and support by the controller. + /// + /// Examples: `1.2.3.4`, `128::1`, `my-ip-address`. + pub value: String, +} diff --git a/gateway-api/src/standard/grpcroutes.rs b/gateway-api/src/standard/grpcroutes.rs new file mode 100644 index 0000000..5cb1d24 --- /dev/null +++ b/gateway-api/src/standard/grpcroutes.rs @@ -0,0 +1,383 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of GRPCRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "GRPCRoute", + plural = "grpcroutes" +)] +#[kube(namespaced)] +#[kube(status = "RouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct GrpcRouteSpec { + /// Hostnames defines a set of hostnames to match against the GRPC + /// Host header to select a GRPCRoute to process the request. This matches + /// the RFC 1123 definition of a hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label MUST appear by itself as the first label. + /// + /// If a hostname is specified by both the Listener and GRPCRoute, there + /// MUST be at least one intersecting hostname for the GRPCRoute to be + /// attached to the Listener. For example: + /// + /// * A Listener with `test.example.com` as the hostname matches GRPCRoutes + /// that have either not specified any hostnames, or have specified at + /// least one of `test.example.com` or `*.example.com`. + /// * A Listener with `*.example.com` as the hostname matches GRPCRoutes + /// that have either not specified any hostnames or have specified at least + /// one hostname that matches the Listener hostname. For example, + /// `test.example.com` and `*.example.com` would both match. On the other + /// hand, `example.com` and `test.example.net` would not match. + /// + /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted + /// as a suffix match. That means that a match for `*.example.com` would match + /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. + /// + /// If both the Listener and GRPCRoute have specified hostnames, any + /// GRPCRoute hostnames that do not match the Listener hostname MUST be + /// ignored. For example, if a Listener specified `*.example.com`, and the + /// GRPCRoute specified `test.example.com` and `test.example.net`, + /// `test.example.net` MUST NOT be considered for a match. + /// + /// If both the Listener and GRPCRoute have specified hostnames, and none + /// match with the criteria above, then the GRPCRoute MUST NOT be accepted by + /// the implementation. The implementation MUST raise an 'Accepted' Condition + /// with a status of `False` in the corresponding RouteParentStatus. + /// + /// If a Route (A) of type HTTPRoute or GRPCRoute is attached to a + /// Listener and that listener already has another Route (B) of the other + /// type attached and the intersection of the hostnames of A and B is + /// non-empty, then the implementation MUST accept exactly one of these two + /// routes, determined by the following criteria, in order: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// The rejected Route MUST raise an 'Accepted' condition with a status of + /// 'False' in the corresponding RouteParentStatus. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostnames: Option>, + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of GRPC matchers, filters and actions. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rules: Option>, +} +/// GRPCRouteRule defines the semantics for matching a gRPC request based on +/// conditions (matches), processing it (filters), and forwarding the request to +/// an API object (backendRefs). +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GrpcRouteRule { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. + /// + /// Failure behavior here depends on how many BackendRefs are specified and + /// how many are invalid. + /// + /// If *all* entries in BackendRefs are invalid, and there are also no filters + /// specified in this route rule, *all* traffic which matches this rule MUST + /// receive an `UNAVAILABLE` status. + /// + /// See the GRPCBackendRef definition for the rules about what makes a single + /// GRPCBackendRef invalid. + /// + /// When a GRPCBackendRef is invalid, `UNAVAILABLE` statuses MUST be returned for + /// requests that would have otherwise been routed to an invalid backend. If + /// multiple backends are specified, and some are invalid, the proportion of + /// requests that would otherwise have been routed to an invalid backend + /// MUST receive an `UNAVAILABLE` status. + /// + /// For example, if two backends are specified with equal weights, and one is + /// invalid, 50 percent of traffic MUST receive an `UNAVAILABLE` status. + /// Implementations may choose how that 50 percent is determined. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRefs" + )] + pub backend_refs: Option>, + /// Filters define the filters that are applied to requests that match + /// this rule. + /// + /// The effects of ordering of multiple behaviors are currently unspecified. + /// This can change in the future based on feedback during the alpha stage. + /// + /// Conformance-levels at this level are defined based on the type of filter: + /// + /// - ALL core filters MUST be supported by all implementations that support + /// GRPCRoute. + /// - Implementers are encouraged to support extended filters. + /// - Implementation-specific custom filters have no API guarantees across + /// implementations. + /// + /// Specifying the same filter multiple times is not supported unless explicitly + /// indicated in the filter. + /// + /// If an implementation cannot support a combination of filters, it must clearly + /// document that limitation. In cases where incompatible or unsupported + /// filters are specified and cause the `Accepted` condition to be set to status + /// `False`, implementations may use the `IncompatibleFilters` reason to specify + /// this configuration error. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Matches define conditions used for matching the rule against incoming + /// gRPC requests. Each match is independent, i.e. this rule will be matched + /// if **any** one of the matches is satisfied. + /// + /// For example, take the following matches configuration: + /// + /// ```text + /// matches: + /// - method: + /// service: foo.bar + /// headers: + /// values: + /// version: 2 + /// - method: + /// service: foo.bar.v2 + /// ``` + /// + /// For a request to match against this rule, it MUST satisfy + /// EITHER of the two conditions: + /// + /// - service of foo.bar AND contains the header `version: 2` + /// - service of foo.bar.v2 + /// + /// See the documentation for GRPCRouteMatch on how to specify multiple + /// match conditions to be ANDed together. + /// + /// If no matches are specified, the implementation MUST match every gRPC request. + /// + /// Proxy or Load Balancer routing configuration generated from GRPCRoutes + /// MUST prioritize rules based on the following criteria, continuing on + /// ties. Merging MUST not be done between GRPCRoutes and HTTPRoutes. + /// Precedence MUST be given to the rule with the largest number of: + /// + /// * Characters in a matching non-wildcard hostname. + /// * Characters in a matching hostname. + /// * Characters in a matching service. + /// * Characters in a matching method. + /// * Header matches. + /// + /// If ties still exist across multiple Routes, matching precedence MUST be + /// determined in order of the following criteria, continuing on ties: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// If ties still exist within the Route that has been given precedence, + /// matching precedence MUST be granted to the first matching rule meeting + /// the above criteria. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub matches: Option>, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} +/// GRPCBackendRef defines how a GRPCRoute forwards a gRPC request. +/// +/// Note that when a namespace different than the local namespace is specified, a +/// ReferenceGrant object is required in the referent namespace to allow that +/// namespace's owner to accept the reference. See the ReferenceGrant +/// documentation for details. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GRPCBackendReference { + /// Filters defined at this level MUST be executed if and only if the + /// request is being forwarded to the backend defined here. + /// + /// Support: Implementation-specific (For broader support of filters, use the + /// Filters field in GRPCRouteRule.) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Group is the group of the referent. For example, "gateway.networking.k8s.io". + /// When unspecified or empty string, core API group is inferred. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. For example + /// "Service". + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations SHOULD NOT + /// support ExternalName Services. + /// + /// Support: Core (Services with a type other than ExternalName) + /// + /// Support: Implementation-specific (Services with type ExternalName) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent. + pub name: String, + /// Namespace is the namespace of the backend. When unspecified, the local + /// namespace is inferred. + /// + /// Note that when a namespace different than the local namespace is specified, + /// a ReferenceGrant object is required in the referent namespace to allow that + /// namespace's owner to accept the reference. See the ReferenceGrant + /// documentation for details. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + /// Port specifies the destination port number to use for this resource. + /// Port is required when the referent is a Kubernetes Service. In this + /// case, the port number is the service port number, not the target port. + /// For other resources, destination port might be derived from the referent + /// resource or this field. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + /// Weight specifies the proportion of requests forwarded to the referenced + /// backend. This is computed as weight/(sum of all weights in this + /// BackendRefs list). For non-zero values, there may be some epsilon from + /// the exact proportion defined here depending on the precision an + /// implementation supports. Weight is not a percentage and the sum of + /// weights does not need to equal 100. + /// + /// If only one backend is specified and it has a weight greater than 0, 100% + /// of the traffic is forwarded to that backend. If weight is set to 0, no + /// traffic should be forwarded for this entry. If unspecified, weight + /// defaults to 1. + /// + /// Support for this field varies based on the context where used. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} +/// GRPCRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a gRPC request only if its service +/// is `foo` AND it contains the `version: v1` header: +/// +/// ```text +/// matches: +/// - method: +/// type: Exact +/// service: "foo" +/// - headers: +/// name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GrpcRouteMatch { + /// Headers specifies gRPC request header matchers. Multiple match values are + /// ANDed together, meaning, a request MUST match all the specified headers + /// to select the route. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub headers: Option>, + /// Method specifies a gRPC request service/method matcher. If this field is + /// not specified, all services and methods will match. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, +} +/// Method specifies a gRPC request service/method matcher. If this field is +/// not specified, all services and methods will match. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GRPCMethodMatch { + /// Value of the method to match against. If left empty or omitted, will + /// match all services. + /// + /// At least one of Service and Method MUST be a non-empty string. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, + /// Value of the service to match against. If left empty or omitted, will + /// match any service. + /// + /// At least one of Service and Method MUST be a non-empty string. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub service: Option, + /// Type specifies how to match against the service and/or method. + /// Support: Core (Exact with service and method specified) + /// + /// Support: Implementation-specific (Exact with method specified but no service specified) + /// + /// Support: Implementation-specific (RegularExpression) + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, +} diff --git a/gateway-api/src/standard/httproutes.rs b/gateway-api/src/standard/httproutes.rs new file mode 100644 index 0000000..165be1d --- /dev/null +++ b/gateway-api/src/standard/httproutes.rs @@ -0,0 +1,1240 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of HTTPRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "HTTPRoute", + plural = "httproutes" +)] +#[kube(namespaced)] +#[kube(status = "RouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct HttpRouteSpec { + /// Hostnames defines a set of hostnames that should match against the HTTP Host + /// header to select a HTTPRoute used to process the request. Implementations + /// MUST ignore any port value specified in the HTTP Host header while + /// performing a match and (absent of any applicable header modification + /// configuration) MUST forward this header unmodified to the backend. + /// + /// Valid values for Hostnames are determined by RFC 1123 definition of a + /// hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label must appear by itself as the first label. + /// + /// If a hostname is specified by both the Listener and HTTPRoute, there + /// must be at least one intersecting hostname for the HTTPRoute to be + /// attached to the Listener. For example: + /// + /// * A Listener with `test.example.com` as the hostname matches HTTPRoutes + /// that have either not specified any hostnames, or have specified at + /// least one of `test.example.com` or `*.example.com`. + /// * A Listener with `*.example.com` as the hostname matches HTTPRoutes + /// that have either not specified any hostnames or have specified at least + /// one hostname that matches the Listener hostname. For example, + /// `*.example.com`, `test.example.com`, and `foo.test.example.com` would + /// all match. On the other hand, `example.com` and `test.example.net` would + /// not match. + /// + /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted + /// as a suffix match. That means that a match for `*.example.com` would match + /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`. + /// + /// If both the Listener and HTTPRoute have specified hostnames, any + /// HTTPRoute hostnames that do not match the Listener hostname MUST be + /// ignored. For example, if a Listener specified `*.example.com`, and the + /// HTTPRoute specified `test.example.com` and `test.example.net`, + /// `test.example.net` must not be considered for a match. + /// + /// If both the Listener and HTTPRoute have specified hostnames, and none + /// match with the criteria above, then the HTTPRoute is not accepted. The + /// implementation must raise an 'Accepted' Condition with a status of + /// `False` in the corresponding RouteParentStatus. + /// + /// In the event that multiple HTTPRoutes specify intersecting hostnames (e.g. + /// overlapping wildcard matching and exact matching hostnames), precedence must + /// be given to rules from the HTTPRoute with the largest number of: + /// + /// * Characters in a matching non-wildcard hostname. + /// * Characters in a matching hostname. + /// + /// If ties exist across multiple Routes, the matching precedence rules for + /// HTTPRouteMatches takes over. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hostnames: Option>, + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of HTTP matchers, filters and actions. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rules: Option>, +} +/// HTTPRouteRule defines semantics for matching an HTTP request based on +/// conditions (matches), processing it (filters), and forwarding the request to +/// an API object (backendRefs). +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRule { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. + /// + /// Failure behavior here depends on how many BackendRefs are specified and + /// how many are invalid. + /// + /// If *all* entries in BackendRefs are invalid, and there are also no filters + /// specified in this route rule, *all* traffic which matches this rule MUST + /// receive a 500 status code. + /// + /// See the HTTPBackendRef definition for the rules about what makes a single + /// HTTPBackendRef invalid. + /// + /// When a HTTPBackendRef is invalid, 500 status codes MUST be returned for + /// requests that would have otherwise been routed to an invalid backend. If + /// multiple backends are specified, and some are invalid, the proportion of + /// requests that would otherwise have been routed to an invalid backend + /// MUST receive a 500 status code. + /// + /// For example, if two backends are specified with equal weights, and one is + /// invalid, 50 percent of traffic must receive a 500. Implementations may + /// choose how that 50 percent is determined. + /// + /// When a HTTPBackendRef refers to a Service that has no ready endpoints, + /// implementations SHOULD return a 503 for requests to that backend instead. + /// If an implementation chooses to do this, all of the above rules for 500 responses + /// MUST also apply for responses that return a 503. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRefs" + )] + pub backend_refs: Option>, + /// Filters define the filters that are applied to requests that match + /// this rule. + /// + /// Wherever possible, implementations SHOULD implement filters in the order + /// they are specified. + /// + /// Implementations MAY choose to implement this ordering strictly, rejecting + /// any combination or order of filters that cannot be supported. If implementations + /// choose a strict interpretation of filter ordering, they MUST clearly document + /// that behavior. + /// + /// To reject an invalid combination or order of filters, implementations SHOULD + /// consider the Route Rules with this configuration invalid. If all Route Rules + /// in a Route are invalid, the entire Route would be considered invalid. If only + /// a portion of Route Rules are invalid, implementations MUST set the + /// "PartiallyInvalid" condition for the Route. + /// + /// Conformance-levels at this level are defined based on the type of filter: + /// + /// - ALL core filters MUST be supported by all implementations. + /// - Implementers are encouraged to support extended filters. + /// - Implementation-specific custom filters have no API guarantees across + /// implementations. + /// + /// Specifying the same filter multiple times is not supported unless explicitly + /// indicated in the filter. + /// + /// All filters are expected to be compatible with each other except for the + /// URLRewrite and RequestRedirect filters, which may not be combined. If an + /// implementation cannot support other combinations of filters, they must clearly + /// document that limitation. In cases where incompatible or unsupported + /// filters are specified and cause the `Accepted` condition to be set to status + /// `False`, implementations may use the `IncompatibleFilters` reason to specify + /// this configuration error. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Matches define conditions used for matching the rule against incoming + /// HTTP requests. Each match is independent, i.e. this rule will be matched + /// if **any** one of the matches is satisfied. + /// + /// For example, take the following matches configuration: + /// + /// ```text + /// matches: + /// - path: + /// value: "/foo" + /// headers: + /// - name: "version" + /// value: "v2" + /// - path: + /// value: "/v2/foo" + /// ``` + /// + /// For a request to match against this rule, a request must satisfy + /// EITHER of the two conditions: + /// + /// - path prefixed with `/foo` AND contains the header `version: v2` + /// - path prefix of `/v2/foo` + /// + /// See the documentation for HTTPRouteMatch on how to specify multiple + /// match conditions that should be ANDed together. + /// + /// If no matches are specified, the default is a prefix + /// path match on "/", which has the effect of matching every + /// HTTP request. + /// + /// Proxy or Load Balancer routing configuration generated from HTTPRoutes + /// MUST prioritize matches based on the following criteria, continuing on + /// ties. Across all rules specified on applicable Routes, precedence must be + /// given to the match having: + /// + /// * "Exact" path match. + /// * "Prefix" path match with largest number of characters. + /// * Method match. + /// * Largest number of header matches. + /// * Largest number of query param matches. + /// + /// Note: The precedence of RegularExpression path matches are implementation-specific. + /// + /// If ties still exist across multiple Routes, matching precedence MUST be + /// determined in order of the following criteria, continuing on ties: + /// + /// * The oldest Route based on creation timestamp. + /// * The Route appearing first in alphabetical order by + /// "{namespace}/{name}". + /// + /// If ties still exist within an HTTPRoute, matching precedence MUST be granted + /// to the FIRST matching rule (in list order) with a match meeting the above + /// criteria. + /// + /// When no rules matching a request have been successfully attached to the + /// parent a request is coming from, a HTTP 404 status code MUST be returned. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub matches: Option>, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + /// Timeouts defines the timeouts that can be configured for an HTTP request. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub timeouts: Option, +} +/// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. +/// +/// Note that when a namespace different than the local namespace is specified, a +/// ReferenceGrant object is required in the referent namespace to allow that +/// namespace's owner to accept the reference. See the ReferenceGrant +/// documentation for details. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HTTPBackendReference { + /// Filters defined at this level should be executed if and only if the + /// request is being forwarded to the backend defined here. + /// + /// Support: Implementation-specific (For broader support of filters, use the + /// Filters field in HTTPRouteRule.) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub filters: Option>, + /// Group is the group of the referent. For example, "gateway.networking.k8s.io". + /// When unspecified or empty string, core API group is inferred. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. For example + /// "Service". + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations SHOULD NOT + /// support ExternalName Services. + /// + /// Support: Core (Services with a type other than ExternalName) + /// + /// Support: Implementation-specific (Services with type ExternalName) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent. + pub name: String, + /// Namespace is the namespace of the backend. When unspecified, the local + /// namespace is inferred. + /// + /// Note that when a namespace different than the local namespace is specified, + /// a ReferenceGrant object is required in the referent namespace to allow that + /// namespace's owner to accept the reference. See the ReferenceGrant + /// documentation for details. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + /// Port specifies the destination port number to use for this resource. + /// Port is required when the referent is a Kubernetes Service. In this + /// case, the port number is the service port number, not the target port. + /// For other resources, destination port might be derived from the referent + /// resource or this field. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + /// Weight specifies the proportion of requests forwarded to the referenced + /// backend. This is computed as weight/(sum of all weights in this + /// BackendRefs list). For non-zero values, there may be some epsilon from + /// the exact proportion defined here depending on the precision an + /// implementation supports. Weight is not a percentage and the sum of + /// weights does not need to equal 100. + /// + /// If only one backend is specified and it has a weight greater than 0, 100% + /// of the traffic is forwarded to that backend. If weight is set to 0, no + /// traffic should be forwarded for this entry. If unspecified, weight + /// defaults to 1. + /// + /// Support for this field varies based on the context where used. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} +/// HTTPRouteFilter defines processing steps that must be completed during the +/// request or response lifecycle. HTTPRouteFilters are meant as an extension +/// point to express processing that may be done in Gateway implementations. Some +/// examples include request or response modification, implementing +/// authentication strategies, rate-limiting, and traffic shaping. API +/// guarantee/conformance is defined based on the type of the filter. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteBackendFilter { + /// CORS defines a schema for a filter that responds to the + /// cross-origin request based on HTTP response header. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cors: Option, + /// ExtensionRef is an optional, implementation-specific extension to the + /// "filter" behavior. For example, resource "myroutefilter" in group + /// "networking.example.net"). ExtensionRef MUST NOT be used for core and + /// extended filters. + /// + /// This filter can be used multiple times within the same rule. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + /// RequestHeaderModifier defines a schema for a filter that modifies request + /// headers. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + /// RequestMirror defines a schema for a filter that mirrors requests. + /// Requests are sent to the specified destination, but responses from + /// that destination are ignored. + /// + /// This filter can be used multiple times within the same rule. Note that + /// not all implementations will be able to support mirroring to multiple + /// backends. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + /// RequestRedirect defines a schema for a filter that responds to the + /// request with an HTTP redirection. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestRedirect" + )] + pub request_redirect: Option, + /// ResponseHeaderModifier defines a schema for a filter that modifies response + /// headers. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + /// Type identifies the type of filter to apply. As with other API fields, + /// types are classified into three conformance levels: + /// + /// - Core: Filter types and their corresponding configuration defined by + /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All + /// implementations must support core filters. + /// + /// - Extended: Filter types and their corresponding configuration defined by + /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers + /// are encouraged to support extended filters. + /// + /// - Implementation-specific: Filters that are defined and supported by + /// specific vendors. + /// In the future, filters showing convergence in behavior across multiple + /// implementations will be considered for inclusion in extended or core + /// conformance levels. Filter-specific configuration for such filters + /// is specified using the ExtensionRef field. `Type` should be set to + /// "ExtensionRef" for custom filters. + /// + /// Implementers are encouraged to define custom implementation types to + /// extend the core API with implementation-specific behavior. + /// + /// If a reference to a custom filter type cannot be resolved, the filter + /// MUST NOT be skipped. Instead, requests that would have been processed by + /// that filter MUST receive a HTTP error response. + /// + /// Note that values may be added to this enum, implementations + /// must ensure that unknown values will not cause a crash. + /// + /// Unknown values here must result in the implementation setting the + /// Accepted Condition for the Route to `status: False`, with a + /// Reason of `UnsupportedValue`. + #[serde(rename = "type")] + pub r#type: HTTPFilterType, + /// URLRewrite defines a schema for a filter that modifies a request during forwarding. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "urlRewrite" + )] + pub url_rewrite: Option, +} +/// CORS defines a schema for a filter that responds to the +/// cross-origin request based on HTTP response header. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesBackendRefsFiltersCors { + /// AllowCredentials indicates whether the actual cross-origin request allows + /// to include credentials. + /// + /// When set to true, the gateway will include the `Access-Control-Allow-Credentials` + /// response header with value true (case-sensitive). + /// + /// When set to false or omitted the gateway will omit the header + /// `Access-Control-Allow-Credentials` entirely (this is the standard CORS + /// behavior). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowCredentials" + )] + pub allow_credentials: Option, + /// AllowHeaders indicates which HTTP request headers are supported for + /// accessing the requested resource. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Allow-Headers` + /// response header are separated by a comma (","). + /// + /// When the `AllowHeaders` field is configured with one or more headers, the + /// gateway must return the `Access-Control-Allow-Headers` response header + /// which value is present in the `AllowHeaders` field. + /// + /// If any header name in the `Access-Control-Request-Headers` request header + /// is not included in the list of header names specified by the response + /// header `Access-Control-Allow-Headers`, it will present an error on the + /// client side. + /// + /// If any header name in the `Access-Control-Allow-Headers` response header + /// does not recognize by the client, it will also occur an error on the + /// client side. + /// + /// A wildcard indicates that the requests with all HTTP headers are allowed. + /// If config contains the wildcard "*" in allowHeaders and the request is + /// not credentialed, the `Access-Control-Allow-Headers` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Headers from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Headers` response header. When + /// also the `AllowCredentials` field is true and `AllowHeaders` field + /// is specified with the `*` wildcard, the gateway must specify one or more + /// HTTP headers in the value of the `Access-Control-Allow-Headers` response + /// header. The value of the header `Access-Control-Allow-Headers` is same as + /// the `Access-Control-Request-Headers` header provided by the client. If + /// the header `Access-Control-Request-Headers` is not included in the + /// request, the gateway will omit the `Access-Control-Allow-Headers` + /// response header, instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowHeaders" + )] + pub allow_headers: Option>, + /// AllowMethods indicates which HTTP methods are supported for accessing the + /// requested resource. + /// + /// Valid values are any method defined by RFC9110, along with the special + /// value `*`, which represents all HTTP methods are allowed. + /// + /// Method names are case-sensitive, so these values are also case-sensitive. + /// (See + /// + /// Multiple method names in the value of the `Access-Control-Allow-Methods` + /// response header are separated by a comma (","). + /// + /// A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`. + /// (See The + /// CORS-safelisted methods are always allowed, regardless of whether they + /// are specified in the `AllowMethods` field. + /// + /// When the `AllowMethods` field is configured with one or more methods, the + /// gateway must return the `Access-Control-Allow-Methods` response header + /// which value is present in the `AllowMethods` field. + /// + /// If the HTTP method of the `Access-Control-Request-Method` request header + /// is not included in the list of methods specified by the response header + /// `Access-Control-Allow-Methods`, it will present an error on the client + /// side. + /// + /// If config contains the wildcard "*" in allowMethods and the request is + /// not credentialed, the `Access-Control-Allow-Methods` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Method from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Methods` response header. When + /// also the `AllowCredentials` field is true and `AllowMethods` field + /// specified with the `*` wildcard, the gateway must specify one HTTP method + /// in the value of the Access-Control-Allow-Methods response header. The + /// value of the header `Access-Control-Allow-Methods` is same as the + /// `Access-Control-Request-Method` header provided by the client. If the + /// header `Access-Control-Request-Method` is not included in the request, + /// the gateway will omit the `Access-Control-Allow-Methods` response header, + /// instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowMethods" + )] + pub allow_methods: Option>, + /// AllowOrigins indicates whether the response can be shared with requested + /// resource from the given `Origin`. + /// + /// The `Origin` consists of a scheme and a host, with an optional port, and + /// takes the form `://(:)`. + /// + /// Valid values for scheme are: `http` and `https`. + /// + /// Valid values for port are any integer between 1 and 65535 (the list of + /// available TCP/UDP ports). Note that, if not included, port `80` is + /// assumed for `http` scheme origins, and port `443` is assumed for `https` + /// origins. This may affect origin matching. + /// + /// The host part of the origin may contain the wildcard character `*`. These + /// wildcard characters behave as follows: + /// + /// * `*` is a greedy match to the _left_, including any number of + /// DNS labels to the left of its position. This also means that + /// `*` will include any number of period `.` characters to the + /// left of its position. + /// * A wildcard by itself matches all hosts. + /// + /// An origin value that includes _only_ the `*` character indicates requests + /// from all `Origin`s are allowed. + /// + /// When the `AllowOrigins` field is configured with multiple origins, it + /// means the server supports clients from multiple origins. If the request + /// `Origin` matches the configured allowed origins, the gateway must return + /// the given `Origin` and sets value of the header + /// `Access-Control-Allow-Origin` same as the `Origin` header provided by the + /// client. + /// + /// The status code of a successful response to a "preflight" request is + /// always an OK status (i.e., 204 or 200). + /// + /// If the request `Origin` does not match the configured allowed origins, + /// the gateway returns 204/200 response but doesn't set the relevant + /// cross-origin response headers. Alternatively, the gateway responds with + /// 403 status to the "preflight" request is denied, coupled with omitting + /// the CORS headers. The cross-origin request fails on the client side. + /// Therefore, the client doesn't attempt the actual cross-origin request. + /// + /// Conversely, if the request `Origin` matches one of the configured + /// allowed origins, the gateway sets the response header + /// `Access-Control-Allow-Origin` to the same value as the `Origin` + /// header provided by the client. + /// + /// When config has the wildcard ("*") in allowOrigins, and the request + /// is not credentialed (e.g., it is a preflight request), the + /// `Access-Control-Allow-Origin` response header either contains the + /// wildcard as well or the Origin from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Origin` response header. When + /// also the `AllowCredentials` field is true and `AllowOrigins` field + /// specified with the `*` wildcard, the gateway must return a single origin + /// in the value of the `Access-Control-Allow-Origin` response header, + /// instead of specifying the `*` wildcard. The value of the header + /// `Access-Control-Allow-Origin` is same as the `Origin` header provided by + /// the client. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowOrigins" + )] + pub allow_origins: Option>, + /// ExposeHeaders indicates which HTTP response headers can be exposed + /// to client-side scripts in response to a cross-origin request. + /// + /// A CORS-safelisted response header is an HTTP header in a CORS response + /// that it is considered safe to expose to the client scripts. + /// The CORS-safelisted response headers include the following headers: + /// `Cache-Control` + /// `Content-Language` + /// `Content-Length` + /// `Content-Type` + /// `Expires` + /// `Last-Modified` + /// `Pragma` + /// (See + /// The CORS-safelisted response headers are exposed to client by default. + /// + /// When an HTTP header name is specified using the `ExposeHeaders` field, + /// this additional header will be exposed as part of the response to the + /// client. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Expose-Headers` + /// response header are separated by a comma (","). + /// + /// A wildcard indicates that the responses with all HTTP headers are exposed + /// to clients. The `Access-Control-Expose-Headers` response header can only + /// use `*` wildcard as value when the request is not credentialed. + /// + /// When the `exposeHeaders` config field contains the "*" wildcard and + /// the request is credentialed, the gateway cannot use the `*` wildcard in + /// the `Access-Control-Expose-Headers` response header. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "exposeHeaders" + )] + pub expose_headers: Option>, + /// MaxAge indicates the duration (in seconds) for the client to cache the + /// results of a "preflight" request. + /// + /// The information provided by the `Access-Control-Allow-Methods` and + /// `Access-Control-Allow-Headers` response headers can be cached by the + /// client until the time specified by `Access-Control-Max-Age` elapses. + /// + /// The default value of `Access-Control-Max-Age` response header is 5 + /// (seconds). + /// + /// When the `MaxAge` field is unspecified, the gateway sets the response + /// header "Access-Control-Max-Age: 5" by default. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] + pub max_age: Option, +} +/// HTTPRouteFilter defines processing steps that must be completed during the +/// request or response lifecycle. HTTPRouteFilters are meant as an extension +/// point to express processing that may be done in Gateway implementations. Some +/// examples include request or response modification, implementing +/// authentication strategies, rate-limiting, and traffic shaping. API +/// guarantee/conformance is defined based on the type of the filter. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteFilter { + /// CORS defines a schema for a filter that responds to the + /// cross-origin request based on HTTP response header. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cors: Option, + /// ExtensionRef is an optional, implementation-specific extension to the + /// "filter" behavior. For example, resource "myroutefilter" in group + /// "networking.example.net"). ExtensionRef MUST NOT be used for core and + /// extended filters. + /// + /// This filter can be used multiple times within the same rule. + /// + /// Support: Implementation-specific + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "extensionRef" + )] + pub extension_ref: Option, + /// RequestHeaderModifier defines a schema for a filter that modifies request + /// headers. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestHeaderModifier" + )] + pub request_header_modifier: Option, + /// RequestMirror defines a schema for a filter that mirrors requests. + /// Requests are sent to the specified destination, but responses from + /// that destination are ignored. + /// + /// This filter can be used multiple times within the same rule. Note that + /// not all implementations will be able to support mirroring to multiple + /// backends. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestMirror" + )] + pub request_mirror: Option, + /// RequestRedirect defines a schema for a filter that responds to the + /// request with an HTTP redirection. + /// + /// Support: Core + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "requestRedirect" + )] + pub request_redirect: Option, + /// ResponseHeaderModifier defines a schema for a filter that modifies response + /// headers. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + /// Type identifies the type of filter to apply. As with other API fields, + /// types are classified into three conformance levels: + /// + /// - Core: Filter types and their corresponding configuration defined by + /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All + /// implementations must support core filters. + /// + /// - Extended: Filter types and their corresponding configuration defined by + /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers + /// are encouraged to support extended filters. + /// + /// - Implementation-specific: Filters that are defined and supported by + /// specific vendors. + /// In the future, filters showing convergence in behavior across multiple + /// implementations will be considered for inclusion in extended or core + /// conformance levels. Filter-specific configuration for such filters + /// is specified using the ExtensionRef field. `Type` should be set to + /// "ExtensionRef" for custom filters. + /// + /// Implementers are encouraged to define custom implementation types to + /// extend the core API with implementation-specific behavior. + /// + /// If a reference to a custom filter type cannot be resolved, the filter + /// MUST NOT be skipped. Instead, requests that would have been processed by + /// that filter MUST receive a HTTP error response. + /// + /// Note that values may be added to this enum, implementations + /// must ensure that unknown values will not cause a crash. + /// + /// Unknown values here must result in the implementation setting the + /// Accepted Condition for the Route to `status: False`, with a + /// Reason of `UnsupportedValue`. + #[serde(rename = "type")] + pub r#type: HTTPFilterType, + /// URLRewrite defines a schema for a filter that modifies a request during forwarding. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "urlRewrite" + )] + pub url_rewrite: Option, +} +/// CORS defines a schema for a filter that responds to the +/// cross-origin request based on HTTP response header. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesFiltersCors { + /// AllowCredentials indicates whether the actual cross-origin request allows + /// to include credentials. + /// + /// When set to true, the gateway will include the `Access-Control-Allow-Credentials` + /// response header with value true (case-sensitive). + /// + /// When set to false or omitted the gateway will omit the header + /// `Access-Control-Allow-Credentials` entirely (this is the standard CORS + /// behavior). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowCredentials" + )] + pub allow_credentials: Option, + /// AllowHeaders indicates which HTTP request headers are supported for + /// accessing the requested resource. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Allow-Headers` + /// response header are separated by a comma (","). + /// + /// When the `AllowHeaders` field is configured with one or more headers, the + /// gateway must return the `Access-Control-Allow-Headers` response header + /// which value is present in the `AllowHeaders` field. + /// + /// If any header name in the `Access-Control-Request-Headers` request header + /// is not included in the list of header names specified by the response + /// header `Access-Control-Allow-Headers`, it will present an error on the + /// client side. + /// + /// If any header name in the `Access-Control-Allow-Headers` response header + /// does not recognize by the client, it will also occur an error on the + /// client side. + /// + /// A wildcard indicates that the requests with all HTTP headers are allowed. + /// If config contains the wildcard "*" in allowHeaders and the request is + /// not credentialed, the `Access-Control-Allow-Headers` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Headers from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Headers` response header. When + /// also the `AllowCredentials` field is true and `AllowHeaders` field + /// is specified with the `*` wildcard, the gateway must specify one or more + /// HTTP headers in the value of the `Access-Control-Allow-Headers` response + /// header. The value of the header `Access-Control-Allow-Headers` is same as + /// the `Access-Control-Request-Headers` header provided by the client. If + /// the header `Access-Control-Request-Headers` is not included in the + /// request, the gateway will omit the `Access-Control-Allow-Headers` + /// response header, instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowHeaders" + )] + pub allow_headers: Option>, + /// AllowMethods indicates which HTTP methods are supported for accessing the + /// requested resource. + /// + /// Valid values are any method defined by RFC9110, along with the special + /// value `*`, which represents all HTTP methods are allowed. + /// + /// Method names are case-sensitive, so these values are also case-sensitive. + /// (See + /// + /// Multiple method names in the value of the `Access-Control-Allow-Methods` + /// response header are separated by a comma (","). + /// + /// A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`. + /// (See The + /// CORS-safelisted methods are always allowed, regardless of whether they + /// are specified in the `AllowMethods` field. + /// + /// When the `AllowMethods` field is configured with one or more methods, the + /// gateway must return the `Access-Control-Allow-Methods` response header + /// which value is present in the `AllowMethods` field. + /// + /// If the HTTP method of the `Access-Control-Request-Method` request header + /// is not included in the list of methods specified by the response header + /// `Access-Control-Allow-Methods`, it will present an error on the client + /// side. + /// + /// If config contains the wildcard "*" in allowMethods and the request is + /// not credentialed, the `Access-Control-Allow-Methods` response header + /// can either use the `*` wildcard or the value of + /// Access-Control-Request-Method from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Methods` response header. When + /// also the `AllowCredentials` field is true and `AllowMethods` field + /// specified with the `*` wildcard, the gateway must specify one HTTP method + /// in the value of the Access-Control-Allow-Methods response header. The + /// value of the header `Access-Control-Allow-Methods` is same as the + /// `Access-Control-Request-Method` header provided by the client. If the + /// header `Access-Control-Request-Method` is not included in the request, + /// the gateway will omit the `Access-Control-Allow-Methods` response header, + /// instead of specifying the `*` wildcard. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowMethods" + )] + pub allow_methods: Option>, + /// AllowOrigins indicates whether the response can be shared with requested + /// resource from the given `Origin`. + /// + /// The `Origin` consists of a scheme and a host, with an optional port, and + /// takes the form `://(:)`. + /// + /// Valid values for scheme are: `http` and `https`. + /// + /// Valid values for port are any integer between 1 and 65535 (the list of + /// available TCP/UDP ports). Note that, if not included, port `80` is + /// assumed for `http` scheme origins, and port `443` is assumed for `https` + /// origins. This may affect origin matching. + /// + /// The host part of the origin may contain the wildcard character `*`. These + /// wildcard characters behave as follows: + /// + /// * `*` is a greedy match to the _left_, including any number of + /// DNS labels to the left of its position. This also means that + /// `*` will include any number of period `.` characters to the + /// left of its position. + /// * A wildcard by itself matches all hosts. + /// + /// An origin value that includes _only_ the `*` character indicates requests + /// from all `Origin`s are allowed. + /// + /// When the `AllowOrigins` field is configured with multiple origins, it + /// means the server supports clients from multiple origins. If the request + /// `Origin` matches the configured allowed origins, the gateway must return + /// the given `Origin` and sets value of the header + /// `Access-Control-Allow-Origin` same as the `Origin` header provided by the + /// client. + /// + /// The status code of a successful response to a "preflight" request is + /// always an OK status (i.e., 204 or 200). + /// + /// If the request `Origin` does not match the configured allowed origins, + /// the gateway returns 204/200 response but doesn't set the relevant + /// cross-origin response headers. Alternatively, the gateway responds with + /// 403 status to the "preflight" request is denied, coupled with omitting + /// the CORS headers. The cross-origin request fails on the client side. + /// Therefore, the client doesn't attempt the actual cross-origin request. + /// + /// Conversely, if the request `Origin` matches one of the configured + /// allowed origins, the gateway sets the response header + /// `Access-Control-Allow-Origin` to the same value as the `Origin` + /// header provided by the client. + /// + /// When config has the wildcard ("*") in allowOrigins, and the request + /// is not credentialed (e.g., it is a preflight request), the + /// `Access-Control-Allow-Origin` response header either contains the + /// wildcard as well or the Origin from the request. + /// + /// When the request is credentialed, the gateway must not specify the `*` + /// wildcard in the `Access-Control-Allow-Origin` response header. When + /// also the `AllowCredentials` field is true and `AllowOrigins` field + /// specified with the `*` wildcard, the gateway must return a single origin + /// in the value of the `Access-Control-Allow-Origin` response header, + /// instead of specifying the `*` wildcard. The value of the header + /// `Access-Control-Allow-Origin` is same as the `Origin` header provided by + /// the client. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "allowOrigins" + )] + pub allow_origins: Option>, + /// ExposeHeaders indicates which HTTP response headers can be exposed + /// to client-side scripts in response to a cross-origin request. + /// + /// A CORS-safelisted response header is an HTTP header in a CORS response + /// that it is considered safe to expose to the client scripts. + /// The CORS-safelisted response headers include the following headers: + /// `Cache-Control` + /// `Content-Language` + /// `Content-Length` + /// `Content-Type` + /// `Expires` + /// `Last-Modified` + /// `Pragma` + /// (See + /// The CORS-safelisted response headers are exposed to client by default. + /// + /// When an HTTP header name is specified using the `ExposeHeaders` field, + /// this additional header will be exposed as part of the response to the + /// client. + /// + /// Header names are not case-sensitive. + /// + /// Multiple header names in the value of the `Access-Control-Expose-Headers` + /// response header are separated by a comma (","). + /// + /// A wildcard indicates that the responses with all HTTP headers are exposed + /// to clients. The `Access-Control-Expose-Headers` response header can only + /// use `*` wildcard as value when the request is not credentialed. + /// + /// When the `exposeHeaders` config field contains the "*" wildcard and + /// the request is credentialed, the gateway cannot use the `*` wildcard in + /// the `Access-Control-Expose-Headers` response header. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "exposeHeaders" + )] + pub expose_headers: Option>, + /// MaxAge indicates the duration (in seconds) for the client to cache the + /// results of a "preflight" request. + /// + /// The information provided by the `Access-Control-Allow-Methods` and + /// `Access-Control-Allow-Headers` response headers can be cached by the + /// client until the time specified by `Access-Control-Max-Age` elapses. + /// + /// The default value of `Access-Control-Max-Age` response header is 5 + /// (seconds). + /// + /// When the `MaxAge` field is unspecified, the gateway sets the response + /// header "Access-Control-Max-Age: 5" by default. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] + pub max_age: Option, +} +/// HTTPRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a HTTP request only if its path +/// starts with `/foo` AND it contains the `version: v1` header: +/// +/// ```text +/// match: +/// +/// path: +/// value: "/foo" +/// headers: +/// - name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RouteMatch { + /// Headers specifies HTTP request header matchers. Multiple match values are + /// ANDed together, meaning, a request must match all the specified headers + /// to select the route. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub headers: Option>, + /// Method specifies HTTP method matcher. + /// When specified, this route will be matched only if the request has the + /// specified method. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub method: Option, + /// Path specifies a HTTP request path matcher. If this field is not + /// specified, a default prefix match on the "/" path is provided. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, + /// QueryParams specifies HTTP query parameter matchers. Multiple match + /// values are ANDed together, meaning, a request must match all the + /// specified query parameters to select the route. + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "queryParams" + )] + pub query_params: Option>, +} +/// HTTPRouteMatch defines the predicate used to match requests to a given +/// action. Multiple match types are ANDed together, i.e. the match will +/// evaluate to true only if all conditions are satisfied. +/// +/// For example, the match below will match a HTTP request only if its path +/// starts with `/foo` AND it contains the `version: v1` header: +/// +/// ```text +/// match: +/// +/// path: +/// value: "/foo" +/// headers: +/// - name: "version" +/// value "v1" +/// +/// ``` +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HTTPMethodMatch { + #[serde(rename = "GET")] + Get, + #[serde(rename = "HEAD")] + Head, + #[serde(rename = "POST")] + Post, + #[serde(rename = "PUT")] + Put, + #[serde(rename = "DELETE")] + Delete, + #[serde(rename = "CONNECT")] + Connect, + #[serde(rename = "OPTIONS")] + Options, + #[serde(rename = "TRACE")] + Trace, + #[serde(rename = "PATCH")] + Patch, +} +/// Path specifies a HTTP request path matcher. If this field is not +/// specified, a default prefix match on the "/" path is provided. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct PathMatch { + /// Type specifies how to match against the path Value. + /// + /// Support: Core (Exact, PathPrefix) + /// + /// Support: Implementation-specific (RegularExpression) + #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] + pub r#type: Option, + /// Value of the HTTP path to match against. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, +} +/// Path specifies a HTTP request path matcher. If this field is not +/// specified, a default prefix match on the "/" path is provided. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HttpRouteRulesMatchesPathType { + Exact, + PathPrefix, + RegularExpression, +} +/// Timeouts defines the timeouts that can be configured for an HTTP request. +/// +/// Support: Extended +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteTimeout { + /// BackendRequest specifies a timeout for an individual request from the gateway + /// to a backend. This covers the time from when the request first starts being + /// sent from the gateway to when the full response has been received from the backend. + /// + /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout + /// completely. Implementations that cannot completely disable the timeout MUST + /// instead interpret the zero duration as the longest possible value to which + /// the timeout can be set. + /// + /// An entire client HTTP transaction with a gateway, covered by the Request timeout, + /// may result in more than one call from the gateway to the destination backend, + /// for example, if automatic retries are supported. + /// + /// The value of BackendRequest must be a Gateway API Duration string as defined by + /// GEP-2257. When this field is unspecified, its behavior is implementation-specific; + /// when specified, the value of BackendRequest must be no more than the value of the + /// Request timeout (since the Request timeout encompasses the BackendRequest timeout). + /// + /// Support: Extended + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRequest" + )] + pub backend_request: Option, + /// Request specifies the maximum duration for a gateway to respond to an HTTP request. + /// If the gateway has not been able to respond before this deadline is met, the gateway + /// MUST return a timeout error. + /// + /// For example, setting the `rules.timeouts.request` field to the value `10s` in an + /// `HTTPRoute` will cause a timeout if a client request is taking longer than 10 seconds + /// to complete. + /// + /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout + /// completely. Implementations that cannot completely disable the timeout MUST + /// instead interpret the zero duration as the longest possible value to which + /// the timeout can be set. + /// + /// This timeout is intended to cover as close to the whole request-response transaction + /// as possible although an implementation MAY choose to start the timeout after the entire + /// request stream has been received instead of immediately after the transaction is + /// initiated by the client. + /// + /// The value of Request is a Gateway API Duration string as defined by GEP-2257. When this + /// field is unspecified, request timeout behavior is implementation-specific. + /// + /// Support: Extended + #[serde(default, skip_serializing_if = "Option::is_none")] + pub request: Option, +} diff --git a/gateway-api/src/standard/listenersets.rs b/gateway-api/src/standard/listenersets.rs new file mode 100644 index 0000000..15afda4 --- /dev/null +++ b/gateway-api/src/standard/listenersets.rs @@ -0,0 +1,76 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*; +/// Spec defines the desired state of ListenerSet. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "ListenerSet", + plural = "listenersets" +)] +#[kube(namespaced)] +#[kube(status = "ListenerSetStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct ListenerSetSpec { + /// Listeners associated with this ListenerSet. Listeners define + /// logical endpoints that are bound on this referenced parent Gateway's addresses. + /// + /// Listeners in a `Gateway` and their attached `ListenerSets` are concatenated + /// as a list when programming the underlying infrastructure. Each listener + /// name does not need to be unique across the Gateway and ListenerSets. + /// See ListenerEntry.Name for more details. + /// + /// Implementations MUST treat the parent Gateway as having the merged + /// list of all listeners from itself and attached ListenerSets using + /// the following precedence: + /// + /// 1. "parent" Gateway + /// 2. ListenerSet ordered by creation time (oldest first) + /// 3. ListenerSet ordered alphabetically by "{namespace}/{name}". + /// + /// An implementation MAY reject listeners by setting the ListenerEntryStatus + /// `Accepted` condition to False with the Reason `TooManyListeners` + /// + /// If a listener has a conflict, this will be reported in the + /// Status.ListenerEntryStatus setting the `Conflicted` condition to True. + /// + /// Implementations SHOULD be cautious about what information from the + /// parent or siblings are reported to avoid accidentally leaking + /// sensitive information that the child would not otherwise have access + /// to. This can include contents of secrets etc. + pub listeners: Vec, + /// ParentRef references the Gateway that the listeners are attached to. + #[serde(rename = "parentRef")] + pub parent_ref: Reference, +} +/// Status defines the current state of ListenerSet. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetStatus { + /// Conditions describe the current conditions of the ListenerSet. + /// + /// Implementations MUST express ListenerSet conditions using the + /// `ListenerSetConditionType` and `ListenerSetConditionReason` + /// constants so that operators and tools can converge on a common + /// vocabulary to describe ListenerSet state. + /// + /// Known condition types are: + /// + /// * "Accepted" + /// * "Programmed" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + /// Listeners provide status for each unique listener port defined in the Spec. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub listeners: Option>, +} diff --git a/gateway-api/src/standard/mod.rs b/gateway-api/src/standard/mod.rs new file mode 100644 index 0000000..3aa2f59 --- /dev/null +++ b/gateway-api/src/standard/mod.rs @@ -0,0 +1,12 @@ +// WARNING: generated file - manual changes will be overriden +pub mod backendtlspolicies; +pub mod common; +pub mod constants; +pub mod enum_defaults; +pub mod gatewayclasses; +pub mod gateways; +pub mod grpcroutes; +pub mod httproutes; +pub mod listenersets; +pub mod referencegrants; +pub mod tlsroutes; diff --git a/gateway-api/src/standard/referencegrants.rs b/gateway-api/src/standard/referencegrants.rs new file mode 100644 index 0000000..6eb6981 --- /dev/null +++ b/gateway-api/src/standard/referencegrants.rs @@ -0,0 +1,87 @@ +// WARNING: generated file - manual changes will be overriden + +#[allow(unused_imports)] +mod prelude { + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of ReferenceGrant. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "ReferenceGrant", + plural = "referencegrants" +)] +#[kube(namespaced)] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct ReferenceGrantSpec { + /// From describes the trusted namespaces and kinds that can reference the + /// resources described in "To". Each entry in this list MUST be considered + /// to be an additional place that references can be valid from, or to put + /// this another way, entries MUST be combined using OR. + /// + /// Support: Core + pub from: Vec, + /// To describes the resources that may be referenced by the resources + /// described in "From". Each entry in this list MUST be considered to be an + /// additional place that references can be valid to, or to put this another + /// way, entries MUST be combined using OR. + /// + /// Support: Core + pub to: Vec, +} +/// ReferenceGrantFrom describes trusted namespaces and kinds. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ReferenceGrantFrom { + /// Group is the group of the referent. + /// When empty, the Kubernetes core API group is inferred. + /// + /// Support: Core + pub group: String, + /// Kind is the kind of the referent. Although implementations may support + /// additional resources, the following types are part of the "Core" + /// support level for this field. + /// + /// When used to permit a SecretObjectReference: + /// + /// * Gateway + /// + /// When used to permit a BackendObjectReference: + /// + /// * GRPCRoute + /// * HTTPRoute + /// * TCPRoute + /// * TLSRoute + /// * UDPRoute + pub kind: String, + /// Namespace is the namespace of the referent. + /// + /// Support: Core + pub namespace: String, +} +/// ReferenceGrantTo describes what Kinds are allowed as targets of the +/// references. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ReferenceGrantTo { + /// Group is the group of the referent. + /// When empty, the Kubernetes core API group is inferred. + /// + /// Support: Core + pub group: String, + /// Kind is the kind of the referent. Although implementations may support + /// additional resources, the following types are part of the "Core" + /// support level for this field: + /// + /// * Secret when used to permit a SecretObjectReference + /// * Service when used to permit a BackendObjectReference + pub kind: String, + /// Name is the name of the referent. When unspecified, this policy + /// refers to all resources of the specified Group and Kind in the local + /// namespace. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} diff --git a/gateway-api/src/standard/tlsroutes.rs b/gateway-api/src/standard/tlsroutes.rs new file mode 100644 index 0000000..f0f07d6 --- /dev/null +++ b/gateway-api/src/standard/tlsroutes.rs @@ -0,0 +1,185 @@ +// WARNING: generated file - manual changes will be overriden + +use super::common::*; +#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; +} +use self::prelude::*; +/// Spec defines the desired state of TLSRoute. +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +#[kube( + group = "gateway.networking.k8s.io", + version = "v1", + kind = "TLSRoute", + plural = "tlsroutes" +)] +#[kube(namespaced)] +#[kube(status = "RouteStatus")] +#[kube(derive = "Default")] +#[kube(derive = "PartialEq")] +pub struct TlsRouteSpec { + /// Hostnames defines a set of SNI hostnames that should match against the + /// SNI attribute of TLS ClientHello message in TLS handshake. This matches + /// the RFC 1123 definition of a hostname with 2 notable exceptions: + /// + /// 1. IPs are not allowed in SNI hostnames per RFC 6066. + /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard + /// label must appear by itself as the first label. + pub hostnames: Vec, + /// ParentRefs references the resources (usually Gateways) that a Route wants + /// to be attached to. Note that the referenced parent resource needs to + /// allow this for the attachment to be complete. For Gateways, that means + /// the Gateway needs to allow attachment from Routes of this kind and + /// namespace. For Services, that means the Service must either be in the same + /// namespace for a "producer" route, or the mesh implementation must support + /// and allow "consumer" routes for the referenced Service. ReferenceGrant is + /// not applicable for governing ParentRefs to Services - it is not possible to + /// create a "producer" route for a Service in a different namespace from the + /// Route. + /// + /// There are two kinds of parent resources with "Core" support: + /// + /// * Gateway (Gateway conformance profile) + /// * Service (Mesh conformance profile, ClusterIP Services only) + /// + /// This API may be extended in the future to support additional kinds of parent + /// resources. + /// + /// ParentRefs must be _distinct_. This means either that: + /// + /// * They select different objects. If this is the case, then parentRef + /// entries are distinct. In terms of fields, this means that the + /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must + /// be unique across all parentRef entries in the Route. + /// * They do not select different objects, but for each optional field used, + /// each ParentRef that selects the same object must set the same set of + /// optional fields to different values. If one ParentRef sets a + /// combination of optional fields, all must set the same combination. + /// + /// Some examples: + /// + /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the + /// same object must also set `sectionName`. + /// * If one ParentRef sets `port`, all ParentRefs referencing the same + /// object must also set `port`. + /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs + /// referencing the same object must also set `sectionName` and `port`. + /// + /// It is possible to separately reference multiple distinct objects that may + /// be collapsed by an implementation. For example, some implementations may + /// choose to merge compatible Gateway Listeners together. If that is the + /// case, the list of routes attached to those resources should also be + /// merged. + /// + /// Note that for ParentRefs that cross namespace boundaries, there are specific + /// rules. Cross-namespace references are only valid if they are explicitly + /// allowed by something in the namespace they are referring to. For example, + /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a + /// generic way to enable other kinds of cross-namespace reference. + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "parentRefs" + )] + pub parent_refs: Option>, + /// Rules are a list of actions. + pub rules: Vec, +} +/// TLSRouteRule is the configuration for a given rule. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TlsRouteRules { + /// BackendRefs defines the backend(s) where matching requests should be + /// sent. If unspecified or invalid (refers to a nonexistent resource or + /// a Service with no endpoints), the rule performs no forwarding; if no + /// filters are specified that would result in a response being sent, the + /// underlying implementation must actively reject request attempts to this + /// backend, by rejecting the connection. Request rejections must respect + /// weight; if an invalid backend is requested to have 80% of requests, then + /// 80% of requests must be rejected instead. + /// + /// Support: Core for Kubernetes Service + /// + /// Support: Extended for Kubernetes ServiceImport + /// + /// Support: Implementation-specific for any other resource + /// + /// Support for weight: Extended + #[serde(rename = "backendRefs")] + pub backend_refs: Vec, + /// Name is the name of the route rule. This name MUST be unique within a Route if it is set. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} +/// BackendRef defines how a Route should forward a request to a Kubernetes +/// resource. +/// +/// Note that when a namespace different than the local namespace is specified, a +/// ReferenceGrant object is required in the referent namespace to allow that +/// namespace's owner to accept the reference. See the ReferenceGrant +/// documentation for details. +/// +/// Note that when the BackendTLSPolicy object is enabled by the implementation, +/// there are some extra rules about validity to consider here. See the fields +/// where this struct is used for more information about the exact behavior. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct TlsRouteRulesBackendRefs { + /// Group is the group of the referent. For example, "gateway.networking.k8s.io". + /// When unspecified or empty string, core API group is inferred. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is the Kubernetes resource kind of the referent. For example + /// "Service". + /// + /// Defaults to "Service" when not specified. + /// + /// ExternalName services can refer to CNAME DNS records that may live + /// outside of the cluster and as such are difficult to reason about in + /// terms of conformance. They also may not be safe to forward to (see + /// CVE-2021-25740 for more information). Implementations SHOULD NOT + /// support ExternalName Services. + /// + /// Support: Core (Services with a type other than ExternalName) + /// + /// Support: Implementation-specific (Services with type ExternalName) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent. + pub name: String, + /// Namespace is the namespace of the backend. When unspecified, the local + /// namespace is inferred. + /// + /// Note that when a namespace different than the local namespace is specified, + /// a ReferenceGrant object is required in the referent namespace to allow that + /// namespace's owner to accept the reference. See the ReferenceGrant + /// documentation for details. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, + /// Port specifies the destination port number to use for this resource. + /// Port is required when the referent is a Kubernetes Service. In this + /// case, the port number is the service port number, not the target port. + /// For other resources, destination port might be derived from the referent + /// resource or this field. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, + /// Weight specifies the proportion of requests forwarded to the referenced + /// backend. This is computed as weight/(sum of all weights in this + /// BackendRefs list). For non-zero values, there may be some epsilon from + /// the exact proportion defined here depending on the precision an + /// implementation supports. Weight is not a percentage and the sum of + /// weights does not need to equal 100. + /// + /// If only one backend is specified and it has a weight greater than 0, 100% + /// of the traffic is forwarded to that backend. If weight is set to 0, no + /// traffic should be forwarded for this entry. If unspecified, weight + /// defaults to 1. + /// + /// Support for this field varies based on the context where used. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weight: Option, +} diff --git a/scripts/generators/enums_generator.sh b/scripts/generators/enums_generator.sh new file mode 100755 index 0000000..840a4ea --- /dev/null +++ b/scripts/generators/enums_generator.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -eou pipefail + +export GATEWAY_API_ENUMS=$1 +export GATEWAY_API_INFERENCE_ENUMS=$2 +export GATEWAY_API_EXPERIMENTAL=false +cargo xtask gen_enum_defaults > $APIS_DIR/standard/enum_defaults.rs +echo "pub mod enum_defaults;" >> $APIS_DIR/standard/mod.rs +sort -ur $APIS_DIR/standard/mod.rs -o $APIS_DIR/standard/mod.rs + +export GATEWAY_API_EXPERIMENTAL=true + +export GATEWAY_API_ENUMS=$3 +export GATEWAY_API_INFERENCE_ENUMS=$4 + +cargo xtask gen_enum_defaults > $APIS_DIR/experimental/enum_defaults.rs +echo "pub mod enum_defaults;" >> $APIS_DIR/experimental/mod.rs +sort -ur $APIS_DIR/experimental/mod.rs -o $APIS_DIR/experimental/mod.rs diff --git a/scripts/generators/experimental_enum_names.txt b/scripts/generators/experimental_enum_names.txt new file mode 100644 index 0000000..c7d4c70 --- /dev/null +++ b/scripts/generators/experimental_enum_names.txt @@ -0,0 +1,38 @@ +BackendTlsPolicyValidationSubjectAltNamesType=Hostname +GatewayAllowedListenersNamespacesFrom=Same +GatewayDefaultScope=All +GatewayListenersAllowedRoutesNamespacesFrom=Same +GatewayListenersTlsMode=Terminate +GatewayTlsFrontendDefaultValidationMode=AllowValidOnly +GatewayTlsFrontendPerPortTlsValidationMode=AllowValidOnly +GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier +GrpcRouteRulesFiltersType=RequestHeaderModifier +GrpcRouteRulesMatchesHeadersType=Exact +GrpcRouteRulesMatchesMethodType=Exact +GrpcRouteRulesSessionPersistenceCookieConfigLifetimeType=Permanent +GrpcRouteRulesSessionPersistenceType=Cookie +GrpcRouteUseDefaultGateways=All +HttpRouteRulesBackendRefsFiltersExternalAuthProtocol=Http +HttpRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath +HttpRouteRulesBackendRefsFiltersRequestRedirectScheme=Https +HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode=r#_301 +HttpRouteRulesBackendRefsFiltersType=RequestHeaderModifier +HttpRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath +HttpRouteRulesFiltersExternalAuthProtocol=Http +HttpRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath +HttpRouteRulesFiltersRequestRedirectScheme=Https +HttpRouteRulesFiltersRequestRedirectStatusCode=r#_301 +HttpRouteRulesFiltersType=RequestHeaderModifier +HttpRouteRulesFiltersUrlRewritePathType=ReplaceFullPath +HttpRouteRulesMatchesHeadersType=Exact +HttpRouteRulesMatchesMethod=Get +HttpRouteRulesMatchesPathType=Exact +HttpRouteRulesMatchesQueryParamsType=Exact +HttpRouteRulesSessionPersistenceCookieConfigLifetimeType=Permanent +HttpRouteRulesSessionPersistenceType=Cookie +HttpRouteUseDefaultGateways=All +ListenerSetListenersAllowedRoutesNamespacesFrom=Same +ListenerSetListenersTlsMode=Terminate +TcpRouteUseDefaultGateways=All +TlsRouteUseDefaultGateways=All +UdpRouteUseDefaultGateways=All diff --git a/scripts/generators/experimental_inference_enum_names.txt b/scripts/generators/experimental_inference_enum_names.txt new file mode 100644 index 0000000..3fd2ef9 --- /dev/null +++ b/scripts/generators/experimental_inference_enum_names.txt @@ -0,0 +1,2 @@ +InferencePoolExtensionRefFailureMode=FailOpen +InferenceModelRewriteRulesMatchesModelType=Exact diff --git a/scripts/generators/extensions/inference.sh b/scripts/generators/extensions/inference.sh new file mode 100755 index 0000000..5ec5c5e --- /dev/null +++ b/scripts/generators/extensions/inference.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +# ------------------------------------------------------------------------------ +# This script will automatically generate API updates for new Inference Extension +# releases. Update the $INFERENCE_EXT_VERSION to the new release version before +# executing. +# +# This script requires kopium, which can be installed with: +# +# cargo install kopium +# +# See: https://github.com/kube-rs/kopium +# ------------------------------------------------------------------------------ +set -euo pipefail + +export EXTENSION_DIR=extensions +echo " **** Inference Extension Processing Starts **** " + +INFERENCE_EXT_VERSION="v1.0.2" +INFERENCE_API_DIR=${EXTENSION_DIR}/inference/src/apis +echo "Using Inference Extension version ${INFERENCE_EXT_VERSION}" + +INFERENCE_EXT_STANDARD_APIS=( + inferencepools +) + +INFERENCE_EXT_EXPERIMENTAL_APIS=( + inferencepools + inferenceobjectives +) + +rm -rf $INFERENCE_API_DIR/standard +rm -rf $INFERENCE_API_DIR/experimental + +mkdir -p $INFERENCE_API_DIR/standard +mkdir -p $INFERENCE_API_DIR/experimental + + +echo "// WARNING! generated file do not edit" > $INFERENCE_API_DIR/standard/mod.rs + +for API in "${INFERENCE_EXT_STANDARD_APIS[@]}" +do + echo "generating inference extension standard api ${API}" + curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api-inference-extension/${INFERENCE_EXT_VERSION}/config/crd/bases/inference.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $INFERENCE_API_DIR/standard/${API}.rs + sed -i 's/pub use kube::CustomResource;/pub use kube_derive::CustomResource;/g' $INFERENCE_API_DIR/standard/${API}.rs + echo "pub mod ${API};" >> $INFERENCE_API_DIR/standard/mod.rs +done + +echo "// WARNING! generated file do not edit" > $INFERENCE_API_DIR/experimental/mod.rs + +for API in "${INFERENCE_EXT_EXPERIMENTAL_APIS[@]}" +do + echo "generating inference extension experimental api ${API}" + curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api-inference-extension/${INFERENCE_EXT_VERSION}/config/crd/bases/inference.networking.x-k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $INFERENCE_API_DIR/experimental/${API}.rs + sed -i 's/pub use kube::CustomResource;/pub use kube_derive::CustomResource;/g' $INFERENCE_API_DIR/experimental/${API}.rs + echo "pub mod ${API};" >> $INFERENCE_API_DIR/experimental/mod.rs +done + + +export RUST_LOG=info + +export TMP_ARTIFACTS="artifacts" +mkdir -p ${TMP_ARTIFACTS}/inference/ + +echo " **** Standard APIs Start **** " +echo " **** Starting Type Reducer - Collapsing Duplicative Types **** " +echo " **** Type Reducer - PHASE 1 - First Pass ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $INFERENCE_API_DIR/standard --out-dir $INFERENCE_API_DIR/standard reduce --previous-pass-derived-type-names ./type-reducer/extension/inference/standard_reduced_types_pass_0.txt --current-pass-substitute-names ./type-reducer/extension/inference/standard_customized_mapped_names.txt +mv mapped_names.txt ${TMP_ARTIFACTS}/inference/standard_extension_inference_mapped_names_phase_1.txt +mv mapped_types_to_names.txt ${TMP_ARTIFACTS}/inference/standard_extension_inference_mapped_types_to_names_phase_1.txt + +echo " **** RENAMING PHASE ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $INFERENCE_API_DIR/standard --out-dir $INFERENCE_API_DIR/standard rename --rename-only-substitute-names ./type-reducer/extension/inference/standard_rename_only_mapped_names.txt +echo " **** Standard APIs End **** " + + +echo " **** Experimental APIs Start **** " +echo " **** Starting Type Reducer - Collapsing Duplicative Types **** " +echo " **** Type Reducer - PHASE 1 - First Pass ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $INFERENCE_API_DIR/experimental --out-dir $INFERENCE_API_DIR/experimental reduce --previous-pass-derived-type-names ./type-reducer/extension/inference/experimental_reduced_types_pass_0.txt --current-pass-substitute-names ./type-reducer/extension/inference/experimental_customized_mapped_names.txt +mv mapped_names.txt ${TMP_ARTIFACTS}/inference/experimental_extension_inference_mapped_names_phase_1.txt +mv mapped_types_to_names.txt ${TMP_ARTIFACTS}/inference/experimental_extension_inference_mapped_types_to_names_phase_1.txt + +echo " **** RENAMING PHASE ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $INFERENCE_API_DIR/experimental --out-dir $INFERENCE_API_DIR/experimental rename --rename-only-substitute-names ./type-reducer/extension/inference/experimental_rename_only_mapped_names.txt +echo " **** Experimental APIs End **** " + + +cargo fmt +echo "Inference Extension API Generation complete" + +echo "Inference Extension API Cleaning up temporary files" +set -x +rm ${TMP_ARTIFACTS}/inference/standard_extension_inference_mapped_names_phase_*.txt +rm ${TMP_ARTIFACTS}/inference/standard_extension_inference_mapped_types_to_names_phase_*.txt +rm ${TMP_ARTIFACTS}/inference/experimental_extension_inference_mapped_names_phase_*.txt +rm ${TMP_ARTIFACTS}/inference/experimental_extension_inference_mapped_types_to_names_phase_*.txt +set +x +echo "Inference Extension API Cleanup complete" \ No newline at end of file diff --git a/scripts/generators/gateway.sh b/scripts/generators/gateway.sh new file mode 100755 index 0000000..1681240 --- /dev/null +++ b/scripts/generators/gateway.sh @@ -0,0 +1,268 @@ +#!/bin/bash + +# ------------------------------------------------------------------------------ +# This script will automatically generate API updates for new Gateway API +# releases. Update the $GATEWAY_API_VERSION to the new release version before +# executing. +# +# This script requires kopium, which can be installed with: +# +# cargo install kopium +# +# See: https://github.com/kube-rs/kopium +# ------------------------------------------------------------------------------ + +set -eou pipefail + +GATEWAY_API_VERSION="v1.5.0" +REQUIRED_KOPIUM_VERSION="0.22.5" +KOPIUM_VERSION=$(kopium --version 2>/dev/null | grep -oP 'kopium \K[0-9]+\.[0-9]+\.[0-9]+' || echo "") + +if [ -z "$KOPIUM_VERSION" ]; then + echo "Error: kopium is not installed or not in PATH" + echo "Please install kopium version ${REQUIRED_KOPIUM_VERSION} with:" + echo " cargo install kopium --version ${REQUIRED_KOPIUM_VERSION}" + exit 1 +fi + +if [ "$KOPIUM_VERSION" != "$REQUIRED_KOPIUM_VERSION" ]; then + echo "Error: kopium version mismatch" + echo " Required: ${REQUIRED_KOPIUM_VERSION}" + echo " Found: ${KOPIUM_VERSION}" + echo "Please install the correct version with:" + echo " cargo install kopium --version ${REQUIRED_KOPIUM_VERSION}" + exit 1 +fi + +echo "Using kopium version ${KOPIUM_VERSION}" +echo "Using Gateway API version ${GATEWAY_API_VERSION}" + +STANDARD_APIS=( + gatewayclasses + gateways + httproutes + referencegrants + grpcroutes + backendtlspolicies + listenersets + tlsroutes +) + +EXPERIMENTAL_APIS=( + gatewayclasses + gateways + httproutes + referencegrants + grpcroutes + tcproutes + tlsroutes + udproutes + backendtlspolicies + listenersets +) + +export APIS_DIR='gateway-api/src/apis' +rm -rf $APIS_DIR/standard/ +rm -rf $APIS_DIR/experimental/ + +cat << EOF > $APIS_DIR/mod.rs +pub mod experimental; +pub mod standard; +EOF + + +mkdir -p $APIS_DIR/standard/ +mkdir -p $APIS_DIR/experimental/ + + +echo "// WARNING! generated file do not edit" > $APIS_DIR/standard/mod.rs + +for API in "${STANDARD_APIS[@]}" +do + echo "generating standard api ${API}" + curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${GATEWAY_API_VERSION}/config/crd/standard/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $APIS_DIR/standard/${API}.rs + sed -i 's/pub use kube::CustomResource;/pub use kube_derive::CustomResource;/g' $APIS_DIR/standard/${API}.rs + echo "pub mod ${API};" >> $APIS_DIR/standard/mod.rs +done + +# Standard API enums that need a Default trait impl along with their respective default variant. +ENUMS=( + HttpRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesFiltersType=RequestHeaderModifier + HttpRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersType=RequestHeaderModifier + GrpcRouteRulesFiltersType=RequestHeaderModifier + GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier + BackendTlsPolicyValidationSubjectAltNamesType=Hostname +) + +# Create a comma separated string out of $ENUMS. +ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} + +# The task searches for $GATEWAY_API_ENUMS in the environment to get the enum names and their default variants. +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $APIS_DIR/standard/enum_defaults.rs +echo "mod enum_defaults;" >> $APIS_DIR/standard/mod.rs + + +GATEWAY_CLASS_CONDITION_CONSTANTS="GatewayClassConditionType=Accepted" +GATEWAY_CLASS_REASON_CONSTANTS="GatewayClassConditionReason=Accepted,InvalidParameters,Pending,Unsupported,Waiting" +GATEWAY_CONDITION_CONSTANTS="GatewayConditionType=Programmed,Accepted,Ready" +GATEWAY_REASON_CONSTANTS="GatewayConditionReason=Programmed,Invalid,NoResources,AddressNotAssigned,AddressNotUsable,Accepted,ListenersNotValid,Pending,UnsupportedAddress,InvalidParameters,Ready,ListenersNotReady" +LISTENER_CONDITION_CONSTANTS="ListenerConditionType=Conflicted,Accepted,ResolvedRefs,Programmed,Ready" +LISTENER_REASON_CONSTANTS="ListenerConditionReason=HostnameConflict,ProtocolConflict,NoConflicts,Accepted,PortUnavailable,UnsupportedProtocol,ResolvedRefs,InvalidCertificateRef,InvalidRouteKinds,RefNotPermitted,Programmed,Invalid,Pending,Ready" +ROUTE_CONDITION_CONSTANTS="RouteConditionType=Accepted,ResolvedRefs,PartiallyInvalid" +ROUTE_REASON_CONSTANTS="RouteConditionReason=Accepted,NotAllowedByListeners,NoMatchingListenerHostname,NoMatchingParent,UnsupportedValue,Pending,IncompatibleFilters,ResolvedRefs,RefNotPermitted,InvalidKind,BackendNotFound,UnsupportedProtocol" + +GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \ + GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \ + LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \ + ROUTE_CONDITION_CONSTANTS=${ROUTE_CONDITION_CONSTANTS} ROUTE_REASON_CONSTANTS=${ROUTE_REASON_CONSTANTS} \ + cargo xtask gen_condition_constants >> $APIS_DIR/standard/constants.rs +echo "pub mod constants;" >> $APIS_DIR/standard/mod.rs + +echo "// WARNING! generated file do not edit" > $APIS_DIR/experimental/mod.rs + +for API in "${EXPERIMENTAL_APIS[@]}" +do + echo "generating experimental api $API" + curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${GATEWAY_API_VERSION}/config/crd/experimental/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $APIS_DIR/experimental/${API}.rs + sed -i 's/pub use kube::CustomResource;/pub use kube_derive::CustomResource;/g' $APIS_DIR/experimental/${API}.rs + echo "pub mod ${API};" >> $APIS_DIR/experimental/mod.rs +done + +# Experimental API enums that need a Default trait impl along with their respective default variant. +ENUMS=( + HttpRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesFiltersType=RequestHeaderModifier + HttpRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersType=RequestHeaderModifier + HttpRouteRulesBackendRefsFiltersExternalAuthProtocol=Http + GrpcRouteRulesFiltersType=RequestHeaderModifier + GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier + BackendTlsPolicyValidationSubjectAltNamesType=Hostname + HttpRouteRulesFiltersExternalAuthProtocol=Http + +) + +ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $APIS_DIR/experimental/enum_defaults.rs +echo "mod enum_defaults;" >> $APIS_DIR/experimental/mod.rs + +# GatewayClass conditions vary between standard and experimental +GATEWAY_CLASS_CONDITION_CONSTANTS="${GATEWAY_CLASS_CONDITION_CONSTANTS},SupportedVersion" +GATEWAY_CLASS_REASON_CONSTANTS="${GATEWAY_CLASS_REASON_CONSTANTS},SupportedVersion,UnsupportedVersion" +ROUTE_CONDITION_CONSTANTS="RouteConditionType=Accepted,ResolvedRefs" +ROUTE_REASON_CONSTANTS="RouteConditionReason=Accepted,NotAllowedByListeners,NoMatchingListenerHostname,UnsupportedValue,Pending,ResolvedRefs,RefNotPermitted,InvalidKind,BackendNotFound" + +GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \ + GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \ + LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \ + ROUTE_CONDITION_CONSTANTS=${ROUTE_CONDITION_CONSTANTS} ROUTE_REASON_CONSTANTS=${ROUTE_REASON_CONSTANTS} \ + cargo xtask gen_condition_constants >> $APIS_DIR/experimental/constants.rs +echo "pub mod constants;" >> $APIS_DIR/experimental/mod.rs + +# Format the code. +cargo fmt + + +export RUST_LOG=info + +echo " **** Starting Type Reducer - Collapsing Duplicative Types **** " +echo " **** Type Reducer - PHASE 1 - First Pass ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/standard --out-dir $APIS_DIR/standard reduce --previous-pass-derived-type-names ./type-reducer/standard_reduced_types_pass_0.txt --current-pass-substitute-names ./type-reducer/standard_customized_mapped_names.txt +mv mapped_names.txt standard_mapped_names_phase_1.txt +mv mapped_types_to_names.txt standard_mapped_types_to_names_phase_1.txt +echo " **** PHASE 2 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/standard --out-dir $APIS_DIR/standard reduce --previous-pass-derived-type-names ./type-reducer/standard_reduced_types_pass_1.txt --current-pass-substitute-names ./type-reducer/standard_customized_mapped_names.txt +mv mapped_names.txt standard_mapped_names_phase_2.txt +mv mapped_types_to_names.txt standard_mapped_types_to_names_phase_2.txt +echo " **** PHASE 3 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/standard --out-dir $APIS_DIR/standard reduce --previous-pass-derived-type-names ./type-reducer/standard_reduced_types_pass_2.txt --current-pass-substitute-names ./type-reducer/standard_customized_mapped_names.txt +mv mapped_names.txt standard_mapped_names_phase_3.txt +mv mapped_types_to_names.txt standard_mapped_types_to_names_phase_3.txt +echo " **** PHASE 4 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/standard --out-dir $APIS_DIR/standard reduce --previous-pass-derived-type-names ./type-reducer/standard_reduced_types_pass_3.txt --current-pass-substitute-names ./type-reducer/standard_customized_mapped_names.txt +mv mapped_names.txt standard_mapped_names_phase_4.txt +mv mapped_types_to_names.txt standard_mapped_types_to_names_phase_4.txt + + +echo " **** RENAMING PHASE ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/standard --out-dir $APIS_DIR/standard rename --rename-only-substitute-names ./type-reducer/standard_rename_only_mapped_names.txt + + +ENUMS=( + GRPCFilterType=RequestHeaderModifier + RequestOperationType=ReplaceFullPath + HTTPFilterType=RequestHeaderModifier + BackendTlsPolicyValidationSubjectAltNamesType=Hostname +) + +ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults > $APIS_DIR/standard/enum_defaults.rs +echo "use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/standard/enum_defaults.rs + +sed -i '/#\[kube(status = "GrpcRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/grpcroutes.rs +sed -i '/#\[kube(status = "HttpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/httproutes.rs +sed -i '/#\[kube(status = "TlsRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/tlsroutes.rs + + +export RUST_LOG=info +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/experimental --out-dir $APIS_DIR/experimental reduce --previous-pass-derived-type-names ./type-reducer/experimental_reduced_types_pass_0.txt --current-pass-substitute-names ./type-reducer/experimental_customized_mapped_names.txt +mv mapped_names.txt experimental_mapped_names_phase_1.txt +mv mapped_types_to_names.txt experimental_mapped_types_to_names_phase_1.txt +echo " **** PHASE 2 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/experimental --out-dir $APIS_DIR/experimental reduce --previous-pass-derived-type-names ./type-reducer/experimental_reduced_types_pass_1.txt --current-pass-substitute-names ./type-reducer/experimental_customized_mapped_names.txt +mv mapped_names.txt experimental_mapped_names_phase_2.txt +mv mapped_types_to_names.txt experimental_mapped_types_to_names_phase_2.txt +echo " **** PHASE 3 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/experimental --out-dir $APIS_DIR/experimental reduce --previous-pass-derived-type-names ./type-reducer/experimental_reduced_types_pass_2.txt --current-pass-substitute-names ./type-reducer/experimental_customized_mapped_names.txt --ignorable-type-names ./type-reducer/experimental_ignorable_mapped_names.txt +mv mapped_names.txt experimental_mapped_names_phase_3.txt +mv mapped_types_to_names.txt experimental_mapped_types_to_names_phase_3.txt +echo " **** PHASE 4 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/experimental --out-dir $APIS_DIR/experimental reduce --previous-pass-derived-type-names ./type-reducer/experimental_reduced_types_pass_3.txt --current-pass-substitute-names ./type-reducer/experimental_customized_mapped_names.txt --ignorable-type-names ./type-reducer/experimental_ignorable_mapped_names.txt +mv mapped_names.txt experimental_mapped_names_phase_4.txt +mv mapped_types_to_names.txt experimental_mapped_types_to_names_phase_4.txt + +echo " **** RENAMING PHASE ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/experimental --out-dir $APIS_DIR/experimental rename --rename-only-substitute-names ./type-reducer/experimental_rename_only_mapped_names.txt + +ENUMS=( + GRPCFilterType=RequestHeaderModifier + RequestOperationType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersExternalAuthProtocol=Http + HTTPFilterType=RequestHeaderModifier + BackendTlsPolicyValidationSubjectAltNamesType=Hostname +) + +ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults > $APIS_DIR/experimental/enum_defaults.rs + +echo "use crate::experimental::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/experimental/enum_defaults.rs + +sed -i '/#\[kube(status = "GrpcRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/grpcroutes.rs +sed -i '/#\[kube(status = "HttpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/httproutes.rs +sed -i '/#\[kube(status = "TlsRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tlsroutes.rs +sed -i '/#\[kube(status = "UdpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/udproutes.rs +sed -i '/#\[kube(status = "TcpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tcproutes.rs + +cargo fmt +echo "Gateway API Generation complete" + +echo "Gateway API Cleaning up temporary files" +set -x +rm -f standard_mapped_names_phase_*.txt +rm -f standard_mapped_types_to_names_phase_*.txt +rm -f experimental_mapped_names_phase_*.txt +rm -f experimental_mapped_types_to_names_phase_*.txt +rm -f mapped_names.txt +rm -f mapped_types_to_names.txt +set +x +echo "Gateway API Cleanup complete" diff --git a/scripts/generators/gateway_experimental.sh b/scripts/generators/gateway_experimental.sh new file mode 100755 index 0000000..f5ad150 --- /dev/null +++ b/scripts/generators/gateway_experimental.sh @@ -0,0 +1,170 @@ +#!/bin/bash + +# ------------------------------------------------------------------------------ +# This script will automatically generate API updates for new Gateway API +# releases. Update the $GATEWAY_API_VERSION to the new release version before +# executing. +# +# This script requires kopium, which can be installed with: +# +# cargo install kopium +# +# See: https://github.com/kube-rs/kopium +# ------------------------------------------------------------------------------ + +set -eou pipefail + +GATEWAY_API_VERSION="v1.5.0" +REQUIRED_KOPIUM_VERSION="0.22.5" +KOPIUM_VERSION=$(kopium --version 2>/dev/null | grep -oP 'kopium \K[0-9]+\.[0-9]+\.[0-9]+' || echo "") + +if [ -z "$KOPIUM_VERSION" ]; then + echo "Error: kopium is not installed or not in PATH" + echo "Please install kopium version ${REQUIRED_KOPIUM_VERSION} with:" + echo " cargo install kopium --version ${REQUIRED_KOPIUM_VERSION}" + exit 1 +fi + +if [ "$KOPIUM_VERSION" != "$REQUIRED_KOPIUM_VERSION" ]; then + echo "Error: kopium version mismatch" + echo " Required: ${REQUIRED_KOPIUM_VERSION}" + echo " Found: ${KOPIUM_VERSION}" + echo "Please install the correct version with:" + echo " cargo install kopium --version ${REQUIRED_KOPIUM_VERSION}" + exit 1 +fi + +echo "Using kopium version ${KOPIUM_VERSION}" +echo "Using Gateway API version ${GATEWAY_API_VERSION}" + + +EXPERIMENTAL_APIS=( + gatewayclasses + gateways + httproutes + referencegrants + grpcroutes + tcproutes + tlsroutes + udproutes + backendtlspolicies + listenersets +) + +export APIS_DIR='gateway-api/src/apis' +rm -rf $APIS_DIR/experimental/ + +echo "pub mod experimental;" >> $APIS_DIR/mod.rs +sort -u $APIS_DIR/mod.rs > $APIS_DIR/mod.rs + + +mkdir -p $APIS_DIR/experimental/ + +echo "// WARNING! generated file do not edit" > $APIS_DIR/experimental/mod.rs + +for API in "${EXPERIMENTAL_APIS[@]}" +do + echo "generating experimental api $API" + curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${GATEWAY_API_VERSION}/config/crd/experimental/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $APIS_DIR/experimental/${API}.rs + sed -i 's/pub use kube::CustomResource;/pub use kube_derive::CustomResource;/g' $APIS_DIR/experimental/${API}.rs + echo "pub mod ${API};" >> $APIS_DIR/experimental/mod.rs +done + +# Experimental API enums that need a Default trait impl along with their respective default variant. +ENUMS=( + HttpRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesFiltersType=RequestHeaderModifier + HttpRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersType=RequestHeaderModifier + HttpRouteRulesBackendRefsFiltersExternalAuthProtocol=Http + GrpcRouteRulesFiltersType=RequestHeaderModifier + GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier + BackendTlsPolicyValidationSubjectAltNamesType=Hostname + HttpRouteRulesFiltersExternalAuthProtocol=Http + +) + +GATEWAY_CLASS_CONDITION_CONSTANTS="GatewayClassConditionType=Accepted" +GATEWAY_CLASS_REASON_CONSTANTS="GatewayClassConditionReason=Accepted,InvalidParameters,Pending,Unsupported,Waiting" +GATEWAY_CONDITION_CONSTANTS="GatewayConditionType=Programmed,Accepted,Ready" +GATEWAY_REASON_CONSTANTS="GatewayConditionReason=Programmed,Invalid,NoResources,AddressNotAssigned,AddressNotUsable,Accepted,ListenersNotValid,Pending,UnsupportedAddress,InvalidParameters,Ready,ListenersNotReady" +LISTENER_CONDITION_CONSTANTS="ListenerConditionType=Conflicted,Accepted,ResolvedRefs,Programmed,Ready" +LISTENER_REASON_CONSTANTS="ListenerConditionReason=HostnameConflict,ProtocolConflict,NoConflicts,Accepted,PortUnavailable,UnsupportedProtocol,ResolvedRefs,InvalidCertificateRef,InvalidRouteKinds,RefNotPermitted,Programmed,Invalid,Pending,Ready" +ROUTE_CONDITION_CONSTANTS="RouteConditionType=Accepted,ResolvedRefs,PartiallyInvalid" +ROUTE_REASON_CONSTANTS="RouteConditionReason=Accepted,NotAllowedByListeners,NoMatchingListenerHostname,NoMatchingParent,UnsupportedValue,Pending,IncompatibleFilters,ResolvedRefs,RefNotPermitted,InvalidKind,BackendNotFound,UnsupportedProtocol" + +ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $APIS_DIR/experimental/enum_defaults.rs +echo "mod enum_defaults;" >> $APIS_DIR/experimental/mod.rs + +# GatewayClass conditions vary between standard and experimental +GATEWAY_CLASS_CONDITION_CONSTANTS="${GATEWAY_CLASS_CONDITION_CONSTANTS},SupportedVersion" +GATEWAY_CLASS_REASON_CONSTANTS="${GATEWAY_CLASS_REASON_CONSTANTS},SupportedVersion,UnsupportedVersion" +ROUTE_CONDITION_CONSTANTS="RouteConditionType=Accepted,ResolvedRefs" +ROUTE_REASON_CONSTANTS="RouteConditionReason=Accepted,NotAllowedByListeners,NoMatchingListenerHostname,UnsupportedValue,Pending,ResolvedRefs,RefNotPermitted,InvalidKind,BackendNotFound" + +GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \ + GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \ + LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \ + ROUTE_CONDITION_CONSTANTS=${ROUTE_CONDITION_CONSTANTS} ROUTE_REASON_CONSTANTS=${ROUTE_REASON_CONSTANTS} \ + cargo xtask gen_condition_constants >> $APIS_DIR/experimental/constants.rs +echo "pub mod constants;" >> $APIS_DIR/experimental/mod.rs + +# Format the code. +cargo fmt + + +export RUST_LOG=info +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/experimental --out-dir $APIS_DIR/experimental reduce --previous-pass-derived-type-names ./type-reducer/experimental_reduced_types_pass_0.txt --current-pass-substitute-names ./type-reducer/experimental_customized_mapped_names.txt +mv mapped_names.txt experimental_mapped_names_phase_1.txt +mv mapped_types_to_names.txt experimental_mapped_types_to_names_phase_1.txt +echo " **** PHASE 2 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/experimental --out-dir $APIS_DIR/experimental reduce --previous-pass-derived-type-names ./type-reducer/experimental_reduced_types_pass_1.txt --current-pass-substitute-names ./type-reducer/experimental_customized_mapped_names.txt +mv mapped_names.txt experimental_mapped_names_phase_2.txt +mv mapped_types_to_names.txt experimental_mapped_types_to_names_phase_2.txt +echo " **** PHASE 3 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/experimental --out-dir $APIS_DIR/experimental reduce --previous-pass-derived-type-names ./type-reducer/experimental_reduced_types_pass_2.txt --current-pass-substitute-names ./type-reducer/experimental_customized_mapped_names.txt --ignorable-type-names ./type-reducer/experimental_ignorable_mapped_names.txt +mv mapped_names.txt experimental_mapped_names_phase_3.txt +mv mapped_types_to_names.txt experimental_mapped_types_to_names_phase_3.txt +echo " **** PHASE 4 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/experimental --out-dir $APIS_DIR/experimental reduce --previous-pass-derived-type-names ./type-reducer/experimental_reduced_types_pass_3.txt --current-pass-substitute-names ./type-reducer/experimental_customized_mapped_names.txt --ignorable-type-names ./type-reducer/experimental_ignorable_mapped_names.txt +mv mapped_names.txt experimental_mapped_names_phase_4.txt +mv mapped_types_to_names.txt experimental_mapped_types_to_names_phase_4.txt + +echo " **** RENAMING PHASE ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/experimental --out-dir $APIS_DIR/experimental rename --rename-only-substitute-names ./type-reducer/experimental_rename_only_mapped_names.txt + +ENUMS=( + GRPCFilterType=RequestHeaderModifier + RequestOperationType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersExternalAuthProtocol=Http + HTTPFilterType=RequestHeaderModifier + BackendTlsPolicyValidationSubjectAltNamesType=Hostname +) + +ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults > $APIS_DIR/experimental/enum_defaults.rs + +echo "use crate::experimental::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/experimental/enum_defaults.rs + +sed -i '/#\[kube(status = "GrpcRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/grpcroutes.rs +sed -i '/#\[kube(status = "HttpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/httproutes.rs +sed -i '/#\[kube(status = "TlsRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tlsroutes.rs +sed -i '/#\[kube(status = "UdpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/udproutes.rs +sed -i '/#\[kube(status = "TcpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tcproutes.rs + +cargo fmt +echo "Gateway API Generation complete" + +echo "Gateway API Cleaning up temporary files" +set -x +rm -f experimental_mapped_names_phase_*.txt +rm -f experimental_mapped_types_to_names_phase_*.txt +rm -f mapped_names.txt +rm -f mapped_types_to_names.txt +set +x +echo "Gateway API Cleanup complete" diff --git a/scripts/generators/gateway_generator.sh b/scripts/generators/gateway_generator.sh new file mode 100755 index 0000000..e5c1d9b --- /dev/null +++ b/scripts/generators/gateway_generator.sh @@ -0,0 +1,174 @@ +#!/bin/bash + +# ------------------------------------------------------------------------------ +# This script will automatically generate API updates for new Gateway API +# releases. Update the $GATEWAY_API_VERSION to the new release version before +# executing. +# +# This script requires kopium, which can be installed with: +# +# cargo install kopium +# +# See: https://github.com/kube-rs/kopium +# ------------------------------------------------------------------------------ + +echo "GENERATING GATEWAY API ONLY" + +set -eou pipefail + +GATEWAY_API_VERSION="v1.5.0" +REQUIRED_KOPIUM_VERSION="0.22.5" +KOPIUM_VERSION=$(kopium --version 2>/dev/null | grep -oP 'kopium \K[0-9]+\.[0-9]+\.[0-9]+' || echo "") + +if [ -z "$KOPIUM_VERSION" ]; then + echo "Error: kopium is not installed or not in PATH" + echo "Please install kopium version ${REQUIRED_KOPIUM_VERSION} with:" + echo " cargo install kopium --version ${REQUIRED_KOPIUM_VERSION}" + exit 1 +fi + +if [ "$KOPIUM_VERSION" != "$REQUIRED_KOPIUM_VERSION" ]; then + echo "Error: kopium version mismatch" + echo " Required: ${REQUIRED_KOPIUM_VERSION}" + echo " Found: ${KOPIUM_VERSION}" + echo "Please install the correct version with:" + echo " cargo install kopium --version ${REQUIRED_KOPIUM_VERSION}" + exit 1 +fi + +echo "Using kopium version ${KOPIUM_VERSION}" +echo "Using Gateway API version ${GATEWAY_API_VERSION}" + +STANDARD_APIS=( + gatewayclasses + gateways + httproutes + referencegrants + grpcroutes + backendtlspolicies + listenersets + tlsroutes +) + +EXPERIMENTAL_APIS=( + gatewayclasses + gateways + httproutes + referencegrants + grpcroutes + tcproutes + tlsroutes + udproutes + backendtlspolicies + listenersets +) + +cat << EOF > $APIS_DIR/mod.rs +pub mod experimental; +pub mod standard; +EOF + + +mkdir -p $APIS_DIR/standard/ +mkdir -p $APIS_DIR/experimental/ + + +echo "// WARNING! generated file do not edit" > $APIS_DIR/standard/mod.rs + +for API in "${STANDARD_APIS[@]}" +do + echo "generating standard api ${API}" + curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${GATEWAY_API_VERSION}/config/crd/standard/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $APIS_DIR/standard/${API}.rs + sed -i 's/pub use kube::CustomResource;/pub use kube_derive::CustomResource;/g' $APIS_DIR/standard/${API}.rs + echo "pub mod ${API};" >> $APIS_DIR/standard/mod.rs +done + +# # Standard API enums that need a Default trait impl along with their respective default variant. +# ENUMS=( +# HttpRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath +# HttpRouteRulesFiltersUrlRewritePathType=ReplaceFullPath +# HttpRouteRulesFiltersType=RequestHeaderModifier +# HttpRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath +# HttpRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath +# HttpRouteRulesBackendRefsFiltersType=RequestHeaderModifier +# GrpcRouteRulesFiltersType=RequestHeaderModifier +# GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier +# BackendTlsPolicyValidationSubjectAltNamesType=Hostname +# ) + +# # Create a comma separated string out of $ENUMS. +# ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +# ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} + +# # The task searches for $GATEWAY_API_ENUMS in the environment to get the enum names and their default variants. +# GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $APIS_DIR/standard/enum_defaults.rs +# echo "mod enum_defaults;" >> $APIS_DIR/standard/mod.rs + + +GATEWAY_CLASS_CONDITION_CONSTANTS="GatewayClassConditionType=Accepted" +GATEWAY_CLASS_REASON_CONSTANTS="GatewayClassConditionReason=Accepted,InvalidParameters,Pending,Unsupported,Waiting" +GATEWAY_CONDITION_CONSTANTS="GatewayConditionType=Programmed,Accepted,Ready" +GATEWAY_REASON_CONSTANTS="GatewayConditionReason=Programmed,Invalid,NoResources,AddressNotAssigned,AddressNotUsable,Accepted,ListenersNotValid,Pending,UnsupportedAddress,InvalidParameters,Ready,ListenersNotReady" +LISTENER_CONDITION_CONSTANTS="ListenerConditionType=Conflicted,Accepted,ResolvedRefs,Programmed,Ready" +LISTENER_REASON_CONSTANTS="ListenerConditionReason=HostnameConflict,ProtocolConflict,NoConflicts,Accepted,PortUnavailable,UnsupportedProtocol,ResolvedRefs,InvalidCertificateRef,InvalidRouteKinds,RefNotPermitted,Programmed,Invalid,Pending,Ready" +ROUTE_CONDITION_CONSTANTS="RouteConditionType=Accepted,ResolvedRefs,PartiallyInvalid" +ROUTE_REASON_CONSTANTS="RouteConditionReason=Accepted,NotAllowedByListeners,NoMatchingListenerHostname,NoMatchingParent,UnsupportedValue,Pending,IncompatibleFilters,ResolvedRefs,RefNotPermitted,InvalidKind,BackendNotFound,UnsupportedProtocol" + +GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \ + GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \ + LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \ + ROUTE_CONDITION_CONSTANTS=${ROUTE_CONDITION_CONSTANTS} ROUTE_REASON_CONSTANTS=${ROUTE_REASON_CONSTANTS} \ + cargo xtask gen_condition_constants >> $APIS_DIR/standard/constants.rs +echo "pub mod constants;" >> $APIS_DIR/standard/mod.rs + +echo "// WARNING! generated file do not edit" > $APIS_DIR/experimental/mod.rs + +for API in "${EXPERIMENTAL_APIS[@]}" +do + echo "generating experimental api $API" + curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${GATEWAY_API_VERSION}/config/crd/experimental/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $APIS_DIR/experimental/${API}.rs + sed -i 's/pub use kube::CustomResource;/pub use kube_derive::CustomResource;/g' $APIS_DIR/experimental/${API}.rs + echo "pub mod ${API};" >> $APIS_DIR/experimental/mod.rs +done + +# # Experimental API enums that need a Default trait impl along with their respective default variant. +# ENUMS=( +# HttpRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath +# HttpRouteRulesFiltersUrlRewritePathType=ReplaceFullPath +# HttpRouteRulesFiltersType=RequestHeaderModifier +# HttpRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath +# HttpRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath +# HttpRouteRulesBackendRefsFiltersType=RequestHeaderModifier +# HttpRouteRulesBackendRefsFiltersExternalAuthProtocol=Http +# GrpcRouteRulesFiltersType=RequestHeaderModifier +# GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier +# BackendTlsPolicyValidationSubjectAltNamesType=Hostname +# HttpRouteRulesFiltersExternalAuthProtocol=Http + +# ) + +# ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +# ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} +# GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $APIS_DIR/experimental/enum_defaults.rs +# echo "mod enum_defaults;" >> $APIS_DIR/experimental/mod.rs + +# GatewayClass conditions vary between standard and experimental +GATEWAY_CLASS_CONDITION_CONSTANTS="${GATEWAY_CLASS_CONDITION_CONSTANTS},SupportedVersion" +GATEWAY_CLASS_REASON_CONSTANTS="${GATEWAY_CLASS_REASON_CONSTANTS},SupportedVersion,UnsupportedVersion" +ROUTE_CONDITION_CONSTANTS="RouteConditionType=Accepted,ResolvedRefs" +ROUTE_REASON_CONSTANTS="RouteConditionReason=Accepted,NotAllowedByListeners,NoMatchingListenerHostname,UnsupportedValue,Pending,ResolvedRefs,RefNotPermitted,InvalidKind,BackendNotFound" + +GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \ + GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \ + LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \ + ROUTE_CONDITION_CONSTANTS=${ROUTE_CONDITION_CONSTANTS} ROUTE_REASON_CONSTANTS=${ROUTE_REASON_CONSTANTS} \ + cargo xtask gen_condition_constants >> $APIS_DIR/experimental/constants.rs +echo "pub mod constants;" >> $APIS_DIR/experimental/mod.rs + +# Format the code. +echo "use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/standard/enum_defaults.rs +cargo fmt + + +echo "GENERATING GATEWAY API ONLY Done" + diff --git a/scripts/generators/gateway_standard.sh b/scripts/generators/gateway_standard.sh new file mode 100755 index 0000000..5b9dd0b --- /dev/null +++ b/scripts/generators/gateway_standard.sh @@ -0,0 +1,161 @@ +#!/bin/bash + +# ------------------------------------------------------------------------------ +# This script will automatically generate API updates for new Gateway API +# releases. Update the $GATEWAY_API_VERSION to the new release version before +# executing. +# +# This script requires kopium, which can be installed with: +# +# cargo install kopium +# +# See: https://github.com/kube-rs/kopium +# ------------------------------------------------------------------------------ + +set -eou pipefail + +GATEWAY_API_VERSION="v1.5.0" +REQUIRED_KOPIUM_VERSION="0.22.5" +KOPIUM_VERSION=$(kopium --version 2>/dev/null | grep -oP 'kopium \K[0-9]+\.[0-9]+\.[0-9]+' || echo "") + +if [ -z "$KOPIUM_VERSION" ]; then + echo "Error: kopium is not installed or not in PATH" + echo "Please install kopium version ${REQUIRED_KOPIUM_VERSION} with:" + echo " cargo install kopium --version ${REQUIRED_KOPIUM_VERSION}" + exit 1 +fi + +if [ "$KOPIUM_VERSION" != "$REQUIRED_KOPIUM_VERSION" ]; then + echo "Error: kopium version mismatch" + echo " Required: ${REQUIRED_KOPIUM_VERSION}" + echo " Found: ${KOPIUM_VERSION}" + echo "Please install the correct version with:" + echo " cargo install kopium --version ${REQUIRED_KOPIUM_VERSION}" + exit 1 +fi + +echo "Using kopium version ${KOPIUM_VERSION}" +echo "Using Gateway API version ${GATEWAY_API_VERSION}" + +STANDARD_APIS=( + gatewayclasses + gateways + httproutes + referencegrants + grpcroutes + backendtlspolicies + listenersets + tlsroutes +) + +export APIS_DIR='gateway-api/src/apis' +rm -rf $APIS_DIR/standard/ + +echo "pub mod standard;" >> $APIS_DIR/mod.rs +sort -u $APIS_DIR/mod.rs > $APIS_DIR/mod.rs + + +mkdir -p $APIS_DIR/standard/ + +echo "// WARNING! generated file do not edit" > $APIS_DIR/standard/mod.rs + +for API in "${STANDARD_APIS[@]}" +do + echo "generating standard api ${API}" + curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${GATEWAY_API_VERSION}/config/crd/standard/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $APIS_DIR/standard/${API}.rs + sed -i 's/pub use kube::CustomResource;/pub use kube_derive::CustomResource;/g' $APIS_DIR/standard/${API}.rs + echo "pub mod ${API};" >> $APIS_DIR/standard/mod.rs +done + +# Standard API enums that need a Default trait impl along with their respective default variant. +ENUMS=( + HttpRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesFiltersType=RequestHeaderModifier + HttpRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersType=RequestHeaderModifier + GrpcRouteRulesFiltersType=RequestHeaderModifier + GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier + BackendTlsPolicyValidationSubjectAltNamesType=Hostname +) + +# Create a comma separated string out of $ENUMS. +ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} + +# The task searches for $GATEWAY_API_ENUMS in the environment to get the enum names and their default variants. +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $APIS_DIR/standard/enum_defaults.rs +echo "mod enum_defaults;" >> $APIS_DIR/standard/mod.rs + + +GATEWAY_CLASS_CONDITION_CONSTANTS="GatewayClassConditionType=Accepted" +GATEWAY_CLASS_REASON_CONSTANTS="GatewayClassConditionReason=Accepted,InvalidParameters,Pending,Unsupported,Waiting" +GATEWAY_CONDITION_CONSTANTS="GatewayConditionType=Programmed,Accepted,Ready" +GATEWAY_REASON_CONSTANTS="GatewayConditionReason=Programmed,Invalid,NoResources,AddressNotAssigned,AddressNotUsable,Accepted,ListenersNotValid,Pending,UnsupportedAddress,InvalidParameters,Ready,ListenersNotReady" +LISTENER_CONDITION_CONSTANTS="ListenerConditionType=Conflicted,Accepted,ResolvedRefs,Programmed,Ready" +LISTENER_REASON_CONSTANTS="ListenerConditionReason=HostnameConflict,ProtocolConflict,NoConflicts,Accepted,PortUnavailable,UnsupportedProtocol,ResolvedRefs,InvalidCertificateRef,InvalidRouteKinds,RefNotPermitted,Programmed,Invalid,Pending,Ready" +ROUTE_CONDITION_CONSTANTS="RouteConditionType=Accepted,ResolvedRefs,PartiallyInvalid" +ROUTE_REASON_CONSTANTS="RouteConditionReason=Accepted,NotAllowedByListeners,NoMatchingListenerHostname,NoMatchingParent,UnsupportedValue,Pending,IncompatibleFilters,ResolvedRefs,RefNotPermitted,InvalidKind,BackendNotFound,UnsupportedProtocol" + +GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \ + GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \ + LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \ + ROUTE_CONDITION_CONSTANTS=${ROUTE_CONDITION_CONSTANTS} ROUTE_REASON_CONSTANTS=${ROUTE_REASON_CONSTANTS} \ + cargo xtask gen_condition_constants >> $APIS_DIR/standard/constants.rs +echo "pub mod constants;" >> $APIS_DIR/standard/mod.rs + + + +export RUST_LOG=info + +echo " **** Starting Type Reducer - Collapsing Duplicative Types **** " +echo " **** Type Reducer - PHASE 1 - First Pass ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/standard --out-dir $APIS_DIR/standard reduce --previous-pass-derived-type-names ./type-reducer/standard_reduced_types_pass_0.txt --current-pass-substitute-names ./type-reducer/standard_customized_mapped_names.txt +mv mapped_names.txt standard_mapped_names_phase_1.txt +mv mapped_types_to_names.txt standard_mapped_types_to_names_phase_1.txt +echo " **** PHASE 2 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/standard --out-dir $APIS_DIR/standard reduce --previous-pass-derived-type-names ./type-reducer/standard_reduced_types_pass_1.txt --current-pass-substitute-names ./type-reducer/standard_customized_mapped_names.txt +mv mapped_names.txt standard_mapped_names_phase_2.txt +mv mapped_types_to_names.txt standard_mapped_types_to_names_phase_2.txt +echo " **** PHASE 3 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/standard --out-dir $APIS_DIR/standard reduce --previous-pass-derived-type-names ./type-reducer/standard_reduced_types_pass_2.txt --current-pass-substitute-names ./type-reducer/standard_customized_mapped_names.txt +mv mapped_names.txt standard_mapped_names_phase_3.txt +mv mapped_types_to_names.txt standard_mapped_types_to_names_phase_3.txt +echo " **** PHASE 4 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/standard --out-dir $APIS_DIR/standard reduce --previous-pass-derived-type-names ./type-reducer/standard_reduced_types_pass_3.txt --current-pass-substitute-names ./type-reducer/standard_customized_mapped_names.txt +mv mapped_names.txt standard_mapped_names_phase_4.txt +mv mapped_types_to_names.txt standard_mapped_types_to_names_phase_4.txt + + +echo " **** RENAMING PHASE ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/standard --out-dir $APIS_DIR/standard rename --rename-only-substitute-names ./type-reducer/standard_rename_only_mapped_names.txt + + +ENUMS=( + GRPCFilterType=RequestHeaderModifier + RequestOperationType=ReplaceFullPath + HTTPFilterType=RequestHeaderModifier + BackendTlsPolicyValidationSubjectAltNamesType=Hostname +) + +ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults > $APIS_DIR/standard/enum_defaults.rs +echo "use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/standard/enum_defaults.rs + +sed -i '/#\[kube(status = "GrpcRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/grpcroutes.rs +sed -i '/#\[kube(status = "HttpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/httproutes.rs +sed -i '/#\[kube(status = "TlsRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/tlsroutes.rs + +cargo fmt +echo "Gateway API Generation complete" + +echo "Gateway API Cleaning up temporary files" +set -x +rm -f standard_mapped_names_phase_*.txt +rm -f standard_mapped_types_to_names_phase_*.txt +rm -f mapped_names.txt +rm -f mapped_types_to_names.txt +set +x +echo "Gateway API Cleanup complete" diff --git a/scripts/generators/generate_all.sh b/scripts/generators/generate_all.sh new file mode 100755 index 0000000..629a09d --- /dev/null +++ b/scripts/generators/generate_all.sh @@ -0,0 +1,4 @@ +#!/bin/bash +./scripts/generators/generate_gateway.sh +./scripts/generators/generate_gateway_with_extensions.sh +./scripts/generators/generate_inference_only.sh diff --git a/scripts/generators/generate_gateway.sh b/scripts/generators/generate_gateway.sh new file mode 100755 index 0000000..dd570a1 --- /dev/null +++ b/scripts/generators/generate_gateway.sh @@ -0,0 +1,46 @@ +#!/bin/bash +export APIS_DIR='gateway-api/src' +export GATEWAY_API=true +export GATEWAY_API_INFERENCE=false +export GATEWAY_API_REDUCED=false + +rm -rf $APIS_DIR/standard/ +rm -rf $APIS_DIR/experimental/ +cat << EOF > $APIS_DIR/mod.rs +pub mod experimental; +pub mod standard; +EOF + +mkdir -p $APIS_DIR/standard/ +mkdir -p $APIS_DIR/experimental/ + + +./scripts/generators/gateway_generator.sh +./scripts/generators/enums_generator.sh ./scripts/generators/standard_enum_names.txt ./scripts/generators/empty.txt ./scripts/generators/experimental_enum_names.txt ./scripts/generators/empty.txt +echo "use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/standard/enum_defaults.rs + + +./scripts/generators/reducer.sh standard +./scripts/generators/reducer.sh experimental + +export GATEWAY_API_REDUCED=true +./scripts/generators/enums_generator.sh ./scripts/generators/reduced_standard_enum_names.txt ./scripts/generators/empty.txt ./scripts/generators/reduced_experimental_enum_names.txt ./scripts/generators/empty.txt + + +echo "use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/standard/enum_defaults.rs + +sed -i '/#\[kube(status = "GrpcRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/grpcroutes.rs +sed -i '/#\[kube(status = "HttpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/httproutes.rs +sed -i '/#\[kube(status = "TlsRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/tlsroutes.rs + + +echo "use crate::experimental::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/experimental/enum_defaults.rs + +# sed -i '/#\[kube(status = "GrpcRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/grpcroutes.rs +# sed -i '/#\[kube(status = "HttpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/httproutes.rs +# sed -i '/#\[kube(status = "TlsRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tlsroutes.rs +# sed -i '/#\[kube(status = "UdpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/udproutes.rs +# sed -i '/#\[kube(status = "TcpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tcproutes.rs + + +cargo fmt diff --git a/scripts/generators/generate_gateway_with_extensions.sh b/scripts/generators/generate_gateway_with_extensions.sh new file mode 100755 index 0000000..e4c3f7c --- /dev/null +++ b/scripts/generators/generate_gateway_with_extensions.sh @@ -0,0 +1,54 @@ +#!/bin/bash +export APIS_DIR='gateway-api-with-extensions/src' +export GATEWAY_API=true +export GATEWAY_API_INFERENCE=true +export GATEWAY_API_REDUCED=false + +echo "GENERATING GATEWAY API WITH EXTENSIONS" + + +rm -rf $APIS_DIR/standard/ +rm -rf $APIS_DIR/experimental/ +cat << EOF > $APIS_DIR/mod.rs +pub mod experimental; +pub mod standard; +EOF + +mkdir -p $APIS_DIR/standard/ +mkdir -p $APIS_DIR/experimental/ + + +./scripts/generators/gateway_generator.sh +./scripts/generators/inference_generator.sh +./scripts/generators/enums_generator.sh ./scripts/generators/standard_enum_names.txt ./scripts/generators/standard_inference_enum_names.txt ./scripts/generators/experimental_enum_names.txt ./scripts/generators/experimental_inference_enum_names.txt +echo "use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/standard/enum_defaults.rs + + +./scripts/generators/reducer.sh standard +./scripts/generators/reducer.sh experimental + +export GATEWAY_API_REDUCED=true +./scripts/generators/enums_generator.sh ./scripts/generators/reduced_standard_enum_names.txt ./scripts/generators/reduced_standard_inference_enum_names.txt ./scripts/generators/reduced_experimental_enum_names.txt ./scripts/generators/reduced_experimental_inference_enum_names.txt + + +echo "use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/standard/enum_defaults.rs + +sed -i '/#\[kube(status = "GrpcRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/grpcroutes.rs +sed -i '/#\[kube(status = "HttpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/httproutes.rs +sed -i '/#\[kube(status = "TlsRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/tlsroutes.rs + + +echo "use crate::experimental::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/experimental/enum_defaults.rs + +# sed -i '/#\[kube(status = "GrpcRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/grpcroutes.rs +# sed -i '/#\[kube(status = "HttpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/httproutes.rs +# sed -i '/#\[kube(status = "TlsRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tlsroutes.rs +# sed -i '/#\[kube(status = "UdpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/udproutes.rs +# sed -i '/#\[kube(status = "TcpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tcproutes.rs +sed -i '/#\[kube(status = "InferenceModelRewriteStatus")\]/c\#\[kube(status = "InferenceStatus")\]' $APIS_DIR/experimental/inferencemodelrewrites.rs +sed -i '/#\[kube(status = "InferenceObjectiveStatus")\]/c\#\[kube(status = "InferenceStatus")\]' $APIS_DIR/experimental/inferenceobjectives.rs + +cargo fmt + + +echo "GENERATING GATEWAY API WITH EXTENSIONS Done" diff --git a/scripts/generators/generate_inference_only.sh b/scripts/generators/generate_inference_only.sh new file mode 100755 index 0000000..0083431 --- /dev/null +++ b/scripts/generators/generate_inference_only.sh @@ -0,0 +1,41 @@ +#!/bin/bash +export APIS_DIR='gateway-api-inference-extension/src' +export GATEWAY_API=false +export GATEWAY_API_INFERENCE=true +export GATEWAY_API_REDUCED=false + +echo "GENERATING GATEWAY API INFERENCE EXTENSION ONLY" + +rm -rf $APIS_DIR/standard/ +rm -rf $APIS_DIR/experimental/ +cat << EOF > $APIS_DIR/mod.rs +pub mod experimental; +pub mod standard; +EOF + +mkdir -p $APIS_DIR/standard/ +mkdir -p $APIS_DIR/experimental/ + +echo "// WARNING! generated file do not edit" > $APIS_DIR/standard/mod.rs +echo "// WARNING! generated file do not edit" > $APIS_DIR/experimental/mod.rs + + +./scripts/generators/inference_generator.sh + +export GATEWAY_API_REDUCED=true +./scripts/generators/enums_generator.sh ./scripts/generators/empy.txt ./scripts/generators/standard_inference_enum_names.txt ./scripts/generators/empty.txt ./scripts/generators/experimental_inference_enum_names.txt + + +./scripts/generators/reducer.sh standard +./scripts/generators/reducer.sh experimental + + +./scripts/generators/enums_generator.sh ./scripts/generators/empty.txt ./scripts/generators/reduced_standard_inference_enum_names.txt ./scripts/generators/empty.txt ./scripts/generators/reduced_experimental_inference_enum_names.txt + +sed -i '/#\[kube(status = "InferenceModelRewriteStatus")\]/c\#\[kube(status = "InferenceStatus")\]' $APIS_DIR/experimental/inferencemodelrewrites.rs +sed -i '/#\[kube(status = "InferenceObjectiveStatus")\]/c\#\[kube(status = "InferenceStatus")\]' $APIS_DIR/experimental/inferenceobjectives.rs + +cargo fmt + + +echo "GENERATING GATEWAY API INFERENCE EXTENSION ONLY Done" diff --git a/scripts/generators/inference_generator.sh b/scripts/generators/inference_generator.sh new file mode 100755 index 0000000..f3fc95f --- /dev/null +++ b/scripts/generators/inference_generator.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# ------------------------------------------------------------------------------ +# This script will automatically generate API updates for new Inference Extension +# releases. Update the $INFERENCE_EXT_VERSION to the new release version before +# executing. +# +# This script requires kopium, which can be installed with: +# +# cargo install kopium +# +# See: https://github.com/kube-rs/kopium +# ------------------------------------------------------------------------------ +set -euo pipefail + + +echo " **** Inference Extension Processing Starts **** " +INFERENCE_API_DIR=$APIS_DIR +INFERENCE_EXT_VERSION="v1.3.0" +REQUIRED_KOPIUM_VERSION="0.22.5" +KOPIUM_VERSION=$(kopium --version 2>/dev/null | grep -oP 'kopium \K[0-9]+\.[0-9]+\.[0-9]+' || echo "") +echo "Using Inference Extension version ${INFERENCE_EXT_VERSION}" + +INFERENCE_EXT_STANDARD_APIS=( + inferencepools +) + +INFERENCE_EXT_EXPERIMENTAL_APIS=( + inferencepools + inferenceobjectives + inferencemodelrewrites + inferencepoolimports +) + + + +mkdir -p $APIS_DIR/standard/ +mkdir -p $APIS_DIR/experimental/ + + +for API in "${INFERENCE_EXT_STANDARD_APIS[@]}" +do + echo "generating inference extension standard api ${API}" + curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api-inference-extension/${INFERENCE_EXT_VERSION}/config/crd/bases/inference.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $INFERENCE_API_DIR/standard/${API}.rs + sed -i 's/pub use kube::CustomResource;/pub use kube_derive::CustomResource;/g' $INFERENCE_API_DIR/standard/${API}.rs + echo "pub mod ${API};" >> $INFERENCE_API_DIR/standard/mod.rs +done + +for API in "${INFERENCE_EXT_EXPERIMENTAL_APIS[@]}" +do + echo "generating inference extension experimental api ${API}" + curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api-inference-extension/${INFERENCE_EXT_VERSION}/config/crd/bases/inference.networking.x-k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $INFERENCE_API_DIR/experimental/${API}.rs + sed -i 's/pub use kube::CustomResource;/pub use kube_derive::CustomResource;/g' $INFERENCE_API_DIR/experimental/${API}.rs + echo "pub mod ${API};" >> $INFERENCE_API_DIR/experimental/mod.rs +done diff --git a/scripts/generators/reduced_experimental_enum_names.txt b/scripts/generators/reduced_experimental_enum_names.txt new file mode 100644 index 0000000..f8a9375 --- /dev/null +++ b/scripts/generators/reduced_experimental_enum_names.txt @@ -0,0 +1,16 @@ +AllowedRoutesNamespacesFrom=Same +BackendTlsPolicyValidationSubjectAltNamesType=Hostname +GatewayAllowedListenersNamespacesFrom=Same +GRPCFilterType=RequestHeaderModifier +CookieConfigLifetimeType=Session +SessionPersistenceType=Cookie +HeaderMatchType=Exact +HTTPFilterType=RequestHeaderModifier +HTTPMethodMatch=Get +HttpRouteRulesMatchesPathType=Exact +RedirectStatusCode=r#_301 +RequestOperationType=ReplaceFullPath +RequestRedirectScheme=Https +TlsMode=Terminate +TlsValidationMode=AllowValidOnly +ExternalAuthProtocol=Http diff --git a/scripts/generators/reduced_experimental_inference_enum_names.txt b/scripts/generators/reduced_experimental_inference_enum_names.txt new file mode 100644 index 0000000..eadfb8c --- /dev/null +++ b/scripts/generators/reduced_experimental_inference_enum_names.txt @@ -0,0 +1 @@ +InferencePoolExtensionRefFailureMode=FailOpen diff --git a/scripts/generators/reduced_standard_enum_names.txt b/scripts/generators/reduced_standard_enum_names.txt new file mode 100644 index 0000000..49546d6 --- /dev/null +++ b/scripts/generators/reduced_standard_enum_names.txt @@ -0,0 +1,13 @@ +AllowedRoutesNamespacesFrom=Same +BackendTlsPolicyValidationSubjectAltNamesType=Hostname +GatewayAllowedListenersNamespacesFrom=Same +GRPCFilterType=RequestHeaderModifier +HeaderMatchType=Exact +HTTPFilterType=RequestHeaderModifier +HTTPMethodMatch=Get +HttpRouteRulesMatchesPathType=Exact +RedirectStatusCode=r#_301 +RequestOperationType=ReplaceFullPath +RequestRedirectScheme=Https +TlsMode=Terminate +TlsValidationMode=AllowValidOnly diff --git a/scripts/generators/reduced_standard_inference_enum_names.txt b/scripts/generators/reduced_standard_inference_enum_names.txt new file mode 100644 index 0000000..e209cba --- /dev/null +++ b/scripts/generators/reduced_standard_inference_enum_names.txt @@ -0,0 +1 @@ +InferencePoolEndpointPickerRefFailureMode=FailOpen diff --git a/scripts/generators/reducer.sh b/scripts/generators/reducer.sh new file mode 100755 index 0000000..7826705 --- /dev/null +++ b/scripts/generators/reducer.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -eou pipefail +export RUST_LOG=info + +API_TYPE=$1 + +echo " **** Starting Type Reducer - Collapsing Duplicative Types **** " +echo " **** Type Reducer - PHASE 1 - First Pass ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/$API_TYPE --out-dir $APIS_DIR/$API_TYPE reduce --previous-pass-derived-type-names ./type-reducer/${API_TYPE}_reduced_types_pass_0.txt --current-pass-substitute-names ./type-reducer/${API_TYPE}_customized_mapped_names.txt +mv mapped_names.txt ${API_TYPE}_mapped_names_phase_1.txt +mv mapped_types_to_names.txt ${API_TYPE}_mapped_types_to_names_phase_1.txt +echo " **** PHASE 2 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/$API_TYPE --out-dir $APIS_DIR/$API_TYPE reduce --previous-pass-derived-type-names ./type-reducer/${API_TYPE}_reduced_types_pass_1.txt --current-pass-substitute-names ./type-reducer/${API_TYPE}_customized_mapped_names.txt +mv mapped_names.txt ${API_TYPE}_mapped_names_phase_2.txt +mv mapped_types_to_names.txt ${API_TYPE}_mapped_types_to_names_phase_2.txt +echo " **** PHASE 3 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/$API_TYPE --out-dir $APIS_DIR/$API_TYPE reduce --previous-pass-derived-type-names ./type-reducer/${API_TYPE}_reduced_types_pass_2.txt --current-pass-substitute-names ./type-reducer/${API_TYPE}_customized_mapped_names.txt +mv mapped_names.txt ${API_TYPE}_mapped_names_phase_3.txt +mv mapped_types_to_names.txt ${API_TYPE}_mapped_types_to_names_phase_3.txt +echo " **** PHASE 4 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/$API_TYPE --out-dir $APIS_DIR/$API_TYPE reduce --previous-pass-derived-type-names ./type-reducer/${API_TYPE}_reduced_types_pass_3.txt --current-pass-substitute-names ./type-reducer/${API_TYPE}_customized_mapped_names.txt +mv mapped_names.txt ${API_TYPE}_mapped_names_phase_4.txt +mv mapped_types_to_names.txt ${API_TYPE}_mapped_types_to_names_phase_4.txt +echo " **** PHASE 5 ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/$API_TYPE --out-dir $APIS_DIR/$API_TYPE reduce --previous-pass-derived-type-names ./type-reducer/${API_TYPE}_reduced_types_pass_4.txt --current-pass-substitute-names ./type-reducer/${API_TYPE}_customized_mapped_names.txt +mv mapped_names.txt ${API_TYPE}_mapped_names_phase_5.txt +mv mapped_types_to_names.txt ${API_TYPE}_mapped_types_to_names_phase_5.txt +# echo " **** PHASE 6 ***** " +# cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/$API_TYPE --out-dir $APIS_DIR/$API_TYPE reduce --previous-pass-derived-type-names ./type-reducer/${API_TYPE}_reduced_types_pass_5.txt --current-pass-substitute-names ./type-reducer/${API_TYPE}_customized_mapped_names.txt +# mv mapped_names.txt ${API_TYPE}_mapped_names_phase_6.txt +# mv mapped_types_to_names.txt ${API_TYPE}_mapped_types_to_names_phase_6.txt + + +echo " **** RENAMING PHASE ***** " +cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/$API_TYPE --out-dir $APIS_DIR/$API_TYPE rename --rename-only-substitute-names ./type-reducer/${API_TYPE}_rename_only_mapped_names.txt diff --git a/scripts/generators/standard_enum_names.txt b/scripts/generators/standard_enum_names.txt new file mode 100644 index 0000000..9c4de96 --- /dev/null +++ b/scripts/generators/standard_enum_names.txt @@ -0,0 +1,26 @@ +BackendTlsPolicyValidationSubjectAltNamesType=Hostname +GatewayAllowedListenersNamespacesFrom=Same +GatewayListenersAllowedRoutesNamespacesFrom=Same +GatewayListenersTlsMode=Terminate +GatewayTlsFrontendDefaultValidationMode=AllowValidOnly +GatewayTlsFrontendPerPortTlsValidationMode=AllowValidOnly +GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier +GrpcRouteRulesFiltersType=RequestHeaderModifier +GrpcRouteRulesMatchesHeadersType=Exact +GrpcRouteRulesMatchesMethodType=Exact +HttpRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath +HttpRouteRulesBackendRefsFiltersRequestRedirectScheme=Https +HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode=r#_301 +HttpRouteRulesBackendRefsFiltersType=RequestHeaderModifier +HttpRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath +HttpRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath +HttpRouteRulesFiltersRequestRedirectScheme=Https +HttpRouteRulesFiltersRequestRedirectStatusCode=r#_301 +HttpRouteRulesFiltersType=RequestHeaderModifier +HttpRouteRulesFiltersUrlRewritePathType=ReplaceFullPath +HttpRouteRulesMatchesHeadersType=Exact +HttpRouteRulesMatchesMethod=Get +HttpRouteRulesMatchesPathType=Exact +HttpRouteRulesMatchesQueryParamsType=Exact +ListenerSetListenersAllowedRoutesNamespacesFrom=Same +ListenerSetListenersTlsMode=Terminate diff --git a/scripts/generators/standard_inference_enum_names.txt b/scripts/generators/standard_inference_enum_names.txt new file mode 100644 index 0000000..e69de29 diff --git a/type-reducer/Cargo.toml b/type-reducer/Cargo.toml new file mode 100644 index 0000000..46dc93a --- /dev/null +++ b/type-reducer/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "type-reducer" + +version.workspace = true +edition.workspace = true +authors.workspace = true + +[dependencies] +syn = { version = "2", features = [ + "full", + "extra-traits", + "visit", + "visit-mut", + "proc-macro", +] } +proc-macro2 = "1" +prettyplease = "0.2" +itertools = "0.14" +multimap = "0.10" +clap = { version = "4.5", features = ["derive"] } +log = { version = "0.4", features = ["std", "serde"] } +simple_logger = "5" diff --git a/type-reducer/README.md b/type-reducer/README.md new file mode 100644 index 0000000..ce271b7 --- /dev/null +++ b/type-reducer/README.md @@ -0,0 +1,48 @@ +## Type Reduction + +This application will parse Kopium generated files and will try to identify the types that are potentially the same. The new types will be saved into "common" mod with a new, user selected name and the code will be updated with the new names. +The overall approach has three steps. + +### 1. Reducing leaf types. +The algorithm will try to identify the structs that can be reduced or "leaf" types. Leaf types are the types with fields which are simple types (String, u32, u64) or types reduced in the previous steps. As the output, the application will produce files with "mappings". + +### 2. Provide new names +The mappings from step 1 should be used to provide new, user selected names. + + +##### Before the change. +This shows that all above Kopium generated types are the same and we should replace "GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd" with a more meaningful name. + +| Kopium generated names | | User selected name| +|------------------------|--|-------------------| +|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierSet|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierAdd|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierSet|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|HttpRouteRulesBackendRefsFiltersRequestHeaderModifierSet|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|HttpRouteRulesBackendRefsFiltersResponseHeaderModifierAdd|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|HttpRouteRulesBackendRefsFiltersResponseHeaderModifierSet|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| + + +##### After the change. +On subsequent runs, the algorithm will use HTTPHeader as new name for all those types. + + +| Kopium generated names | | User selected name| +|------------------------|--|-------------------| +|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd|->|HTTPHeader| +|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierSet|->|HTTPHeader| +|GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierAdd|->|HTTPHeader| +|GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierSet|->|HTTPHeader| +|HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd|->|HTTPHeader| +|HttpRouteRulesBackendRefsFiltersRequestHeaderModifierSet|->|HTTPHeader| +|HttpRouteRulesBackendRefsFiltersResponseHeaderModifierAdd|->|HTTPHeader| +|HttpRouteRulesBackendRefsFiltersResponseHeaderModifierSet|->|HTTPHeader| + + +### 3. Re-run the application to produce the code with desired types + + +Steps 1 to 3 should be repeated until no similar types are detected for Gateway API or extensions. Check [scripts/generators/](../scripts/generators/) directory for more details on how to use respective generator scripts. + diff --git a/type-reducer/experimental_customized_mapped_names.txt b/type-reducer/experimental_customized_mapped_names.txt new file mode 100644 index 0000000..fad2581 --- /dev/null +++ b/type-reducer/experimental_customized_mapped_names.txt @@ -0,0 +1,165 @@ +GrpcRouteRulesBackendRefsFiltersType->GRPCFilterType +GrpcRouteRulesFiltersType->GRPCFilterType +GatewayAddresses->GatewayAddress +GatewayStatusAddresses->GatewayAddress +GrpcRouteRulesBackendRefsFiltersExtensionRef->ExtensionParametersReference +GrpcRouteRulesFiltersExtensionRef->ExtensionParametersReference +GatewayInfrastructureParametersRef->ExtensionParametersReference +HttpRouteRulesBackendRefsFiltersExtensionRef->ExtensionParametersReference +HttpRouteRulesFiltersExtensionRef->ExtensionParametersReference +BackendTlsPolicyValidationCaCertificateRefs->ExtensionParametersReference +GatewayAllowedListenersNamespacesSelectorMatchExpressions->MatchExpressions +GatewayListenersAllowedRoutesNamespacesSelectorMatchExpressions->MatchExpressions +ListenerSetListenersAllowedRoutesNamespacesSelectorMatchExpressions->MatchExpressions +GatewayClassParametersRef->GatewayParametersRef +GatewayTlsFrontendDefaultValidationCaCertificateRefs->GatewayParametersRef +GatewayTlsFrontendPerPortTlsValidationCaCertificateRefs->GatewayParametersRef +GatewayListenersAllowedRoutesKinds->Kind +GatewayStatusListenersSupportedKinds->Kind +ListenerSetListenersAllowedRoutesKinds->Kind +ListenerSetStatusListenersSupportedKinds->Kind +GatewayListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespacesFrom +ListenerSetListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespacesFrom +GatewayListenersTlsCertificateRefs->Reference +GatewayTlsBackendClientCertificateRef->Reference +ListenerSetListenersTlsCertificateRefs->Reference +ListenerSetParentRef->Reference +GatewayListenersTlsMode->TlsMode +ListenerSetListenersTlsMode->TlsMode +GatewayTlsFrontendDefaultValidationMode->TlsValidationMode +GatewayTlsFrontendPerPortTlsValidationMode->TlsValidationMode +BackendTlsPolicyStatusAncestorsAncestorRef->ParentReference +GrpcRouteParentRefs->ParentReference +GrpcRouteStatusParentsParentRef->ParentReference +HttpRouteParentRefs->ParentReference +HttpRouteStatusParentsParentRef->ParentReference +TlsRouteParentRefs->ParentReference +TlsRouteStatusParentsParentRef->ParentReference +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd->HTTPHeader +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierSet->HTTPHeader +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierAdd->HTTPHeader +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierSet->HTTPHeader +GrpcRouteRulesFiltersRequestHeaderModifierAdd->HTTPHeader +GrpcRouteRulesFiltersRequestHeaderModifierSet->HTTPHeader +GrpcRouteRulesFiltersResponseHeaderModifierAdd->HTTPHeader +GrpcRouteRulesFiltersResponseHeaderModifierSet->HTTPHeader +HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd->HTTPHeader +HttpRouteRulesBackendRefsFiltersRequestHeaderModifierSet->HTTPHeader +HttpRouteRulesBackendRefsFiltersResponseHeaderModifierAdd->HTTPHeader +HttpRouteRulesBackendRefsFiltersResponseHeaderModifierSet->HTTPHeader +HttpRouteRulesFiltersRequestHeaderModifierAdd->HTTPHeader +HttpRouteRulesFiltersRequestHeaderModifierSet->HTTPHeader +HttpRouteRulesFiltersResponseHeaderModifierAdd->HTTPHeader +HttpRouteRulesFiltersResponseHeaderModifierSet->HTTPHeader +GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference +GrpcRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference +HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference +HttpRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference +GrpcRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +GrpcRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesBackendRefsFiltersRequestRedirectPathType->RequestOperationType +HttpRouteRulesBackendRefsFiltersUrlRewritePathType->RequestOperationType +HttpRouteRulesFiltersRequestRedirectPathType->RequestOperationType +HttpRouteRulesFiltersUrlRewritePathType->RequestOperationType +HttpRouteRulesBackendRefsFiltersRequestRedirectScheme->RequestRedirectScheme +HttpRouteRulesFiltersRequestRedirectScheme->RequestRedirectScheme +HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode->RedirectStatusCode +HttpRouteRulesFiltersRequestRedirectStatusCode->RedirectStatusCode +HttpRouteRulesBackendRefsFiltersType->HTTPFilterType +HttpRouteRulesFiltersType->HTTPFilterType +GrpcRouteRulesMatchesHeadersType->HeaderMatchType +GrpcRouteRulesMatchesMethodType->HeaderMatchType +HttpRouteRulesMatchesHeadersType->HeaderMatchType +HttpRouteRulesMatchesQueryParamsType->HeaderMatchType +HttpRouteRulesBackendRefsFiltersExternalAuthForwardBody->ForwardBody +HttpRouteRulesFiltersExternalAuthForwardBody->ForwardBody +HttpRouteRulesBackendRefsFiltersExternalAuthHttp->ExternalAuthHttp +HttpRouteRulesFiltersExternalAuthHttp->ExternalAuthHttp +HttpRouteRulesBackendRefsFiltersExternalAuthGrpc->ExternalAuthGrpc +HttpRouteRulesFiltersExternalAuthGrpc->ExternalAuthGrpc +GrpcRouteRulesSessionPersistenceCookieConfigLifetimeType->CookieConfigLifetimeType +HttpRouteRulesSessionPersistenceCookieConfigLifetimeType->CookieConfigLifetimeType +GatewayDefaultScope->DefaultGateway +GrpcRouteUseDefaultGateways->DefaultGateway +HttpRouteUseDefaultGateways->DefaultGateway +TcpRouteUseDefaultGateways->DefaultGateway +TlsRouteUseDefaultGateways->DefaultGateway +UdpRouteUseDefaultGateways->DefaultGateway +InferenceModelRewritePoolRef->InferencePoolRef +InferenceObjectivePoolRef->InferencePoolRef +InferenceModelRewriteStatus->InferenceStatus +InferenceObjectiveStatus->InferenceStatus +GatewayClassStatusSupportedFeatures->SupportedFeatures +InferencePoolImportStatusControllersExportingClusters->ExportingClusters +GrpcRouteRulesSessionPersistenceType->SessionPersistenceType +HttpRouteRulesSessionPersistenceType->SessionPersistenceType +HttpRouteRulesBackendRefsFiltersExternalAuthProtocol->ExternalAuthProtocol +HttpRouteRulesFiltersExternalAuthProtocol->ExternalAuthProtocol + +#### Pass 2 +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier +GrpcRouteRulesFiltersRequestHeaderModifier->HeaderModifier +GrpcRouteRulesFiltersResponseHeaderModifier->HeaderModifier +HttpRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier +HttpRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier +HttpRouteRulesFiltersRequestHeaderModifier->HeaderModifier +HttpRouteRulesFiltersResponseHeaderModifier->HeaderModifier +GrpcRouteRulesMatchesHeaders->HeaderMatch +HttpRouteRulesMatchesHeaders->HeaderMatch +HttpRouteRulesMatchesQueryParams->HeaderMatch +GrpcRouteStatusParents->ParentRouteStatus +HttpRouteStatusParents->ParentRouteStatus +GrpcRouteRulesBackendRefsFiltersRequestMirror->RequestMirror +GrpcRouteRulesFiltersRequestMirror->RequestMirror +HttpRouteRulesBackendRefsFiltersRequestMirror->RequestMirror +HttpRouteRulesFiltersRequestMirror->RequestMirror +HttpRouteRulesBackendRefsFiltersRequestRedirectPath->RequestRedirectPath +HttpRouteRulesBackendRefsFiltersUrlRewritePath->RequestRedirectPath +HttpRouteRulesFiltersRequestRedirectPath->RequestRedirectPath +HttpRouteRulesFiltersUrlRewritePath->RequestRedirectPath +GatewayAllowedListenersNamespacesSelector->NamespaceSelector +GatewayListenersAllowedRoutesNamespacesSelector->NamespaceSelector +ListenerSetListenersAllowedRoutesNamespacesSelector->NamespaceSelector +GatewayStatusListeners->ListenerStatus +ListenerSetStatusListeners->ListenerStatus +GatewayListenersTls->ListenerTls +ListenerSetListenersTls->ListenerTls +GrpcRouteRulesSessionPersistenceCookieConfig->PersistenceCookieConfig +HttpRouteRulesSessionPersistenceCookieConfig->PersistenceCookieConfig +GatewayTlsFrontendDefaultValidation->FrontendTlsValidation +GatewayTlsFrontendPerPortTlsValidation->FrontendTlsValidation +HttpRouteRulesBackendRefsFiltersExternalAuth->ExternalAuthFilter +HttpRouteRulesFiltersExternalAuth->ExternalAuthFilter + +#### Pass 3 +GrpcRouteRulesBackendRefsFilters->GrpcRouteFilter +GrpcRouteRulesFilters->GrpcRouteFilter +HttpRouteRulesBackendRefsFiltersRequestRedirect->HttpRouteRequestRedirect +HttpRouteRulesFiltersRequestRedirect->HttpRouteRequestRedirect +HttpRouteRulesBackendRefsFiltersUrlRewrite->HttpRouteUrlRewrite +HttpRouteRulesFiltersUrlRewrite->HttpRouteUrlRewrite +GrpcRouteStatus->RouteStatus +HttpRouteStatus->RouteStatus +TlsRouteStatus->RouteStatus +UdpRouteStatus->RouteStatus +TcpRouteStatus->RouteStatus +HttpRouteRulesBackendRefsFiltersRequestRedirect->FilterRequestRedirect +HttpRouteRulesFiltersRequestRedirect->FilterRequestRedirect +GatewayListenersAllowedRoutesNamespaces->AllowedRoutesNamespaces +ListenerSetListenersAllowedRoutesNamespaces->AllowedRoutesNamespaces +GrpcRouteRulesSessionPersistence->SessionPersistence +HttpRouteRulesSessionPersistence->SessionPersistence +GatewayTlsFrontendDefault->FrontendTls +GatewayTlsFrontendPerPortTls->FrontendTls + + +#### Pass 4 +GatewayListenersAllowedRoutes->AllowedRoutes +ListenerSetListenersAllowedRoutes->AllowedRoutes + +#### Pass 5 +GatewayListeners->Listeners +ListenerSetListeners->Listeners diff --git a/type-reducer/experimental_ignorable_mapped_names.txt b/type-reducer/experimental_ignorable_mapped_names.txt new file mode 100644 index 0000000..c80e826 --- /dev/null +++ b/type-reducer/experimental_ignorable_mapped_names.txt @@ -0,0 +1,6 @@ +TcpRouteSpec->RouteSpec +UdpRouteSpec->RouteSpec +GrpcRouteRulesFilters->GrpcRouteFilter +GrpcRouteRulesBackendRefsFilters->GrpcRouteFilter +GatewayClassStatusSupportedFeatures->GatewayClassStatusSupportedFeatures +InferencePoolImportStatusControllersExportingClusters->InferencePoolImportStatusControllersExportingClusters diff --git a/type-reducer/experimental_reduced_types_pass_0.txt b/type-reducer/experimental_reduced_types_pass_0.txt new file mode 100644 index 0000000..3c2773d --- /dev/null +++ b/type-reducer/experimental_reduced_types_pass_0.txt @@ -0,0 +1 @@ +Condition \ No newline at end of file diff --git a/type-reducer/experimental_reduced_types_pass_1.txt b/type-reducer/experimental_reduced_types_pass_1.txt new file mode 100644 index 0000000..315d9d7 --- /dev/null +++ b/type-reducer/experimental_reduced_types_pass_1.txt @@ -0,0 +1,30 @@ +AllowedRoutesNamespacesFrom +BackendObjectReference +CookieConfigLifetimeType +DefaultGateway +ExportingClusters +ExtensionParametersReference +ExternalAuthGrpc +ExternalAuthHttp +ExternalAuthProtocol +ForwardBody +GatewayAddress +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader +InferencePoolRef +InferenceStatus +Kind +MatchExpressions +ParentReference +RedirectStatusCode +Reference +RequestMirrorFraction +RequestOperationType +RequestRedirectScheme +SessionPersistenceType +SupportedFeatures +TlsMode +TlsValidationMode diff --git a/type-reducer/experimental_reduced_types_pass_2.txt b/type-reducer/experimental_reduced_types_pass_2.txt new file mode 100644 index 0000000..d6a5e6d --- /dev/null +++ b/type-reducer/experimental_reduced_types_pass_2.txt @@ -0,0 +1,42 @@ +AllowedRoutesNamespacesFrom +BackendObjectReference +CookieConfigLifetimeType +DefaultGateway +ExportingClusters +ExtensionParametersReference +ExternalAuthGrpc +ExternalAuthHttp +ExternalAuthProtocol +ForwardBody +GatewayAddress +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader +InferencePoolRef +InferenceStatus +Kind +MatchExpressions +ParentReference +RedirectStatusCode +Reference +RequestMirrorFraction +RequestOperationType +RequestRedirectScheme +SessionPersistenceType +SupportedFeatures +TlsMode +TlsValidationMode +#### Pass 2 +MatchingHeaders +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +NamespaceSelector +ListenerStatus +ListenerTls +ParentRouteStatus +PersistenceCookieConfig +FrontendTlsValidation diff --git a/type-reducer/experimental_reduced_types_pass_3.txt b/type-reducer/experimental_reduced_types_pass_3.txt new file mode 100644 index 0000000..12e49e4 --- /dev/null +++ b/type-reducer/experimental_reduced_types_pass_3.txt @@ -0,0 +1,55 @@ +AllowedRoutesNamespacesFrom +BackendObjectReference +CookieConfigLifetimeType +DefaultGateway +ExportingClusters +ExtensionParametersReference +ExternalAuthGrpc +ExternalAuthHttp +ExternalAuthProtocol +ForwardBody +GatewayAddress +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader +InferencePoolRef +InferenceStatus +Kind +MatchExpressions +ParentReference +RedirectStatusCode +Reference +RequestMirrorFraction +RequestOperationType +RequestRedirectScheme +SessionPersistenceType +SupportedFeatures +TlsMode +TlsValidationMode + + +#### Pass 2 +MatchingHeaders +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +NamespaceSelector +ListenerStatus +ListenerTls +ParentRouteStatus +PersistenceCookieConfig +FrontendTlsValidation +ExternalAuthFilter + +#### Pass 3 +GrpcRouteFilter +HttpRouteRequestRedirect +HttpRouteUrlRewrite +RouteStatus +FilterRequestRedirect +AllowedRoutesNamespaces +SessionPersistence +FrontendTls diff --git a/type-reducer/experimental_reduced_types_pass_4.txt b/type-reducer/experimental_reduced_types_pass_4.txt new file mode 100644 index 0000000..82ea921 --- /dev/null +++ b/type-reducer/experimental_reduced_types_pass_4.txt @@ -0,0 +1,56 @@ +AllowedRoutesNamespacesFrom +BackendObjectReference +CookieConfigLifetimeType +DefaultGateway +ExportingClusters +ExtensionParametersReference +ExternalAuthGrpc +ExternalAuthHttp +ExternalAuthProtocol +ForwardBody +GatewayAddress +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader +InferencePoolRef +InferenceStatus +Kind +MatchExpressions +ParentReference +RedirectStatusCode +Reference +RequestMirrorFraction +RequestOperationType +RequestRedirectScheme +SessionPersistenceType +SupportedFeatures +TlsMode +TlsValidationMode + +#### Pass 2 +MatchingHeaders +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +NamespaceSelector +ListenerStatus +ListenerTls +ParentRouteStatus +PersistenceCookieConfig +FrontendTlsValidation +ExternalAuthFilter + +#### Pass 3 +GrpcRouteFilter +HttpRouteRequestRedirect +HttpRouteUrlRewrite +RouteStatus +FilterRequestRedirect +AllowedRoutesNamespaces +SessionPersistence + +#### Pass 4 +AllowedRoutes diff --git a/type-reducer/experimental_reduced_types_pass_5.txt b/type-reducer/experimental_reduced_types_pass_5.txt new file mode 100644 index 0000000..1fd5d81 --- /dev/null +++ b/type-reducer/experimental_reduced_types_pass_5.txt @@ -0,0 +1,48 @@ +AllowedRoutesNamespacesFrom +BackendObjectReference +CookieConfigLifetimeType +DefaultGateway +ExtensionParametersReference +ExternalAuthGrpc +ExternalAuthHttp +ForwardBody +GatewayAddress +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader +Kind +MatchExpressions +ParentReference +RedirectStatusCode +Reference +RequestMirrorFraction +RequestOperationType +RequestRedirectScheme +TlsMode +TlsValidationMode +#### Pass 2 +MatchingHeaders +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +NamespaceSelector +ListenerStatus +ListenerTls +ParentRouteStatus +#### Pass 3 +GrpcRouteFilter +HttpRouteRequestRedirect +HttpRouteUrlRewrite +RouteStatus +FilterRequestRedirect +AllowedRoutesNamespaces + + +#### Pass 4 +AllowedRoutes + +#### Pass 5 +Listeners diff --git a/type-reducer/experimental_rename_only_mapped_names.txt b/type-reducer/experimental_rename_only_mapped_names.txt new file mode 100644 index 0000000..c551c34 --- /dev/null +++ b/type-reducer/experimental_rename_only_mapped_names.txt @@ -0,0 +1,14 @@ +### Rename only +GrpcRouteRules->GrpcRouteRule +HttpRouteRules->HttpRouteRule +HttpRouteRulesFilters->HttpRouteFilter +GrpcRouteRulesMatches->GrpcRouteMatch +HttpRouteRulesMatches->RouteMatch +HttpRouteRulesTimeouts->HttpRouteTimeout +GrpcRouteRulesBackendRefs->GRPCBackendReference +HttpRouteRulesBackendRefs->HTTPBackendReference +GrpcRouteRulesMatchesMethod->GRPCMethodMatch +HttpRouteRulesMatchesMethod->HTTPMethodMatch +HttpRouteRulesBackendRefsFilters->HttpRouteBackendFilter +HttpRouteRequestRedirect->RequestRedirect +HttpRouteRulesMatchesPath->PathMatch \ No newline at end of file diff --git a/type-reducer/extension/inference/experimental_customized_mapped_names.txt b/type-reducer/extension/inference/experimental_customized_mapped_names.txt new file mode 100644 index 0000000..0bd8d35 --- /dev/null +++ b/type-reducer/extension/inference/experimental_customized_mapped_names.txt @@ -0,0 +1 @@ +#### Pass 1 \ No newline at end of file diff --git a/type-reducer/extension/inference/experimental_reduced_types_pass_0.txt b/type-reducer/extension/inference/experimental_reduced_types_pass_0.txt new file mode 100644 index 0000000..3c2773d --- /dev/null +++ b/type-reducer/extension/inference/experimental_reduced_types_pass_0.txt @@ -0,0 +1 @@ +Condition \ No newline at end of file diff --git a/type-reducer/extension/inference/experimental_rename_only_mapped_names.txt b/type-reducer/extension/inference/experimental_rename_only_mapped_names.txt new file mode 100644 index 0000000..124edbe --- /dev/null +++ b/type-reducer/extension/inference/experimental_rename_only_mapped_names.txt @@ -0,0 +1,5 @@ +### Rename only +InferencePoolStatusParent->InferencePoolParent +InferencePoolStatusParentParentRef->ParentRef +InferencePoolExtensionRef->ExtensionRef +InferencePoolExtensionRefFailureMode->ExtensionFailureMode diff --git a/type-reducer/extension/inference/standard_customized_mapped_names.txt b/type-reducer/extension/inference/standard_customized_mapped_names.txt new file mode 100644 index 0000000..99016ef --- /dev/null +++ b/type-reducer/extension/inference/standard_customized_mapped_names.txt @@ -0,0 +1,3 @@ +#### Pass 1 +InferencePoolEndpointPickerRefPort->EndPointPort +InferencePoolTargetPorts->EndPointPort \ No newline at end of file diff --git a/type-reducer/extension/inference/standard_reduced_types_pass_0.txt b/type-reducer/extension/inference/standard_reduced_types_pass_0.txt new file mode 100644 index 0000000..3c2773d --- /dev/null +++ b/type-reducer/extension/inference/standard_reduced_types_pass_0.txt @@ -0,0 +1 @@ +Condition \ No newline at end of file diff --git a/type-reducer/extension/inference/standard_rename_only_mapped_names.txt b/type-reducer/extension/inference/standard_rename_only_mapped_names.txt new file mode 100644 index 0000000..0ebc961 --- /dev/null +++ b/type-reducer/extension/inference/standard_rename_only_mapped_names.txt @@ -0,0 +1,5 @@ +### Rename only +InferencePoolStatusParents->InferencePoolParent +InferencePoolStatusParentsParentRef->ParentRef +InferencePoolEndpointPickerRef->ExtensionRef +InferencePoolEndpointPickerRefFailureMode->ExtensionFailureMode \ No newline at end of file diff --git a/type-reducer/one_liners.txt b/type-reducer/one_liners.txt new file mode 100644 index 0000000..c693709 --- /dev/null +++ b/type-reducer/one_liners.txt @@ -0,0 +1 @@ +awk -F'->' '{print $2}' type-reducer/standard_customized_mapped_names.txt | sort -u diff --git a/type-reducer/sorted_experimental_customized_mapped_names.txt b/type-reducer/sorted_experimental_customized_mapped_names.txt new file mode 100644 index 0000000..f6f90c7 --- /dev/null +++ b/type-reducer/sorted_experimental_customized_mapped_names.txt @@ -0,0 +1,119 @@ +GatewayAddresses->GatewayAddress +GatewayBackendTlsClientCertificateRef->BackendTlsClientCertificateReference +GatewayClassParametersRef->ParametersReference +GatewayInfrastructureParametersRef->GatewayInfrastructureParametersReference +GatewayListenersAllowedRoutesKinds->Kind +GatewayListenersTlsCertificateRefs->BackendTlsClientCertificateReference +GatewayListenersTlsFrontendValidationCaCertificateRefs->ParametersReference +GatewayStatusAddresses->GatewayAddress +GatewayStatusListenersSupportedKinds->Kind +GrpcRouteParentRefs->ParentReference +GrpcRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference +GrpcRouteRulesBackendRefsFilters->GrpcRouteFilter +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd->HTTPHeader +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierSet->HTTPHeader +GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference +GrpcRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +GrpcRouteRulesBackendRefsFiltersRequestMirror->RequestMirror +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierAdd->HTTPHeader +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierSet->HTTPHeader +GrpcRouteRulesBackendRefsFiltersType->GRPCFilterType +GrpcRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference +GrpcRouteRulesFilters->GrpcRouteFilter +GrpcRouteRulesFiltersRequestHeaderModifierAdd->HTTPHeader +GrpcRouteRulesFiltersRequestHeaderModifier->HeaderModifier +GrpcRouteRulesFiltersRequestHeaderModifierSet->HTTPHeader +GrpcRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference +GrpcRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +GrpcRouteRulesFiltersRequestMirror->RequestMirror +GrpcRouteRulesFiltersResponseHeaderModifierAdd->HTTPHeader +GrpcRouteRulesFiltersResponseHeaderModifier->HeaderModifier +GrpcRouteRulesFiltersResponseHeaderModifierSet->HTTPHeader +GrpcRouteRulesFiltersType->GRPCFilterType +GrpcRouteRulesMatchesHeaders->HeaderMatch +GrpcRouteRulesMatchesHeadersType->HeaderMatchType +GrpcRouteRulesMatchesMethodType->HeaderMatchType +GrpcRouteRulesSessionPersistenceCookieConfigLifetimeType->PersistenceCookieConfigLifetime +GrpcRouteRulesSessionPersistenceCookieConfig->SessionPersistenceCookieConfig +GrpcRouteRulesSessionPersistence->SessionPersistence +GrpcRouteRulesSessionPersistenceType->SessionPersistenceType +GrpcRouteStatusParentsParentRef->ParentReference +GrpcRouteStatusParents->ParentRouteStatus +GrpcRouteStatus->RouteStatus +HttpRouteParentRefs->ParentReference +HttpRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference +HttpRouteRulesBackendRefsFilters->HttpRouteBackendFilters +HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd->HTTPHeader +HttpRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier +HttpRouteRulesBackendRefsFiltersRequestHeaderModifierSet->HTTPHeader +HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference +HttpRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesBackendRefsFiltersRequestMirror->RequestMirror +HttpRouteRulesBackendRefsFiltersRequestRedirect->HttpRouteRequestRedirect +HttpRouteRulesBackendRefsFiltersRequestRedirectPath->RequestRedirectPath +HttpRouteRulesBackendRefsFiltersRequestRedirectPathType->RequestOperationType +HttpRouteRulesBackendRefsFiltersRequestRedirectScheme->RequestRedirectScheme +HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode->RedirectStatusCode +HttpRouteRulesBackendRefsFiltersResponseHeaderModifierAdd->HTTPHeader +HttpRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier +HttpRouteRulesBackendRefsFiltersResponseHeaderModifierSet->HTTPHeader +HttpRouteRulesBackendRefsFiltersType->HTTPFilterType +HttpRouteRulesBackendRefsFiltersUrlRewrite->HttpRouteUrlRewrite +HttpRouteRulesBackendRefsFiltersUrlRewritePath->RequestRedirectPath +HttpRouteRulesBackendRefsFiltersUrlRewritePathType->RequestOperationType +HttpRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference +HttpRouteRulesFilters->HttpRouteRulesBackendRefsFilters +HttpRouteRulesFiltersRequestHeaderModifierAdd->HTTPHeader +HttpRouteRulesFiltersRequestHeaderModifier->HeaderModifier +HttpRouteRulesFiltersRequestHeaderModifierSet->HTTPHeader +HttpRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference +HttpRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesFiltersRequestMirror->RequestMirror +HttpRouteRulesFiltersRequestRedirect->HttpRouteRequestRedirect +HttpRouteRulesFiltersRequestRedirectPath->RequestRedirectPath +HttpRouteRulesFiltersRequestRedirectPathType->RequestOperationType +HttpRouteRulesFiltersRequestRedirectScheme->RequestRedirectScheme +HttpRouteRulesFiltersRequestRedirectStatusCode->RedirectStatusCode +HttpRouteRulesFiltersResponseHeaderModifierAdd->HTTPHeader +HttpRouteRulesFiltersResponseHeaderModifier->HeaderModifier +HttpRouteRulesFiltersResponseHeaderModifierSet->HTTPHeader +HttpRouteRulesFiltersType->HTTPFilterType +HttpRouteRulesFiltersUrlRewrite->HttpRouteUrlRewrite +HttpRouteRulesFiltersUrlRewritePath->RequestRedirectPath +HttpRouteRulesFiltersUrlRewritePathType->RequestOperationType +HttpRouteRulesMatchesHeaders->HeaderMatch +HttpRouteRulesMatchesHeadersType->HeaderMatchType +HttpRouteRulesMatchesQueryParams->HeaderMatch +HttpRouteRulesMatchesQueryParamsType->HeaderMatchType +HttpRouteRulesSessionPersistenceCookieConfigLifetimeType->PersistenceCookieConfigLifetime +HttpRouteRulesSessionPersistenceCookieConfig->SessionPersistenceCookieConfig +HttpRouteRulesSessionPersistence->SessionPersistence +HttpRouteRulesSessionPersistenceType->SessionPersistenceType +HttpRouteStatusParentsParentRef->ParentReference +HttpRouteStatusParents->ParentRouteStatus +HttpRouteStatus->RouteStatus +#### Pass 2 +#### Pass 3 +#### Pass 4 +TcpRouteParentRefs->ParentReference +TcpRouteRulesBackendRefs->BackendReference +TcpRouteRules->CommonRouteRule +TcpRouteSpec->RouteSpec +TcpRouteStatusParentsParentRef->ParentReference +TcpRouteStatusParents->ParentRouteStatus +TcpRouteStatus->RouteStatus +TlsRouteParentRefs->ParentReference +TlsRouteRulesBackendRefs->BackendReference +TlsRouteRules->CommonRouteRule +TlsRouteStatusParentsParentRef->ParentReference +TlsRouteStatusParents->ParentRouteStatus +TlsRouteStatus->RouteStatus +UdpRouteParentRefs->ParentReference +UdpRouteRulesBackendRefs->BackendReference +UdpRouteRules->CommonRouteRule +UdpRouteSpec->RouteSpec +UdpRouteStatusParentsParentRef->ParentReference +UdpRouteStatusParents->ParentRouteStatus +UdpRouteStatus->RouteStatus diff --git a/type-reducer/sorted_standard_customized_mapped_names.txt b/type-reducer/sorted_standard_customized_mapped_names.txt new file mode 100644 index 0000000..8e82829 --- /dev/null +++ b/type-reducer/sorted_standard_customized_mapped_names.txt @@ -0,0 +1,107 @@ +BackendTlsPolicyStatusAncestorsAncestorRef +BackendTlsPolicyValidationCaCertificateRefs +GatewayAddresses +GatewayAllowedListenersNamespacesSelectorMatchExpressions +GatewayClassParametersRef +GatewayInfrastructureParametersRef +GatewayListenersAllowedRoutesKinds +GatewayListenersAllowedRoutesNamespacesFrom +GatewayListenersAllowedRoutesNamespacesSelectorMatchExpressions +GatewayListenersTlsCertificateRefs +GatewayListenersTlsMode +GatewayStatusAddresses +GatewayStatusListenersSupportedKinds +GatewayTlsBackendClientCertificateRef +GatewayTlsFrontendDefaultValidationCaCertificateRefs +GatewayTlsFrontendDefaultValidationMode +GatewayTlsFrontendPerPortTlsValidationCaCertificateRefs +GatewayTlsFrontendPerPortTlsValidationMode +GrpcRouteParentRefs +GrpcRouteRulesBackendRefsFilters +GrpcRouteRulesBackendRefsFiltersExtensionRef +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifier +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierSet +GrpcRouteRulesBackendRefsFiltersRequestMirror +GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef +GrpcRouteRulesBackendRefsFiltersRequestMirrorFraction +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifier +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierAdd +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierSet +GrpcRouteRulesBackendRefsFiltersType +GrpcRouteRulesFilters +GrpcRouteRulesFiltersExtensionRef +GrpcRouteRulesFiltersRequestHeaderModifier +GrpcRouteRulesFiltersRequestHeaderModifierAdd +GrpcRouteRulesFiltersRequestHeaderModifierSet +GrpcRouteRulesFiltersRequestMirror +GrpcRouteRulesFiltersRequestMirrorBackendRef +GrpcRouteRulesFiltersRequestMirrorFraction +GrpcRouteRulesFiltersResponseHeaderModifier +GrpcRouteRulesFiltersResponseHeaderModifierAdd +GrpcRouteRulesFiltersResponseHeaderModifierSet +GrpcRouteRulesFiltersType +GrpcRouteRulesMatchesHeaders +GrpcRouteRulesMatchesHeadersType +GrpcRouteRulesMatchesMethodType +GrpcRouteStatus +GrpcRouteStatusParents +GrpcRouteStatusParentsParentRef +HttpRouteParentRefs +HttpRouteRulesBackendRefsFiltersExtensionRef +HttpRouteRulesBackendRefsFiltersRequestHeaderModifier +HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd +HttpRouteRulesBackendRefsFiltersRequestHeaderModifierSet +HttpRouteRulesBackendRefsFiltersRequestMirror +HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef +HttpRouteRulesBackendRefsFiltersRequestMirrorFraction +HttpRouteRulesBackendRefsFiltersRequestRedirect +HttpRouteRulesBackendRefsFiltersRequestRedirectPath +HttpRouteRulesBackendRefsFiltersRequestRedirectPathType +HttpRouteRulesBackendRefsFiltersRequestRedirectScheme +HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode +HttpRouteRulesBackendRefsFiltersResponseHeaderModifier +HttpRouteRulesBackendRefsFiltersResponseHeaderModifierAdd +HttpRouteRulesBackendRefsFiltersResponseHeaderModifierSet +HttpRouteRulesBackendRefsFiltersType +HttpRouteRulesBackendRefsFiltersUrlRewrite +HttpRouteRulesBackendRefsFiltersUrlRewritePath +HttpRouteRulesBackendRefsFiltersUrlRewritePathType +HttpRouteRulesFiltersExtensionRef +HttpRouteRulesFiltersRequestHeaderModifier +HttpRouteRulesFiltersRequestHeaderModifierAdd +HttpRouteRulesFiltersRequestHeaderModifierSet +HttpRouteRulesFiltersRequestMirror +HttpRouteRulesFiltersRequestMirrorBackendRef +HttpRouteRulesFiltersRequestMirrorFraction +HttpRouteRulesFiltersRequestRedirect +HttpRouteRulesFiltersRequestRedirectPath +HttpRouteRulesFiltersRequestRedirectPathType +HttpRouteRulesFiltersRequestRedirectScheme +HttpRouteRulesFiltersRequestRedirectStatusCode +HttpRouteRulesFiltersResponseHeaderModifier +HttpRouteRulesFiltersResponseHeaderModifierAdd +HttpRouteRulesFiltersResponseHeaderModifierSet +HttpRouteRulesFiltersType +HttpRouteRulesFiltersUrlRewrite +HttpRouteRulesFiltersUrlRewritePath +HttpRouteRulesFiltersUrlRewritePathType +HttpRouteRulesMatchesHeaders +HttpRouteRulesMatchesHeadersType +HttpRouteRulesMatchesQueryParams +HttpRouteRulesMatchesQueryParamsType +HttpRouteStatus +HttpRouteStatusParents +HttpRouteStatusParentsParentRef +ListenerSetListenersAllowedRoutesKinds +ListenerSetListenersAllowedRoutesNamespacesFrom +ListenerSetListenersAllowedRoutesNamespacesSelectorMatchExpressions +ListenerSetListenersTlsCertificateRefs +ListenerSetListenersTlsMode +ListenerSetParentRef +ListenerSetStatusListenersSupportedKinds +#### Pass 2 +#### Pass 3 +TlsRouteParentRefs +TlsRouteStatus +TlsRouteStatusParentsParentRef diff --git a/type-reducer/sorted_unique_standard_customized_mapped_names.txt b/type-reducer/sorted_unique_standard_customized_mapped_names.txt new file mode 100644 index 0000000..8e82829 --- /dev/null +++ b/type-reducer/sorted_unique_standard_customized_mapped_names.txt @@ -0,0 +1,107 @@ +BackendTlsPolicyStatusAncestorsAncestorRef +BackendTlsPolicyValidationCaCertificateRefs +GatewayAddresses +GatewayAllowedListenersNamespacesSelectorMatchExpressions +GatewayClassParametersRef +GatewayInfrastructureParametersRef +GatewayListenersAllowedRoutesKinds +GatewayListenersAllowedRoutesNamespacesFrom +GatewayListenersAllowedRoutesNamespacesSelectorMatchExpressions +GatewayListenersTlsCertificateRefs +GatewayListenersTlsMode +GatewayStatusAddresses +GatewayStatusListenersSupportedKinds +GatewayTlsBackendClientCertificateRef +GatewayTlsFrontendDefaultValidationCaCertificateRefs +GatewayTlsFrontendDefaultValidationMode +GatewayTlsFrontendPerPortTlsValidationCaCertificateRefs +GatewayTlsFrontendPerPortTlsValidationMode +GrpcRouteParentRefs +GrpcRouteRulesBackendRefsFilters +GrpcRouteRulesBackendRefsFiltersExtensionRef +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifier +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierSet +GrpcRouteRulesBackendRefsFiltersRequestMirror +GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef +GrpcRouteRulesBackendRefsFiltersRequestMirrorFraction +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifier +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierAdd +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierSet +GrpcRouteRulesBackendRefsFiltersType +GrpcRouteRulesFilters +GrpcRouteRulesFiltersExtensionRef +GrpcRouteRulesFiltersRequestHeaderModifier +GrpcRouteRulesFiltersRequestHeaderModifierAdd +GrpcRouteRulesFiltersRequestHeaderModifierSet +GrpcRouteRulesFiltersRequestMirror +GrpcRouteRulesFiltersRequestMirrorBackendRef +GrpcRouteRulesFiltersRequestMirrorFraction +GrpcRouteRulesFiltersResponseHeaderModifier +GrpcRouteRulesFiltersResponseHeaderModifierAdd +GrpcRouteRulesFiltersResponseHeaderModifierSet +GrpcRouteRulesFiltersType +GrpcRouteRulesMatchesHeaders +GrpcRouteRulesMatchesHeadersType +GrpcRouteRulesMatchesMethodType +GrpcRouteStatus +GrpcRouteStatusParents +GrpcRouteStatusParentsParentRef +HttpRouteParentRefs +HttpRouteRulesBackendRefsFiltersExtensionRef +HttpRouteRulesBackendRefsFiltersRequestHeaderModifier +HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd +HttpRouteRulesBackendRefsFiltersRequestHeaderModifierSet +HttpRouteRulesBackendRefsFiltersRequestMirror +HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef +HttpRouteRulesBackendRefsFiltersRequestMirrorFraction +HttpRouteRulesBackendRefsFiltersRequestRedirect +HttpRouteRulesBackendRefsFiltersRequestRedirectPath +HttpRouteRulesBackendRefsFiltersRequestRedirectPathType +HttpRouteRulesBackendRefsFiltersRequestRedirectScheme +HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode +HttpRouteRulesBackendRefsFiltersResponseHeaderModifier +HttpRouteRulesBackendRefsFiltersResponseHeaderModifierAdd +HttpRouteRulesBackendRefsFiltersResponseHeaderModifierSet +HttpRouteRulesBackendRefsFiltersType +HttpRouteRulesBackendRefsFiltersUrlRewrite +HttpRouteRulesBackendRefsFiltersUrlRewritePath +HttpRouteRulesBackendRefsFiltersUrlRewritePathType +HttpRouteRulesFiltersExtensionRef +HttpRouteRulesFiltersRequestHeaderModifier +HttpRouteRulesFiltersRequestHeaderModifierAdd +HttpRouteRulesFiltersRequestHeaderModifierSet +HttpRouteRulesFiltersRequestMirror +HttpRouteRulesFiltersRequestMirrorBackendRef +HttpRouteRulesFiltersRequestMirrorFraction +HttpRouteRulesFiltersRequestRedirect +HttpRouteRulesFiltersRequestRedirectPath +HttpRouteRulesFiltersRequestRedirectPathType +HttpRouteRulesFiltersRequestRedirectScheme +HttpRouteRulesFiltersRequestRedirectStatusCode +HttpRouteRulesFiltersResponseHeaderModifier +HttpRouteRulesFiltersResponseHeaderModifierAdd +HttpRouteRulesFiltersResponseHeaderModifierSet +HttpRouteRulesFiltersType +HttpRouteRulesFiltersUrlRewrite +HttpRouteRulesFiltersUrlRewritePath +HttpRouteRulesFiltersUrlRewritePathType +HttpRouteRulesMatchesHeaders +HttpRouteRulesMatchesHeadersType +HttpRouteRulesMatchesQueryParams +HttpRouteRulesMatchesQueryParamsType +HttpRouteStatus +HttpRouteStatusParents +HttpRouteStatusParentsParentRef +ListenerSetListenersAllowedRoutesKinds +ListenerSetListenersAllowedRoutesNamespacesFrom +ListenerSetListenersAllowedRoutesNamespacesSelectorMatchExpressions +ListenerSetListenersTlsCertificateRefs +ListenerSetListenersTlsMode +ListenerSetParentRef +ListenerSetStatusListenersSupportedKinds +#### Pass 2 +#### Pass 3 +TlsRouteParentRefs +TlsRouteStatus +TlsRouteStatusParentsParentRef diff --git a/type-reducer/src/lib.rs b/type-reducer/src/lib.rs new file mode 100644 index 0000000..822a97b --- /dev/null +++ b/type-reducer/src/lib.rs @@ -0,0 +1,313 @@ +use std::collections::BTreeMap; +use std::collections::BTreeSet; + +use itertools::Itertools; +use log::debug; +use log::info; +use multimap::MultiMap; +use proc_macro2::{Ident, Span}; +use std::fs::OpenOptions; +use std::io; +use std::io::BufRead; +use std::io::Write; +use std::path::Path; +use syn::Fields; +use syn::File; +use syn::Item; +use syn::ItemEnum; +use syn::ItemStruct; +use syn::Variant; +use syn::punctuated::Punctuated; +use syn::token::Comma; + +use syn::visit::Visit; + +use syn::visit_mut::VisitMut; + +mod visitors; +pub use visitors::*; + +pub const COMMON_TYPES_MOD_NAME: &str = "common"; +const COMMON_TYPES_FILE_PREAMBLE: &str = "#[allow(unused_imports)] +mod prelude { + pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; + pub use kube_derive::CustomResource; + pub use schemars::JsonSchema; + pub use serde::{Deserialize, Serialize}; + pub use std::collections::BTreeMap; +} +use self::prelude::*;"; + +const COMMON_TYPES_USE_PREAMBLE: &str = "use super::common::*;\n"; +const GENERATED_PREAMBLE: &str = + "// WARNING: generated file - manual changes will be overriden\n\n"; + +pub fn read_substitute(customized_names_from_file: &BTreeMap, i: &Ident) -> String { + if let Some(customized_name) = customized_names_from_file.get(&i.to_string()) { + customized_name.clone() + } else { + i.to_string() + } +} + +pub fn read_type_mappings_from_file( + mapped_names: &Path, +) -> Result, Box> { + let mut mapped_types = BTreeMap::new(); + let mapped_names_file = std::fs::File::open(mapped_names)?; + for line in io::BufReader::new(mapped_names_file) + .lines() + .map_while(Result::ok) + { + let mut parts = line.split("->"); + if let (Some(type_name), Some(new_type_name)) = (parts.next(), parts.next()) { + mapped_types.insert(type_name.to_owned(), new_type_name.to_owned()); + } + } + Ok(mapped_types) +} + +pub fn read_type_names_from_file( + mapped_names: &Path, +) -> Result, Box> { + let mapped_names_file = std::fs::File::open(mapped_names)?; + Ok(io::BufReader::new(mapped_names_file) + .lines() + .map_while(Result::ok) + .collect::>()) +} + +pub fn write_type_names_to_file( + mapped_types: &BTreeMap, +) -> Result<(), Box> { + let mut mapped_names_file = std::fs::File::create("./mapped_names.txt")?; + for v in mapped_types.values().sorted().dedup() { + mapped_names_file.write_all(format!("{v}\n").as_bytes())?; + } + + let mut mapped_names_file = std::fs::File::create("./mapped_types_to_names.txt")?; + for (k, v) in mapped_types + .iter() + .sorted_by(|(_, this), (_, other)| this.cmp(other)) + { + mapped_names_file.write_all(format!("{k}->{v}\n").as_bytes())?; + } + Ok(()) +} + +pub fn delete_replaced_types(file: File, type_names: Vec) -> File { + let File { + shebang, + attrs, + items, + } = file; + + let items = items + .into_iter() + .filter(|i| match i { + // delete top level items with ident that was replaced + Item::Struct(item) => { + if type_names.contains(&item.ident.to_string()) { + debug!("Deleting {}", item.ident); + false + } else { + true + } + } + Item::Enum(item) => { + if type_names.contains(&item.ident.to_string()) { + debug!("Deleting {}", item.ident); + false + } else { + true + } + } + _ => true, + }) + .collect(); + + File { + shebang, + attrs, + items, + } +} + +pub struct FindSimilarTypesResult { + pub visitors: Vec<(String, File)>, + pub similar_structs: MultiMap, + pub similar_enums: MultiMap, (Ident, ItemEnum)>, +} + +pub fn find_similar_types( + visitors: Vec<(StructEnumVisitor<'_, '_>, File)>, +) -> FindSimilarTypesResult { + let mut similar_structs = MultiMap::new(); + let mut similar_enums = MultiMap::new(); + + let visitors: Vec<_> = visitors + .into_iter() + .map(|(mut visitor, file)| { + visitor.visit_file(&file); + visitor.structs.into_iter().for_each(|i| { + let mut fields = i.fields.clone(); + + fields.iter_mut().for_each(|f| { + f.attrs = f + .attrs + .clone() + .into_iter() + .filter(|a| { + a.meta.path().get_ident() != Some(&Ident::new("doc", Span::call_site())) + }) + .collect::>() + }); + + similar_structs.insert(fields, (i.ident.clone(), (*i).clone())); + }); + visitor.enums.into_iter().for_each(|i| { + similar_enums.insert(i.variants.clone(), (i.ident.clone(), (*i).clone())); + }); + (visitor.name, file) + }) + .collect(); + + FindSimilarTypesResult { + visitors, + similar_structs, + similar_enums, + } +} + +pub fn prune_replaced_types( + renaming_visitor: &mut StructEnumFieldsRenamer, + visitors: Vec<(String, File)>, +) -> Vec<(String, String, bool)> { + visitors + .into_iter() + .map(|(name, mut f)| { + renaming_visitor.changed = false; + renaming_visitor.visit_file_mut(&mut f); + let new_file = + delete_replaced_types(f, renaming_visitor.names.keys().cloned().collect()); + ( + name, + prettyplease::unparse(&new_file), + renaming_visitor.changed, + ) + }) + .collect() +} + +pub fn generate_file_preamble( + changed: bool, + content: &str, + output_path: &Path, + name: &str, +) -> Result> { + let output_path = output_path.join(name); + + if changed { + info!("Writing changed file {}", output_path.display()); + let mut out_file = std::fs::File::create(output_path)?; + if !content.starts_with(GENERATED_PREAMBLE) { + out_file.write_all(GENERATED_PREAMBLE.as_bytes())?; + } + + if !content.contains(COMMON_TYPES_USE_PREAMBLE) { + out_file.write_all(COMMON_TYPES_USE_PREAMBLE.as_bytes())?; + } + Ok(out_file) + } else { + info!("Writing NOT changed file {}", output_path.display()); + let mut out_file = std::fs::File::create(output_path)?; + if !content.starts_with(GENERATED_PREAMBLE) { + out_file.write_all(GENERATED_PREAMBLE.as_bytes())?; + } + Ok(out_file) + } +} + +pub fn recreate_project_files( + out_dir: &str, + unparsed_files: Vec<(String, String, bool)>, + items: Vec, +) -> Result<(), Box> { + let common_types = prettyplease::unparse(&File { + shebang: None, + attrs: vec![], + items, + }); + + let output_path = std::path::Path::new(&out_dir); + if output_path.is_dir() && output_path.exists() { + info!("Writing changed file mod.rs"); + let mut mod_file = std::fs::File::create(output_path.join("mod.rs"))?; + mod_file.write_all(GENERATED_PREAMBLE.as_bytes())?; + + let mut mod_names = vec![format!("pub mod {COMMON_TYPES_MOD_NAME};")]; + + for (name, content, changed) in unparsed_files { + let mut out_file = generate_file_preamble(changed, &content, output_path, &name)?; + out_file.write_all(content.as_bytes())?; + mod_names.push(format!("pub mod {};", &name[..name.len() - 3])); + } + + for mod_name in mod_names.into_iter().sorted().dedup() { + mod_file.write_all((mod_name + "\n").as_bytes())?; + } + + let common_types_file_name = output_path.join(COMMON_TYPES_MOD_NAME.to_owned() + ".rs"); + + if common_types_file_name.exists() { + let mut common_out_file = OpenOptions::new() + .append(true) + .open(common_types_file_name)?; + + common_out_file.write_all("\n\n// Next attempt \n\n".as_bytes())?; + common_out_file.write_all(common_types.as_bytes())?; + } else { + let mut common_out_file = std::fs::File::create(common_types_file_name)?; + let common_types_file_content = + COMMON_TYPES_FILE_PREAMBLE.to_owned() + "\n\n\n" + &common_types; + common_out_file.write_all(common_types_file_content.as_bytes())?; + } + Ok(()) + } else { + Err("Make sure that output path is a folder and tha it exists".into()) + } +} + +pub fn create_common_type_struct(s: &ItemStruct, type_new_name: &str) -> ItemStruct { + let mut new_struct = s.clone(); + new_struct.attrs = s + .attrs + .iter() + .filter(|&a| a.meta.path().get_ident() != Some(&Ident::new("doc", Span::call_site()))) + .cloned() + .collect(); + new_struct.fields = s.fields.clone(); + new_struct.fields.iter_mut().for_each(|f| { + f.attrs = f + .attrs + .clone() + .into_iter() + .filter(|a| a.meta.path().get_ident() != Some(&Ident::new("doc", Span::call_site()))) + .collect::>() + }); + + new_struct.ident = Ident::new(type_new_name, Span::call_site()); + new_struct +} + +pub fn create_common_type_enum(s: &ItemEnum, type_new_name: &str) -> ItemEnum { + let mut new_enum = s.clone(); + new_enum.ident = Ident::new(type_new_name, Span::call_site()); + new_enum.attrs = s + .attrs + .iter() + .filter(|&a| a.meta.path().get_ident() != Some(&Ident::new("doc", Span::call_site()))) + .cloned() + .collect(); + new_enum +} diff --git a/type-reducer/src/main.rs b/type-reducer/src/main.rs new file mode 100644 index 0000000..5fb9487 --- /dev/null +++ b/type-reducer/src/main.rs @@ -0,0 +1,305 @@ +use clap::Parser; +use clap::Subcommand; +use itertools::Itertools; +use log::debug; +use log::info; +use std::cmp::Ordering; +use std::collections::BTreeMap; +use std::collections::BTreeSet; +use std::fs; +use std::io::Write; +use std::path::PathBuf; +use syn::Item; +use syn::visit_mut::VisitMut; +use type_reducer::*; + +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Subcommand)] +enum Action { + Reduce(ReduceArgs), + Rename(RenameArgs), +} + +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Parser)] +struct ReduceArgs { + #[arg(long)] + current_pass_substitute_names: PathBuf, + + #[arg(long)] + previous_pass_derived_type_names: PathBuf, + + #[arg(long)] + ignorable_type_names: Option, +} + +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Parser)] +struct RenameArgs { + #[arg(long)] + rename_only_substitute_names: PathBuf, +} + +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] +struct Args { + #[command(subcommand)] + action: Action, + #[arg(long)] + apis_dir: String, + + #[arg(long)] + out_dir: String, +} + +fn main() -> Result<(), Box> { + simple_logger::init_with_env().unwrap(); + let Args { + action, + apis_dir, + out_dir, + } = Args::parse(); + + let Ok(_) = fs::exists(out_dir.clone()) else { + return Err("our dir doesn't exist".into()); + }; + + match action { + Action::Rename(args) => { + let RenameArgs { + rename_only_substitute_names, + } = args; + let rename_only_substitute_names = + read_type_mappings_from_file(rename_only_substitute_names.as_path())?; + + let previous_pass_derived_type_names = BTreeSet::new(); + + let visitors = create_visitors(&apis_dir, &previous_pass_derived_type_names)?; + handle_rename_types(rename_only_substitute_names, visitors, &out_dir) + } + + Action::Reduce(args) => { + let ReduceArgs { + current_pass_substitute_names, + previous_pass_derived_type_names, + ignorable_type_names, + } = args; + let previous_pass_derived_type_names = + read_type_names_from_file(previous_pass_derived_type_names.as_path())?; + + let current_pass_type_name_substitutes = + read_type_mappings_from_file(current_pass_substitute_names.as_path())?; + + let ignorable_type_names = + if let Some(ignorable_type_names) = ignorable_type_names.as_ref() { + read_type_mappings_from_file(ignorable_type_names.as_path())? + } else { + BTreeMap::new() + }; + + let visitors = create_visitors(&apis_dir, &previous_pass_derived_type_names)?; + handle_reduce_types( + current_pass_type_name_substitutes, + visitors, + &out_dir, + ignorable_type_names, + ) + } + } +} + +fn handle_reduce_types( + current_pass_type_name_substitutes: BTreeMap, + visitors: Vec<(StructEnumVisitor<'_, '_>, syn::File)>, + out_dir: &str, + ignorable_types: BTreeMap, +) -> Result<(), Box> { + let FindSimilarTypesResult { + visitors, + similar_structs, + similar_enums, + } = find_similar_types(visitors); + + let struct_items: Vec<_> = similar_structs + .iter_all() + .filter(|(_k, v)| v.len() > 1) + .filter_map(|(_k, v)| { + info!( + "Potentially similar structs {:#?}", + v.iter().map(|(i, _)| i.to_string()).collect::>() + ); + let mapped_type_names = v.iter().map(|v| v.0.to_string()).collect::>(); + + let mut ignore = false; + if !ignorable_types.is_empty() { + for mapped_type in &mapped_type_names { + if ignorable_types.contains_key(mapped_type) { + debug!("Ignoring type {mapped_type}"); + ignore = true; + } + } + } + if ignore { + return None; + } + + if let Some((i, s)) = v.first() { + let new_struct = create_common_type_struct( + s, + &read_substitute(¤t_pass_type_name_substitutes, i), + ); + + let mut mapped = BTreeMap::new(); + for mapped_type_name in mapped_type_names { + mapped.insert(mapped_type_name, new_struct.ident.to_string().to_owned()); + } + + info!("Mapped types = {:#?}", &mapped); + if mapped.keys().len() < 2 { + None + } else { + Some((mapped, Item::Struct(new_struct))) + } + } else { + None + } + }) + .collect(); + + let enum_items: Vec<_> = similar_enums + .iter_all() + .filter(|(_k, v)| v.len() > 1) + .filter_map(|(_k, v)| { + info!( + "Potentially similar enums {:#?}", + v.iter().map(|(i, _)| i.to_string()).collect::>() + ); + let mapped_type_names = v.iter().map(|v| v.0.to_string()).collect::>(); + + if let Some((i, s)) = v.first() { + let new_enum = create_common_type_enum( + s, + &read_substitute(¤t_pass_type_name_substitutes, i), + ); + + let mut mapped = BTreeMap::new(); + for mapped_type_name in mapped_type_names { + mapped.insert(mapped_type_name, new_enum.ident.to_string().to_owned()); + } + + info!("Mapped types = {:#?}", &mapped); + if mapped.keys().len() < 2 { + None + } else { + Some((mapped, Item::Enum(new_enum))) + } + } else { + None + } + }) + .collect(); + + let (mapped_types, items): (Vec>, Vec) = + struct_items.into_iter().chain(enum_items).unzip(); + + let mut renaming_visitor = StructEnumFieldsRenamer { + changed: false, + names: mapped_types.into_iter().flatten().collect(), + }; + + write_type_names_to_file(&renaming_visitor.names)?; + + let unparsed_files = prune_replaced_types(&mut renaming_visitor, visitors); + + recreate_project_files( + out_dir, + unparsed_files, + items.into_iter().sorted_by(order_types).collect(), + ) +} + +fn handle_rename_types( + rename_only_substitute_names: BTreeMap, + visitors: Vec<(StructEnumVisitor<'_, '_>, syn::File)>, + out_dir: &str, +) -> Result<(), Box> { + if !rename_only_substitute_names.is_empty() { + let mut renaming_visitor = StructEnumNameRenamer { + changed: false, + names: rename_only_substitute_names, + }; + + write_type_names_to_file(&renaming_visitor.names)?; + + let files: Vec<_> = visitors + .into_iter() + .map(|(visitor, mut f)| { + renaming_visitor.changed = false; + renaming_visitor.visit_file_mut(&mut f); + + (renaming_visitor.changed, visitor, f) + }) + .collect(); + for (changed, visitor, file) in files { + let changed = if visitor.name == COMMON_TYPES_MOD_NAME.to_owned() + ".rs" { + false + } else { + changed + }; + let path = PathBuf::from(&visitor.name); + info!("Renaming types in files {}", path.display()); + let content = &prettyplease::unparse(&file); + let mut file = generate_file_preamble( + changed, + content, + std::path::Path::new(&out_dir), + &visitor.name, + )?; + file.write_all(content.as_bytes())?; + } + Ok(()) + } else { + Ok(()) + } +} + +fn create_visitors<'a>( + apis_dir: &'a str, + previous_pass_derived_type_names: &'a BTreeSet, +) -> Result, syn::File)>, Box> { + let mut visitors = vec![]; + + // sort for deterministic processing + let mut entries: Vec<_> = fs::read_dir(apis_dir)?.filter_map(|e| e.ok()).collect(); + entries.sort_by_key(|e| e.path()); + + for dir_entry in entries { + if let Ok(name) = dir_entry.file_name().into_string() + && name.ends_with(".rs") + && name != "mod.rs" + { + info!("Adding file {:?}", dir_entry.path()); + if let Ok(api_file) = fs::read_to_string(dir_entry.path()) + && let Ok(syntaxt_file) = syn::parse_file(&api_file) + { + let visitor = StructEnumVisitor { + name, + structs: Vec::new(), + enums: Vec::new(), + derived_type_names: previous_pass_derived_type_names, + }; + visitors.push((visitor, syntaxt_file)); + } + } + } + Ok(visitors) +} + +fn order_types(this: &Item, other: &Item) -> Ordering { + match (this, other) { + (Item::Enum(this), Item::Enum(other)) => this.ident.cmp(&other.ident), + (Item::Struct(this), Item::Struct(other)) => this.ident.cmp(&other.ident), + _ => { + let this_discriminant = unsafe { *(this as *const Item as *const u8) }; + let other_discriminant = unsafe { *(other as *const Item as *const u8) }; + this_discriminant.cmp(&other_discriminant) + } + } +} diff --git a/type-reducer/src/visitors.rs b/type-reducer/src/visitors.rs new file mode 100644 index 0000000..dbf12fa --- /dev/null +++ b/type-reducer/src/visitors.rs @@ -0,0 +1,218 @@ +use log::debug; +use log::trace; +use proc_macro2::{Ident, Span}; +use std::collections::BTreeMap; +use std::collections::BTreeSet; +use syn::Fields; +use syn::ItemEnum; +use syn::ItemStruct; +use syn::PathSegment; +use syn::Type; +use syn::visit; +use syn::visit::Visit; +use syn::visit_mut; + +use syn::visit_mut::VisitMut; + +pub struct StructVisitor<'ast, 'b> { + pub name: String, + pub structs: Vec<&'ast ItemStruct>, + pub derived_type_names: &'b BTreeSet, +} + +pub struct StructEnumVisitor<'ast, 'b> { + pub name: String, + pub structs: Vec<&'ast ItemStruct>, + pub enums: Vec<&'ast ItemEnum>, + pub derived_type_names: &'b BTreeSet, +} + +pub struct StructEnumFieldsRenamer { + pub changed: bool, + pub names: BTreeMap, +} + +pub struct StructEnumNameRenamer { + pub changed: bool, + pub names: BTreeMap, +} + +fn rewrite_ident(path: &mut PathSegment, names: &BTreeMap) -> bool { + let mut file_changed = false; + if path.arguments.is_empty() { + let ident = &path.ident; + if let Some(new_name) = names.get(&ident.to_string()) { + path.ident = Ident::new(new_name, Span::call_site()); + file_changed = true; + } + } else { + match path.arguments { + syn::PathArguments::None => {} + syn::PathArguments::AngleBracketed(ref mut angle_bracketed_generic_arguments) => { + for a in angle_bracketed_generic_arguments.args.iter_mut() { + if let syn::GenericArgument::Type(Type::Path(path)) = a { + for s in path.path.segments.iter_mut() { + file_changed |= rewrite_ident(s, names); + } + } + } + } + syn::PathArguments::Parenthesized(_) => {} + } + } + file_changed +} + +impl<'ast, 'b> Visit<'ast> for StructEnumVisitor<'ast, 'b> { + fn visit_item_struct(&mut self, node: &'ast ItemStruct) { + debug!("Visiting Struct name == {}", node.ident); + let mut is_simple_leaf = true; + node.fields.iter().for_each(|f| match &f.ty { + Type::Path(path_type) => { + trace!( + "\twith field name = {:?} \n\t\tfield type = {:?}", + f.ident, f.ty + ); + + for segment in &path_type.path.segments { + check_simple_type(segment, &mut is_simple_leaf, self.derived_type_names); + } + } + + _ => { + is_simple_leaf = false; + } + }); + debug!( + "Visiting Struct name == {} is leaf {is_simple_leaf}", + node.ident + ); + if is_simple_leaf { + self.structs.push(node); + } + visit::visit_item_struct(self, node); + } + + fn visit_item_enum(&mut self, node: &'ast ItemEnum) { + debug!("Visiting Enum name == {} {:?}", node.ident, node.variants); + + if node + .variants + .iter() + .map(|f| &f.fields) + .all(|f| *f == Fields::Unit) + { + self.enums.push(node); + } + } +} + +impl VisitMut for StructEnumFieldsRenamer { + fn visit_item_struct_mut(&mut self, node: &mut ItemStruct) { + debug!( + "Visiting and changing fields in struct name == {}", + node.ident + ); + + node.fields.iter_mut().for_each(|f| { + let ty = f.ty.clone(); + if let Type::Path(path_type) = &mut f.ty { + trace!( + "\twith field name = {:?} \n\t\tfield type = {:?}", + f.ident, ty + ); + + for segment in &mut path_type.path.segments { + self.changed |= rewrite_ident(segment, &self.names); + } + } + }); + + visit_mut::visit_item_struct_mut(self, node); + } +} + +impl VisitMut for StructEnumNameRenamer { + fn visit_item_struct_mut(&mut self, node: &mut ItemStruct) { + debug!( + "Visiting and renaming struct name in struct name == {}", + node.ident + ); + + if let Some(new_name) = self.names.get(&node.ident.to_string()) { + self.changed = true; + node.ident = Ident::new(new_name, Span::call_site()); + }; + + debug!( + "Visiting and changing fields in struct name == {}", + node.ident + ); + + node.fields.iter_mut().for_each(|f| { + let ty = f.ty.clone(); + if let Type::Path(path_type) = &mut f.ty { + trace!( + "\twith field name = {:?} \n\t\tfield type = {:?}", + f.ident, ty + ); + + for segment in &mut path_type.path.segments { + self.changed |= rewrite_ident(segment, &self.names); + } + } + }); + + visit_mut::visit_item_struct_mut(self, node); + } + + fn visit_item_enum_mut(&mut self, node: &mut ItemEnum) { + debug!("Visiting and renaming enum name == {}", node.ident); + + if let Some(new_name) = self.names.get(&node.ident.to_string()) { + self.changed = true; + node.ident = Ident::new(new_name, Span::call_site()); + }; + } +} + +fn check_simple_type( + path: &PathSegment, + is_simple: &mut bool, + derived_type_names: &BTreeSet, +) { + if path.arguments.is_empty() { + let ident = &path.ident; + debug!( + "Checking path segment {} {} ", + path.ident, + derived_type_names.contains(&ident.to_string()) + ); + + if ident == &Ident::new("String", Span::call_site()) + || ident == &Ident::new("i32", Span::call_site()) + || ident == &Ident::new("i64", Span::call_site()) + || derived_type_names.contains(&ident.to_string()) + { + } else { + *is_simple = false; + } + } else { + match &path.arguments { + syn::PathArguments::None => *is_simple = false, + syn::PathArguments::AngleBracketed(angle_bracketed_generic_arguments) => { + for a in &angle_bracketed_generic_arguments.args { + match a { + syn::GenericArgument::Type(Type::Path(path)) => { + for s in &path.path.segments { + check_simple_type(s, is_simple, derived_type_names); + } + } + _ => *is_simple = false, + } + } + } + syn::PathArguments::Parenthesized(_) => *is_simple = false, + } + } +} diff --git a/type-reducer/standard_customized_mapped_names.txt b/type-reducer/standard_customized_mapped_names.txt new file mode 100644 index 0000000..3c92cc2 --- /dev/null +++ b/type-reducer/standard_customized_mapped_names.txt @@ -0,0 +1,127 @@ +GrpcRouteRulesBackendRefsFiltersType->GRPCFilterType +GrpcRouteRulesFiltersType->GRPCFilterType +GatewayAddresses->GatewayAddress +GatewayStatusAddresses->GatewayAddress +GrpcRouteRulesBackendRefsFiltersExtensionRef->ExtensionParametersReference +GrpcRouteRulesFiltersExtensionRef->ExtensionParametersReference +GatewayInfrastructureParametersRef->ExtensionParametersReference +HttpRouteRulesBackendRefsFiltersExtensionRef->ExtensionParametersReference +HttpRouteRulesFiltersExtensionRef->ExtensionParametersReference +BackendTlsPolicyValidationCaCertificateRefs->ExtensionParametersReference +GatewayAllowedListenersNamespacesSelectorMatchExpressions->MatchExpressions +GatewayListenersAllowedRoutesNamespacesSelectorMatchExpressions->MatchExpressions +ListenerSetListenersAllowedRoutesNamespacesSelectorMatchExpressions->MatchExpressions +GatewayClassParametersRef->GatewayParametersRef +GatewayTlsFrontendDefaultValidationCaCertificateRefs->GatewayParametersRef +GatewayTlsFrontendPerPortTlsValidationCaCertificateRefs->GatewayParametersRef +GatewayListenersAllowedRoutesKinds->Kind +GatewayStatusListenersSupportedKinds->Kind +ListenerSetListenersAllowedRoutesKinds->Kind +ListenerSetStatusListenersSupportedKinds->Kind +GatewayListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespacesFrom +ListenerSetListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespacesFrom +GatewayListenersTlsCertificateRefs->Reference +GatewayTlsBackendClientCertificateRef->Reference +ListenerSetListenersTlsCertificateRefs->Reference +ListenerSetParentRef->Reference +GatewayListenersTlsMode->TlsMode +ListenerSetListenersTlsMode->TlsMode +GatewayTlsFrontendDefaultValidationMode->TlsValidationMode +GatewayTlsFrontendPerPortTlsValidationMode->TlsValidationMode +BackendTlsPolicyStatusAncestorsAncestorRef->ParentReference +GrpcRouteParentRefs->ParentReference +GrpcRouteStatusParentsParentRef->ParentReference +HttpRouteParentRefs->ParentReference +HttpRouteStatusParentsParentRef->ParentReference +TlsRouteParentRefs->ParentReference +TlsRouteStatusParentsParentRef->ParentReference +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd->HTTPHeader +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierSet->HTTPHeader +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierAdd->HTTPHeader +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierSet->HTTPHeader +GrpcRouteRulesFiltersRequestHeaderModifierAdd->HTTPHeader +GrpcRouteRulesFiltersRequestHeaderModifierSet->HTTPHeader +GrpcRouteRulesFiltersResponseHeaderModifierAdd->HTTPHeader +GrpcRouteRulesFiltersResponseHeaderModifierSet->HTTPHeader +HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd->HTTPHeader +HttpRouteRulesBackendRefsFiltersRequestHeaderModifierSet->HTTPHeader +HttpRouteRulesBackendRefsFiltersResponseHeaderModifierAdd->HTTPHeader +HttpRouteRulesBackendRefsFiltersResponseHeaderModifierSet->HTTPHeader +HttpRouteRulesFiltersRequestHeaderModifierAdd->HTTPHeader +HttpRouteRulesFiltersRequestHeaderModifierSet->HTTPHeader +HttpRouteRulesFiltersResponseHeaderModifierAdd->HTTPHeader +HttpRouteRulesFiltersResponseHeaderModifierSet->HTTPHeader +GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference +GrpcRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference +HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference +HttpRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference +GrpcRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +GrpcRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesBackendRefsFiltersRequestRedirectPathType->RequestOperationType +HttpRouteRulesBackendRefsFiltersUrlRewritePathType->RequestOperationType +HttpRouteRulesFiltersRequestRedirectPathType->RequestOperationType +HttpRouteRulesFiltersUrlRewritePathType->RequestOperationType +HttpRouteRulesBackendRefsFiltersRequestRedirectScheme->RequestRedirectScheme +HttpRouteRulesFiltersRequestRedirectScheme->RequestRedirectScheme +HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode->RedirectStatusCode +HttpRouteRulesFiltersRequestRedirectStatusCode->RedirectStatusCode +HttpRouteRulesBackendRefsFiltersType->HTTPFilterType +HttpRouteRulesFiltersType->HTTPFilterType +GrpcRouteRulesMatchesHeadersType->HeaderMatchType +GrpcRouteRulesMatchesMethodType->HeaderMatchType +HttpRouteRulesMatchesHeadersType->HeaderMatchType +HttpRouteRulesMatchesQueryParamsType->HeaderMatchType +#### Pass 2 +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier +GrpcRouteRulesFiltersRequestHeaderModifier->HeaderModifier +GrpcRouteRulesFiltersResponseHeaderModifier->HeaderModifier +HttpRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier +HttpRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier +HttpRouteRulesFiltersRequestHeaderModifier->HeaderModifier +HttpRouteRulesFiltersResponseHeaderModifier->HeaderModifier +GrpcRouteRulesMatchesHeaders->HeaderMatch +HttpRouteRulesMatchesHeaders->HeaderMatch +HttpRouteRulesMatchesQueryParams->HeaderMatch +GrpcRouteStatusParents->ParentRouteStatus +HttpRouteStatusParents->ParentRouteStatus +GrpcRouteRulesBackendRefsFiltersRequestMirror->RequestMirror +GrpcRouteRulesFiltersRequestMirror->RequestMirror +HttpRouteRulesBackendRefsFiltersRequestMirror->RequestMirror +HttpRouteRulesFiltersRequestMirror->RequestMirror +HttpRouteRulesBackendRefsFiltersRequestRedirectPath->RequestRedirectPath +HttpRouteRulesBackendRefsFiltersUrlRewritePath->RequestRedirectPath +HttpRouteRulesFiltersRequestRedirectPath->RequestRedirectPath +HttpRouteRulesFiltersUrlRewritePath->RequestRedirectPath +GatewayAllowedListenersNamespacesSelector->NamespaceSelector +GatewayListenersAllowedRoutesNamespacesSelector->NamespaceSelector +ListenerSetListenersAllowedRoutesNamespacesSelector->NamespaceSelector +GatewayStatusListeners->ListenerStatus +ListenerSetStatusListeners->ListenerStatus +GatewayListenersTls->ListenerTls +ListenerSetListenersTls->ListenerTls + +#### Pass 3 +GrpcRouteRulesBackendRefsFilters->GrpcRouteFilter +GrpcRouteRulesFilters->GrpcRouteFilter +HttpRouteRulesBackendRefsFiltersRequestRedirect->HttpRouteRequestRedirect +HttpRouteRulesFiltersRequestRedirect->HttpRouteRequestRedirect +HttpRouteRulesBackendRefsFiltersUrlRewrite->HttpRouteUrlRewrite +HttpRouteRulesFiltersUrlRewrite->HttpRouteUrlRewrite +GrpcRouteStatus->RouteStatus +HttpRouteStatus->RouteStatus +TlsRouteStatus->RouteStatus +HttpRouteRulesBackendRefsFiltersRequestRedirect->FilterRequestRedirect +HttpRouteRulesFiltersRequestRedirect->FilterRequestRedirect +GatewayListenersAllowedRoutesNamespaces->AllowedRoutesNamespaces +ListenerSetListenersAllowedRoutesNamespaces->AllowedRoutesNamespaces + +#### Pass 4 +GatewayListenersAllowedRoutes->AllowedRoutes +ListenerSetListenersAllowedRoutes->AllowedRoutes + +#### Pass 5 +GatewayListeners->Listeners +ListenerSetListeners->Listeners diff --git a/type-reducer/standard_reduced_types_pass_0.txt b/type-reducer/standard_reduced_types_pass_0.txt new file mode 100644 index 0000000..3c2773d --- /dev/null +++ b/type-reducer/standard_reduced_types_pass_0.txt @@ -0,0 +1 @@ +Condition \ No newline at end of file diff --git a/type-reducer/standard_reduced_types_pass_1.txt b/type-reducer/standard_reduced_types_pass_1.txt new file mode 100644 index 0000000..4968375 --- /dev/null +++ b/type-reducer/standard_reduced_types_pass_1.txt @@ -0,0 +1,23 @@ +AllowedRoutesNamespacesFrom +BackendObjectReference +Condition +ExtensionParametersReference +FilterExtensionReference +FiltersType +GatewayAddress +GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader +Kind +MatchExpressions +ParentReference +RedirectStatusCode +Reference +RequestMirrorFraction +RequestOperationType +RequestRedirectScheme +TlsMode +TlsValidationMode diff --git a/type-reducer/standard_reduced_types_pass_2.txt b/type-reducer/standard_reduced_types_pass_2.txt new file mode 100644 index 0000000..f1a639a --- /dev/null +++ b/type-reducer/standard_reduced_types_pass_2.txt @@ -0,0 +1,33 @@ +AllowedRoutesNamespacesFrom +BackendObjectReference +Condition +ExtensionParametersReference +FilterExtensionReference +FiltersType +GatewayAddress +GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader +Kind +MatchExpressions +ParentReference +RedirectStatusCode +Reference +RequestMirrorFraction +RequestOperationType +RequestRedirectScheme +TlsMode +TlsValidationMode +#### Pass 2 +MatchingHeaders +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +ParentRouteStatus +NamespaceSelector +ListenerStatus +ListenerTls diff --git a/type-reducer/standard_reduced_types_pass_3.txt b/type-reducer/standard_reduced_types_pass_3.txt new file mode 100644 index 0000000..7c45f52 --- /dev/null +++ b/type-reducer/standard_reduced_types_pass_3.txt @@ -0,0 +1,43 @@ +Condition +AllowedRoutesNamespacesFrom +BackendObjectReference +Condition +ExtensionParametersReference +FilterExtensionReference +FiltersType +GatewayAddress +GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader +Kind +MatchExpressions +ParentReference +RedirectStatusCode +Reference +RequestMirrorFraction +RequestOperationType +RequestRedirectScheme +TlsMode +TlsValidationMode +#### Pass 2 +MatchingHeaders +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +ParentRouteStatus +NamespaceSelector +ListenerStatus +ListenerTls +#### Pass 3 +GrpcRouteFilter +HttpRouteRequestRedirect +HttpRouteUrlRewrite +RouteStatus +FilterRequestRedirect +AllowedRoutesNamespaces + + diff --git a/type-reducer/standard_reduced_types_pass_4.txt b/type-reducer/standard_reduced_types_pass_4.txt new file mode 100644 index 0000000..7d4176f --- /dev/null +++ b/type-reducer/standard_reduced_types_pass_4.txt @@ -0,0 +1,47 @@ +Condition +AllowedRoutesNamespacesFrom +BackendObjectReference +Condition +ExtensionParametersReference +FilterExtensionReference +FiltersType +GatewayAddress +GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader +Kind +MatchExpressions +ParentReference +RedirectStatusCode +Reference +RequestMirrorFraction +RequestOperationType +RequestRedirectScheme +TlsMode +TlsValidationMode +#### Pass 2 +MatchingHeaders +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +ParentRouteStatus +NamespaceSelector +ListenerStatus +ListenerTls +#### Pass 3 +GrpcRouteFilter +HttpRouteRequestRedirect +HttpRouteUrlRewrite +RouteStatus +FilterRequestRedirect +AllowedRoutesNamespaces +#### Pass 4 +AllowedRoutes +#### Pass 5 +Listeners + + diff --git a/type-reducer/standard_reduced_types_pass_5.txt b/type-reducer/standard_reduced_types_pass_5.txt new file mode 100644 index 0000000..d85a0bf --- /dev/null +++ b/type-reducer/standard_reduced_types_pass_5.txt @@ -0,0 +1,45 @@ +Condition +AllowedRoutesNamespacesFrom +BackendObjectReference +Condition +ExtensionParametersReference +FilterExtensionReference +FiltersType +GatewayAddress +GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader +Kind +MatchExpressions +ParentReference +RedirectStatusCode +Reference +RequestMirrorFraction +RequestOperationType +RequestRedirectScheme +TlsMode +TlsValidationMode +#### Pass 2 +MatchingHeaders +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +ParentRouteStatus +NamespaceSelector +ListenerStatus +ListenerTls +#### Pass 3 +GrpcRouteFilter +HttpRouteRequestRedirect +HttpRouteUrlRewrite +RouteStatus +FilterRequestRedirect +AllowedRoutesNamespaces +#### Pass 4 +AllowedRoutes + + diff --git a/type-reducer/standard_rename_only_mapped_names.txt b/type-reducer/standard_rename_only_mapped_names.txt new file mode 100644 index 0000000..c551c34 --- /dev/null +++ b/type-reducer/standard_rename_only_mapped_names.txt @@ -0,0 +1,14 @@ +### Rename only +GrpcRouteRules->GrpcRouteRule +HttpRouteRules->HttpRouteRule +HttpRouteRulesFilters->HttpRouteFilter +GrpcRouteRulesMatches->GrpcRouteMatch +HttpRouteRulesMatches->RouteMatch +HttpRouteRulesTimeouts->HttpRouteTimeout +GrpcRouteRulesBackendRefs->GRPCBackendReference +HttpRouteRulesBackendRefs->HTTPBackendReference +GrpcRouteRulesMatchesMethod->GRPCMethodMatch +HttpRouteRulesMatchesMethod->HTTPMethodMatch +HttpRouteRulesBackendRefsFilters->HttpRouteBackendFilter +HttpRouteRequestRedirect->RequestRedirect +HttpRouteRulesMatchesPath->PathMatch \ No newline at end of file diff --git a/update.sh b/update.sh deleted file mode 100755 index 296806e..0000000 --- a/update.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/bash - -# ------------------------------------------------------------------------------ -# This script will automatically generate API updates for new Gateway API -# releases. Update the $VERSION to the new release version before executing. -# -# This script requires kopium, which can be installed with: -# -# cargo install kopium -# -# See: https://github.com/kube-rs/kopium -# ------------------------------------------------------------------------------ - -set -eou pipefail - -VERSION="v1.2.1" - -STANDARD_APIS=( - gatewayclasses - gateways - httproutes - referencegrants - grpcroutes -) - -EXPERIMENTAL_APIS=( - gatewayclasses - gateways - httproutes - referencegrants - grpcroutes - tcproutes - tlsroutes - udproutes -) - -export APIS_DIR='gateway-api/src/apis' -rm -rf $APIS_DIR/standard/ -rm -rf $APIS_DIR/experimental/ - -cat << EOF > $APIS_DIR/mod.rs -pub mod experimental; -pub mod standard; -EOF - - -mkdir -p $APIS_DIR/standard/ -mkdir -p $APIS_DIR/experimental/ - -echo "// WARNING! generated file do not edit" > $APIS_DIR/standard/mod.rs - -for API in "${STANDARD_APIS[@]}" -do - echo "generating standard api ${API}" - curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${VERSION}/config/crd/standard/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $APIS_DIR/standard/${API}.rs - echo "pub mod ${API};" >> $APIS_DIR/standard/mod.rs -done - -# Standard API enums that need a Default trait impl along with their respective default variant. -ENUMS=( - HTTPRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath - HTTPRouteRulesFiltersUrlRewritePathType=ReplaceFullPath - HTTPRouteRulesFiltersType=RequestHeaderModifier - HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath - HTTPRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath - HTTPRouteRulesBackendRefsFiltersType=RequestHeaderModifier - GRPCRouteRulesFiltersType=RequestHeaderModifier - GRPCRouteRulesBackendRefsFiltersType=RequestHeaderModifier -) - -# Create a comma separated string out of $ENUMS. -ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") -ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} - -# The task searches for $GATEWAY_API_ENUMS in the enviornment to get the enum names and their default variants. -GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $APIS_DIR/standard/enum_defaults.rs -echo "mod enum_defaults;" >> $APIS_DIR/standard/mod.rs - -GATEWAY_CLASS_CONDITION_CONSTANTS="GatewayClassConditionType=Accepted" -GATEWAY_CLASS_REASON_CONSTANTS="GatewayClassConditionReason=Accepted,InvalidParameters,Pending,Unsupported,Waiting" -GATEWAY_CONDITION_CONSTANTS="GatewayConditionType=Programmed,Accepted,Ready" -GATEWAY_REASON_CONSTANTS="GatewayConditionReason=Programmed,Invalid,NoResources,AddressNotAssigned,AddressNotUsable,Accepted,ListenersNotValid,Pending,UnsupportedAddress,InvalidParameters,Ready,ListenersNotReady" -LISTENER_CONDITION_CONSTANTS="ListenerConditionType=Conflicted,Accepted,ResolvedRefs,Programmed,Ready" -LISTENER_REASON_CONSTANTS="ListenerConditionReason=HostnameConflict,ProtocolConflict,NoConflicts,Accepted,PortUnavailable,UnsupportedProtocol,ResolvedRefs,InvalidCertificateRef,InvalidRouteKinds,RefNotPermitted,Programmed,Invalid,Pending,Ready" - -GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \ - GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \ - LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \ - cargo xtask gen_condition_constants >> $APIS_DIR/standard/constants.rs -echo "pub mod constants;" >> $APIS_DIR/standard/mod.rs - -echo "// WARNING! generated file do not edit" > $APIS_DIR/experimental/mod.rs - -for API in "${EXPERIMENTAL_APIS[@]}" -do - echo "generating experimental api $API" - curl -sSL "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/${VERSION}/config/crd/experimental/gateway.networking.k8s.io_${API}.yaml" | kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f - > $APIS_DIR/experimental/${API}.rs - echo "pub mod ${API};" >> $APIS_DIR/experimental/mod.rs -done - -# Experimental API enums that need a Default trait impl along with their respective default variant. -ENUMS=( - HTTPRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath - HTTPRouteRulesFiltersUrlRewritePathType=ReplaceFullPath - HTTPRouteRulesFiltersType=RequestHeaderModifier - HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath - HTTPRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath - HTTPRouteRulesBackendRefsFiltersType=RequestHeaderModifier - GRPCRouteRulesFiltersType=RequestHeaderModifier - GRPCRouteRulesBackendRefsFiltersType=RequestHeaderModifier -) - -ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") -ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} -GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $APIS_DIR/experimental/enum_defaults.rs -echo "mod enum_defaults;" >> $APIS_DIR/experimental/mod.rs - -# GatewayClass conditions vary between standard and experimental -GATEWAY_CLASS_CONDITION_CONSTANTS="${GATEWAY_CLASS_CONDITION_CONSTANTS},SupportedVersion" -GATEWAY_CLASS_REASON_CONSTANTS="${GATEWAY_CLASS_REASON_CONSTANTS},SupportedVersion,UnsupportedVersion" - -GATEWAY_CLASS_CONDITION_CONSTANTS=${GATEWAY_CLASS_CONDITION_CONSTANTS} GATEWAY_CLASS_REASON_CONSTANTS=${GATEWAY_CLASS_REASON_CONSTANTS} \ - GATEWAY_CONDITION_CONSTANTS=${GATEWAY_CONDITION_CONSTANTS} GATEWAY_REASON_CONSTANTS=${GATEWAY_REASON_CONSTANTS} \ - LISTENER_CONDITION_CONSTANTS=${LISTENER_CONDITION_CONSTANTS} LISTENER_REASON_CONSTANTS=${LISTENER_REASON_CONSTANTS} \ - cargo xtask gen_condition_constants >> $APIS_DIR/experimental/constants.rs -echo "pub mod constants;" >> $APIS_DIR/experimental/mod.rs - -# Format the code. -cargo fmt - diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 875b406..70cc7c6 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -7,7 +7,10 @@ fn main() { match task.as_deref() { Some("gen_enum_defaults") => gen_enum_defaults().unwrap(), - Some("gen_condition_constants") => gen_condition_constants().unwrap(), + Some("gen_condition_constants") => { + let extension = env::args().nth(2); + gen_condition_constants(extension).unwrap() + } _ => print_help(), } } @@ -24,21 +27,37 @@ gen_constants generates constants used for Conditions type DynError = Box; -fn gen_condition_constants() -> Result<(), DynError> { - let gateway_class_condition_types = env::var("GATEWAY_CLASS_CONDITION_CONSTANTS")?; - let gateway_class_reason_types = env::var("GATEWAY_CLASS_REASON_CONSTANTS")?; - let gateway_condition_types = env::var("GATEWAY_CONDITION_CONSTANTS")?; - let gateway_reason_types = env::var("GATEWAY_REASON_CONSTANTS")?; - let listener_condition_types = env::var("LISTENER_CONDITION_CONSTANTS")?; - let listener_reason_types = env::var("LISTENER_REASON_CONSTANTS")?; - +fn gen_condition_constants(extension: Option) -> Result<(), DynError> { let mut scope = Scope::new(); - gen_const_enums(&mut scope, gateway_class_condition_types); - gen_const_enums(&mut scope, gateway_class_reason_types); - gen_const_enums(&mut scope, gateway_condition_types); - gen_const_enums(&mut scope, gateway_reason_types); - gen_const_enums(&mut scope, listener_condition_types); - gen_const_enums(&mut scope, listener_reason_types); + match extension { + None => { + let gateway_class_condition_types = env::var("GATEWAY_CLASS_CONDITION_CONSTANTS")?; + let gateway_class_reason_types = env::var("GATEWAY_CLASS_REASON_CONSTANTS")?; + let gateway_condition_types = env::var("GATEWAY_CONDITION_CONSTANTS")?; + let gateway_reason_types = env::var("GATEWAY_REASON_CONSTANTS")?; + let listener_condition_types = env::var("LISTENER_CONDITION_CONSTANTS")?; + let listener_reason_types = env::var("LISTENER_REASON_CONSTANTS")?; + let route_condition_types = env::var("ROUTE_CONDITION_CONSTANTS")?; + let route_reason_types = env::var("ROUTE_REASON_CONSTANTS")?; + + gen_const_enums(&mut scope, gateway_class_condition_types); + gen_const_enums(&mut scope, gateway_class_reason_types); + gen_const_enums(&mut scope, gateway_condition_types); + gen_const_enums(&mut scope, gateway_reason_types); + gen_const_enums(&mut scope, listener_condition_types); + gen_const_enums(&mut scope, listener_reason_types); + gen_const_enums(&mut scope, route_condition_types); + gen_const_enums(&mut scope, route_reason_types); + } + Some(extension) if extension == "inference" => { + let inference_extension_failure_types = + env::var("EXT_INFERENCE_FAILURE_MODE_CONSTANTS")?; + + gen_const_enums(&mut scope, inference_extension_failure_types); + } + Some(extension) => println!("{} is not a supported extension", extension), + } + println!("{}", gen_generated_file_warning()); println!("{}", scope.to_string()); Ok(()) @@ -79,14 +98,21 @@ fn gen_display_impl(scope: &mut Scope, ty: &str) { fn gen_enum_defaults() -> Result<(), DynError> { // GATEWAY_API_ENUMS provides the enum names along with their default variant to be used in the // generated Default impl. For eg: GATEWAY_API_ENUMS=enum1=default1,enum2=default2. + let gw_api_experimental = env::var("GATEWAY_API_EXPERIMENTAL"); + let gw_api = env::var("GATEWAY_API").unwrap_or("true".to_owned()); + let gw_api_inference = env::var("GATEWAY_API_INFERENCE"); + let gw_api_reduced = env::var("GATEWAY_API_REDUCED"); let gw_api_enums = env::var("GATEWAY_API_ENUMS")?; - let enums_with_defaults = get_enums_with_defaults_map(gw_api_enums); + let inference_enums = env::var("GATEWAY_API_INFERENCE_ENUMS"); + eprintln!( + "Inputs: standard {gw_api} experimental {gw_api_experimental:?} inference {gw_api_inference:?} {gw_api_enums:?} {inference_enums:?} " + ); + let enums_with_defaults = get_enums_with_defaults_map(gw_api_enums); let mut scope = Scope::new(); - let mut httproute_enums = vec![]; - let mut grpcroute_enums = vec![]; + let mut inference_scope = Scope::new(); - for (e, d) in enums_with_defaults { + for (e, d) in enums_with_defaults? { // The `fn default()` function. let mut func = Function::new("default".to_string()); func.ret("Self").line(format!("{}::{}", e, d)); @@ -96,29 +122,115 @@ fn gen_enum_defaults() -> Result<(), DynError> { .new_impl(e.as_str()) .impl_trait("Default") .push_fn(func); + } - // Determine which enums belong to the httproute module and which belong to the - // grpcroute module. - if e.starts_with("HTTPRoute") { - httproute_enums.push(e); - } else if e.starts_with("GRPCRoute") { - grpcroute_enums.push(e); + if let Ok(inference_enums) = inference_enums.map(|s| { + if s.is_empty() { + Ok(BTreeMap::new()) + } else { + get_enums_with_defaults_map(s) + } + }) { + for (e, d) in inference_enums? { + // The `fn default()` function. + let mut func = Function::new("default".to_string()); + func.ret("Self").line(format!("{}::{}", e, d)); + + // The impl Default for implementation. + inference_scope + .new_impl(e.as_str()) + .impl_trait("Default") + .push_fn(func); } } println!("{}", gen_generated_file_warning()); - // Generate use statements for the enums. - if !httproute_enums.is_empty() { - let use_http_stmt = gen_use_stmt(httproute_enums, "httproutes".to_string()); - println!("{}\n", use_http_stmt); + let gw_api = gw_api.parse::().map_err(|e| e.to_string())?; + + let gw_api_experimental = gw_api_experimental + .map_err(|e| e.to_string()) + .and_then(|s| s.parse::().map_err(|e| e.to_string())); + let gw_api_inference = gw_api_inference + .map_err(|e| e.to_string()) + .and_then(|s| s.parse::().map_err(|e| e.to_string())); + let gw_api_reduced = gw_api_reduced + .map_err(|e| e.to_string()) + .and_then(|s| s.parse::().map_err(|e| e.to_string())); + + let standard_only = " + pub use super::super::backendtlspolicies::*; + pub use super::super::gatewayclasses::*; + pub use super::super::gateways::*; + pub use super::super::grpcroutes::*; + pub use super::super::httproutes::*; + pub use super::super::listenersets::*; + pub use super::super::referencegrants::*; + pub use super::super::tlsroutes::*; + "; + + let standard_inference = " + pub use super::super::inferencepools::*; + "; + + let experimental = " + pub use super::super::backendtlspolicies::*; + pub use super::super::gatewayclasses::*; + pub use super::super::gateways::*; + pub use super::super::grpcroutes::*; + pub use super::super::httproutes::*; + pub use super::super::listenersets::*; + pub use super::super::referencegrants::*; + pub use super::super::tlsroutes::*; + pub use super::super::tcproutes::*; + pub use super::super::udproutes::*; + "; + + let experimental_inference = " + pub use super::super::inferencepools::*; + pub use super::super::inferenceobjectives::*; + "; + + let reduced = " + pub use super::super::common::*; + "; + + println!(r#"#[allow(unused_imports)]"#); + println!("pub mod prelude {{"); + match (gw_api, gw_api_inference) { + (true, Ok(true)) => { + if let Ok(true) = gw_api_experimental { + println!("{experimental}"); + println!("{experimental_inference}"); + } else { + println!("{standard_only}"); + println!("{standard_inference}"); + } + } + + (true, _) => { + if let Ok(true) = gw_api_experimental { + println!("{experimental}"); + } else { + println!("{standard_only}"); + } + } + (false, Ok(true)) => { + if let Ok(true) = gw_api_experimental { + println!("{experimental_inference}"); + } else { + println!("{standard_inference}"); + } + } + (false, _) => {} } - if !grpcroute_enums.is_empty() { - let use_grpc_stmt = gen_use_stmt(grpcroute_enums, "grpcroutes".to_string()); - println!("{}\n", use_grpc_stmt); + if let Ok(true) = gw_api_reduced { + println!("{reduced}"); } + println!("}}\nuse prelude::*;"); println!("{}", scope.to_string()); + println!("{}", inference_scope.to_string()); Ok(()) } @@ -126,24 +238,23 @@ fn gen_generated_file_warning() -> String { "// WARNING: generated file - manual changes will be overriden\n".into() } -fn gen_use_stmt(items: Vec, module: String) -> String { - let mut stmt = format!("use super::{}::{{", module); - for item in items { - stmt.push_str(format!("{}, ", item).as_str()); - } - stmt.push_str("};"); - stmt -} - -fn get_enums_with_defaults_map(env_var_val: String) -> BTreeMap { +fn get_enums_with_defaults_map(env_var_val: String) -> Result, String> { + use std::fs::read_to_string; let mut enums_with_defaults = BTreeMap::new(); - env_var_val.split(',').for_each(|enum_with_default| { - let enum_and_default: Vec<&str> = enum_with_default.split('=').collect(); - enums_with_defaults.insert( - enum_and_default[0].to_string(), - enum_and_default[1].to_string(), - ); - }); - - enums_with_defaults + read_to_string(env_var_val) + .map_err(|e| e.to_string())? + .lines() + .for_each(|enum_with_default| { + if enum_with_default.len() > 1 && enum_with_default.contains("=") { + let enum_and_default: Vec<&str> = enum_with_default.split('=').collect(); + enums_with_defaults.insert( + enum_and_default[0].to_string(), + enum_and_default[1].to_string(), + ); + } + }); + + eprintln!("Enums with defaults: {:#?}", &enums_with_defaults); + + Ok(enums_with_defaults) }