From 39a43ce2096ab5b188432e81bf53e6462af77c22 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 07:09:11 -0400 Subject: [PATCH 01/95] chore(deps): bump hyper-util from 0.1.14 to 0.1.15 (#148) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c23b21..dd34869 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -585,9 +585,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc2fdfdbff08affe55bb779f33b053aa1fe5dd5b54c257343c17edfa55711bdb" +checksum = "7f66d5bd4c6f02bf0542fad85d626775bab9258cf795a4256dcaf3161114d1df" dependencies = [ "bytes", "futures-channel", diff --git a/Cargo.toml b/Cargo.toml index f808cf1..654a5ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ version = "0.16.0" [workspace.dependencies] anyhow = "1.0.98" delegate = "0.13.3" -hyper-util = "0.1.14" +hyper-util = "0.1.15" kube = { version = "1.1.0" } k8s-openapi = { version = "0.25.0" } once_cell = "1.21.3" From 7de74e69c7edd2fbe41bba7c21d33d27c8dc68c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 11:13:06 +0000 Subject: [PATCH 02/95] chore(deps): bump tokio from 1.45.1 to 1.46.1 (#149) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 17 +++++++++++++++-- Cargo.toml | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd34869..38a5b05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -630,6 +630,17 @@ dependencies = [ "hashbrown 0.15.3", ] +[[package]] +name = "io-uring" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013" +dependencies = [ + "bitflags", + "cfg-if", + "libc", +] + [[package]] name = "itoa" version = "1.0.15" @@ -1453,17 +1464,19 @@ dependencies = [ [[package]] name = "tokio" -version = "1.45.1" +version = "1.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779" +checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17" dependencies = [ "backtrace", "bytes", + "io-uring", "libc", "mio", "parking_lot", "pin-project-lite", "signal-hook-registry", + "slab", "socket2", "tokio-macros", "windows-sys 0.52.0", diff --git a/Cargo.toml b/Cargo.toml index 654a5ce..e320317 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ schemars = "0.8.22" serde_json = "1.0.140" serde = { version = "1.0.219", features = ["derive"] } serde_yaml = "0.9.34" -tokio = { version = "1.45.1", features = ["full"] } +tokio = { version = "1.46.1", features = ["full"] } tower = { version = "0.5.2", features = ["limit"] } tracing = "0.1.41" tracing-subscriber = "0.3.19" From e4ba1abe317b571ee1d26fe041b0c02340d2ca86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 08:10:40 -0400 Subject: [PATCH 03/95] chore(deps): bump delegate from 0.13.3 to 0.13.4 (#150) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 38a5b05..1e8a292 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,9 +202,9 @@ dependencies = [ [[package]] name = "delegate" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b6483c2bbed26f97861cf57651d4f2b731964a28cd2257f934a4b452480d21" +checksum = "6178a82cf56c836a3ba61a7935cdb1c49bfaa6fa4327cd5bf554a503087de26b" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index e320317..62a5954 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ version = "0.16.0" [workspace.dependencies] anyhow = "1.0.98" -delegate = "0.13.3" +delegate = "0.13.4" hyper-util = "0.1.15" kube = { version = "1.1.0" } k8s-openapi = { version = "0.25.0" } From 633c583cf2135d815f580f81a1c60a3260b36d83 Mon Sep 17 00:00:00 2001 From: Dawid Nowak Date: Tue, 15 Jul 2025 19:45:42 +0000 Subject: [PATCH 04/95] Reducing common structs types or https://github.com/kube-rs/gateway-api-rs/issues/38 (#147) Signed-off-by: Dawid Nowak Co-authored-by: Shane Utt --- Cargo.lock | 443 +++- Cargo.toml | 2 +- gateway-api/CHANGELOG.md | 16 + gateway-api/Cargo.toml | 10 +- gateway-api/src/apis/experimental/common.rs | 351 +++ .../src/apis/experimental/constants.rs | 11 - .../src/apis/experimental/enum_defaults.rs | 52 +- .../src/apis/experimental/gatewayclasses.rs | 43 +- gateway-api/src/apis/experimental/gateways.rs | 206 +- .../src/apis/experimental/grpcroutes.rs | 1395 +--------- .../src/apis/experimental/httproutes.rs | 2257 ++--------------- gateway-api/src/apis/experimental/mod.rs | 6 +- .../src/apis/experimental/referencegrants.rs | 7 +- .../src/apis/experimental/tcproutes.rs | 434 +--- .../src/apis/experimental/tlsroutes.rs | 437 +--- .../src/apis/experimental/udproutes.rs | 434 +--- gateway-api/src/apis/standard/common.rs | 209 ++ gateway-api/src/apis/standard/constants.rs | 11 - .../src/apis/standard/enum_defaults.rs | 52 +- .../src/apis/standard/gatewayclasses.rs | 7 +- gateway-api/src/apis/standard/gateways.rs | 95 +- gateway-api/src/apis/standard/grpcroutes.rs | 1183 +-------- gateway-api/src/apis/standard/httproutes.rs | 1748 +------------ gateway-api/src/apis/standard/mod.rs | 6 +- .../src/apis/standard/referencegrants.rs | 7 +- gateway-api/src/duration.rs | 7 +- gateway-api/src/lib.rs | 55 +- type-reducer/Cargo.toml | 21 + type-reducer/README.md | 48 + .../experimental_customized_mapped_names.txt | 119 + .../experimental_ignorable_mapped_names.txt | 2 + .../experimental_reduced_types_pass_0.txt | 1 + .../experimental_reduced_types_pass_1.txt | 19 + .../experimental_reduced_types_pass_2.txt | 27 + .../experimental_reduced_types_pass_3.txt | 33 + .../experimental_reduced_types_pass_4.txt | 35 + .../experimental_rename_only_mapped_names.txt | 14 + type-reducer/src/lib.rs | 313 +++ type-reducer/src/main.rs | 304 +++ type-reducer/src/visitors.rs | 218 ++ .../standard_customized_mapped_names.txt | 84 + .../standard_reduced_types_pass_0.txt | 1 + .../standard_reduced_types_pass_1.txt | 14 + .../standard_reduced_types_pass_2.txt | 21 + .../standard_reduced_types_pass_3.txt | 26 + .../standard_rename_only_mapped_names.txt | 14 + update.sh | 74 + 47 files changed, 2745 insertions(+), 8127 deletions(-) create mode 100644 gateway-api/CHANGELOG.md create mode 100644 gateway-api/src/apis/experimental/common.rs create mode 100644 gateway-api/src/apis/standard/common.rs create mode 100644 type-reducer/Cargo.toml create mode 100644 type-reducer/README.md create mode 100644 type-reducer/experimental_customized_mapped_names.txt create mode 100644 type-reducer/experimental_ignorable_mapped_names.txt create mode 100644 type-reducer/experimental_reduced_types_pass_0.txt create mode 100644 type-reducer/experimental_reduced_types_pass_1.txt create mode 100644 type-reducer/experimental_reduced_types_pass_2.txt create mode 100644 type-reducer/experimental_reduced_types_pass_3.txt create mode 100644 type-reducer/experimental_reduced_types_pass_4.txt create mode 100644 type-reducer/experimental_rename_only_mapped_names.txt create mode 100644 type-reducer/src/lib.rs create mode 100644 type-reducer/src/main.rs create mode 100644 type-reducer/src/visitors.rs create mode 100644 type-reducer/standard_customized_mapped_names.txt create mode 100644 type-reducer/standard_reduced_types_pass_0.txt create mode 100644 type-reducer/standard_reduced_types_pass_1.txt create mode 100644 type-reducer/standard_reduced_types_pass_2.txt create mode 100644 type-reducer/standard_reduced_types_pass_3.txt create mode 100644 type-reducer/standard_rename_only_mapped_names.txt diff --git a/Cargo.lock b/Cargo.lock index 1e8a292..907f6c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "adler2" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "aho-corasick" @@ -26,6 +26,56 @@ dependencies = [ "memchr", ] +[[package]] +name = "anstream" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.59.0", +] + [[package]] name = "anyhow" version = "1.0.98" @@ -34,9 +84,9 @@ checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "autocfg" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "backtrace" @@ -50,7 +100,7 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -76,9 +126,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.18.1" +version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db76d6187cd04dff33004d8e6c9cc4e05cd330500379d2394209271b4aeee" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "bytes" @@ -88,18 +138,18 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cc" -version = "1.2.26" +version = "1.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956a5e21988b87f372569b66183b78babf23ebc2e744b733e4350a752c4dafac" +checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc" dependencies = [ "shlex", ] [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "chrono" @@ -111,6 +161,46 @@ dependencies = [ "serde", ] +[[package]] +name = "clap" +version = "4.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" + [[package]] name = "codegen" version = "0.2.0" @@ -120,6 +210,22 @@ dependencies = [ "indexmap 1.9.3", ] +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "colored" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" +dependencies = [ + "lazy_static", + "windows-sys 0.59.0", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -211,6 +317,15 @@ dependencies = [ "syn", ] +[[package]] +name = "deranged" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +dependencies = [ + "powerfmt", +] + [[package]] name = "derive_more" version = "2.0.1" @@ -401,7 +516,7 @@ checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.11.1+wasi-snapshot-preview1", ] [[package]] @@ -430,9 +545,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.15.3" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" [[package]] name = "headers" @@ -458,6 +573,12 @@ dependencies = [ "http", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "home" version = "0.5.11" @@ -627,7 +748,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", - "hashbrown 0.15.3", + "hashbrown 0.15.4", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", ] [[package]] @@ -772,9 +908,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.172" +version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "lock_api" @@ -791,12 +927,15 @@ name = "log" version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +dependencies = [ + "serde", +] [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "mime" @@ -806,9 +945,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", ] @@ -820,10 +959,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.11.1+wasi-snapshot-preview1", "windows-sys 0.59.0", ] +[[package]] +name = "multimap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" +dependencies = [ + "serde", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -834,6 +982,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-traits" version = "0.2.19" @@ -843,6 +997,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + [[package]] name = "object" version = "0.36.7" @@ -858,6 +1021,12 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + [[package]] name = "openssl-probe" version = "0.1.6" @@ -899,7 +1068,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -920,9 +1089,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "198db74531d58c70a361c42201efde7e2591e976d518caf7662a47dc5720e7b6" +checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" dependencies = [ "memchr", "thiserror", @@ -931,9 +1100,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d725d9cfd79e87dccc9341a2ef39d1b6f6353d68c4b33c177febbe1a402c97c5" +checksum = "bb056d9e8ea77922845ec74a1c4e8fb17e7c218cc4fc11a15c5d25e189aa40bc" dependencies = [ "pest", "pest_generator", @@ -941,9 +1110,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db7d01726be8ab66ab32f9df467ae8b1148906685bbe75c82d1e65d7f5b3f841" +checksum = "87e404e638f781eb3202dc82db6760c8ae8a1eeef7fb3fa8264b2ef280504966" dependencies = [ "pest", "pest_meta", @@ -954,11 +1123,10 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9f832470494906d1fca5329f8ab5791cc60beb230c74815dff541cbd2b5ca0" +checksum = "edd1101f170f5903fde0914f899bb503d9ff5271d7ba76bbb70bea63690cc0d5" dependencies = [ - "once_cell", "pest", "sha2", ] @@ -975,6 +1143,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.21" @@ -984,6 +1158,16 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "prettyplease" +version = "0.2.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "061c1221631e079b26479d25bbf2275bfe5917ae8419cd7e34f13bfc2aa7539a" +dependencies = [ + "proc-macro2", + "syn", +] + [[package]] name = "proc-macro2" version = "1.0.95" @@ -1004,9 +1188,9 @@ dependencies = [ [[package]] name = "r-efi" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "rand" @@ -1039,9 +1223,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.12" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" +checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" dependencies = [ "bitflags", ] @@ -1097,15 +1281,15 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" [[package]] name = "rustls" -version = "0.23.27" +version = "0.23.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321" +checksum = "7160e3e10bf4535308537f3c4e1641468cd0e485175d6163087c0393c7d46643" dependencies = [ "log", "once_cell", @@ -1379,14 +1563,23 @@ dependencies = [ ] [[package]] -name = "slab" -version = "0.4.9" +name = "simple_logger" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +checksum = "e8c5dfa5e08767553704aa0ffd9d9794d527103c736aba9854773851fd7497eb" dependencies = [ - "autocfg", + "colored", + "log", + "time", + "windows-sys 0.48.0", ] +[[package]] +name = "slab" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" + [[package]] name = "smallvec" version = "1.15.1" @@ -1417,9 +1610,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.101" +version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", @@ -1454,12 +1647,44 @@ 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.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" +dependencies = [ + "deranged", + "itoa", + "libc", + "num-conv", + "num_threads", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" + +[[package]] +name = "time-macros" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" +dependencies = [ + "num-conv", + "time-core", ] [[package]] @@ -1577,9 +1802,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.29" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1ffbcf9c6f6b99d386e7444eb608ba646ae452a36b39737deb9663b610f662" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", @@ -1627,6 +1852,20 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "type-reducer" +version = "0.1.0" +dependencies = [ + "clap", + "itertools", + "log", + "multimap", + "prettyplease", + "proc-macro2", + "simple_logger", + "syn", +] + [[package]] name = "typenum" version = "1.18.0" @@ -1657,6 +1896,12 @@ 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" @@ -1692,9 +1937,9 @@ 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" @@ -1785,13 +2030,22 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1800,7 +2054,22 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -1809,28 +2078,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1843,24 +2130,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -1878,18 +2189,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.25" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.25" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 62a5954..4d0dc27 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["gateway-api", "gateway-api/examples", "xtask"] +members = ["gateway-api", "gateway-api/examples", "xtask", "type-reducer"] resolver = "2" [workspace.package] diff --git a/gateway-api/CHANGELOG.md b/gateway-api/CHANGELOG.md new file mode 100644 index 0000000..401e38c --- /dev/null +++ b/gateway-api/CHANGELOG.md @@ -0,0 +1,16 @@ +# Changelog + +## Next + +>[!IMPORTANT] +Breaking change + +### Changed +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. + +## 0.16.0 + +### Changed +Initial release. All types are generated with Kopium. diff --git a/gateway-api/Cargo.toml b/gateway-api/Cargo.toml index 81cef86..a36f39e 100644 --- a/gateway-api/Cargo.toml +++ b/gateway-api/Cargo.toml @@ -38,5 +38,13 @@ uuid.workspace = true features = ["k8s-openapi/v1_32"] [features] -default = [] +default = ["standard", "experimental"] +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/src/apis/experimental/common.rs b/gateway-api/src/apis/experimental/common.rs new file mode 100644 index 0000000..600a85b --- /dev/null +++ b/gateway-api/src/apis/experimental/common.rs @@ -0,0 +1,351 @@ +// 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::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 GRPCFilterType { + ResponseHeaderModifier, + RequestHeaderModifier, + RequestMirror, + ExtensionRef, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HTTPFilterType { + RequestHeaderModifier, + ResponseHeaderModifier, + RequestMirror, + RequestRedirect, + #[serde(rename = "URLRewrite")] + UrlRewrite, + ExtensionRef, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HeaderMatchType { + Exact, + RegularExpression, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum PersistenceCookieConfigLifetime { + Permanent, + Session, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum RedirectStatusCode { + #[serde(rename = "301")] + r#_301, + #[serde(rename = "302")] + r#_302, +} +#[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, Default, PartialEq)] +pub struct BackendReference { + #[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 BackendTlsClientCertificateReference { + #[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 GatewayAddress { + #[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 GatewayInfrastructureParametersReference { + pub group: String, + pub kind: String, + pub name: String, +} +#[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 ParametersReference { + 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 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 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 RequestMirrorReference { + #[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 CommonRouteRule { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "backendRefs" + )] + pub backend_refs: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: 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 ParentRouteStatus { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + #[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: RequestMirrorReference, + #[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 SessionPersistenceCookieConfig { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "lifetimeType" + )] + pub lifetime_type: 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 RequestRedirect { + #[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 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 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 HTTPRouteBackendFilters { + #[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 = "requestRedirect" + )] + pub request_redirect: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "responseHeaderModifier" + )] + pub response_header_modifier: Option, + #[serde(rename = "type")] + pub r#type: HTTPFilterType, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "urlRewrite" + )] + pub url_rewrite: Option, +} diff --git a/gateway-api/src/apis/experimental/constants.rs b/gateway-api/src/apis/experimental/constants.rs index 83691ec..65653d9 100644 --- a/gateway-api/src/apis/experimental/constants.rs +++ b/gateway-api/src/apis/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,7 +86,6 @@ 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) diff --git a/gateway-api/src/apis/experimental/enum_defaults.rs b/gateway-api/src/apis/experimental/enum_defaults.rs index 3fee275..fe4f3ae 100644 --- a/gateway-api/src/apis/experimental/enum_defaults.rs +++ b/gateway-api/src/apis/experimental/enum_defaults.rs @@ -1,58 +1,20 @@ +use super::common::*; // 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 { +impl Default for GRPCFilterType { fn default() -> Self { - HTTPRouteRulesFiltersRequestRedirectPathType::ReplaceFullPath + GRPCFilterType::RequestHeaderModifier } } -impl Default for HTTPRouteRulesFiltersType { +impl Default for HTTPFilterType { fn default() -> Self { - HTTPRouteRulesFiltersType::RequestHeaderModifier + HTTPFilterType::RequestHeaderModifier } } -impl Default for HTTPRouteRulesFiltersUrlRewritePathType { +impl Default for RequestOperationType { fn default() -> Self { - HTTPRouteRulesFiltersUrlRewritePathType::ReplaceFullPath + RequestOperationType::ReplaceFullPath } } diff --git a/gateway-api/src/apis/experimental/gatewayclasses.rs b/gateway-api/src/apis/experimental/gatewayclasses.rs index 2d6053a..b2c3268 100644 --- a/gateway-api/src/apis/experimental/gatewayclasses.rs +++ b/gateway-api/src/apis/experimental/gatewayclasses.rs @@ -1,7 +1,6 @@ -// 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; @@ -10,7 +9,6 @@ mod prelude { 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 @@ -118,7 +82,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/src/apis/experimental/gateways.rs b/gateway-api/src/apis/experimental/gateways.rs index fa590f4..10e21a0 100644 --- a/gateway-api/src/apis/experimental/gateways.rs +++ b/gateway-api/src/apis/experimental/gateways.rs @@ -1,7 +1,6 @@ -// 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; @@ -11,7 +10,6 @@ mod prelude { 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( @@ -48,7 +46,7 @@ pub struct GatewaySpec { /// /// #[serde(default, skip_serializing_if = "Option::is_none")] - pub addresses: Option>, + pub addresses: Option>, /// BackendTLS configures TLS settings for when this Gateway is connecting to /// backends with TLS. /// @@ -189,20 +187,6 @@ pub struct GatewaySpec { /// 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. /// @@ -233,50 +217,8 @@ pub struct GatewayBackendTls { skip_serializing_if = "Option::is_none", rename = "clientCertificateRef" )] - pub client_certificate_ref: Option, + 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 @@ -321,30 +263,8 @@ pub struct GatewayInfrastructure { 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, + pub parameters_ref: Option, } - /// Listener embodies the concept of a logical endpoint where a Gateway accepts /// network connections. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] @@ -435,7 +355,6 @@ pub struct GatewayListeners { #[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. @@ -474,7 +393,7 @@ pub struct GatewayListenersAllowedRoutes { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub kinds: Option>, + 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. /// @@ -482,17 +401,6 @@ pub struct GatewayListenersAllowedRoutes { #[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. /// @@ -518,7 +426,6 @@ pub struct GatewayListenersAllowedRoutesNamespaces { #[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. /// @@ -529,7 +436,6 @@ pub enum GatewayListenersAllowedRoutesNamespacesFrom { 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". @@ -555,7 +461,6 @@ pub struct GatewayListenersAllowedRoutesNamespacesSelector { )] 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)] @@ -572,7 +477,6 @@ pub struct GatewayListenersAllowedRoutesNamespacesSelectorMatchExpressions { #[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". @@ -615,7 +519,7 @@ pub struct GatewayListenersTls { skip_serializing_if = "Option::is_none", rename = "certificateRefs" )] - pub certificate_refs: Option>, + 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 @@ -659,40 +563,6 @@ pub struct GatewayListenersTls { #[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 @@ -730,39 +600,8 @@ pub struct GatewayListenersTlsFrontendValidation { skip_serializing_if = "Option::is_none", rename = "caCertificateRefs" )] - pub ca_certificate_refs: Option>, + 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". @@ -779,7 +618,6 @@ pub enum GatewayListenersTlsMode { Terminate, Passthrough, } - /// Status defines the current state of Gateway. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct GatewayStatus { @@ -795,7 +633,7 @@ pub struct GatewayStatus { /// /// #[serde(default, skip_serializing_if = "Option::is_none")] - pub addresses: Option>, + pub addresses: Option>, /// Conditions describe the current conditions of the Gateway. /// /// Implementations should prefer to express Gateway conditions @@ -814,20 +652,6 @@ pub struct GatewayStatus { #[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 { @@ -864,15 +688,5 @@ pub struct GatewayStatusListeners { /// 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, + pub supported_kinds: Vec, } diff --git a/gateway-api/src/apis/experimental/grpcroutes.rs b/gateway-api/src/apis/experimental/grpcroutes.rs index 5710d30..e47c4b8 100644 --- a/gateway-api/src/apis/experimental/grpcroutes.rs +++ b/gateway-api/src/apis/experimental/grpcroutes.rs @@ -1,7 +1,6 @@ -// 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; @@ -10,7 +9,6 @@ mod prelude { 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( @@ -20,7 +18,7 @@ use self::prelude::*; plural = "grpcroutes" )] #[kube(namespaced)] -#[kube(status = "GRPCRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct GRPCRouteSpec { @@ -148,143 +146,18 @@ pub struct GRPCRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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, + 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 GRPCRouteRules { +pub struct GRPCRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -318,7 +191,7 @@ pub struct GRPCRouteRules { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -344,7 +217,7 @@ pub struct GRPCRouteRules { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -395,7 +268,7 @@ pub struct GRPCRouteRules { /// 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>, + 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 @@ -413,9 +286,8 @@ pub struct GRPCRouteRules { skip_serializing_if = "Option::is_none", rename = "sessionPersistence" )] - pub session_persistence: Option, + 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 @@ -441,14 +313,14 @@ pub struct GRPCRouteRules { /// /// #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefs { +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>, + 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")] @@ -505,907 +377,6 @@ pub struct GRPCRouteRulesBackendRefs { #[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. @@ -1424,49 +395,21 @@ pub enum GRPCRouteRulesFiltersType { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesMatches { +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>, + 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, + 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 { +pub struct GRPCMethodMatch { /// Value of the method to match against. If left empty or omitted, will /// match all services. /// @@ -1486,309 +429,5 @@ pub struct GRPCRouteRulesMatchesMethod { /// /// 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, + pub r#type: Option, } diff --git a/gateway-api/src/apis/experimental/httproutes.rs b/gateway-api/src/apis/experimental/httproutes.rs index d5dfc8a..8a7115b 100644 --- a/gateway-api/src/apis/experimental/httproutes.rs +++ b/gateway-api/src/apis/experimental/httproutes.rs @@ -1,7 +1,6 @@ -// 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; @@ -10,7 +9,6 @@ mod prelude { 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( @@ -20,7 +18,7 @@ use self::prelude::*; plural = "httproutes" )] #[kube(namespaced)] -#[kube(status = "HTTPRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct HTTPRouteSpec { @@ -151,143 +149,18 @@ pub struct HTTPRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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, + 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 HTTPRouteRules { +pub struct HTTPRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -328,7 +201,7 @@ pub struct HTTPRouteRules { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -366,7 +239,7 @@ pub struct HTTPRouteRules { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -424,7 +297,7 @@ pub struct HTTPRouteRules { /// 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>, + 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 @@ -449,14 +322,13 @@ pub struct HTTPRouteRules { skip_serializing_if = "Option::is_none", rename = "sessionPersistence" )] - pub session_persistence: Option, + 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, + 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 @@ -482,14 +354,14 @@ pub struct HTTPRouteRules { /// /// #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefs { +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>, + 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")] @@ -546,1826 +418,183 @@ pub struct HTTPRouteRulesBackendRefs { #[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. +/// 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 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. +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", - 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. + #[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 = "urlRewrite" + rename = "queryParams" )] - pub url_rewrite: Option, + pub query_params: 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. +/// 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: /// -/// This filter can be used multiple times within the same rule. +/// ```text +/// match: /// -/// 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. +/// path: +/// value: "/foo" +/// headers: +/// - name: "version" +/// value "v1" /// -/// 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>, +/// ``` +#[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, } - -/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. +/// 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 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, +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, } - -/// 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, +/// 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, } - -/// 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. +/// Retry defines the configuration for when to retry an HTTP request. /// /// 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. +pub struct HTTPRouteRulesRetry { + /// Attempts specifies the maxmimum number of times an individual request + /// from the gateway to a backend should be retried. /// - /// 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 the maximum number of retries has been attempted without a successful + /// response from the backend, the Gateway MUST return an error. /// - /// 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. + /// When this field is unspecified, the number of times to attempt to retry + /// a backend request is implementation-specific. /// - /// In either error case, the Message of the `ResolvedRefs` Condition - /// should be used to provide more detail about the problem. + /// 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. /// - /// Support: Extended for Kubernetes Service + /// 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. /// - /// 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. + /// 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. /// - /// Only one of Fraction or Percent may be specified. If neither field - /// is specified, 100% of requests will be mirrored. + /// 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. /// - #[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). + /// 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. /// - /// Only one of Fraction or Percent may be specified. If neither field - /// is specified, 100% of requests will be mirrored. + /// 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 percent: Option, + pub codes: 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 +/// Timeouts defines the timeouts that can be configured for an HTTP request. /// -/// Support: Implementation-specific for any other resource +/// Support: Extended #[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 { +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. @@ -2416,183 +645,3 @@ pub struct HTTPRouteRulesTimeouts { #[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/mod.rs b/gateway-api/src/apis/experimental/mod.rs index 2c13095..67cff9c 100644 --- a/gateway-api/src/apis/experimental/mod.rs +++ b/gateway-api/src/apis/experimental/mod.rs @@ -1,6 +1,8 @@ -// WARNING! generated file do not edit +// WARNING: generated file - manual changes will be overriden + +pub mod common; pub mod constants; -mod enum_defaults; +pub mod enum_defaults; pub mod gatewayclasses; pub mod gateways; pub mod grpcroutes; diff --git a/gateway-api/src/apis/experimental/referencegrants.rs b/gateway-api/src/apis/experimental/referencegrants.rs index a383a35..70f0bbc 100644 --- a/gateway-api/src/apis/experimental/referencegrants.rs +++ b/gateway-api/src/apis/experimental/referencegrants.rs @@ -1,6 +1,4 @@ -// 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 { @@ -9,7 +7,6 @@ mod prelude { 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( @@ -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/src/apis/experimental/tcproutes.rs b/gateway-api/src/apis/experimental/tcproutes.rs index 9342e6b..dea5e1e 100644 --- a/gateway-api/src/apis/experimental/tcproutes.rs +++ b/gateway-api/src/apis/experimental/tcproutes.rs @@ -1,7 +1,6 @@ -// 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; @@ -10,7 +9,6 @@ mod prelude { 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( @@ -20,7 +18,7 @@ use self::prelude::*; plural = "tcproutes" )] #[kube(namespaced)] -#[kube(status = "TCPRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct TCPRouteSpec { @@ -96,431 +94,9 @@ pub struct TCPRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + pub parent_refs: Option>, /// Rules are a list of TCP 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 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) - /// - /// 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, -} - -/// 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. -/// -/// 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 TCPRouteRulesBackendRefs { - /// 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 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 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: 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 rules: Vec, } diff --git a/gateway-api/src/apis/experimental/tlsroutes.rs b/gateway-api/src/apis/experimental/tlsroutes.rs index fed8e98..397fc3b 100644 --- a/gateway-api/src/apis/experimental/tlsroutes.rs +++ b/gateway-api/src/apis/experimental/tlsroutes.rs @@ -1,7 +1,6 @@ -// 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; @@ -10,7 +9,6 @@ mod prelude { 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( @@ -20,7 +18,7 @@ use self::prelude::*; plural = "tlsroutes" )] #[kube(namespaced)] -#[kube(status = "TLSRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct TLSRouteSpec { @@ -131,434 +129,9 @@ pub struct TLSRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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, + pub rules: Vec, } diff --git a/gateway-api/src/apis/experimental/udproutes.rs b/gateway-api/src/apis/experimental/udproutes.rs index b531c7e..85b5d1b 100644 --- a/gateway-api/src/apis/experimental/udproutes.rs +++ b/gateway-api/src/apis/experimental/udproutes.rs @@ -1,7 +1,6 @@ -// 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; @@ -10,7 +9,6 @@ mod prelude { 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( @@ -20,7 +18,7 @@ use self::prelude::*; plural = "udproutes" )] #[kube(namespaced)] -#[kube(status = "UDPRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct UDPRouteSpec { @@ -96,431 +94,9 @@ pub struct UDPRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + pub parent_refs: Option>, /// Rules are a list of UDP 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 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) - /// - /// 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, -} - -/// 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. -/// -/// 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 UDPRouteRulesBackendRefs { - /// 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 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 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: 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 rules: Vec, } diff --git a/gateway-api/src/apis/standard/common.rs b/gateway-api/src/apis/standard/common.rs new file mode 100644 index 0000000..024f39d --- /dev/null +++ b/gateway-api/src/apis/standard/common.rs @@ -0,0 +1,209 @@ +// 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::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 GRPCFilterType { + ResponseHeaderModifier, + RequestHeaderModifier, + RequestMirror, + ExtensionRef, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HTTPFilterType { + RequestHeaderModifier, + ResponseHeaderModifier, + RequestMirror, + RequestRedirect, + #[serde(rename = "URLRewrite")] + UrlRewrite, + ExtensionRef, +} +#[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, +} +#[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, Default, PartialEq)] +pub struct GatewayAddress { + #[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 GatewayInfrastructureParametersReference { + pub group: String, + pub kind: String, + pub name: String, +} +#[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 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 RequestMirrorReference { + #[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 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 ParentRouteStatus { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, + #[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: RequestMirrorReference, +} +#[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 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 RequestRedirect { + #[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 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, +} diff --git a/gateway-api/src/apis/standard/constants.rs b/gateway-api/src/apis/standard/constants.rs index 2605e44..0403176 100644 --- a/gateway-api/src/apis/standard/constants.rs +++ b/gateway-api/src/apis/standard/constants.rs @@ -4,13 +4,11 @@ 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, @@ -19,26 +17,22 @@ pub enum GatewayClassConditionReason { 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, @@ -54,13 +48,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 +61,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,7 +83,6 @@ 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) diff --git a/gateway-api/src/apis/standard/enum_defaults.rs b/gateway-api/src/apis/standard/enum_defaults.rs index 3fee275..fe4f3ae 100644 --- a/gateway-api/src/apis/standard/enum_defaults.rs +++ b/gateway-api/src/apis/standard/enum_defaults.rs @@ -1,58 +1,20 @@ +use super::common::*; // 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 { +impl Default for GRPCFilterType { fn default() -> Self { - HTTPRouteRulesFiltersRequestRedirectPathType::ReplaceFullPath + GRPCFilterType::RequestHeaderModifier } } -impl Default for HTTPRouteRulesFiltersType { +impl Default for HTTPFilterType { fn default() -> Self { - HTTPRouteRulesFiltersType::RequestHeaderModifier + HTTPFilterType::RequestHeaderModifier } } -impl Default for HTTPRouteRulesFiltersUrlRewritePathType { +impl Default for RequestOperationType { fn default() -> Self { - HTTPRouteRulesFiltersUrlRewritePathType::ReplaceFullPath + RequestOperationType::ReplaceFullPath } } diff --git a/gateway-api/src/apis/standard/gatewayclasses.rs b/gateway-api/src/apis/standard/gatewayclasses.rs index 7cde0c9..f83a7f1 100644 --- a/gateway-api/src/apis/standard/gatewayclasses.rs +++ b/gateway-api/src/apis/standard/gatewayclasses.rs @@ -1,6 +1,4 @@ -// 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 { @@ -10,7 +8,6 @@ mod prelude { 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( @@ -61,7 +58,6 @@ pub struct GatewayClassSpec { )] 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. @@ -94,7 +90,6 @@ pub struct GatewayClassParametersRef { #[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 diff --git a/gateway-api/src/apis/standard/gateways.rs b/gateway-api/src/apis/standard/gateways.rs index 96f62a1..98257a8 100644 --- a/gateway-api/src/apis/standard/gateways.rs +++ b/gateway-api/src/apis/standard/gateways.rs @@ -1,7 +1,6 @@ -// 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; @@ -11,7 +10,6 @@ mod prelude { 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( @@ -48,7 +46,7 @@ pub struct GatewaySpec { /// /// #[serde(default, skip_serializing_if = "Option::is_none")] - pub addresses: Option>, + pub addresses: Option>, /// GatewayClassName used for this Gateway. This is the name of a /// GatewayClass resource. #[serde(rename = "gatewayClassName")] @@ -177,20 +175,6 @@ pub struct GatewaySpec { /// 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 @@ -235,30 +219,8 @@ pub struct GatewayInfrastructure { 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 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)] @@ -349,7 +311,6 @@ pub struct GatewayListeners { #[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. @@ -388,7 +349,7 @@ pub struct GatewayListenersAllowedRoutes { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub kinds: Option>, + 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. /// @@ -396,17 +357,6 @@ pub struct GatewayListenersAllowedRoutes { #[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. /// @@ -432,7 +382,6 @@ pub struct GatewayListenersAllowedRoutesNamespaces { #[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. /// @@ -443,7 +392,6 @@ pub enum GatewayListenersAllowedRoutesNamespacesFrom { 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". @@ -469,7 +417,6 @@ pub struct GatewayListenersAllowedRoutesNamespacesSelector { )] 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)] @@ -486,7 +433,6 @@ pub struct GatewayListenersAllowedRoutesNamespacesSelectorMatchExpressions { #[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". @@ -558,7 +504,6 @@ pub struct GatewayListenersTls { #[serde(default, skip_serializing_if = "Option::is_none")] pub options: Option>, } - /// SecretObjectReference identifies an API object including its namespace, /// defaulting to Secret. /// @@ -591,7 +536,6 @@ pub struct GatewayListenersTlsCertificateRefs { #[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". @@ -608,7 +552,6 @@ pub enum GatewayListenersTlsMode { Terminate, Passthrough, } - /// Status defines the current state of Gateway. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct GatewayStatus { @@ -624,7 +567,7 @@ pub struct GatewayStatus { /// /// #[serde(default, skip_serializing_if = "Option::is_none")] - pub addresses: Option>, + pub addresses: Option>, /// Conditions describe the current conditions of the Gateway. /// /// Implementations should prefer to express Gateway conditions @@ -643,20 +586,6 @@ pub struct GatewayStatus { #[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 { @@ -693,15 +622,5 @@ pub struct GatewayStatusListeners { /// 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, + pub supported_kinds: Vec, } diff --git a/gateway-api/src/apis/standard/grpcroutes.rs b/gateway-api/src/apis/standard/grpcroutes.rs index 60949b7..80ffb94 100644 --- a/gateway-api/src/apis/standard/grpcroutes.rs +++ b/gateway-api/src/apis/standard/grpcroutes.rs @@ -1,7 +1,6 @@ -// 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; @@ -10,7 +9,6 @@ mod prelude { 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( @@ -20,7 +18,7 @@ use self::prelude::*; plural = "grpcroutes" )] #[kube(namespaced)] -#[kube(status = "GRPCRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct GRPCRouteSpec { @@ -138,129 +136,18 @@ pub struct GRPCRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, + 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 { +pub struct GRPCRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -294,7 +181,7 @@ pub struct GRPCRouteRules { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -320,7 +207,7 @@ pub struct GRPCRouteRules { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -371,9 +258,8 @@ pub struct GRPCRouteRules { /// 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>, + 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 @@ -399,14 +285,14 @@ pub struct GRPCRouteRules { /// /// #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefs { +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>, + 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")] @@ -463,841 +349,6 @@ pub struct GRPCRouteRulesBackendRefs { #[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. @@ -1316,49 +367,21 @@ pub enum GRPCRouteRulesFiltersType { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesMatches { +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>, + 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, + 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 { +pub struct GRPCMethodMatch { /// Value of the method to match against. If left empty or omitted, will /// match all services. /// @@ -1378,179 +401,5 @@ pub struct GRPCRouteRulesMatchesMethod { /// /// 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, + pub r#type: Option, } diff --git a/gateway-api/src/apis/standard/httproutes.rs b/gateway-api/src/apis/standard/httproutes.rs index 978a747..ef1183e 100644 --- a/gateway-api/src/apis/standard/httproutes.rs +++ b/gateway-api/src/apis/standard/httproutes.rs @@ -1,7 +1,6 @@ -// 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; @@ -10,7 +9,6 @@ mod prelude { 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( @@ -20,7 +18,7 @@ use self::prelude::*; plural = "httproutes" )] #[kube(namespaced)] -#[kube(status = "HTTPRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct HTTPRouteSpec { @@ -141,129 +139,18 @@ pub struct HTTPRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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, + 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 HTTPRouteRules { +pub struct HTTPRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -304,7 +191,7 @@ pub struct HTTPRouteRules { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -342,7 +229,7 @@ pub struct HTTPRouteRules { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -400,14 +287,13 @@ pub struct HTTPRouteRules { /// 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>, + 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, + 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 @@ -433,14 +319,14 @@ pub struct HTTPRouteRules { /// /// #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefs { +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>, + 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")] @@ -497,7 +383,6 @@ pub struct HTTPRouteRulesBackendRefs { #[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 @@ -505,7 +390,7 @@ pub struct HTTPRouteRulesBackendRefs { /// 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 { +pub struct HTTPRouteBackendFilter { /// 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 @@ -519,7 +404,7 @@ pub struct HTTPRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + pub extension_ref: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -529,7 +414,7 @@ pub struct HTTPRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier" )] - pub request_header_modifier: Option, + 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. @@ -546,7 +431,7 @@ pub struct HTTPRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -556,7 +441,7 @@ pub struct HTTPRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestRedirect" )] - pub request_redirect: Option, + pub request_redirect: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -566,7 +451,7 @@ pub struct HTTPRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier" )] - pub response_header_modifier: Option, + 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: /// @@ -600,7 +485,7 @@ pub struct HTTPRouteRulesBackendRefsFilters { /// Accepted Condition for the Route to `status: False`, with a /// Reason of `UnsupportedValue`. #[serde(rename = "type")] - pub r#type: HTTPRouteRulesBackendRefsFiltersType, + pub r#type: HTTPFilterType, /// URLRewrite defines a schema for a filter that modifies a request during forwarding. /// /// Support: Extended @@ -609,278 +494,102 @@ pub struct HTTPRouteRulesBackendRefsFilters { 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, + pub url_rewrite: 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 -/// -/// +/// 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 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 +pub struct HTTPRouteFilter { + /// 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 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". + /// This filter can be used multiple times within the same rule. /// - /// Defaults to "Service" when not specified. + /// 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. /// - /// 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 + #[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. /// - /// Support: Core (Services with a type other than ExternalName) + /// 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: 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. + /// Support: Extended /// - /// 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. + #[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")] - 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. + #[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")] - 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: + #[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: /// - /// * 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. + /// - Core: Filter types and their corresponding configuration defined by + /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All + /// implementations must support core filters. /// - /// Implementations SHOULD NOT add the port number in the 'Location' - /// header in the following cases: + /// - Extended: Filter types and their corresponding configuration defined by + /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers + /// are encouraged to support extended filters. /// - /// * 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. + /// - 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. /// - /// 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. + /// Implementers are encouraged to define custom implementation types to + /// extend the core API with implementation-specific behavior. /// - /// Scheme redirects can affect the port of the redirect, for more information, - /// refer to the documentation for the port field of this filter. + /// 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. @@ -888,991 +597,27 @@ pub struct HTTPRouteRulesBackendRefsFiltersRequestRedirect { /// 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")] - 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" + rename = "urlRewrite" )] - pub status_code: Option, + pub url_rewrite: 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. +/// 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. /// -/// 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. +/// For example, the match below will match a HTTP request only if its path +/// starts with `/foo` AND it contains the `version: v1` header: /// -/// 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: +/// ```text +/// match: /// /// path: /// value: "/foo" @@ -1882,23 +627,23 @@ pub enum HTTPRouteRulesFiltersUrlRewritePathType { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesMatches { +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>, + 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, + 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, + 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. @@ -1909,52 +654,8 @@ pub struct HTTPRouteRulesMatches { 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, + pub query_params: Option>, } - -/// 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. @@ -1973,7 +674,7 @@ pub enum HTTPRouteRulesMatchesHeadersType { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesMatchesMethod { +pub enum HTTPMethodMatch { #[serde(rename = "GET")] Get, #[serde(rename = "HEAD")] @@ -1993,11 +694,10 @@ pub enum HTTPRouteRulesMatchesMethod { #[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 { +pub struct PathMatch { /// Type specifies how to match against the path Value. /// /// Support: Core (Exact, PathPrefix) @@ -2009,7 +709,6 @@ pub struct HTTPRouteRulesMatchesPath { #[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)] @@ -2018,58 +717,11 @@ pub enum HTTPRouteRulesMatchesPathType { 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 { +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. @@ -2120,169 +772,3 @@ pub struct HTTPRouteRulesTimeouts { #[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 index 5111225..d6ed9b1 100644 --- a/gateway-api/src/apis/standard/mod.rs +++ b/gateway-api/src/apis/standard/mod.rs @@ -1,6 +1,8 @@ -// WARNING! generated file do not edit +// WARNING: generated file - manual changes will be overriden + +pub mod common; pub mod constants; -mod enum_defaults; +pub mod enum_defaults; pub mod gatewayclasses; pub mod gateways; pub mod grpcroutes; diff --git a/gateway-api/src/apis/standard/referencegrants.rs b/gateway-api/src/apis/standard/referencegrants.rs index a383a35..70f0bbc 100644 --- a/gateway-api/src/apis/standard/referencegrants.rs +++ b/gateway-api/src/apis/standard/referencegrants.rs @@ -1,6 +1,4 @@ -// 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 { @@ -9,7 +7,6 @@ mod prelude { 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( @@ -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/src/duration.rs b/gateway-api/src/duration.rs index 699bee9..2ec98ed 100644 --- a/gateway-api/src/duration.rs +++ b/gateway-api/src/duration.rs @@ -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/lib.rs b/gateway-api/src/lib.rs index 492d60b..91a761e 100644 --- a/gateway-api/src/lib.rs +++ b/gateway-api/src/lib.rs @@ -1,6 +1,8 @@ pub mod duration; pub use duration::Duration; pub mod apis; + +#[cfg(feature = "standard")] pub use apis::standard::*; #[cfg(feature = "experimental")] @@ -25,15 +27,14 @@ mod tests { use tower::ServiceBuilder; use uuid::Uuid; + use crate::common::GatewayAddress; use crate::{ - constants::{ + apis::standard::constants::{ GatewayConditionReason, GatewayConditionType, ListenerConditionReason, ListenerConditionType, }, - gatewayclasses::{GatewayClass, GatewayClassSpec}, - gateways::{ - Gateway, GatewaySpec, GatewayStatus, GatewayStatusAddresses, GatewayStatusListeners, - }, + apis::standard::gatewayclasses::{GatewayClass, GatewayClassSpec}, + apis::standard::gateways::{Gateway, GatewaySpec, GatewayStatus, GatewayStatusListeners}, }; // ------------------------------------------------------------------------- @@ -87,29 +88,30 @@ 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 { + let gw_status = GatewayStatus { + addresses: Some(vec![GatewayAddress::default()]), + listeners: Some(vec![GatewayStatusListeners { + name: "tcp".into(), + attached_routes: 0, + supported_kinds: vec![], + conditions: vec![Condition { + last_transition_time: Time(Utc::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(Utc::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(), - }]); + type_: GatewayConditionType::Programmed.to_string(), + }]), + }; gw = Api::default_namespaced(client) .patch_status( @@ -139,9 +141,8 @@ 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) } } } diff --git a/type-reducer/Cargo.toml b/type-reducer/Cargo.toml new file mode 100644 index 0000000..a521d3a --- /dev/null +++ b/type-reducer/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "type-reducer" +version = "0.1.0" +edition = "2024" +authors = ["Dawid Nowak nowakd@gmail.com"] + +[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..aac0c1a --- /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. Check [update.sh](../update.sh) for more details on how to use it. + diff --git a/type-reducer/experimental_customized_mapped_names.txt b/type-reducer/experimental_customized_mapped_names.txt new file mode 100644 index 0000000..245e344 --- /dev/null +++ b/type-reducer/experimental_customized_mapped_names.txt @@ -0,0 +1,119 @@ +GRPCRouteRulesBackendRefsFiltersType->GRPCFilterType +GRPCRouteRulesFiltersType->GRPCFilterType +GRPCRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +GRPCRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +HTTPRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +HTTPRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +GRPCRouteRulesSessionPersistenceCookieConfigLifetimeType->PersistenceCookieConfigLifetime +HTTPRouteRulesSessionPersistenceCookieConfigLifetimeType->PersistenceCookieConfigLifetime +GRPCRouteRulesSessionPersistenceType->SessionPersistenceType +HTTPRouteRulesSessionPersistenceType->SessionPersistenceType +GatewayAddresses->GatewayAddress +GatewayStatusAddresses->GatewayAddress +GatewayBackendTlsClientCertificateRef->BackendTlsClientCertificateReference +GatewayListenersTlsCertificateRefs->BackendTlsClientCertificateReference +GatewayClassParametersRef->ParametersReference +GatewayListenersTlsFrontendValidationCaCertificateRefs->ParametersReference +GRPCRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference +GRPCRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference +GatewayInfrastructureParametersRef->GatewayInfrastructureParametersReference +HTTPRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference +HTTPRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference +HTTPRouteRulesBackendRefsFiltersType->HTTPFilterType +HTTPRouteRulesFiltersType->HTTPFilterType +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 +GRPCRouteRulesMatchesHeadersType->HeaderMatchType +GRPCRouteRulesMatchesMethodType->HeaderMatchType +HTTPRouteRulesMatchesHeadersType->HeaderMatchType +HTTPRouteRulesMatchesQueryParamsType->HeaderMatchType +GatewayListenersAllowedRoutesKinds->Kind +GatewayStatusListenersSupportedKinds->Kind +HTTPRouteRulesBackendRefsFiltersRequestRedirectStatusCode->RedirectStatusCode +HTTPRouteRulesFiltersRequestRedirectStatusCode->RedirectStatusCode +GRPCRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference +GRPCRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference +HTTPRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference +HTTPRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference +HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType->RequestOperationType +HTTPRouteRulesBackendRefsFiltersUrlRewritePathType->RequestOperationType +HTTPRouteRulesFiltersRequestRedirectPathType->RequestOperationType +HTTPRouteRulesFiltersUrlRewritePathType->RequestOperationType +HTTPRouteRulesBackendRefsFiltersRequestRedirectScheme->RequestRedirectScheme +HTTPRouteRulesFiltersRequestRedirectScheme->RequestRedirectScheme +GRPCRouteParentRefs->ParentReference +GRPCRouteStatusParentsParentRef->ParentReference +HTTPRouteParentRefs->ParentReference +HTTPRouteStatusParentsParentRef->ParentReference +TCPRouteParentRefs->ParentReference +TCPRouteStatusParentsParentRef->ParentReference +TLSRouteParentRefs->ParentReference +TLSRouteStatusParentsParentRef->ParentReference +UDPRouteParentRefs->ParentReference +UDPRouteStatusParentsParentRef->ParentReference +TCPRouteRulesBackendRefs->BackendReference +TLSRouteRulesBackendRefs->BackendReference +UDPRouteRulesBackendRefs->BackendReference +#### Pass 2 +GRPCRouteRulesSessionPersistenceCookieConfig->SessionPersistenceCookieConfig +HTTPRouteRulesSessionPersistenceCookieConfig->SessionPersistenceCookieConfig +GRPCRouteRulesMatchesHeaders->HeaderMatch +HTTPRouteRulesMatchesHeaders->HeaderMatch +HTTPRouteRulesMatchesQueryParams->HeaderMatch +GRPCRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier +GRPCRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier +GRPCRouteRulesFiltersRequestHeaderModifier->HeaderModifier +GRPCRouteRulesFiltersResponseHeaderModifier->HeaderModifier +HTTPRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier +HTTPRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier +HTTPRouteRulesFiltersRequestHeaderModifier->HeaderModifier +HTTPRouteRulesFiltersResponseHeaderModifier->HeaderModifier +GRPCRouteRulesBackendRefsFiltersRequestMirror->RequestMirror +GRPCRouteRulesFiltersRequestMirror->RequestMirror +HTTPRouteRulesBackendRefsFiltersRequestMirror->RequestMirror +HTTPRouteRulesFiltersRequestMirror->RequestMirror +HTTPRouteRulesBackendRefsFiltersRequestRedirectPath->RequestRedirectPath +HTTPRouteRulesBackendRefsFiltersUrlRewritePath->RequestRedirectPath +HTTPRouteRulesFiltersRequestRedirectPath->RequestRedirectPath +HTTPRouteRulesFiltersUrlRewritePath->RequestRedirectPath +TCPRouteRules->CommonRouteRule +TLSRouteRules->CommonRouteRule +UDPRouteRules->CommonRouteRule +GRPCRouteStatusParents->ParentRouteStatus +HTTPRouteStatusParents->ParentRouteStatus +TCPRouteStatusParents->ParentRouteStatus +TLSRouteStatusParents->ParentRouteStatus +UDPRouteStatusParents->ParentRouteStatus +#### Pass 3 +GRPCRouteRulesBackendRefsFilters->GRPCRouteFilter +GRPCRouteRulesFilters->GRPCRouteFilter +GRPCRouteRulesSessionPersistence->SessionPersistence +HTTPRouteRulesSessionPersistence->SessionPersistence +HTTPRouteRulesBackendRefsFiltersRequestRedirect->HTTPRouteRequestRedirect +HTTPRouteRulesFiltersRequestRedirect->HTTPRouteRequestRedirect +HTTPRouteRulesBackendRefsFiltersUrlRewrite->HTTPRouteUrlRewrite +HTTPRouteRulesFiltersUrlRewrite->HTTPRouteUrlRewrite +TCPRouteSpec->RouteSpec +UDPRouteSpec->RouteSpec +GRPCRouteStatus->RouteStatus +HTTPRouteStatus->RouteStatus +TCPRouteStatus->RouteStatus +TLSRouteStatus->RouteStatus +UDPRouteStatus->RouteStatus +#### Pass 4 +HTTPRouteRulesBackendRefsFilters->HTTPRouteBackendFilters +HTTPRouteRulesFilters->HTTPRouteRulesBackendRefsFilters diff --git a/type-reducer/experimental_ignorable_mapped_names.txt b/type-reducer/experimental_ignorable_mapped_names.txt new file mode 100644 index 0000000..b278bf5 --- /dev/null +++ b/type-reducer/experimental_ignorable_mapped_names.txt @@ -0,0 +1,2 @@ +TCPRouteSpec->RouteSpec +UDPRouteSpec->RouteSpec 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..9fe55af --- /dev/null +++ b/type-reducer/experimental_reduced_types_pass_1.txt @@ -0,0 +1,19 @@ +Condition +GRPCFilterType +RequestMirrorFraction +PersistenceCookieConfigLifetime +SessionPersistenceType +GatewayAddress +BackendTlsClientCertificateReference +ParametersReference +GatewayInfrastructureParametersReference +HTTPFilterType +HTTPHeader +HeaderMatchType +Kind +RedirectStatusCode +RequestMirrorReference +RequestOperationType +RequestRedirectScheme +ParentReference +BackendReference 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..402636a --- /dev/null +++ b/type-reducer/experimental_reduced_types_pass_2.txt @@ -0,0 +1,27 @@ +Condition +GRPCFilterType +RequestMirrorFraction +PersistenceCookieConfigLifetime +SessionPersistenceType +GatewayAddress +BackendTlsClientCertificateReference +ParametersReference +GatewayInfrastructureParametersReference +HTTPFilterType +HTTPHeader +HeaderMatchType +Kind +RedirectStatusCode +RequestMirrorReference +RequestOperationType +RequestRedirectScheme +ParentReference +BackendReference +#### Pass 2 +SessionPersistenceCookieConfig +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +ParentRouteStatus +CommonRouteRule 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..2c06609 --- /dev/null +++ b/type-reducer/experimental_reduced_types_pass_3.txt @@ -0,0 +1,33 @@ +Condition +GRPCFilterType +RequestMirrorFraction +PersistenceCookieConfigLifetime +SessionPersistenceType +GatewayAddress +BackendTlsClientCertificateReference +ParametersReference +GatewayInfrastructureParametersReference +HTTPFilterType +HTTPHeader +HeaderMatchType +Kind +RedirectStatusCode +RequestMirrorReference +RequestOperationType +RequestRedirectScheme +ParentReference +BackendReference +#### Pass 2 +SessionPersistenceCookieConfig +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +ParentRouteStatus +CommonRouteRule +#### Pass 3 +GRPCRouteFilter +HTTPRouteRequestRedirect +HTTPRouteUrlRewrite +RouteStatus +SessionPersistence 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..2d40c18 --- /dev/null +++ b/type-reducer/experimental_reduced_types_pass_4.txt @@ -0,0 +1,35 @@ +Condition +GRPCFilterType +RequestMirrorFraction +PersistenceCookieConfigLifetime +SessionPersistenceType +GatewayAddress +BackendTlsClientCertificateReference +ParametersReference +GatewayInfrastructureParametersReference +HTTPFilterType +HTTPHeader +HeaderMatchType +Kind +RedirectStatusCode +RequestMirrorReference +RequestOperationType +RequestRedirectScheme +ParentReference +BackendReference +#### Pass 2 +SessionPersistenceCookieConfig +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +ParentRouteStatus +CommonRouteRule +#### Pass 3 +GRPCRouteFilter +HTTPRouteRequestRedirect +HTTPRouteUrlRewrite +RouteStatus +SessionPersistence +#### Pass 4 +HTTPRouteBackendFilters 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..b8c7e41 --- /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/src/lib.rs b/type-reducer/src/lib.rs new file mode 100644 index 0000000..39af624 --- /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::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..8f8684c --- /dev/null +++ b/type-reducer/src/main.rs @@ -0,0 +1,304 @@ +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![]; + + for dir_entry in fs::read_dir(apis_dir)? { + let Ok(dir_entry) = dir_entry else { + continue; + }; + + if let Ok(name) = dir_entry.file_name().into_string() { + if 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()) { + if 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..7e4ca88 --- /dev/null +++ b/type-reducer/standard_customized_mapped_names.txt @@ -0,0 +1,84 @@ +GRPCRouteRulesBackendRefsFiltersType->GRPCFilterType +GRPCRouteRulesFiltersType->GRPCFilterType +GatewayAddresses->GatewayAddress +GatewayStatusAddresses->GatewayAddress +GRPCRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference +GRPCRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference +GatewayInfrastructureParametersRef->GatewayInfrastructureParametersReference +HTTPRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference +HTTPRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference +GatewayListenersAllowedRoutesKinds->Kind +GatewayStatusListenersSupportedKinds->Kind +GRPCRouteParentRefs->ParentReference +GRPCRouteStatusParentsParentRef->ParentReference +HTTPRouteParentRefs->ParentReference +HTTPRouteStatusParentsParentRef->ParentReference +GRPCRouteRulesBackendRefsFiltersExtensionRef->FilterExtensionReference +GRPCRouteRulesFiltersExtensionRef->FilterExtensionReference +HTTPRouteRulesBackendRefsFiltersExtensionRef->FilterExtensionReference +HTTPRouteRulesFiltersExtensionRef->FilterExtensionReference +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->RequestMirrorReference +GRPCRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference +HTTPRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference +HTTPRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference +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 +#### Pass 3 +GRPCRouteRulesBackendRefsFilters->GRPCRouteFilter +GRPCRouteRulesFilters->GRPCRouteFilter +HTTPRouteRulesBackendRefsFiltersRequestRedirect->HTTPRouteRequestRedirect +HTTPRouteRulesFiltersRequestRedirect->HTTPRouteRequestRedirect +HTTPRouteRulesBackendRefsFiltersUrlRewrite->HTTPRouteUrlRewrite +HTTPRouteRulesFiltersUrlRewrite->HTTPRouteUrlRewrite +GRPCRouteStatus->RouteStatus +HTTPRouteStatus->RouteStatus 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..312e0e4 --- /dev/null +++ b/type-reducer/standard_reduced_types_pass_1.txt @@ -0,0 +1,14 @@ +Condition +GRPCFilterType +GatewayAddress +GatewayInfrastructureParametersReference +Kind +ParentReference +FilterExtensionReference +HTTPHeader +RequestMirrorReference +RequestOperationType +RequestRedirectScheme +RedirectStatusCode +FiltersType +HeaderMatchType 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..145b480 --- /dev/null +++ b/type-reducer/standard_reduced_types_pass_2.txt @@ -0,0 +1,21 @@ +Condition +GRPCFilterType +GatewayAddress +GatewayInfrastructureParametersReference +Kind +ParentReferenceerence +FilterExtensionReference +HTTPHeader +RequestMirrorReference +RequestOperationType +RequestRedirectScheme +RedirectStatusCode +FiltersType +HeaderMatchType +#### Pass 2 +MatchingHeaders +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +ParentRouteStatus 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..3b5cbd3 --- /dev/null +++ b/type-reducer/standard_reduced_types_pass_3.txt @@ -0,0 +1,26 @@ +Condition +GRPCFilterType +GatewayAddress +GatewayInfrastructureParametersReference +Kind +ParentReferenceerence +FilterExtensionReference +HTTPHeader +RequestMirrorReference +RequestOperationType +RequestRedirectScheme +RedirectStatusCode +FiltersType +HeaderMatchType +#### Pass 2 +MatchingHeaders +HeaderModifier +HeaderMatch +RequestMirror +RequestRedirectPath +ParentRouteStatus +#### Pass 3 +GRPCRouteFilter +HTTPRouteRequestRedirect +HTTPRouteUrlRewrite +RouteStatus 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..b8c7e41 --- /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 index 296806e..e6c3210 100755 --- a/update.sh +++ b/update.sh @@ -47,6 +47,7 @@ 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[@]}" @@ -128,3 +129,76 @@ 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 " **** 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 +) + +ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} +echo "use super::common::*;" > $APIS_DIR/standard/enum_defaults.rs +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $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 + +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 + HTTPFilterType=RequestHeaderModifier +) + +ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") +ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} +echo "use super::common::*;" > $APIS_DIR/experimental/enum_defaults.rs +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $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 From a6bd8f2847a8fbddcc0bdc28fedb855104ee81b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Jul 2025 12:32:30 -0400 Subject: [PATCH 05/95] chore(deps): bump serde_json from 1.0.140 to 1.0.141 (#155) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 907f6c0..479d8f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -751,6 +751,17 @@ dependencies = [ "hashbrown 0.15.4", ] +[[package]] +name = "io-uring" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013" +dependencies = [ + "bitflags", + "cfg-if", + "libc", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -766,17 +777,6 @@ dependencies = [ "either", ] -[[package]] -name = "io-uring" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013" -dependencies = [ - "bitflags", - "cfg-if", - "libc", -] - [[package]] name = "itoa" version = "1.0.15" @@ -1493,9 +1493,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3" dependencies = [ "itoa", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 4d0dc27..bb6218b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ k8s-openapi = { version = "0.25.0" } once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.6" } schemars = "0.8.22" -serde_json = "1.0.140" +serde_json = "1.0.141" serde = { version = "1.0.219", features = ["derive"] } serde_yaml = "0.9.34" tokio = { version = "1.46.1", features = ["full"] } From 34e9e89ed56410481759e755e60d95d0deca2d85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Jul 2025 16:35:56 +0000 Subject: [PATCH 06/95] chore(deps): bump clap from 4.5.40 to 4.5.41 (#154) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 479d8f6..ec97181 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.40" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" +checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9" dependencies = [ "clap_builder", "clap_derive", @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.40" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e" +checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d" dependencies = [ "anstream", "anstyle", @@ -185,9 +185,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.40" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce" +checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491" dependencies = [ "heck", "proc-macro2", From 3dbd6713c53d7ea32e9e9412176448bfe5fbf9e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Jul 2025 16:40:07 +0000 Subject: [PATCH 07/95] chore(deps): bump prettyplease from 0.2.35 to 0.2.36 (#151) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec97181..1b5e6cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1160,9 +1160,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.35" +version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "061c1221631e079b26479d25bbf2275bfe5917ae8419cd7e34f13bfc2aa7539a" +checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2" dependencies = [ "proc-macro2", "syn", From 360d4b0cdeeb0a7e0b039242b92d663f062f4ef5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Jul 2025 16:44:20 +0000 Subject: [PATCH 08/95] chore(deps): bump tokio from 1.46.1 to 1.47.0 (#152) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 20 +++++++++++++++----- Cargo.toml | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b5e6cd..32062fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -719,7 +719,7 @@ dependencies = [ "hyper", "libc", "pin-project-lite", - "socket2", + "socket2 0.5.10", "tokio", "tower-service", "tracing", @@ -1596,6 +1596,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "socket2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + [[package]] name = "strsim" version = "0.11.1" @@ -1689,9 +1699,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.46.1" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17" +checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35" dependencies = [ "backtrace", "bytes", @@ -1702,9 +1712,9 @@ dependencies = [ "pin-project-lite", "signal-hook-registry", "slab", - "socket2", + "socket2 0.6.0", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index bb6218b..fe9df92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ schemars = "0.8.22" serde_json = "1.0.141" serde = { version = "1.0.219", features = ["derive"] } serde_yaml = "0.9.34" -tokio = { version = "1.46.1", features = ["full"] } +tokio = { version = "1.47.0", features = ["full"] } tower = { version = "0.5.2", features = ["limit"] } tracing = "0.1.41" tracing-subscriber = "0.3.19" From 5a875e182e94c3427b09a9ab30c796b15db13a07 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Jul 2025 16:52:53 +0000 Subject: [PATCH 09/95] chore(deps): bump hyper-util from 0.1.15 to 0.1.16 (#153) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Shane Utt --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32062fb..7db14ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -706,9 +706,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f66d5bd4c6f02bf0542fad85d626775bab9258cf795a4256dcaf3161114d1df" +checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e" dependencies = [ "bytes", "futures-channel", diff --git a/Cargo.toml b/Cargo.toml index fe9df92..cc7a51b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ version = "0.16.0" [workspace.dependencies] anyhow = "1.0.98" delegate = "0.13.4" -hyper-util = "0.1.15" +hyper-util = "0.1.16" kube = { version = "1.1.0" } k8s-openapi = { version = "0.25.0" } once_cell = "1.21.3" From 1ef95cae9125e7323b8002ec4901ef29adae121e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Aug 2025 13:14:10 -0400 Subject: [PATCH 10/95] chore(deps): bump clap from 4.5.41 to 4.5.42 (#158) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7db14ef..80fcfb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.41" +version = "4.5.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9" +checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" dependencies = [ "clap_builder", "clap_derive", @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.41" +version = "4.5.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d" +checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" dependencies = [ "anstream", "anstyle", @@ -719,7 +719,7 @@ dependencies = [ "hyper", "libc", "pin-project-lite", - "socket2 0.5.10", + "socket2", "tokio", "tower-service", "tracing", @@ -1586,16 +1586,6 @@ version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" -[[package]] -name = "socket2" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "socket2" version = "0.6.0" @@ -1712,7 +1702,7 @@ dependencies = [ "pin-project-lite", "signal-hook-registry", "slab", - "socket2 0.6.0", + "socket2", "tokio-macros", "windows-sys 0.59.0", ] From 1ec84c02d61108cbe15511adb1e3172754e27053 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Aug 2025 17:17:22 +0000 Subject: [PATCH 11/95] chore(deps): bump tokio from 1.47.0 to 1.47.1 (#157) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80fcfb7..8a3ebf9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1689,9 +1689,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.47.0" +version = "1.47.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35" +checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" dependencies = [ "backtrace", "bytes", diff --git a/Cargo.toml b/Cargo.toml index cc7a51b..058c671 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ schemars = "0.8.22" serde_json = "1.0.141" serde = { version = "1.0.219", features = ["derive"] } serde_yaml = "0.9.34" -tokio = { version = "1.47.0", features = ["full"] } +tokio = { version = "1.47.1", features = ["full"] } tower = { version = "0.5.2", features = ["limit"] } tracing = "0.1.41" tracing-subscriber = "0.3.19" From de96c45801dca97f6ca7d2117012dcb341b09c08 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Aug 2025 17:28:58 +0000 Subject: [PATCH 12/95] chore(deps): bump serde_json from 1.0.141 to 1.0.142 (#156) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a3ebf9..853aff8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1493,9 +1493,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.141" +version = "1.0.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3" +checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" dependencies = [ "itoa", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 058c671..02887a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ k8s-openapi = { version = "0.25.0" } once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.6" } schemars = "0.8.22" -serde_json = "1.0.141" +serde_json = "1.0.142" serde = { version = "1.0.219", features = ["derive"] } serde_yaml = "0.9.34" tokio = { version = "1.47.1", features = ["full"] } From d4133a1a72be5947fd7bb249a8ee88e440e42e63 Mon Sep 17 00:00:00 2001 From: Scott Fleener Date: Wed, 6 Aug 2025 08:38:25 -0400 Subject: [PATCH 13/95] fix(deps): Replace `kube` dependency with `kube-core` and `kube-derive ` (#159) Signed-off-by: Scott Fleener --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 4 +++- gateway-api/Cargo.toml | 5 +++-- gateway-api/examples/Cargo.toml | 1 - gateway-api/src/apis/experimental/common.rs | 2 +- .../src/apis/experimental/gatewayclasses.rs | 3 ++- gateway-api/src/apis/experimental/gateways.rs | 3 ++- gateway-api/src/apis/experimental/grpcroutes.rs | 3 ++- gateway-api/src/apis/experimental/httproutes.rs | 3 ++- .../src/apis/experimental/referencegrants.rs | 3 ++- gateway-api/src/apis/experimental/tcproutes.rs | 3 ++- gateway-api/src/apis/experimental/tlsroutes.rs | 3 ++- gateway-api/src/apis/experimental/udproutes.rs | 3 ++- gateway-api/src/apis/standard/common.rs | 2 +- gateway-api/src/apis/standard/gatewayclasses.rs | 3 ++- gateway-api/src/apis/standard/gateways.rs | 3 ++- gateway-api/src/apis/standard/grpcroutes.rs | 3 ++- gateway-api/src/apis/standard/httproutes.rs | 3 ++- gateway-api/src/apis/standard/referencegrants.rs | 3 ++- gateway-api/src/duration.rs | 2 +- type-reducer/src/lib.rs | 2 +- 21 files changed, 44 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 853aff8..e15640f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,9 +138,9 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cc" -version = "1.2.27" +version = "1.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc" +checksum = "c3a42d84bb6b69d3a8b3eaacf0d88f179e1929695e1ad012b6cf64d9caaa5fd2" dependencies = [ "shlex", ] @@ -470,6 +470,8 @@ dependencies = [ "hyper-util", "k8s-openapi", "kube", + "kube-core", + "kube-derive", "once_cell", "regex-lite", "schemars", @@ -489,7 +491,6 @@ dependencies = [ "gateway-api", "hyper-util", "k8s-openapi", - "kube", "serde_json", "tokio", "tower", @@ -828,7 +829,6 @@ dependencies = [ "k8s-openapi", "kube-client", "kube-core", - "kube-derive", ] [[package]] @@ -1287,9 +1287,9 @@ checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" [[package]] name = "rustls" -version = "0.23.28" +version = "0.23.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7160e3e10bf4535308537f3c4e1641468cd0e485175d6163087c0393c7d46643" +checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc" dependencies = [ "log", "once_cell", @@ -1345,9 +1345,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.3" +version = "0.103.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" +checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" dependencies = [ "ring", "rustls-pki-types", diff --git a/Cargo.toml b/Cargo.toml index 02887a8..e2006fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,9 @@ version = "0.16.0" anyhow = "1.0.98" delegate = "0.13.4" hyper-util = "0.1.16" -kube = { version = "1.1.0" } +kube = { version = "1.1.0", default-features = false } +kube-core = { version = "1.1.0", default-features = false } +kube-derive = { version = "1.1.0" } k8s-openapi = { version = "0.25.0" } once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.6" } diff --git a/gateway-api/Cargo.toml b/gateway-api/Cargo.toml index a36f39e..e1a9b33 100644 --- a/gateway-api/Cargo.toml +++ b/gateway-api/Cargo.toml @@ -16,7 +16,8 @@ version.workspace = true [dependencies] delegate.workspace = true k8s-openapi = { workspace = true, features = ["schemars"] } -kube = { workspace = true, features = ["derive"] } +kube-core = { workspace = true, features = ["schema"] } +kube-derive.workspace = true once_cell.workspace = true regex.workspace = true schemars.workspace = true @@ -26,7 +27,7 @@ serde_yaml.workspace = true [dev-dependencies] k8s-openapi = { workspace = true, features = ["v1_32", "schemars"] } -kube = { workspace = true, features = ["derive"] } +kube = { workspace = true, features = ["client", "rustls-tls", "ring"] } anyhow.workspace = true hyper-util.workspace = true diff --git a/gateway-api/examples/Cargo.toml b/gateway-api/examples/Cargo.toml index e28efe8..379cda4 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 diff --git a/gateway-api/src/apis/experimental/common.rs b/gateway-api/src/apis/experimental/common.rs index 600a85b..933619c 100644 --- a/gateway-api/src/apis/experimental/common.rs +++ b/gateway-api/src/apis/experimental/common.rs @@ -3,7 +3,7 @@ #[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}; pub use std::collections::BTreeMap; diff --git a/gateway-api/src/apis/experimental/gatewayclasses.rs b/gateway-api/src/apis/experimental/gatewayclasses.rs index b2c3268..a2e1e1c 100644 --- a/gateway-api/src/apis/experimental/gatewayclasses.rs +++ b/gateway-api/src/apis/experimental/gatewayclasses.rs @@ -4,7 +4,7 @@ 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}; } @@ -17,6 +17,7 @@ use self::prelude::*; kind = "GatewayClass", plural = "gatewayclasses" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(status = "GatewayClassStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] diff --git a/gateway-api/src/apis/experimental/gateways.rs b/gateway-api/src/apis/experimental/gateways.rs index 10e21a0..b4cf1f9 100644 --- a/gateway-api/src/apis/experimental/gateways.rs +++ b/gateway-api/src/apis/experimental/gateways.rs @@ -4,7 +4,7 @@ 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}; pub use std::collections::BTreeMap; @@ -18,6 +18,7 @@ use self::prelude::*; kind = "Gateway", plural = "gateways" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(status = "GatewayStatus")] #[kube(derive = "Default")] diff --git a/gateway-api/src/apis/experimental/grpcroutes.rs b/gateway-api/src/apis/experimental/grpcroutes.rs index e47c4b8..2249490 100644 --- a/gateway-api/src/apis/experimental/grpcroutes.rs +++ b/gateway-api/src/apis/experimental/grpcroutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -17,6 +17,7 @@ use self::prelude::*; kind = "GRPCRoute", plural = "grpcroutes" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(status = "RouteStatus")] #[kube(derive = "Default")] diff --git a/gateway-api/src/apis/experimental/httproutes.rs b/gateway-api/src/apis/experimental/httproutes.rs index 8a7115b..ebd78ff 100644 --- a/gateway-api/src/apis/experimental/httproutes.rs +++ b/gateway-api/src/apis/experimental/httproutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -17,6 +17,7 @@ use self::prelude::*; kind = "HTTPRoute", plural = "httproutes" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(status = "RouteStatus")] #[kube(derive = "Default")] diff --git a/gateway-api/src/apis/experimental/referencegrants.rs b/gateway-api/src/apis/experimental/referencegrants.rs index 70f0bbc..c9e79c6 100644 --- a/gateway-api/src/apis/experimental/referencegrants.rs +++ b/gateway-api/src/apis/experimental/referencegrants.rs @@ -2,7 +2,7 @@ #[allow(unused_imports)] mod prelude { - pub use kube::CustomResource; + pub use kube_derive::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -15,6 +15,7 @@ use self::prelude::*; kind = "ReferenceGrant", plural = "referencegrants" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] diff --git a/gateway-api/src/apis/experimental/tcproutes.rs b/gateway-api/src/apis/experimental/tcproutes.rs index dea5e1e..49c656e 100644 --- a/gateway-api/src/apis/experimental/tcproutes.rs +++ b/gateway-api/src/apis/experimental/tcproutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -17,6 +17,7 @@ use self::prelude::*; kind = "TCPRoute", plural = "tcproutes" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(status = "RouteStatus")] #[kube(derive = "Default")] diff --git a/gateway-api/src/apis/experimental/tlsroutes.rs b/gateway-api/src/apis/experimental/tlsroutes.rs index 397fc3b..0c1dc34 100644 --- a/gateway-api/src/apis/experimental/tlsroutes.rs +++ b/gateway-api/src/apis/experimental/tlsroutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -17,6 +17,7 @@ use self::prelude::*; kind = "TLSRoute", plural = "tlsroutes" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(status = "RouteStatus")] #[kube(derive = "Default")] diff --git a/gateway-api/src/apis/experimental/udproutes.rs b/gateway-api/src/apis/experimental/udproutes.rs index 85b5d1b..8adc198 100644 --- a/gateway-api/src/apis/experimental/udproutes.rs +++ b/gateway-api/src/apis/experimental/udproutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -17,6 +17,7 @@ use self::prelude::*; kind = "UDPRoute", plural = "udproutes" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(status = "RouteStatus")] #[kube(derive = "Default")] diff --git a/gateway-api/src/apis/standard/common.rs b/gateway-api/src/apis/standard/common.rs index 024f39d..6d4a704 100644 --- a/gateway-api/src/apis/standard/common.rs +++ b/gateway-api/src/apis/standard/common.rs @@ -3,7 +3,7 @@ #[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}; pub use std::collections::BTreeMap; diff --git a/gateway-api/src/apis/standard/gatewayclasses.rs b/gateway-api/src/apis/standard/gatewayclasses.rs index f83a7f1..b8e318e 100644 --- a/gateway-api/src/apis/standard/gatewayclasses.rs +++ b/gateway-api/src/apis/standard/gatewayclasses.rs @@ -3,7 +3,7 @@ #[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}; } @@ -16,6 +16,7 @@ use self::prelude::*; kind = "GatewayClass", plural = "gatewayclasses" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(status = "GatewayClassStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] diff --git a/gateway-api/src/apis/standard/gateways.rs b/gateway-api/src/apis/standard/gateways.rs index 98257a8..5dde20a 100644 --- a/gateway-api/src/apis/standard/gateways.rs +++ b/gateway-api/src/apis/standard/gateways.rs @@ -4,7 +4,7 @@ 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}; pub use std::collections::BTreeMap; @@ -18,6 +18,7 @@ use self::prelude::*; kind = "Gateway", plural = "gateways" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(status = "GatewayStatus")] #[kube(derive = "Default")] diff --git a/gateway-api/src/apis/standard/grpcroutes.rs b/gateway-api/src/apis/standard/grpcroutes.rs index 80ffb94..7932f3d 100644 --- a/gateway-api/src/apis/standard/grpcroutes.rs +++ b/gateway-api/src/apis/standard/grpcroutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -17,6 +17,7 @@ use self::prelude::*; kind = "GRPCRoute", plural = "grpcroutes" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(status = "RouteStatus")] #[kube(derive = "Default")] diff --git a/gateway-api/src/apis/standard/httproutes.rs b/gateway-api/src/apis/standard/httproutes.rs index ef1183e..1749b1c 100644 --- a/gateway-api/src/apis/standard/httproutes.rs +++ b/gateway-api/src/apis/standard/httproutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -17,6 +17,7 @@ use self::prelude::*; kind = "HTTPRoute", plural = "httproutes" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(status = "RouteStatus")] #[kube(derive = "Default")] diff --git a/gateway-api/src/apis/standard/referencegrants.rs b/gateway-api/src/apis/standard/referencegrants.rs index 70f0bbc..c9e79c6 100644 --- a/gateway-api/src/apis/standard/referencegrants.rs +++ b/gateway-api/src/apis/standard/referencegrants.rs @@ -2,7 +2,7 @@ #[allow(unused_imports)] mod prelude { - pub use kube::CustomResource; + pub use kube_derive::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -15,6 +15,7 @@ use self::prelude::*; kind = "ReferenceGrant", plural = "referencegrants" )] +#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] diff --git a/gateway-api/src/duration.rs b/gateway-api/src/duration.rs index 2ec98ed..669bbfd 100644 --- a/gateway-api/src/duration.rs +++ b/gateway-api/src/duration.rs @@ -11,7 +11,7 @@ //! digits each. See https://gateway-api.sigs.k8s.io/geps/gep-2257 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; diff --git a/type-reducer/src/lib.rs b/type-reducer/src/lib.rs index 39af624..822a97b 100644 --- a/type-reducer/src/lib.rs +++ b/type-reducer/src/lib.rs @@ -31,7 +31,7 @@ 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::CustomResource; + pub use kube_derive::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; pub use std::collections::BTreeMap; From 4772827c3e9d4c10144a7e4f94bc05d3eee4e381 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Aug 2025 07:32:45 -0400 Subject: [PATCH 14/95] chore(deps): bump uuid from 1.17.0 to 1.18.0 (#161) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e15640f..460f732 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1904,9 +1904,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" +checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be" dependencies = [ "getrandom 0.3.3", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index e2006fb..4f9131a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,4 +26,4 @@ tokio = { version = "1.47.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"] } +uuid = { version = "1.18.0", features = ["v4", "fast-rng"] } From 94073b4837e385a33724d85e2d541b2d8e2a50d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Aug 2025 11:36:08 +0000 Subject: [PATCH 15/95] chore(deps): bump clap from 4.5.42 to 4.5.44 (#162) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 460f732..e59025b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.42" +version = "4.5.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" +checksum = "1c1f056bae57e3e54c3375c41ff79619ddd13460a17d7438712bd0d83fda4ff8" dependencies = [ "clap_builder", "clap_derive", @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.42" +version = "4.5.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" +checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8" dependencies = [ "anstream", "anstyle", From fe9610a242221939e4c75559f112e3fea667b6ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Aug 2025 12:39:33 +0000 Subject: [PATCH 16/95] chore(deps): bump proc-macro2 from 1.0.95 to 1.0.96 (#163) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e59025b..b635d86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1170,9 +1170,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "beef09f85ae72cea1ef96ba6870c51e6382ebfa4f0e85b643459331f3daa5be0" dependencies = [ "unicode-ident", ] From e44d3c23ebfa49f3249b534cf402d9deb0be13b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Aug 2025 11:32:32 +0000 Subject: [PATCH 17/95] chore(deps): bump slab from 0.4.10 to 0.4.11 (#164) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b635d86..25e1f24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1576,9 +1576,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "smallvec" From 878365c547549984808e740ff2da20db68b6e896 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Aug 2025 08:22:11 -0400 Subject: [PATCH 18/95] chore(deps): bump clap from 4.5.44 to 4.5.45 (#165) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25e1f24..c0e5eaa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.44" +version = "4.5.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c1f056bae57e3e54c3375c41ff79619ddd13460a17d7438712bd0d83fda4ff8" +checksum = "1fc0e74a703892159f5ae7d3aac52c8e6c392f5ae5f359c70b5881d60aaac318" dependencies = [ "clap_builder", "clap_derive", @@ -185,9 +185,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.41" +version = "4.5.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491" +checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6" dependencies = [ "heck", "proc-macro2", From 9eb66f00048bce745b8ce4e1d1a69e6e2a9ca4cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Aug 2025 12:25:43 +0000 Subject: [PATCH 19/95] chore(deps): bump anyhow from 1.0.98 to 1.0.99 (#166) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c0e5eaa..b8a8f7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" +checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" [[package]] name = "autocfg" diff --git a/Cargo.toml b/Cargo.toml index 4f9131a..f5955b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" version = "0.16.0" [workspace.dependencies] -anyhow = "1.0.98" +anyhow = "1.0.99" delegate = "0.13.4" hyper-util = "0.1.16" kube = { version = "1.1.0", default-features = false } From ef06a479d109123021de78c7aaed3e339dcf4ed9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Aug 2025 12:29:52 +0000 Subject: [PATCH 20/95] chore(deps): bump proc-macro2 from 1.0.96 to 1.0.101 (#168) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8a8f7f..bd0c59b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1170,9 +1170,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.96" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beef09f85ae72cea1ef96ba6870c51e6382ebfa4f0e85b643459331f3daa5be0" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] From 3e78c2bdff92c31c698ec820664f957ddc03e2cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Aug 2025 12:34:12 +0000 Subject: [PATCH 21/95] chore(deps): bump syn from 2.0.104 to 2.0.106 (#167) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd0c59b..93c204c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1610,9 +1610,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.104" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", From f7e13899c472a43de49997dfc54a77c889d6d69f Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 19 Aug 2025 15:23:59 -0400 Subject: [PATCH 22/95] docs: update README.md Signed-off-by: Shane Utt --- README.md | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 5b1cdf6..20e480d 100644 --- a/README.md +++ b/README.md @@ -4,29 +4,28 @@ > **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 - # Gateway API (Rust) +This project provides bindings in [Rust] for [Kubernetes] [Gateway API]. + > **Note**: Currently supports [Gateway API version v1.2.1][gwv] -This project provides bindings in [Rust] for [Kubernetes] [Gateway API]. +> **Note**: The aspiration is to eventually become the "official" Gateway +> API bindings for Rust. However [Kubernetes SIG Network] has not +> officially endorsed it so this should be considered "unofficial" for now. [gwv]:https://github.com/kubernetes-sigs/gateway-api/releases/tag/v1.2.1 [Rust]:https://rust-lang.org [Kubernetes]:https://kubernetes.io/ [Gateway API]:https://gateway-api.sigs.k8s.io/ +[Kubernetes SIG Network]:https://github.com/kubernetes/community/tree/master/sig-network ## 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. +Basic usage involves using a [kube-rs] [Client] to perform operations on +[Gateway API resources]. You can either use a basic `Client` to perform +operations, or you can build a [Controller]. See the `gateway-api/examples/` +directory for detailed (and specific) usage examples. [kube-rs]:https://github.com/kube-rs/kube [Gateway API resources]:https://gateway-api.sigs.k8s.io/api-types/gateway/ @@ -40,7 +39,7 @@ Gateway API. 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.21.3 ``` After which you can run the `update.sh` script: @@ -57,19 +56,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. +Contributions are welcome. Please create an issue describing the contribution +needed prior to creating a PR. -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. +Please check our [project board] to see what work has been accepted and is +in need of an owner. The `next` column will hold high priority items. -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]. +For discussions we prefer the [discussion board]. -[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 From 29da2db2af7e7ad3c219536413fbc7a5bdea1ea7 Mon Sep 17 00:00:00 2001 From: "Po Han(Hank) Huang" Date: Sun, 24 Aug 2025 22:35:29 +0800 Subject: [PATCH 23/95] chore: bump up kopium (#169) Signed-off-by: pohanhuangtw Co-authored-by: pohanhuangtw --- gateway-api/src/duration.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway-api/src/duration.rs b/gateway-api/src/duration.rs index 669bbfd..c090600 100644 --- a/gateway-api/src/duration.rs +++ b/gateway-api/src/duration.rs @@ -8,7 +8,7 @@ //! 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; @@ -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 From ef47e7ff6d7a0c094b5840a8ba44ca4a71cee48f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Aug 2025 13:04:23 -0400 Subject: [PATCH 24/95] chore(deps): bump serde_json from 1.0.142 to 1.0.143 (#172) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 93c204c..2b089f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1493,9 +1493,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.142" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" +checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" dependencies = [ "itoa", "memchr", diff --git a/Cargo.toml b/Cargo.toml index f5955b4..420490d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ k8s-openapi = { version = "0.25.0" } once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.6" } schemars = "0.8.22" -serde_json = "1.0.142" +serde_json = "1.0.143" serde = { version = "1.0.219", features = ["derive"] } serde_yaml = "0.9.34" tokio = { version = "1.47.1", features = ["full"] } From 4772eb3051ff94212d75dedc08b517b60077b5c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Aug 2025 17:08:27 +0000 Subject: [PATCH 25/95] chore(deps): bump prettyplease from 0.2.36 to 0.2.37 (#171) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b089f3..6462e7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1160,9 +1160,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.36" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", "syn", From 52cf9ccaeb880c0e9e4b2b1de4c9ec9365346e72 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 10:17:07 -0400 Subject: [PATCH 26/95] chore(deps): bump tracing-subscriber from 0.3.19 to 0.3.20 (#173) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 39 +++++---------------------------------- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6462e7c..d3e1f33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -974,12 +974,11 @@ dependencies = [ [[package]] name = "nu-ansi-term" -version = "0.46.0" +version = "0.50.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" dependencies = [ - "overload", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -1042,12 +1041,6 @@ 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" @@ -1834,9 +1827,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" dependencies = [ "nu-ansi-term", "sharded-slab", @@ -2008,28 +2001,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index 420490d..d19fc6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,5 +25,5 @@ serde_yaml = "0.9.34" tokio = { version = "1.47.1", features = ["full"] } tower = { version = "0.5.2", features = ["limit"] } tracing = "0.1.41" -tracing-subscriber = "0.3.19" +tracing-subscriber = "0.3.20" uuid = { version = "1.18.0", features = ["v4", "fast-rng"] } From a248b11aa1f6f233a3992da25740f0b9e074a2fd Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Fri, 5 Sep 2025 08:45:11 -0400 Subject: [PATCH 27/95] docs: update .gitattributes Signed-off-by: Shane Utt --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index 2af3ba9..b2f54a8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,3 @@ Cargo.lock linguist-generated=false +Makefile linguist-detectable=false +update.sh linguist-detectable=false From 5a6ac75f37322ac42a08913b8da77ff2fb365276 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Fri, 5 Sep 2025 08:47:33 -0400 Subject: [PATCH 28/95] docs: update README.md Updated warning and note wording for clarity. Signed-off-by: Shane Utt --- README.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 20e480d..9a2a1a4 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,18 @@ [![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**. +> **Warning**: EXPERIMENTAL. # Gateway API (Rust) -This project provides bindings in [Rust] for [Kubernetes] [Gateway API]. +[Rust] bindings for [Kubernetes] [Gateway API]. > **Note**: Currently supports [Gateway API version v1.2.1][gwv] -> **Note**: The aspiration is to eventually become the "official" Gateway -> API bindings for Rust. However [Kubernetes SIG Network] has not -> officially endorsed it so this should be considered "unofficial" for now. - [gwv]:https://github.com/kubernetes-sigs/gateway-api/releases/tag/v1.2.1 [Rust]:https://rust-lang.org [Kubernetes]:https://kubernetes.io/ [Gateway API]:https://gateway-api.sigs.k8s.io/ -[Kubernetes SIG Network]:https://github.com/kubernetes/community/tree/master/sig-network ## Usage @@ -56,13 +51,13 @@ which you can then commit. ## Contributions -Contributions are welcome. Please create an issue describing the contribution -needed prior to creating a PR. +Contributions are welcome. Please create an issue describing what changes are +desired prior to creating a PR. Please check our [project board] to see what work has been accepted and is in need of an owner. The `next` column will hold high priority items. -For discussions we prefer the [discussion board]. +For questions and general discussion, please use the [discussion board]. [project board]:https://github.com/orgs/kube-rs/projects/3 [discussion board]:https://github.com/kube-rs/gateway-api-rs/discussions From 8a4114a79ad8274c67cc65f1ed48c50493d81599 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Sep 2025 07:41:19 -0400 Subject: [PATCH 29/95] chore(deps): bump uuid from 1.18.0 to 1.18.1 (#178) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d3e1f33..0e2982b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1897,9 +1897,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.18.0" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be" +checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" dependencies = [ "getrandom 0.3.3", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index d19fc6d..15da9dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,4 +26,4 @@ tokio = { version = "1.47.1", features = ["full"] } tower = { version = "0.5.2", features = ["limit"] } tracing = "0.1.41" tracing-subscriber = "0.3.20" -uuid = { version = "1.18.0", features = ["v4", "fast-rng"] } +uuid = { version = "1.18.1", features = ["v4", "fast-rng"] } From 78d5572c2de7ffae41357915d9db1e3e7d6d33a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Sep 2025 11:44:46 +0000 Subject: [PATCH 30/95] chore(deps): bump clap from 4.5.45 to 4.5.47 (#177) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e2982b..31b08f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.45" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc0e74a703892159f5ae7d3aac52c8e6c392f5ae5f359c70b5881d60aaac318" +checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931" dependencies = [ "clap_builder", "clap_derive", @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.44" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8" +checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6" dependencies = [ "anstream", "anstyle", @@ -185,9 +185,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.45" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6" +checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c" dependencies = [ "heck", "proc-macro2", From d64e6d549be2e5ba24e16bb70c7e654d999009e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Sep 2025 12:09:49 +0000 Subject: [PATCH 31/95] chore(deps): bump log from 0.4.27 to 0.4.28 (#176) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31b08f3..c591f9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -924,9 +924,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.27" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" dependencies = [ "serde", ] From ddb37504c9fddc6b4d8b41dc619fad8225400ac8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Oct 2025 07:47:12 -0400 Subject: [PATCH 32/95] chore(deps): bump serde_json from 1.0.143 to 1.0.145 (#181) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 23 +++++++++++++++++------ Cargo.toml | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c591f9b..f18ea94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1445,10 +1445,11 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.219" +version = "1.0.224" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "6aaeb1e94f53b16384af593c71e20b095e958dab1d26939c1b70645c5cfbcc0b" dependencies = [ + "serde_core", "serde_derive", ] @@ -1462,11 +1463,20 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_core" +version = "1.0.224" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f39390fa6346e24defbcdd3d9544ba8a19985d0af74df8501fbfe9a64341ab" +dependencies = [ + "serde_derive", +] + [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.224" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "87ff78ab5e8561c9a675bfc1785cb07ae721f0ee53329a595cefd8c04c2ac4e0" dependencies = [ "proc-macro2", "quote", @@ -1486,14 +1496,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.143" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", "memchr", "ryu", "serde", + "serde_core", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 15da9dc..5bddf2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ k8s-openapi = { version = "0.25.0" } once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.6" } schemars = "0.8.22" -serde_json = "1.0.143" +serde_json = "1.0.145" serde = { version = "1.0.219", features = ["derive"] } serde_yaml = "0.9.34" tokio = { version = "1.47.1", features = ["full"] } From a4d4655db271b5033a4fb5306e7bc74483437e26 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:50:20 +0000 Subject: [PATCH 33/95] chore(deps): bump hyper-util from 0.1.16 to 0.1.17 (#182) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f18ea94..fd3d186 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -707,9 +707,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e" +checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" dependencies = [ "bytes", "futures-channel", diff --git a/Cargo.toml b/Cargo.toml index 5bddf2b..0f5c3f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ version = "0.16.0" [workspace.dependencies] anyhow = "1.0.99" delegate = "0.13.4" -hyper-util = "0.1.16" +hyper-util = "0.1.17" kube = { version = "1.1.0", default-features = false } kube-core = { version = "1.1.0", default-features = false } kube-derive = { version = "1.1.0" } From 87774ac2a43aaa2ef3e882bbd17c53f0a18c5b4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:54:10 +0000 Subject: [PATCH 34/95] chore(deps): bump anyhow from 1.0.99 to 1.0.100 (#184) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd3d186..f1e2371 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.99" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "autocfg" diff --git a/Cargo.toml b/Cargo.toml index 0f5c3f4..afa4b0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" version = "0.16.0" [workspace.dependencies] -anyhow = "1.0.99" +anyhow = "1.0.100" delegate = "0.13.4" hyper-util = "0.1.17" kube = { version = "1.1.0", default-features = false } From 2214597fa9ee9d7dbe470e6e6956333cc51b97c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:57:43 +0000 Subject: [PATCH 35/95] chore(deps): bump clap from 4.5.47 to 4.5.49 (#187) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f1e2371..22103d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.47" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931" +checksum = "f4512b90fa68d3a9932cea5184017c5d200f5921df706d45e853537dea51508f" dependencies = [ "clap_builder", "clap_derive", @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.47" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6" +checksum = "0025e98baa12e766c67ba13ff4695a887a1eba19569aad00a472546795bd6730" dependencies = [ "anstream", "anstyle", @@ -185,9 +185,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.47" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" dependencies = [ "heck", "proc-macro2", From 7180fefd60f180f07d8fa290fc98e4c923380838 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Oct 2025 12:00:45 +0000 Subject: [PATCH 36/95] chore(deps): bump serde from 1.0.219 to 1.0.228 (#186) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 22103d9..7ea5684 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1445,9 +1445,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.224" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aaeb1e94f53b16384af593c71e20b095e958dab1d26939c1b70645c5cfbcc0b" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ "serde_core", "serde_derive", @@ -1465,18 +1465,18 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.224" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f39390fa6346e24defbcdd3d9544ba8a19985d0af74df8501fbfe9a64341ab" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.224" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ff78ab5e8561c9a675bfc1785cb07ae721f0ee53329a595cefd8c04c2ac4e0" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index afa4b0e..e48a99c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.6" } schemars = "0.8.22" serde_json = "1.0.145" -serde = { version = "1.0.219", features = ["derive"] } +serde = { version = "1.0.228", features = ["derive"] } serde_yaml = "0.9.34" tokio = { version = "1.47.1", features = ["full"] } tower = { version = "0.5.2", features = ["limit"] } From cc0f6a6578ae64fef67dfb3f5446e31efafa6676 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Tue, 14 Oct 2025 08:06:43 -0400 Subject: [PATCH 37/95] chore: update dependencies for kube 2.0 and k8s-openapi 0.26 (#179) Signed-off-by: Daniel A. White Signed-off-by: Shane Utt Co-authored-by: Shane Utt --- Cargo.lock | 178 ++++++++++++++--------------------------------------- 1 file changed, 46 insertions(+), 132 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7ea5684..9197857 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,16 +226,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation" version = "0.10.1" @@ -273,9 +263,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" dependencies = [ "darling_core", "darling_macro", @@ -283,9 +273,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" dependencies = [ "fnv", "ident_case", @@ -297,9 +287,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", @@ -550,30 +540,6 @@ version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" -[[package]] -name = "headers" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3314d5adb5d94bcdf56771f2e50dbbc80bb4bdf88967526706205ac9eff24eb" -dependencies = [ - "base64", - "bytes", - "headers-core", - "http", - "httpdate", - "mime", - "sha1", -] - -[[package]] -name = "headers-core" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" -dependencies = [ - "http", -] - [[package]] name = "heck" version = "0.5.0" @@ -629,12 +595,6 @@ 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" @@ -654,26 +614,6 @@ dependencies = [ "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" @@ -685,7 +625,7 @@ dependencies = [ "hyper-util", "log", "rustls", - "rustls-native-certs 0.8.1", + "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls", @@ -809,9 +749,9 @@ dependencies = [ [[package]] name = "k8s-openapi" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa60a41b57ae1a0a071af77dbcf89fc9819cfe66edaf2beeb204c34459dcf0b2" +checksum = "d13f06d5326a915becaffabdfab75051b8cdc260c2a5c06c0e90226ede89a692" dependencies = [ "base64", "chrono", @@ -822,9 +762,9 @@ dependencies = [ [[package]] name = "kube" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "778f98664beaf4c3c11372721e14310d1ae00f5e2d9aabcf8906c881aa4e9f51" +checksum = "06da663f20352f5ab08cf70610289a1a180de114985a7d1c6010d4c67a92a35d" dependencies = [ "k8s-openapi", "kube-client", @@ -833,9 +773,9 @@ dependencies = [ [[package]] name = "kube-client" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cb276b85b6e94ded00ac8ea2c68fcf4697ea0553cb25fddc35d4a0ab718db8d" +checksum = "1c0cfc0acb17d167fd1e689aab910c9e072e69baddc515ee02482680148ca3a5" dependencies = [ "base64", "bytes", @@ -847,7 +787,6 @@ dependencies = [ "http-body", "http-body-util", "hyper", - "hyper-http-proxy", "hyper-rustls", "hyper-timeout", "hyper-util", @@ -870,9 +809,9 @@ dependencies = [ [[package]] name = "kube-core" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c56ff45deb0031f2a476017eed60c06872251f271b8387ad8020b8fef60960" +checksum = "ac010c9e87b2840f2124b46d9ec8d7d55933d44bd43ab029ae82ce129ef6bb47" dependencies = [ "chrono", "derive_more", @@ -888,9 +827,9 @@ dependencies = [ [[package]] name = "kube-derive" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "079fc8c1c397538628309cfdee20696ebdcc26745f9fb17f89b78782205bd995" +checksum = "1db0f1aeeef1b5fcaa5f30c98dcd0422a3771dd0510648ceac43f2a3f9ce2b4f" dependencies = [ "darling", "proc-macro2", @@ -1223,6 +1162,26 @@ dependencies = [ "bitflags", ] +[[package]] +name = "ref-cast" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "regex" version = "1.11.1" @@ -1248,9 +1207,9 @@ dependencies = [ [[package]] name = "regex-lite" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" +checksum = "943f41321c63ef1c92fd763bfe054d2668f7f225a5c29f0105903dc2fc04ba30" [[package]] name = "regex-syntax" @@ -1293,19 +1252,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustls-native-certs" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" -dependencies = [ - "openssl-probe", - "rustls-pemfile", - "rustls-pki-types", - "schannel", - "security-framework 2.11.1", -] - [[package]] name = "rustls-native-certs" version = "0.8.1" @@ -1315,16 +1261,7 @@ 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]] @@ -1370,11 +1307,12 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.22" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" +checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" dependencies = [ "dyn-clone", + "ref-cast", "schemars_derive", "serde", "serde_json", @@ -1382,9 +1320,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.22" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" +checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80" dependencies = [ "proc-macro2", "quote", @@ -1407,19 +1345,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "security-framework" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" -dependencies = [ - "bitflags", - "core-foundation 0.9.4", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - [[package]] name = "security-framework" version = "3.2.0" @@ -1427,7 +1352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" dependencies = [ "bitflags", - "core-foundation 0.10.1", + "core-foundation", "core-foundation-sys", "libc", "security-framework-sys", @@ -1520,17 +1445,6 @@ dependencies = [ "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" From 8b998e1c0b55a39068cab7775b90b0a335423a3b Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 14 Oct 2025 08:42:50 -0400 Subject: [PATCH 38/95] chore: bump to gwapi v1.4.0 Signed-off-by: Shane Utt --- README.md | 6 +++--- update.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9a2a1a4..7727dcb 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ [Rust] bindings for [Kubernetes] [Gateway API]. -> **Note**: Currently supports [Gateway API version v1.2.1][gwv] +> **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/ @@ -34,7 +34,7 @@ Gateway API. Make sure you install `kopium` locally in order to run the generator: ```console -$ cargo install kopium --version 0.21.3 +$ cargo install kopium --version 0.22.5 ``` After which you can run the `update.sh` script: diff --git a/update.sh b/update.sh index e6c3210..6e52339 100755 --- a/update.sh +++ b/update.sh @@ -13,7 +13,7 @@ set -eou pipefail -VERSION="v1.2.1" +VERSION="v1.4.0" STANDARD_APIS=( gatewayclasses From 92c9171eb996ea852bb699bc7326a06d5cedcd42 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 14 Oct 2025 09:42:55 -0400 Subject: [PATCH 39/95] chore: ignore .txt files in base Signed-off-by: Shane Utt --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eb5a316..689db3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target +*.txt From 51a9fc4c3de8ddba7739b4b97cdc15df346888b8 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 14 Oct 2025 09:44:20 -0400 Subject: [PATCH 40/95] chore: run generators Signed-off-by: Shane Utt --- gateway-api/src/apis/experimental/common.rs | 330 +-- .../src/apis/experimental/gatewayclasses.rs | 4 +- gateway-api/src/apis/experimental/gateways.rs | 576 +++-- .../src/apis/experimental/grpcroutes.rs | 758 ++++++- .../src/apis/experimental/httproutes.rs | 1887 ++++++++++++++++- .../src/apis/experimental/referencegrants.rs | 3 +- .../src/apis/experimental/tcproutes.rs | 125 +- .../src/apis/experimental/tlsroutes.rs | 151 +- .../src/apis/experimental/udproutes.rs | 125 +- gateway-api/src/apis/standard/common.rs | 172 +- .../src/apis/standard/gatewayclasses.rs | 17 +- gateway-api/src/apis/standard/gateways.rs | 199 +- gateway-api/src/apis/standard/grpcroutes.rs | 664 +++++- gateway-api/src/apis/standard/httproutes.rs | 975 ++++++++- .../src/apis/standard/referencegrants.rs | 3 +- 15 files changed, 5161 insertions(+), 828 deletions(-) diff --git a/gateway-api/src/apis/experimental/common.rs b/gateway-api/src/apis/experimental/common.rs index 933619c..db56b88 100644 --- a/gateway-api/src/apis/experimental/common.rs +++ b/gateway-api/src/apis/experimental/common.rs @@ -10,14 +10,50 @@ mod prelude { } use self::prelude::*; #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCFilterType { +pub enum GatewayDefaultScope { + All, + None, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GatewayTlsFrontendDefaultValidationMode { + AllowValidOnly, + AllowInsecureFallback, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GrpcRouteRulesBackendRefsFiltersType { ResponseHeaderModifier, RequestHeaderModifier, RequestMirror, ExtensionRef, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPFilterType { +pub enum HttpRouteRulesBackendRefsFiltersExternalAuthProtocol { + #[serde(rename = "HTTP")] + Http, + #[serde(rename = "GRPC")] + Grpc, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectPathType { + ReplaceFullPath, + ReplacePrefixMatch, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectScheme { + #[serde(rename = "http")] + Http, + #[serde(rename = "https")] + Https, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode { + #[serde(rename = "301")] + r#_301, + #[serde(rename = "302")] + r#_302, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HttpRouteRulesBackendRefsFiltersType { RequestHeaderModifier, ResponseHeaderModifier, RequestMirror, @@ -25,56 +61,26 @@ pub enum HTTPFilterType { #[serde(rename = "URLRewrite")] UrlRewrite, ExtensionRef, + #[serde(rename = "CORS")] + Cors, + ExternalAuth, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HeaderMatchType { +pub enum HttpRouteRulesMatchesHeadersType { Exact, RegularExpression, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum PersistenceCookieConfigLifetime { +pub enum HttpRouteRulesSessionPersistenceCookieConfigLifetimeType { Permanent, Session, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum RedirectStatusCode { - #[serde(rename = "301")] - r#_301, - #[serde(rename = "302")] - r#_302, -} -#[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 { +pub enum HttpRouteRulesSessionPersistenceType { Cookie, Header, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct BackendReference { - #[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 BackendTlsClientCertificateReference { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, @@ -85,38 +91,20 @@ pub struct BackendTlsClientCertificateReference { pub namespace: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayAddress { - #[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 GatewayInfrastructureParametersReference { - pub group: String, - pub kind: String, - pub name: String, -} -#[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 { +pub struct GatewayAllowedListenersNamespacesSelectorMatchExpressions { + pub key: String, + pub operator: String, #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - pub kind: String, + pub values: Option>, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct ParametersReference { +pub struct GatewayInfrastructureParametersReference { 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 ParentReference { +pub struct HttpRouteParentRefs { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -134,13 +122,7 @@ pub struct ParentReference { pub section_name: 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 RequestMirrorReference { +pub struct HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -152,200 +134,72 @@ pub struct RequestMirrorReference { pub port: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct CommonRouteRule { - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "backendRefs" - )] - pub backend_refs: Option>, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub name: 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 ParentRouteStatus { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: Option>, - #[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: RequestMirrorReference, - #[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, +pub struct HttpRouteRulesBackendRefsFiltersExternalAuthForwardBody { + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxSize")] + pub max_size: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct SessionPersistenceCookieConfig { +pub struct HttpRouteRulesBackendRefsFiltersExternalAuthGrpc { #[serde( default, skip_serializing_if = "Option::is_none", - rename = "lifetimeType" + rename = "allowedHeaders" )] - pub lifetime_type: Option, + pub allowed_headers: Option>, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteFilter { +pub struct HttpRouteRulesBackendRefsFiltersExternalAuthHttp { #[serde( default, skip_serializing_if = "Option::is_none", - rename = "extensionRef" + rename = "allowedHeaders" )] - pub extension_ref: Option, + pub allowed_headers: Option>, #[serde( default, skip_serializing_if = "Option::is_none", - rename = "requestHeaderModifier" + rename = "allowedResponseHeaders" )] - 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, + 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 RequestRedirect { - #[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, +pub struct HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd { + pub name: String, + pub value: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteUrlRewrite { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, +pub struct HttpRouteRulesBackendRefsFiltersRequestMirrorFraction { #[serde(default, skip_serializing_if = "Option::is_none")] - pub path: Option, + pub denominator: Option, + pub numerator: i32, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct RouteStatus { - pub parents: Vec, +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 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, +pub struct ParametersReference { + 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 HTTPRouteBackendFilters { - #[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 = "requestRedirect" - )] - pub request_redirect: Option, - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "responseHeaderModifier" - )] - pub response_header_modifier: Option, - #[serde(rename = "type")] - pub r#type: HTTPFilterType, - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "urlRewrite" - )] - pub url_rewrite: Option, +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, } diff --git a/gateway-api/src/apis/experimental/gatewayclasses.rs b/gateway-api/src/apis/experimental/gatewayclasses.rs index a2e1e1c..925e60a 100644 --- a/gateway-api/src/apis/experimental/gatewayclasses.rs +++ b/gateway-api/src/apis/experimental/gatewayclasses.rs @@ -4,7 +4,7 @@ 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 kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -17,7 +17,6 @@ use self::prelude::*; kind = "GatewayClass", plural = "gatewayclasses" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(status = "GatewayClassStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] @@ -75,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", diff --git a/gateway-api/src/apis/experimental/gateways.rs b/gateway-api/src/apis/experimental/gateways.rs index b4cf1f9..79fe673 100644 --- a/gateway-api/src/apis/experimental/gateways.rs +++ b/gateway-api/src/apis/experimental/gateways.rs @@ -4,7 +4,7 @@ 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 kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; pub use std::collections::BTreeMap; @@ -18,7 +18,6 @@ use self::prelude::*; kind = "Gateway", plural = "gateways" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(status = "GatewayStatus")] #[kube(derive = "Default")] @@ -27,7 +26,7 @@ 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. + /// 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. @@ -44,22 +43,39 @@ pub struct GatewaySpec { /// 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 - /// - /// + pub addresses: Option>, + /// AllowedListeners defines which ListenerSets can be attached to this Gateway. + /// While this feature is experimental, the default value is to allow no ListenerSets. #[serde( default, skip_serializing_if = "Option::is_none", - rename = "backendTLS" + rename = "allowedListeners" )] - pub backend_tls: Option, + 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")] @@ -73,6 +89,8 @@ pub struct GatewaySpec { /// 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 @@ -84,55 +102,76 @@ pub struct GatewaySpec { /// 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: + /// Core support and MUST be supported by implementations based on the objects + /// they support: /// - /// HTTP Profile + /// HTTPRoute /// /// 1. HTTPRoute, Port: 80, Protocol: HTTP /// 2. HTTPRoute, Port: 443, Protocol: HTTPS, TLS Mode: Terminate, TLS keypair provided /// - /// TLS Profile + /// 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 + /// **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: + /// 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 /// - /// 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. + /// One **very** important rule to call out involves what happens when an + /// implementation: /// - /// 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. + /// * 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. /// - /// 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. + /// In this case all the Listeners that share a port with the + /// TCP Listener are not distinct and so MUST NOT be accepted. /// - /// When the Listeners are distinct based on Hostname, inbound request + /// 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) + /// 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. /// @@ -140,18 +179,26 @@ pub struct GatewaySpec { /// 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" + /// 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. 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. + /// 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 @@ -160,7 +207,25 @@ pub struct GatewaySpec { /// 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: + /// ## 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 @@ -175,50 +240,95 @@ pub struct GatewaySpec { /// 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. /// + /// 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, } -/// BackendTLS configures TLS settings for when this Gateway is connecting to -/// backends with TLS. -/// -/// Support: Core -/// -/// +/// GatewaySpecAddress describes an address that can be bound to a Gateway. #[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. +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. /// - /// 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. + /// If an implementation does not support an empty value, they MUST set the + /// "Programmed" condition in status to False with a reason of "AddressNotAssigned". /// - /// This setting can be overridden on the service level by use of BackendTLSPolicy. - /// - /// Support: Core + /// 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. +/// While this feature is experimental, 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. + /// While this feature is experimental, 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. +/// While this feature is experimental, 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 /// + /// While this feature is experimental, 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. +/// While this feature is experimental, the default value is to allow no ListenerSets. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GatewayAllowedListenersNamespacesFrom { + All, + Selector, + Same, + None, +} +/// 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". +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAllowedListenersNamespacesSelector { + /// matchExpressions is a list of label selector requirements. The requirements are ANDed. #[serde( default, skip_serializing_if = "Option::is_none", - rename = "clientCertificateRef" + rename = "matchExpressions" )] - pub client_certificate_ref: Option, + 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>, } /// Infrastructure defines infrastructure level attributes about this Gateway instance. /// @@ -258,6 +368,11 @@ pub struct GatewayInfrastructure { /// 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, @@ -310,10 +425,31 @@ pub struct GatewayListeners { /// /// * 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. + /// * HTTPS: The Listener Hostname SHOULD match both the SNI and Host header. + /// Note that this does not require the SNI and Host header to be the same. + /// The semantics of this are described in more detail below. + /// + /// To ensure security, Section 11.1 of RFC-6066 emphasizes that server + /// implementations that rely on SNI hostname matching MUST also verify + /// hostnames within the application protocol. + /// + /// Section 9.1.2 of RFC-7540 provides a mechanism for servers to reject the + /// reuse of a connection by responding with the HTTP 421 Misdirected Request + /// status code. This indicates that the origin server has rejected the + /// request because it appears to have been misdirected. + /// + /// To detect misdirected requests, Gateways SHOULD match the authority of + /// the requests with all the SNI hostname(s) configured across all the + /// Gateway Listeners on the same port and protocol: + /// + /// * If another Listener has an exact match or more specific wildcard entry, + /// the Gateway SHOULD return a 421. + /// * If the current Listener (selected by SNI matching during ClientHello) + /// does not match the Host: + /// * If another Listener does match the Host the Gateway SHOULD return a + /// 421. + /// * If no other Listener matches the Host, the Gateway MUST return a + /// 404. /// /// For HTTPRoute and TLSRoute resources, there is an interaction with the /// `spec.hostnames` array. When both listener and route specify hostnames, @@ -346,7 +482,7 @@ pub struct GatewayListeners { /// 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 + /// The association of SNIs to Certificate defined in ListenerTLSConfig is /// defined based on the Hostname field for this listener. /// /// The GatewayClass MUST use the longest matching SNI out of all @@ -450,8 +586,7 @@ pub struct GatewayListenersAllowedRoutesNamespacesSelector { skip_serializing_if = "Option::is_none", rename = "matchExpressions" )] - pub match_expressions: - Option>, + 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. @@ -462,27 +597,11 @@ pub struct GatewayListenersAllowedRoutesNamespacesSelector { )] 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 +/// The association of SNIs to Certificate defined in ListenerTLSConfig is /// defined based on the Hostname field for this listener. /// /// The GatewayClass MUST use the longest matching SNI out of all @@ -521,21 +640,6 @@ pub struct GatewayListenersTls { 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: /// @@ -564,17 +668,118 @@ pub struct GatewayListenersTls { #[serde(default, skip_serializing_if = "Option::is_none")] pub options: 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. +/// 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 ListenerTLSConfig 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, +} +/// 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 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. + /// + /// Support: Core + #[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, +} +/// 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 #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersTlsFrontendValidation { +pub struct GatewayTlsFrontendDefaultValidation { /// CACertificateRefs contains one or more references to /// Kubernetes objects that contain TLS certificates of /// the Certificate Authorities that can be used @@ -588,36 +793,115 @@ pub struct GatewayListenersTlsFrontendValidation { /// 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). + /// Support: Implementation-specific (More than one certificate in a ConfigMap + /// with different keys or 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>, + #[serde(rename = "caCertificateRefs")] + pub ca_certificate_refs: Vec, + /// FrontendValidationMode defines the mode for validating the client certificate. + /// There are two possible modes: + /// + /// - AllowValidOnly: In this mode, the gateway will accept connections only if + /// the client presents a valid certificate. This certificate must successfully + /// pass validation against the CA certificates specified in `CACertificateRefs`. + /// - AllowInsecureFallback: In this mode, the gateway will accept connections + /// even if the client certificate is not presented or fails verification. + /// + /// This approach delegates client authorization to the backend and introduce + /// a significant security risk. It should be used in testing environments or + /// on a temporary basis in non-testing environments. + /// + /// Defaults to AllowValidOnly. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: 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. +#[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. /// -/// 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 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, +} +/// 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 -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayListenersTlsMode { - Terminate, - Passthrough, +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendPerPortTlsValidation { + /// 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 certificate in a ConfigMap + /// with different keys or 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(rename = "caCertificateRefs")] + pub ca_certificate_refs: Vec, + /// FrontendValidationMode defines the mode for validating the client certificate. + /// There are two possible modes: + /// + /// - AllowValidOnly: In this mode, the gateway will accept connections only if + /// the client presents a valid certificate. This certificate must successfully + /// pass validation against the CA certificates specified in `CACertificateRefs`. + /// - AllowInsecureFallback: In this mode, the gateway will accept connections + /// even if the client certificate is not presented or fails verification. + /// + /// This approach delegates client authorization to the backend and introduce + /// a significant security risk. It should be used in testing environments or + /// on a temporary basis in non-testing environments. + /// + /// Defaults to AllowValidOnly. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: Option, } /// Status defines the current state of Gateway. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] @@ -631,10 +915,8 @@ pub struct GatewayStatus { /// * 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>, + pub addresses: Option>, /// Conditions describe the current conditions of the Gateway. /// /// Implementations should prefer to express Gateway conditions @@ -653,6 +935,18 @@ pub struct GatewayStatus { #[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 { diff --git a/gateway-api/src/apis/experimental/grpcroutes.rs b/gateway-api/src/apis/experimental/grpcroutes.rs index 2249490..45b960a 100644 --- a/gateway-api/src/apis/experimental/grpcroutes.rs +++ b/gateway-api/src/apis/experimental/grpcroutes.rs @@ -4,7 +4,7 @@ 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 kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -17,12 +17,11 @@ use self::prelude::*; kind = "GRPCRoute", plural = "grpcroutes" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "GrpcRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct GRPCRouteSpec { +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: @@ -136,29 +135,39 @@ pub struct GRPCRouteSpec { /// 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>, + 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>, + 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, } /// 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 { +pub struct GrpcRouteRules { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -192,7 +201,7 @@ pub struct GRPCRouteRule { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -210,7 +219,7 @@ pub struct GRPCRouteRule { /// 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 + /// 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 @@ -218,7 +227,7 @@ pub struct GRPCRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -269,25 +278,22 @@ pub struct GRPCRouteRule { /// 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>, + 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, + pub session_persistence: Option, } /// GRPCBackendRef defines how a GRPCRoute forwards a gRPC request. /// @@ -296,7 +302,6 @@ pub struct GRPCRouteRule { /// 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. @@ -311,17 +316,15 @@ pub struct GRPCRouteRule { /// 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 GRPCBackendReference { +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>, + 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")] @@ -378,6 +381,522 @@ pub struct GRPCBackendReference { #[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, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + /// 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, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: GrpcRouteRulesBackendRefsFiltersType, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + /// 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, +} +/// 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 + /// + /// + /// 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>, +} /// 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. @@ -396,21 +915,39 @@ pub struct GRPCBackendReference { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteMatch { +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>, + 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, + 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, } /// 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 { +pub struct GrpcRouteRulesMatchesMethod { /// Value of the method to match against. If left empty or omitted, will /// match all services. /// @@ -430,5 +967,160 @@ pub struct GRPCMethodMatch { /// /// Support: Implementation-specific (RegularExpression) #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, + pub r#type: Option, +} +/// 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. + /// + /// Defaults to "Session". + /// + /// Support: Core for "Session" type + /// + /// Support: Extended for "Permanent" type + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "lifetimeType" + )] + pub lifetime_type: Option, +} +/// 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 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. + 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: HttpRouteParentRefs, } diff --git a/gateway-api/src/apis/experimental/httproutes.rs b/gateway-api/src/apis/experimental/httproutes.rs index ebd78ff..ad9e67d 100644 --- a/gateway-api/src/apis/experimental/httproutes.rs +++ b/gateway-api/src/apis/experimental/httproutes.rs @@ -4,7 +4,7 @@ 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 kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -17,12 +17,11 @@ use self::prelude::*; kind = "HTTPRoute", plural = "httproutes" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "HttpRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct HTTPRouteSpec { +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 @@ -139,29 +138,39 @@ pub struct HTTPRouteSpec { /// 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>, + 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>, + 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 { +pub struct HttpRouteRules { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -202,7 +211,7 @@ pub struct HTTPRouteRule { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -210,7 +219,7 @@ pub struct HTTPRouteRule { /// 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 + /// 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. /// @@ -232,7 +241,7 @@ pub struct HTTPRouteRule { /// /// 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 + /// 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 @@ -240,7 +249,7 @@ pub struct HTTPRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -298,37 +307,32 @@ pub struct HTTPRouteRule { /// 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>, + 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, + 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, + 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, + pub timeouts: Option, } /// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. /// @@ -337,7 +341,6 @@ pub struct HTTPRouteRule { /// 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. @@ -352,17 +355,15 @@ pub struct HTTPRouteRule { /// 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 { +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>, + 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")] @@ -419,6 +420,1574 @@ pub struct HTTPBackendReference { #[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 { + /// 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: 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, +} +/// 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. + /// The `Access-Control-Allow-Headers` response header can only use `*` + /// wildcard as value when the `AllowCredentials` field is false or omitted. + /// + /// When the `AllowCredentials` field is true and `AllowHeaders` field + /// 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. A Gateway + /// implementation may choose to add implementation-specific default headers. + /// + /// 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. + /// + /// The `Access-Control-Allow-Methods` response header can only use `*` + /// wildcard as value when the `AllowCredentials` field is false or omitted. + /// + /// When 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. A Gateway implementation may + /// choose to add implementation-specific default methods. + /// + /// 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. + /// + /// The `Access-Control-Allow-Origin` response header can only use `*` + /// wildcard as value when the `AllowCredentials` field is false or omitted. + /// + /// When 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 `AllowCredentials` field is false or omitted. + /// + /// 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). + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] + pub max_age: 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 +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesBackendRefsFiltersExternalAuth { + /// BackendRef is a reference to a backend to send authorization + /// requests to. + /// + /// The backend must speak the selected protocol (GRPC or HTTP) on the + /// referenced port. + /// + /// If the backend service requires TLS, use BackendTLSPolicy to tell the + /// implementation to supply the TLS details to be used to connect to that + /// backend. + #[serde(rename = "backendRef")] + pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + /// ForwardBody controls if requests to the authorization server should include + /// the body of the client request; and if so, how big that body is allowed + /// to be. + /// + /// It is expected that implementations will buffer the request body up to + /// `forwardBody.maxSize` bytes. Bodies over that size must be rejected with a + /// 4xx series error (413 or 403 are common examples), and fail processing + /// of the filter. + /// + /// If unset, or `forwardBody.maxSize` is set to `0`, then the body will not + /// be forwarded. + /// + /// Feature Name: HTTPRouteExternalAuthForwardBody + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "forwardBody" + )] + pub forward_body: Option, + /// GRPCAuthConfig contains configuration for communication with ext_authz + /// protocol-speaking backends. + /// + /// If unset, implementations must assume the default behavior for each + /// included field is intended. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub grpc: Option, + /// HTTPAuthConfig contains configuration for communication with HTTP-speaking + /// backends. + /// + /// If unset, implementations must assume the default behavior for each + /// included field is intended. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub http: Option, + /// ExternalAuthProtocol describes which protocol to use when communicating with an + /// ext_authz authorization server. + /// + /// When this is set to GRPC, each backend must use the Envoy ext_authz protocol + /// on the port specified in `backendRefs`. Requests and responses are defined + /// in the protobufs explained at: + /// + /// + /// When this is set to HTTP, each backend must respond with a `200` status + /// code in on a successful authorization. Any other code is considered + /// an authorization failure. + /// + /// Feature Names: + /// GRPC Support - HTTPRouteExternalAuthGRPC + /// HTTP Support - HTTPRouteExternalAuthHTTP + pub protocol: HttpRouteRulesBackendRefsFiltersExternalAuthProtocol, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + /// 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, +} +/// 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, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, +} +/// 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 { + /// 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: 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, +} +/// 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. + /// The `Access-Control-Allow-Headers` response header can only use `*` + /// wildcard as value when the `AllowCredentials` field is false or omitted. + /// + /// When the `AllowCredentials` field is true and `AllowHeaders` field + /// 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. A Gateway + /// implementation may choose to add implementation-specific default headers. + /// + /// 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. + /// + /// The `Access-Control-Allow-Methods` response header can only use `*` + /// wildcard as value when the `AllowCredentials` field is false or omitted. + /// + /// When 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. A Gateway implementation may + /// choose to add implementation-specific default methods. + /// + /// 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. + /// + /// The `Access-Control-Allow-Origin` response header can only use `*` + /// wildcard as value when the `AllowCredentials` field is false or omitted. + /// + /// When 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 `AllowCredentials` field is false or omitted. + /// + /// 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). + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] + pub max_age: 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 +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesFiltersExternalAuth { + /// BackendRef is a reference to a backend to send authorization + /// requests to. + /// + /// The backend must speak the selected protocol (GRPC or HTTP) on the + /// referenced port. + /// + /// If the backend service requires TLS, use BackendTLSPolicy to tell the + /// implementation to supply the TLS details to be used to connect to that + /// backend. + #[serde(rename = "backendRef")] + pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + /// ForwardBody controls if requests to the authorization server should include + /// the body of the client request; and if so, how big that body is allowed + /// to be. + /// + /// It is expected that implementations will buffer the request body up to + /// `forwardBody.maxSize` bytes. Bodies over that size must be rejected with a + /// 4xx series error (413 or 403 are common examples), and fail processing + /// of the filter. + /// + /// If unset, or `forwardBody.maxSize` is set to `0`, then the body will not + /// be forwarded. + /// + /// Feature Name: HTTPRouteExternalAuthForwardBody + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "forwardBody" + )] + pub forward_body: Option, + /// GRPCAuthConfig contains configuration for communication with ext_authz + /// protocol-speaking backends. + /// + /// If unset, implementations must assume the default behavior for each + /// included field is intended. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub grpc: Option, + /// HTTPAuthConfig contains configuration for communication with HTTP-speaking + /// backends. + /// + /// If unset, implementations must assume the default behavior for each + /// included field is intended. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub http: Option, + /// ExternalAuthProtocol describes which protocol to use when communicating with an + /// ext_authz authorization server. + /// + /// When this is set to GRPC, each backend must use the Envoy ext_authz protocol + /// on the port specified in `backendRefs`. Requests and responses are defined + /// in the protobufs explained at: + /// + /// + /// When this is set to HTTP, each backend must respond with a `200` status + /// code in on a successful authorization. Any other code is considered + /// an authorization failure. + /// + /// Feature Names: + /// GRPC Support - HTTPRouteExternalAuthGRPC + /// HTTP Support - HTTPRouteExternalAuthHTTP + pub protocol: HttpRouteRulesBackendRefsFiltersExternalAuthProtocol, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + /// 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, +} +/// 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, +} /// 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. @@ -437,23 +2006,23 @@ pub struct HTTPBackendReference { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct RouteMatch { +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>, + 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, + 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, + 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. @@ -464,7 +2033,41 @@ pub struct RouteMatch { skip_serializing_if = "Option::is_none", rename = "queryParams" )] - pub query_params: Option>, + 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 + /// + /// 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: + /// 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, } /// HTTPRouteMatch defines the predicate used to match requests to a given /// action. Multiple match types are ANDed together, i.e. the match will @@ -484,7 +2087,7 @@ pub struct RouteMatch { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPMethodMatch { +pub enum HttpRouteRulesMatchesMethod { #[serde(rename = "GET")] Get, #[serde(rename = "HEAD")] @@ -507,14 +2110,14 @@ pub enum HTTPMethodMatch { /// 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 { +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, + pub r#type: Option, /// Value of the HTTP path to match against. #[serde(default, skip_serializing_if = "Option::is_none")] pub value: Option, @@ -522,19 +2125,54 @@ pub struct PathMatch { /// 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 { +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 + /// + /// + /// 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, +} /// 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 +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 @@ -591,11 +2229,103 @@ pub struct HTTPRouteRulesRetry { #[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. + /// + /// Defaults to "Session". + /// + /// Support: Core for "Session" type + /// + /// Support: Extended for "Permanent" type + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "lifetimeType" + )] + pub lifetime_type: 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 { +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. @@ -646,3 +2376,66 @@ pub struct HTTPRouteTimeout { #[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 the controller does not have access to. + 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: HttpRouteParentRefs, +} diff --git a/gateway-api/src/apis/experimental/referencegrants.rs b/gateway-api/src/apis/experimental/referencegrants.rs index c9e79c6..70f0bbc 100644 --- a/gateway-api/src/apis/experimental/referencegrants.rs +++ b/gateway-api/src/apis/experimental/referencegrants.rs @@ -2,7 +2,7 @@ #[allow(unused_imports)] mod prelude { - pub use kube_derive::CustomResource; + pub use kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -15,7 +15,6 @@ use self::prelude::*; kind = "ReferenceGrant", plural = "referencegrants" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] diff --git a/gateway-api/src/apis/experimental/tcproutes.rs b/gateway-api/src/apis/experimental/tcproutes.rs index 49c656e..1003493 100644 --- a/gateway-api/src/apis/experimental/tcproutes.rs +++ b/gateway-api/src/apis/experimental/tcproutes.rs @@ -4,7 +4,7 @@ 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 kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -17,12 +17,11 @@ use self::prelude::*; kind = "TCPRoute", plural = "tcproutes" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "TcpRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct TCPRouteSpec { +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 @@ -84,20 +83,118 @@ 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>, + pub parent_refs: Option>, /// Rules are a list of TCP matchers and actions. - /// - /// - pub rules: Vec, + 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 the controller does not have access to. + 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: HttpRouteParentRefs, } diff --git a/gateway-api/src/apis/experimental/tlsroutes.rs b/gateway-api/src/apis/experimental/tlsroutes.rs index 0c1dc34..0f3b3ee 100644 --- a/gateway-api/src/apis/experimental/tlsroutes.rs +++ b/gateway-api/src/apis/experimental/tlsroutes.rs @@ -4,7 +4,7 @@ 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 kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -13,21 +13,20 @@ use self::prelude::*; #[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] #[kube( group = "gateway.networking.k8s.io", - version = "v1alpha2", + version = "v1alpha3", kind = "TLSRoute", plural = "tlsroutes" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "TlsRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct TLSRouteSpec { - /// Hostnames defines a set of SNI names that should match against the +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 names per RFC 6066. + /// 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. /// @@ -36,13 +35,13 @@ pub struct TLSRouteSpec { /// 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`. + /// that 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. + /// that 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 @@ -56,8 +55,7 @@ pub struct TLSRouteSpec { /// `False` in the corresponding RouteParentStatus. /// /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostnames: Option>, + 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 @@ -119,20 +117,121 @@ pub struct TLSRouteSpec { /// 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, + 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 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(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 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 the controller does not have access to. + 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: HttpRouteParentRefs, } diff --git a/gateway-api/src/apis/experimental/udproutes.rs b/gateway-api/src/apis/experimental/udproutes.rs index 8adc198..d99e324 100644 --- a/gateway-api/src/apis/experimental/udproutes.rs +++ b/gateway-api/src/apis/experimental/udproutes.rs @@ -4,7 +4,7 @@ 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 kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -17,12 +17,11 @@ use self::prelude::*; kind = "UDPRoute", plural = "udproutes" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "UdpRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct UDPRouteSpec { +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 @@ -84,20 +83,118 @@ 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>, + pub parent_refs: Option>, /// Rules are a list of UDP matchers and actions. - /// - /// - pub rules: Vec, + 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 the controller does not have access to. + 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: HttpRouteParentRefs, } diff --git a/gateway-api/src/apis/standard/common.rs b/gateway-api/src/apis/standard/common.rs index 6d4a704..ddc002c 100644 --- a/gateway-api/src/apis/standard/common.rs +++ b/gateway-api/src/apis/standard/common.rs @@ -10,51 +10,45 @@ mod prelude { } use self::prelude::*; #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCFilterType { +pub enum GrpcRouteRulesBackendRefsFiltersType { ResponseHeaderModifier, RequestHeaderModifier, RequestMirror, ExtensionRef, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPFilterType { - RequestHeaderModifier, - ResponseHeaderModifier, - RequestMirror, - RequestRedirect, - #[serde(rename = "URLRewrite")] - UrlRewrite, - ExtensionRef, +pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectPathType { + ReplaceFullPath, + ReplacePrefixMatch, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HeaderMatchType { - Exact, - RegularExpression, +pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectScheme { + #[serde(rename = "http")] + Http, + #[serde(rename = "https")] + Https, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum RedirectStatusCode { +pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode { #[serde(rename = "301")] r#_301, #[serde(rename = "302")] r#_302, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum RequestOperationType { - ReplaceFullPath, - ReplacePrefixMatch, +pub enum HttpRouteRulesBackendRefsFiltersType { + RequestHeaderModifier, + ResponseHeaderModifier, + RequestMirror, + RequestRedirect, + #[serde(rename = "URLRewrite")] + UrlRewrite, + ExtensionRef, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum RequestRedirectScheme { - #[serde(rename = "http")] - Http, - #[serde(rename = "https")] - Https, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayAddress { - #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, - pub value: String, +pub enum HttpRouteRulesMatchesHeadersType { + Exact, + RegularExpression, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct GatewayInfrastructureParametersReference { @@ -63,18 +57,7 @@ pub struct GatewayInfrastructureParametersReference { pub name: String, } #[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 ParentReference { +pub struct HttpRouteParentRefs { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -92,7 +75,12 @@ pub struct ParentReference { pub section_name: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct RequestMirrorReference { +pub struct HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd { + pub name: String, + pub value: String, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -104,106 +92,14 @@ pub struct RequestMirrorReference { pub port: 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>, +pub struct HttpRouteRulesBackendRefsFiltersRequestMirrorFraction { #[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 ParentRouteStatus { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: Option>, - #[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: RequestMirrorReference, -} -#[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, + pub denominator: Option, + pub numerator: i32, } #[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 RequestRedirect { - #[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 HTTPRouteUrlRewrite { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub hostname: Option, +pub struct Kind { #[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, + pub group: Option, + pub kind: String, } diff --git a/gateway-api/src/apis/standard/gatewayclasses.rs b/gateway-api/src/apis/standard/gatewayclasses.rs index b8e318e..52e236c 100644 --- a/gateway-api/src/apis/standard/gatewayclasses.rs +++ b/gateway-api/src/apis/standard/gatewayclasses.rs @@ -3,7 +3,7 @@ #[allow(unused_imports)] mod prelude { pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition; - pub use kube_derive::CustomResource; + pub use kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -16,7 +16,6 @@ use self::prelude::*; kind = "GatewayClass", plural = "gatewayclasses" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(status = "GatewayClassStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] @@ -104,4 +103,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/apis/standard/gateways.rs b/gateway-api/src/apis/standard/gateways.rs index 5dde20a..0dff4a6 100644 --- a/gateway-api/src/apis/standard/gateways.rs +++ b/gateway-api/src/apis/standard/gateways.rs @@ -4,7 +4,7 @@ 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 kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; pub use std::collections::BTreeMap; @@ -18,7 +18,6 @@ use self::prelude::*; kind = "Gateway", plural = "gateways" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(status = "GatewayStatus")] #[kube(derive = "Default")] @@ -27,7 +26,7 @@ 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. + /// 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. @@ -44,10 +43,8 @@ pub struct GatewaySpec { /// GatewayStatus.Addresses. /// /// Support: Extended - /// - /// #[serde(default, skip_serializing_if = "Option::is_none")] - pub addresses: Option>, + pub addresses: Option>, /// GatewayClassName used for this Gateway. This is the name of a /// GatewayClass resource. #[serde(rename = "gatewayClassName")] @@ -61,6 +58,8 @@ pub struct GatewaySpec { /// 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 @@ -72,55 +71,76 @@ pub struct GatewaySpec { /// 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: + /// Core support and MUST be supported by implementations based on the objects + /// they support: /// - /// HTTP Profile + /// HTTPRoute /// /// 1. HTTPRoute, Port: 80, Protocol: HTTP /// 2. HTTPRoute, Port: 443, Protocol: HTTPS, TLS Mode: Terminate, TLS keypair provided /// - /// TLS Profile + /// 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 + /// **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: + /// 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. /// - /// 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. + /// In this case all the Listeners that share a port with the + /// TCP Listener are not distinct and so MUST NOT be accepted. /// - /// 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. + /// If an implementation does not support TCP Protocol Listeners, then the + /// previous rule does not apply, and the TCP Listeners SHOULD NOT be + /// accepted. /// - /// 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. + /// 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. /// - /// When the Listeners are distinct based on Hostname, inbound request + /// ### 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) + /// 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. /// @@ -128,18 +148,26 @@ pub struct GatewaySpec { /// 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" + /// 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. 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. + /// 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 @@ -148,7 +176,25 @@ pub struct GatewaySpec { /// 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: + /// ## 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 @@ -163,19 +209,30 @@ pub struct GatewaySpec { /// 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. /// + /// In a future release the MinItems=1 requirement MAY be dropped. + /// /// Support: Core pub listeners: Vec, } +/// 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, +} /// Infrastructure defines infrastructure level attributes about this Gateway instance. /// /// Support: Extended @@ -214,6 +271,11 @@ pub struct GatewayInfrastructure { /// 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, @@ -266,10 +328,31 @@ pub struct GatewayListeners { /// /// * 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. + /// * HTTPS: The Listener Hostname SHOULD match both the SNI and Host header. + /// Note that this does not require the SNI and Host header to be the same. + /// The semantics of this are described in more detail below. + /// + /// To ensure security, Section 11.1 of RFC-6066 emphasizes that server + /// implementations that rely on SNI hostname matching MUST also verify + /// hostnames within the application protocol. + /// + /// Section 9.1.2 of RFC-7540 provides a mechanism for servers to reject the + /// reuse of a connection by responding with the HTTP 421 Misdirected Request + /// status code. This indicates that the origin server has rejected the + /// request because it appears to have been misdirected. + /// + /// To detect misdirected requests, Gateways SHOULD match the authority of + /// the requests with all the SNI hostname(s) configured across all the + /// Gateway Listeners on the same port and protocol: + /// + /// * If another Listener has an exact match or more specific wildcard entry, + /// the Gateway SHOULD return a 421. + /// * If the current Listener (selected by SNI matching during ClientHello) + /// does not match the Host: + /// * If another Listener does match the Host the Gateway SHOULD return a + /// 421. + /// * If no other Listener matches the Host, the Gateway MUST return a + /// 404. /// /// For HTTPRoute and TLSRoute resources, there is an interaction with the /// `spec.hostnames` array. When both listener and route specify hostnames, @@ -302,7 +385,7 @@ pub struct GatewayListeners { /// 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 + /// The association of SNIs to Certificate defined in ListenerTLSConfig is /// defined based on the Hostname field for this listener. /// /// The GatewayClass MUST use the longest matching SNI out of all @@ -438,7 +521,7 @@ pub struct GatewayListenersAllowedRoutesNamespacesSelectorMatchExpressions { /// 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 +/// The association of SNIs to Certificate defined in ListenerTLSConfig is /// defined based on the Hostname field for this listener. /// /// The GatewayClass MUST use the longest matching SNI out of all @@ -541,7 +624,7 @@ pub struct GatewayListenersTlsCertificateRefs { /// 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 +/// The association of SNIs to Certificate defined in ListenerTLSConfig is /// defined based on the Hostname field for this listener. /// /// The GatewayClass MUST use the longest matching SNI out of all @@ -565,10 +648,8 @@ pub struct GatewayStatus { /// * 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>, + pub addresses: Option>, /// Conditions describe the current conditions of the Gateway. /// /// Implementations should prefer to express Gateway conditions @@ -587,6 +668,18 @@ pub struct GatewayStatus { #[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 { diff --git a/gateway-api/src/apis/standard/grpcroutes.rs b/gateway-api/src/apis/standard/grpcroutes.rs index 7932f3d..543ed17 100644 --- a/gateway-api/src/apis/standard/grpcroutes.rs +++ b/gateway-api/src/apis/standard/grpcroutes.rs @@ -4,7 +4,7 @@ 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 kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -17,12 +17,11 @@ use self::prelude::*; kind = "GRPCRoute", plural = "grpcroutes" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "GrpcRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct GRPCRouteSpec { +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: @@ -125,30 +124,21 @@ pub struct GRPCRouteSpec { /// 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>, + 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>, + 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 { +pub struct GrpcRouteRules { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -182,7 +172,7 @@ pub struct GRPCRouteRule { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -200,7 +190,7 @@ pub struct GRPCRouteRule { /// 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 + /// 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 @@ -208,7 +198,7 @@ pub struct GRPCRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -259,7 +249,12 @@ pub struct GRPCRouteRule { /// 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>, + 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. /// @@ -267,33 +262,15 @@ pub struct GRPCRouteRule { /// 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 GRPCBackendReference { +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>, + 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")] @@ -350,6 +327,522 @@ pub struct GRPCBackendReference { #[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, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: 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, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: GrpcRouteRulesBackendRefsFiltersType, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: 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, +} +/// 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 + /// + /// + /// 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>, +} /// 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. @@ -368,21 +861,39 @@ pub struct GRPCBackendReference { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteMatch { +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>, + 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, + 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, } /// 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 { +pub struct GrpcRouteRulesMatchesMethod { /// Value of the method to match against. If left empty or omitted, will /// match all services. /// @@ -402,5 +913,68 @@ pub struct GRPCMethodMatch { /// /// Support: Implementation-specific (RegularExpression) #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, + pub r#type: Option, +} +/// 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 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. + 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: HttpRouteParentRefs, } diff --git a/gateway-api/src/apis/standard/httproutes.rs b/gateway-api/src/apis/standard/httproutes.rs index 1749b1c..d5bb0b5 100644 --- a/gateway-api/src/apis/standard/httproutes.rs +++ b/gateway-api/src/apis/standard/httproutes.rs @@ -4,7 +4,7 @@ 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 kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -17,12 +17,11 @@ use self::prelude::*; kind = "HTTPRoute", plural = "httproutes" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "HttpRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct HTTPRouteSpec { +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 @@ -128,30 +127,21 @@ pub struct HTTPRouteSpec { /// 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>, + 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>, + 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 { +pub struct HttpRouteRules { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -192,7 +182,7 @@ pub struct HTTPRouteRule { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -200,7 +190,7 @@ pub struct HTTPRouteRule { /// 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 + /// 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. /// @@ -222,7 +212,7 @@ pub struct HTTPRouteRule { /// /// 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 + /// 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 @@ -230,7 +220,7 @@ pub struct HTTPRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -288,12 +278,17 @@ pub struct HTTPRouteRule { /// 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>, + 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, + pub timeouts: Option, } /// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. /// @@ -301,33 +296,15 @@ pub struct HTTPRouteRule { /// 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 { +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>, + 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")] @@ -391,7 +368,7 @@ pub struct HTTPBackendReference { /// 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 { +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 @@ -415,7 +392,7 @@ pub struct HTTPRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier" )] - pub request_header_modifier: Option, + 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. @@ -425,14 +402,12 @@ pub struct HTTPRouteBackendFilter { /// backends. /// /// Support: Extended - /// - /// #[serde( default, skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -442,7 +417,7 @@ pub struct HTTPRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "requestRedirect" )] - pub request_redirect: Option, + pub request_redirect: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -452,7 +427,7 @@ pub struct HTTPRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier" )] - pub response_header_modifier: Option, + 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: /// @@ -486,7 +461,7 @@ pub struct HTTPRouteBackendFilter { /// Accepted Condition for the Route to `status: False`, with a /// Reason of `UnsupportedValue`. #[serde(rename = "type")] - pub r#type: HTTPFilterType, + pub r#type: HttpRouteRulesBackendRefsFiltersType, /// URLRewrite defines a schema for a filter that modifies a request during forwarding. /// /// Support: Extended @@ -495,7 +470,371 @@ pub struct HTTPRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "urlRewrite" )] - pub url_rewrite: Option, + pub url_rewrite: Option, +} +/// 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 + /// + /// + /// 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>, +} +/// 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, +} +/// 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, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, } /// HTTPRouteFilter defines processing steps that must be completed during the /// request or response lifecycle. HTTPRouteFilters are meant as an extension @@ -504,7 +843,7 @@ pub struct HTTPRouteBackendFilter { /// 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 { +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 @@ -528,7 +867,7 @@ pub struct HTTPRouteFilter { skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier" )] - pub request_header_modifier: Option, + 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. @@ -538,14 +877,12 @@ pub struct HTTPRouteFilter { /// backends. /// /// Support: Extended - /// - /// #[serde( default, skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -555,7 +892,7 @@ pub struct HTTPRouteFilter { skip_serializing_if = "Option::is_none", rename = "requestRedirect" )] - pub request_redirect: Option, + pub request_redirect: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -565,7 +902,7 @@ pub struct HTTPRouteFilter { skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier" )] - pub response_header_modifier: Option, + 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: /// @@ -599,7 +936,7 @@ pub struct HTTPRouteFilter { /// Accepted Condition for the Route to `status: False`, with a /// Reason of `UnsupportedValue`. #[serde(rename = "type")] - pub r#type: HTTPFilterType, + pub r#type: HttpRouteRulesBackendRefsFiltersType, /// URLRewrite defines a schema for a filter that modifies a request during forwarding. /// /// Support: Extended @@ -608,7 +945,371 @@ pub struct HTTPRouteFilter { skip_serializing_if = "Option::is_none", rename = "urlRewrite" )] - pub url_rewrite: Option, + pub url_rewrite: Option, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: 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, +} +/// 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, +} +/// 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 + /// + /// + /// 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>, +} +/// 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, } /// HTTPRouteMatch defines the predicate used to match requests to a given /// action. Multiple match types are ANDed together, i.e. the match will @@ -628,23 +1329,23 @@ pub struct HTTPRouteFilter { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct RouteMatch { +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>, + 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, + 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, + 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. @@ -655,7 +1356,41 @@ pub struct RouteMatch { skip_serializing_if = "Option::is_none", rename = "queryParams" )] - pub query_params: Option>, + 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 + /// + /// 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: + /// 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, } /// HTTPRouteMatch defines the predicate used to match requests to a given /// action. Multiple match types are ANDed together, i.e. the match will @@ -675,7 +1410,7 @@ pub struct RouteMatch { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPMethodMatch { +pub enum HttpRouteRulesMatchesMethod { #[serde(rename = "GET")] Get, #[serde(rename = "HEAD")] @@ -698,14 +1433,14 @@ pub enum HTTPMethodMatch { /// 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 { +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, + pub r#type: Option, /// Value of the HTTP path to match against. #[serde(default, skip_serializing_if = "Option::is_none")] pub value: Option, @@ -713,16 +1448,53 @@ pub struct PathMatch { /// 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 { +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 + /// + /// + /// 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, +} /// 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 { +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. @@ -773,3 +1545,66 @@ pub struct HTTPRouteTimeout { #[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 the controller does not have access to. + 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: HttpRouteParentRefs, +} diff --git a/gateway-api/src/apis/standard/referencegrants.rs b/gateway-api/src/apis/standard/referencegrants.rs index c9e79c6..70f0bbc 100644 --- a/gateway-api/src/apis/standard/referencegrants.rs +++ b/gateway-api/src/apis/standard/referencegrants.rs @@ -2,7 +2,7 @@ #[allow(unused_imports)] mod prelude { - pub use kube_derive::CustomResource; + pub use kube::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } @@ -15,7 +15,6 @@ use self::prelude::*; kind = "ReferenceGrant", plural = "referencegrants" )] -#[kube(crates(kube_core = "::kube_core"))] #[kube(namespaced)] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] From e818b9a2dafb9f0190df7ed0ec56708368a1c0fb Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 14 Oct 2025 09:45:14 -0400 Subject: [PATCH 41/95] chore: cargo update Signed-off-by: Shane Utt --- Cargo.lock | 657 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 389 insertions(+), 268 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9197857..9d97d89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,21 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "addr2line" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler2" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" - [[package]] name = "aho-corasick" version = "1.1.3" @@ -28,9 +13,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.19" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" dependencies = [ "anstyle", "anstyle-parse", @@ -43,9 +28,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" [[package]] name = "anstyle-parse" @@ -58,22 +43,22 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" +checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.9" +version = "3.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" +checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -83,25 +68,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] -name = "autocfg" -version = "1.5.0" +name = "atomic-waker" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +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 0.52.6", -] +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "base64" @@ -111,9 +87,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" -version = "2.9.1" +version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" [[package]] name = "block-buffer" @@ -138,24 +114,25 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cc" -version = "1.2.31" +version = "1.2.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3a42d84bb6b69d3a8b3eaacf0d88f179e1929695e1ad012b6cf64d9caaa5fd2" +checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7" dependencies = [ + "find-msvc-tools", "shlex", ] [[package]] name = "cfg-if" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" [[package]] name = "chrono" -version = "0.4.41" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" dependencies = [ "num-traits", "serde", @@ -197,9 +174,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "codegen" @@ -226,6 +203,16 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation" version = "0.10.1" @@ -263,9 +250,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.21.3" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" dependencies = [ "darling_core", "darling_macro", @@ -273,9 +260,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.21.3" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" dependencies = [ "fnv", "ident_case", @@ -287,9 +274,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.21.3" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", @@ -309,9 +296,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.4.0" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +checksum = "a41953f86f8a05768a6cda24def994fd2f424b04ec5c719cf89989779f199071" dependencies = [ "powerfmt", ] @@ -348,9 +335,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" @@ -371,6 +358,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "find-msvc-tools" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" + [[package]] name = "fnv" version = "1.0.7" @@ -379,9 +372,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[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", ] @@ -491,9 +484,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.7" +version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" dependencies = [ "typenum", "version_check", @@ -519,15 +512,9 @@ dependencies = [ "cfg-if", "libc", "r-efi", - "wasi 0.14.2+wasi-0.2.4", + "wasi 0.14.7+wasi-0.2.4", ] -[[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" @@ -536,9 +523,33 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.15.4" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" + +[[package]] +name = "headers" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3314d5adb5d94bcdf56771f2e50dbbc80bb4bdf88967526706205ac9eff24eb" +dependencies = [ + "base64", + "bytes", + "headers-core", + "http", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" +dependencies = [ + "http", +] [[package]] name = "heck" @@ -595,25 +606,53 @@ 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.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" 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" @@ -625,7 +664,7 @@ dependencies = [ "hyper-util", "log", "rustls", - "rustls-native-certs", + "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", "tokio-rustls", @@ -684,23 +723,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.9.0" +version = "2.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" dependencies = [ "equivalent", - "hashbrown 0.15.4", -] - -[[package]] -name = "io-uring" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013" -dependencies = [ - "bitflags", - "cfg-if", - "libc", + "hashbrown 0.16.0", ] [[package]] @@ -726,9 +754,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305" dependencies = [ "once_cell", "wasm-bindgen", @@ -749,9 +777,9 @@ dependencies = [ [[package]] name = "k8s-openapi" -version = "0.26.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d13f06d5326a915becaffabdfab75051b8cdc260c2a5c06c0e90226ede89a692" +checksum = "aa60a41b57ae1a0a071af77dbcf89fc9819cfe66edaf2beeb204c34459dcf0b2" dependencies = [ "base64", "chrono", @@ -762,9 +790,9 @@ dependencies = [ [[package]] name = "kube" -version = "2.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06da663f20352f5ab08cf70610289a1a180de114985a7d1c6010d4c67a92a35d" +checksum = "778f98664beaf4c3c11372721e14310d1ae00f5e2d9aabcf8906c881aa4e9f51" dependencies = [ "k8s-openapi", "kube-client", @@ -773,9 +801,9 @@ dependencies = [ [[package]] name = "kube-client" -version = "2.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c0cfc0acb17d167fd1e689aab910c9e072e69baddc515ee02482680148ca3a5" +checksum = "7cb276b85b6e94ded00ac8ea2c68fcf4697ea0553cb25fddc35d4a0ab718db8d" dependencies = [ "base64", "bytes", @@ -787,6 +815,7 @@ dependencies = [ "http-body", "http-body-util", "hyper", + "hyper-http-proxy", "hyper-rustls", "hyper-timeout", "hyper-util", @@ -809,9 +838,9 @@ dependencies = [ [[package]] name = "kube-core" -version = "2.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac010c9e87b2840f2124b46d9ec8d7d55933d44bd43ab029ae82ce129ef6bb47" +checksum = "e3c56ff45deb0031f2a476017eed60c06872251f271b8387ad8020b8fef60960" dependencies = [ "chrono", "derive_more", @@ -827,9 +856,9 @@ dependencies = [ [[package]] name = "kube-derive" -version = "2.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1db0f1aeeef1b5fcaa5f30c98dcd0422a3771dd0510648ceac43f2a3f9ce2b4f" +checksum = "079fc8c1c397538628309cfdee20696ebdcc26745f9fb17f89b78782205bd995" dependencies = [ "darling", "proc-macro2", @@ -847,17 +876,16 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.174" +version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[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", ] @@ -872,9 +900,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "mime" @@ -882,15 +910,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "miniz_oxide" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" -dependencies = [ - "adler2", -] - [[package]] name = "mio" version = "1.0.4" @@ -913,11 +932,11 @@ dependencies = [ [[package]] name = "nu-ansi-term" -version = "0.50.1" +version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -944,15 +963,6 @@ dependencies = [ "libc", ] -[[package]] -name = "object" -version = "0.36.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.21.3" @@ -982,9 +992,9 @@ dependencies = [ [[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", @@ -992,49 +1002,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 0.52.6", + "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.1" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" +checksum = "989e7521a040efde50c3ab6bbadafbe15ab6dc042686926be59ac35d74607df4" dependencies = [ "memchr", - "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.8.1" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb056d9e8ea77922845ec74a1c4e8fb17e7c218cc4fc11a15c5d25e189aa40bc" +checksum = "187da9a3030dbafabbbfb20cb323b976dc7b7ce91fcd84f2f74d6e31d378e2de" dependencies = [ "pest", "pest_generator", @@ -1042,9 +1051,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.1" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e404e638f781eb3202dc82db6760c8ae8a1eeef7fb3fa8264b2ef280504966" +checksum = "49b401d98f5757ebe97a26085998d6c0eecec4995cad6ab7fc30ffdf4b052843" dependencies = [ "pest", "pest_meta", @@ -1055,9 +1064,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.8.1" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd1101f170f5903fde0914f899bb503d9ff5271d7ba76bbb70bea63690cc0d5" +checksum = "72f27a2cfee9f9039c4d86faa5af122a0ac3851441a34865b8a043b46be0065a" dependencies = [ "pest", "sha2", @@ -1111,9 +1120,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" dependencies = [ "proc-macro2", ] @@ -1126,9 +1135,9 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "rand" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ "rand_chacha", "rand_core", @@ -1155,38 +1164,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.13" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ "bitflags", ] -[[package]] -name = "ref-cast" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "regex" -version = "1.11.1" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", @@ -1196,9 +1185,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", @@ -1207,15 +1196,15 @@ dependencies = [ [[package]] name = "regex-lite" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943f41321c63ef1c92fd763bfe054d2668f7f225a5c29f0105903dc2fc04ba30" +checksum = "8d942b98df5e658f56f20d592c7f868833fe38115e65c33003d8cd224b0155da" [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "ring" @@ -1231,17 +1220,11 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rustc-demangle" -version = "0.1.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" - [[package]] name = "rustls" -version = "0.23.31" +version = "0.23.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc" +checksum = "cd3c25631629d034ce7cd9940adc9d45762d46de2b0f57193c4443b92c6d4d40" dependencies = [ "log", "once_cell", @@ -1252,6 +1235,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework 2.11.1", +] + [[package]] name = "rustls-native-certs" version = "0.8.1" @@ -1261,7 +1257,16 @@ dependencies = [ "openssl-probe", "rustls-pki-types", "schannel", - "security-framework", + "security-framework 3.5.1", +] + +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", ] [[package]] @@ -1275,9 +1280,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.4" +version = "0.103.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" +checksum = "e10b3f4191e8a80e6b43eebabfac91e5dcecebb27a71f04e820c47ec41d314bf" dependencies = [ "ring", "rustls-pki-types", @@ -1286,9 +1291,9 @@ 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" @@ -1298,21 +1303,20 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[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 = "1.0.4" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" dependencies = [ "dyn-clone", - "ref-cast", "schemars_derive", "serde", "serde_json", @@ -1320,9 +1324,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "1.0.4" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80" +checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" dependencies = [ "proc-macro2", "quote", @@ -1347,12 +1351,25 @@ dependencies = [ [[package]] name = "security-framework" -version = "3.2.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" +dependencies = [ + "bitflags", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -1360,9 +1377,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.14.0" +version = "2.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" dependencies = [ "core-foundation-sys", "libc", @@ -1438,13 +1455,24 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.9.0", + "indexmap 2.11.4", "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" @@ -1473,9 +1501,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.5" +version = "1.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" dependencies = [ "libc", ] @@ -1506,12 +1534,12 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -1545,18 +1573,18 @@ checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" [[package]] name = "thiserror" -version = "2.0.12" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.12" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", @@ -1574,9 +1602,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.41" +version = "0.3.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" +checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" dependencies = [ "deranged", "itoa", @@ -1591,15 +1619,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" +checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b" [[package]] name = "time-macros" -version = "0.2.22" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" +checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3" dependencies = [ "num-conv", "time-core", @@ -1607,29 +1635,26 @@ dependencies = [ [[package]] name = "tokio" -version = "1.47.1" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" dependencies = [ - "backtrace", "bytes", - "io-uring", "libc", "mio", "parking_lot", "pin-project-lite", "signal-hook-registry", - "slab", "socket2", "tokio-macros", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] name = "tokio-macros" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", @@ -1638,9 +1663,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", @@ -1648,9 +1673,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.15" +version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" dependencies = [ "bytes", "futures-core", @@ -1786,9 +1811,9 @@ dependencies = [ [[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" @@ -1798,9 +1823,9 @@ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" [[package]] name = "unsafe-libyaml" @@ -1861,30 +1886,40 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasi" -version = "0.14.2+wasi-0.2.4" +version = "0.14.7+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" +dependencies = [ + "wasip2", +] + +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" dependencies = [ - "wit-bindgen-rt", + "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.100" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d" dependencies = [ "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", + "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.100" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19" dependencies = [ "bumpalo", "log", @@ -1896,9 +1931,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1906,9 +1941,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" dependencies = [ "proc-macro2", "quote", @@ -1919,13 +1954,19 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1" dependencies = [ "unicode-ident", ] +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-sys" version = "0.48.0" @@ -1953,6 +1994,24 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -1977,13 +2036,30 @@ dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", + "windows_i686_gnullvm 0.52.6", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -1996,6 +2072,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -2008,6 +2090,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -2020,12 +2108,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -2038,6 +2138,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -2050,6 +2156,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -2062,6 +2174,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -2075,28 +2193,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "wit-bindgen-rt" -version = "0.39.0" +name = "windows_x86_64_msvc" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" -dependencies = [ - "bitflags", -] +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "zerocopy" -version = "0.8.26" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.26" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", @@ -2105,6 +2226,6 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.8.1" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" From b3bcb00b0f55e23858d8d673d878392957af43ab Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:23:58 -0400 Subject: [PATCH 42/95] fix: override CustomResource use from kopium Signed-off-by: Shane Utt --- gateway-api/Cargo.toml | 1 + update.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/gateway-api/Cargo.toml b/gateway-api/Cargo.toml index e1a9b33..7543302 100644 --- a/gateway-api/Cargo.toml +++ b/gateway-api/Cargo.toml @@ -16,6 +16,7 @@ version.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 diff --git a/update.sh b/update.sh index 6e52339..2db66c0 100755 --- a/update.sh +++ b/update.sh @@ -54,6 +54,7 @@ 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 + 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 @@ -96,6 +97,7 @@ 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 + 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 From e06072a8b79f1986fd8b3baa5cc9aac434e05916 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:24:43 -0400 Subject: [PATCH 43/95] chore: update kube to v2.0.1 Signed-off-by: Shane Utt --- Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e48a99c..a156b7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,10 @@ version = "0.16.0" anyhow = "1.0.100" delegate = "0.13.4" hyper-util = "0.1.17" -kube = { version = "1.1.0", default-features = false } -kube-core = { version = "1.1.0", default-features = false } -kube-derive = { version = "1.1.0" } -k8s-openapi = { version = "0.25.0" } +kube = { version = "2.0.1", default-features = false } +kube-core = { version = "2.0.1", default-features = false } +kube-derive = { version = "2.0.1" } +k8s-openapi = { version = "0.26.0" } once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.6" } schemars = "0.8.22" From b2b56b4495bf6f1ded00799edb0955b502a039a7 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:24:58 -0400 Subject: [PATCH 44/95] chore: update tokio to v1.48.0 Signed-off-by: Shane Utt --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a156b7a..b55b330 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ schemars = "0.8.22" serde_json = "1.0.145" serde = { version = "1.0.228", features = ["derive"] } serde_yaml = "0.9.34" -tokio = { version = "1.47.1", features = ["full"] } +tokio = { version = "1.48.0", features = ["full"] } tower = { version = "0.5.2", features = ["limit"] } tracing = "0.1.41" tracing-subscriber = "0.3.20" From 061473a49b438eb193fe137536a72225292e4a72 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:25:25 -0400 Subject: [PATCH 45/95] chore: update regex to 0.1.8 Signed-off-by: Shane Utt --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b55b330..e0f6040 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ kube-core = { version = "2.0.1", default-features = false } kube-derive = { version = "2.0.1" } k8s-openapi = { version = "0.26.0" } once_cell = "1.21.3" -regex = { package = "regex-lite", version = "0.1.6" } +regex = { package = "regex-lite", version = "0.1.8" } schemars = "0.8.22" serde_json = "1.0.145" serde = { version = "1.0.228", features = ["derive"] } From 452e9eff357e18a42bcf8ec69c4ce0c2c35716ea Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:25:35 -0400 Subject: [PATCH 46/95] chore: update schemars to v1.0.4 Signed-off-by: Shane Utt --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e0f6040..b4ae364 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ kube-derive = { version = "2.0.1" } k8s-openapi = { version = "0.26.0" } once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.8" } -schemars = "0.8.22" +schemars = "1.0.4" serde_json = "1.0.145" serde = { version = "1.0.228", features = ["derive"] } serde_yaml = "0.9.34" From 4d7b46883d780de3ca23cc9a894ed6a676aefbdb Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:25:51 -0400 Subject: [PATCH 47/95] chore: cargo update Signed-off-by: Shane Utt --- Cargo.lock | 326 ++++++++++++++--------------------------------------- 1 file changed, 82 insertions(+), 244 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d97d89..d57abf4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,9 +87,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" -version = "2.9.4" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "block-buffer" @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "chrono" @@ -140,9 +140,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.49" +version = "4.5.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4512b90fa68d3a9932cea5184017c5d200f5921df706d45e853537dea51508f" +checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623" dependencies = [ "clap_builder", "clap_derive", @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.49" +version = "4.5.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0025e98baa12e766c67ba13ff4695a887a1eba19569aad00a472546795bd6730" +checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0" dependencies = [ "anstream", "anstyle", @@ -195,24 +195,13 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "colored" -version = "2.2.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" +checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e" dependencies = [ - "lazy_static", "windows-sys 0.59.0", ] -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation" version = "0.10.1" @@ -250,9 +239,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" dependencies = [ "darling_core", "darling_macro", @@ -260,9 +249,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" dependencies = [ "fnv", "ident_case", @@ -274,9 +263,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", @@ -500,19 +489,19 @@ checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "libc", - "wasi 0.11.1+wasi-snapshot-preview1", + "wasi", ] [[package]] name = "getrandom" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", "libc", "r-efi", - "wasi 0.14.7+wasi-0.2.4", + "wasip2", ] [[package]] @@ -527,30 +516,6 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" -[[package]] -name = "headers" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3314d5adb5d94bcdf56771f2e50dbbc80bb4bdf88967526706205ac9eff24eb" -dependencies = [ - "base64", - "bytes", - "headers-core", - "http", - "httpdate", - "mime", - "sha1", -] - -[[package]] -name = "headers-core" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" -dependencies = [ - "http", -] - [[package]] name = "heck" version = "0.5.0" @@ -606,12 +571,6 @@ 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.7.0" @@ -633,26 +592,6 @@ dependencies = [ "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" @@ -664,7 +603,7 @@ dependencies = [ "hyper-util", "log", "rustls", - "rustls-native-certs 0.8.1", + "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls", @@ -723,9 +662,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.11.4" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" dependencies = [ "equivalent", "hashbrown 0.16.0", @@ -733,9 +672,9 @@ dependencies = [ [[package]] name = "is_terminal_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "itertools" @@ -777,9 +716,9 @@ dependencies = [ [[package]] name = "k8s-openapi" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa60a41b57ae1a0a071af77dbcf89fc9819cfe66edaf2beeb204c34459dcf0b2" +checksum = "d13f06d5326a915becaffabdfab75051b8cdc260c2a5c06c0e90226ede89a692" dependencies = [ "base64", "chrono", @@ -790,9 +729,9 @@ dependencies = [ [[package]] name = "kube" -version = "1.1.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "778f98664beaf4c3c11372721e14310d1ae00f5e2d9aabcf8906c881aa4e9f51" +checksum = "48e7bb0b6a46502cc20e4575b6ff401af45cfea150b34ba272a3410b78aa014e" dependencies = [ "k8s-openapi", "kube-client", @@ -801,9 +740,9 @@ dependencies = [ [[package]] name = "kube-client" -version = "1.1.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cb276b85b6e94ded00ac8ea2c68fcf4697ea0553cb25fddc35d4a0ab718db8d" +checksum = "4987d57a184d2b5294fdad3d7fc7f278899469d21a4da39a8f6ca16426567a36" dependencies = [ "base64", "bytes", @@ -815,7 +754,6 @@ dependencies = [ "http-body", "http-body-util", "hyper", - "hyper-http-proxy", "hyper-rustls", "hyper-timeout", "hyper-util", @@ -838,9 +776,9 @@ dependencies = [ [[package]] name = "kube-core" -version = "1.1.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c56ff45deb0031f2a476017eed60c06872251f271b8387ad8020b8fef60960" +checksum = "914bbb770e7bb721a06e3538c0edd2babed46447d128f7c21caa68747060ee73" dependencies = [ "chrono", "derive_more", @@ -856,9 +794,9 @@ dependencies = [ [[package]] name = "kube-derive" -version = "1.1.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "079fc8c1c397538628309cfdee20696ebdcc26745f9fb17f89b78782205bd995" +checksum = "03dee8252be137772a6ab3508b81cd797dee62ee771112a2453bc85cbbe150d2" dependencies = [ "darling", "proc-macro2", @@ -912,13 +850,13 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mio" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" dependencies = [ "libc", - "wasi 0.11.1+wasi-snapshot-preview1", - "windows-sys 0.59.0", + "wasi", + "windows-sys 0.61.2", ] [[package]] @@ -971,9 +909,9 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "once_cell_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "openssl-probe" @@ -1159,7 +1097,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", ] [[package]] @@ -1171,6 +1109,26 @@ dependencies = [ "bitflags", ] +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "regex" version = "1.12.2" @@ -1222,9 +1180,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.32" +version = "0.23.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3c25631629d034ce7cd9940adc9d45762d46de2b0f57193c4443b92c6d4d40" +checksum = "751e04a496ca00bb97a5e043158d23d66b5aabf2e1d5aa2a0aaebb1aafe6f82c" dependencies = [ "log", "once_cell", @@ -1237,36 +1195,14 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923" 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.5.1", -] - -[[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]] @@ -1312,11 +1248,12 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.22" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" +checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" dependencies = [ "dyn-clone", + "ref-cast", "schemars_derive", "serde", "serde_json", @@ -1324,9 +1261,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.22" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" +checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80" dependencies = [ "proc-macro2", "quote", @@ -1349,19 +1286,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "security-framework" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" -dependencies = [ - "bitflags", - "core-foundation 0.9.4", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - [[package]] name = "security-framework" version = "3.5.1" @@ -1369,7 +1293,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" dependencies = [ "bitflags", - "core-foundation 0.10.1", + "core-foundation", "core-foundation-sys", "libc", "security-framework-sys", @@ -1455,24 +1379,13 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.11.4", + "indexmap 2.12.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" @@ -1510,14 +1423,14 @@ dependencies = [ [[package]] name = "simple_logger" -version = "5.0.0" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c5dfa5e08767553704aa0ffd9d9794d527103c736aba9854773851fd7497eb" +checksum = "291bee647ce7310b0ea721bfd7e0525517b4468eb7c7e15eb8bd774343179702" dependencies = [ "colored", "log", "time", - "windows-sys 0.48.0", + "windows-sys 0.61.2", ] [[package]] @@ -1556,9 +1469,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.106" +version = "2.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b" dependencies = [ "proc-macro2", "quote", @@ -1823,9 +1736,9 @@ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-ident" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06" [[package]] name = "unsafe-libyaml" @@ -1851,7 +1764,7 @@ version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" dependencies = [ - "getrandom 0.3.3", + "getrandom 0.3.4", "js-sys", "rand", "wasm-bindgen", @@ -1884,15 +1797,6 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" -[[package]] -name = "wasi" -version = "0.14.7+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" -dependencies = [ - "wasip2", -] - [[package]] name = "wasip2" version = "1.0.1+wasi-0.2.4" @@ -1967,15 +1871,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" @@ -2012,21 +1907,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - [[package]] name = "windows-targets" version = "0.52.6" @@ -2060,12 +1940,6 @@ dependencies = [ "windows_x86_64_msvc 0.53.1", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -2078,12 +1952,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" @@ -2096,12 +1964,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -2126,12 +1988,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" @@ -2144,12 +2000,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -2162,12 +2012,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" @@ -2180,12 +2024,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" From 32d56be2e68fdd18151a32273bb312645a8ec77c Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:26:08 -0400 Subject: [PATCH 48/95] fix: add missing external auth protocol to update script Signed-off-by: Shane Utt --- update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/update.sh b/update.sh index 2db66c0..0852e28 100755 --- a/update.sh +++ b/update.sh @@ -109,6 +109,7 @@ ENUMS=( HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath HTTPRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath HTTPRouteRulesBackendRefsFiltersType=RequestHeaderModifier + HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol=HTTP GRPCRouteRulesFiltersType=RequestHeaderModifier GRPCRouteRulesBackendRefsFiltersType=RequestHeaderModifier ) From bc68d97311e6e700f80bd694d756e24269d7110e Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:26:42 -0400 Subject: [PATCH 49/95] fix: implement Default for external auth proto Signed-off-by: Shane Utt --- gateway-api/src/apis/experimental/enum_defaults.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gateway-api/src/apis/experimental/enum_defaults.rs b/gateway-api/src/apis/experimental/enum_defaults.rs index fe4f3ae..b72bd03 100644 --- a/gateway-api/src/apis/experimental/enum_defaults.rs +++ b/gateway-api/src/apis/experimental/enum_defaults.rs @@ -18,3 +18,9 @@ impl Default for RequestOperationType { RequestOperationType::ReplaceFullPath } } + +impl Default for HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol { + fn default() -> Self { + HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol::Http + } +} From 49648ba685ef47e015386323a2657aa3e10df00d Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:27:15 -0400 Subject: [PATCH 50/95] chore: run generators Signed-off-by: Shane Utt --- gateway-api/src/apis/experimental/common.rs | 242 +++-- .../src/apis/experimental/gatewayclasses.rs | 2 +- gateway-api/src/apis/experimental/gateways.rs | 2 +- .../src/apis/experimental/grpcroutes.rs | 483 +-------- .../src/apis/experimental/httproutes.rs | 992 ++---------------- .../src/apis/experimental/referencegrants.rs | 2 +- .../src/apis/experimental/tcproutes.rs | 98 +- .../src/apis/experimental/tlsroutes.rs | 101 +- .../src/apis/experimental/udproutes.rs | 98 +- gateway-api/src/apis/standard/common.rs | 137 ++- .../src/apis/standard/gatewayclasses.rs | 2 +- gateway-api/src/apis/standard/gateways.rs | 2 +- gateway-api/src/apis/standard/grpcroutes.rs | 389 +------ gateway-api/src/apis/standard/httproutes.rs | 842 +-------------- .../src/apis/standard/referencegrants.rs | 2 +- 15 files changed, 480 insertions(+), 2914 deletions(-) diff --git a/gateway-api/src/apis/experimental/common.rs b/gateway-api/src/apis/experimental/common.rs index db56b88..891864d 100644 --- a/gateway-api/src/apis/experimental/common.rs +++ b/gateway-api/src/apis/experimental/common.rs @@ -10,6 +10,13 @@ mod prelude { } use self::prelude::*; #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GRPCFilterType { + ResponseHeaderModifier, + RequestHeaderModifier, + RequestMirror, + ExtensionRef, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum GatewayDefaultScope { All, None, @@ -20,67 +27,74 @@ pub enum GatewayTlsFrontendDefaultValidationMode { AllowInsecureFallback, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GrpcRouteRulesBackendRefsFiltersType { - ResponseHeaderModifier, +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 HttpRouteRulesBackendRefsFiltersExternalAuthProtocol { +pub enum HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol { #[serde(rename = "HTTP")] Http, #[serde(rename = "GRPC")] Grpc, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectPathType { - ReplaceFullPath, - ReplacePrefixMatch, +pub enum HeaderMatchType { + Exact, + RegularExpression, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectScheme { - #[serde(rename = "http")] - Http, - #[serde(rename = "https")] - Https, +pub enum PersistenceCookieConfigLifetime { + Permanent, + Session, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode { +pub enum RedirectStatusCode { #[serde(rename = "301")] r#_301, #[serde(rename = "302")] r#_302, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesBackendRefsFiltersType { - RequestHeaderModifier, - ResponseHeaderModifier, - RequestMirror, - RequestRedirect, - #[serde(rename = "URLRewrite")] - UrlRewrite, - ExtensionRef, - #[serde(rename = "CORS")] - Cors, - ExternalAuth, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesMatchesHeadersType { - Exact, - RegularExpression, +pub enum RequestOperationType { + ReplaceFullPath, + ReplacePrefixMatch, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesSessionPersistenceCookieConfigLifetimeType { - Permanent, - Session, +pub enum RequestRedirectScheme { + #[serde(rename = "http")] + Http, + #[serde(rename = "https")] + Https, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesSessionPersistenceType { +pub enum SessionPersistenceType { Cookie, Header, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct BackendReference { + #[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 BackendTlsClientCertificateReference { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, @@ -104,25 +118,12 @@ pub struct GatewayInfrastructureParametersReference { pub name: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteParentRefs { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, +pub struct HTTPHeader { 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, + pub value: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef { +pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -134,12 +135,12 @@ pub struct HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef { pub port: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersExternalAuthForwardBody { +pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthForwardBody { #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxSize")] pub max_size: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersExternalAuthGrpc { +pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthGrpc { #[serde( default, skip_serializing_if = "Option::is_none", @@ -148,7 +149,7 @@ pub struct HttpRouteRulesBackendRefsFiltersExternalAuthGrpc { pub allowed_headers: Option>, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersExternalAuthHttp { +pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthHttp { #[serde( default, skip_serializing_if = "Option::is_none", @@ -165,17 +166,6 @@ pub struct HttpRouteRulesBackendRefsFiltersExternalAuthHttp { pub path: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd { - pub name: String, - pub value: String, -} -#[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, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct Kind { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, @@ -190,7 +180,7 @@ pub struct ParametersReference { pub namespace: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct TcpRouteRulesBackendRefs { +pub struct ParentReference { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -200,6 +190,130 @@ pub struct TcpRouteRulesBackendRefs { 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 RequestMirrorFraction { #[serde(default, skip_serializing_if = "Option::is_none")] - pub weight: Option, + pub denominator: Option, + pub numerator: i32, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct CommonRouteRule { + #[serde(rename = "backendRefs")] + pub backend_refs: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: 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 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 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 SessionPersistenceCookieConfig { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "lifetimeType" + )] + pub lifetime_type: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct RequestRedirect { + #[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 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 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, } diff --git a/gateway-api/src/apis/experimental/gatewayclasses.rs b/gateway-api/src/apis/experimental/gatewayclasses.rs index 925e60a..35ac3b0 100644 --- a/gateway-api/src/apis/experimental/gatewayclasses.rs +++ b/gateway-api/src/apis/experimental/gatewayclasses.rs @@ -4,7 +4,7 @@ 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}; } diff --git a/gateway-api/src/apis/experimental/gateways.rs b/gateway-api/src/apis/experimental/gateways.rs index 79fe673..dbbe13a 100644 --- a/gateway-api/src/apis/experimental/gateways.rs +++ b/gateway-api/src/apis/experimental/gateways.rs @@ -4,7 +4,7 @@ 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}; pub use std::collections::BTreeMap; diff --git a/gateway-api/src/apis/experimental/grpcroutes.rs b/gateway-api/src/apis/experimental/grpcroutes.rs index 45b960a..840600a 100644 --- a/gateway-api/src/apis/experimental/grpcroutes.rs +++ b/gateway-api/src/apis/experimental/grpcroutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -18,10 +18,10 @@ use self::prelude::*; plural = "grpcroutes" )] #[kube(namespaced)] -#[kube(status = "GrpcRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct GrpcRouteSpec { +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: @@ -140,10 +140,10 @@ pub struct GrpcRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, + 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 @@ -167,7 +167,7 @@ pub struct GrpcRouteSpec { /// 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 { +pub struct GRPCRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -201,7 +201,7 @@ pub struct GrpcRouteRules { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -227,7 +227,7 @@ pub struct GrpcRouteRules { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -278,7 +278,7 @@ pub struct GrpcRouteRules { /// 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>, + 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 @@ -293,7 +293,7 @@ pub struct GrpcRouteRules { skip_serializing_if = "Option::is_none", rename = "sessionPersistence" )] - pub session_persistence: Option, + pub session_persistence: Option, } /// GRPCBackendRef defines how a GRPCRoute forwards a gRPC request. /// @@ -317,14 +317,14 @@ pub struct GrpcRouteRules { /// 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 { +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>, + 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")] @@ -388,7 +388,7 @@ pub struct GrpcRouteRulesBackendRefs { /// 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 { +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 @@ -412,7 +412,7 @@ pub struct GrpcRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier" )] - pub request_header_modifier: Option, + 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. @@ -427,7 +427,7 @@ pub struct GrpcRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -437,7 +437,7 @@ pub struct GrpcRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier" )] - pub response_header_modifier: Option, + 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: /// @@ -463,68 +463,7 @@ pub struct GrpcRouteRulesBackendRefsFilters { /// 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, -} -/// 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 - /// - /// - /// 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>, + pub r#type: GRPCFilterType, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -536,7 +475,7 @@ pub struct GrpcRouteRulesBackendRefsFiltersRequestHeaderModifier { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GrpcRouteRulesBackendRefsFiltersRequestMirror { +pub struct GRPCRouteRulesBackendRefsFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -561,14 +500,14 @@ pub struct GrpcRouteRulesBackendRefsFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// 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, + 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). @@ -578,67 +517,6 @@ pub struct GrpcRouteRulesBackendRefsFiltersRequestMirror { #[serde(default, skip_serializing_if = "Option::is_none")] pub percent: 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 - /// - /// - /// 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>, -} /// 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 @@ -646,7 +524,7 @@ pub struct GrpcRouteRulesBackendRefsFiltersResponseHeaderModifier { /// 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 { +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 @@ -670,7 +548,7 @@ pub struct GrpcRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier" )] - pub request_header_modifier: Option, + 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. @@ -685,7 +563,7 @@ pub struct GrpcRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -695,7 +573,7 @@ pub struct GrpcRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier" )] - pub response_header_modifier: Option, + 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: /// @@ -721,68 +599,7 @@ pub struct GrpcRouteRulesFilters { /// 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, -} -/// 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 - /// - /// - /// 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>, + pub r#type: GRPCFilterType, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -794,7 +611,7 @@ pub struct GrpcRouteRulesFiltersRequestHeaderModifier { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GrpcRouteRulesFiltersRequestMirror { +pub struct GRPCRouteRulesFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -819,14 +636,14 @@ pub struct GrpcRouteRulesFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// 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, + 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). @@ -836,67 +653,6 @@ pub struct GrpcRouteRulesFiltersRequestMirror { #[serde(default, skip_serializing_if = "Option::is_none")] pub percent: 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 - /// - /// - /// 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>, -} /// 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. @@ -915,39 +671,21 @@ pub struct GrpcRouteRulesFiltersResponseHeaderModifier { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GrpcRouteRulesMatches { +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>, + 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, + 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 GrpcRouteRulesMatchesMethod { +pub struct GRPCMethodMatch { /// Value of the method to match against. If left empty or omitted, will /// match all services. /// @@ -967,160 +705,5 @@ pub struct GrpcRouteRulesMatchesMethod { /// /// Support: Implementation-specific (RegularExpression) #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, -} -/// 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. - /// - /// Defaults to "Session". - /// - /// Support: Core for "Session" type - /// - /// Support: Extended for "Permanent" type - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "lifetimeType" - )] - pub lifetime_type: Option, -} -/// 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 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. - 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: HttpRouteParentRefs, + pub r#type: Option, } diff --git a/gateway-api/src/apis/experimental/httproutes.rs b/gateway-api/src/apis/experimental/httproutes.rs index ad9e67d..20d6837 100644 --- a/gateway-api/src/apis/experimental/httproutes.rs +++ b/gateway-api/src/apis/experimental/httproutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -18,10 +18,10 @@ use self::prelude::*; plural = "httproutes" )] #[kube(namespaced)] -#[kube(status = "HttpRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct HttpRouteSpec { +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 @@ -143,10 +143,10 @@ pub struct HttpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, + 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 @@ -170,7 +170,7 @@ pub struct HttpRouteSpec { /// 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 { +pub struct HTTPRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -211,7 +211,7 @@ pub struct HttpRouteRules { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -249,7 +249,7 @@ pub struct HttpRouteRules { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -307,7 +307,7 @@ pub struct HttpRouteRules { /// 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>, + 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 @@ -317,7 +317,7 @@ pub struct HttpRouteRules { /// /// Support: Extended #[serde(default, skip_serializing_if = "Option::is_none")] - pub retry: Option, + pub retry: Option, /// SessionPersistence defines and configures session persistence /// for the route rule. /// @@ -327,12 +327,12 @@ pub struct HttpRouteRules { skip_serializing_if = "Option::is_none", rename = "sessionPersistence" )] - pub session_persistence: Option, + 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, + pub timeouts: Option, } /// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. /// @@ -356,14 +356,14 @@ pub struct HttpRouteRules { /// 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 { +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>, + 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")] @@ -427,13 +427,13 @@ pub struct HttpRouteRulesBackendRefs { /// 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 { +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, + 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 @@ -461,7 +461,7 @@ pub struct HttpRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "externalAuth" )] - pub external_auth: Option, + pub external_auth: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -471,7 +471,7 @@ pub struct HttpRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier" )] - pub request_header_modifier: Option, + 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. @@ -486,7 +486,7 @@ pub struct HttpRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -496,7 +496,7 @@ pub struct HttpRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestRedirect" )] - pub request_redirect: Option, + pub request_redirect: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -506,7 +506,7 @@ pub struct HttpRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier" )] - pub response_header_modifier: Option, + 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: /// @@ -540,7 +540,7 @@ pub struct HttpRouteRulesBackendRefsFilters { /// Accepted Condition for the Route to `status: False`, with a /// Reason of `UnsupportedValue`. #[serde(rename = "type")] - pub r#type: HttpRouteRulesBackendRefsFiltersType, + pub r#type: HTTPFilterType, /// URLRewrite defines a schema for a filter that modifies a request during forwarding. /// /// Support: Extended @@ -549,14 +549,14 @@ pub struct HttpRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "urlRewrite" )] - pub url_rewrite: Option, + 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 { +pub struct HTTPRouteRulesBackendRefsFiltersCors { /// AllowCredentials indicates whether the actual cross-origin request allows /// to include credentials. /// @@ -623,13 +623,13 @@ pub struct HttpRouteRulesBackendRefsFiltersCors { /// value `*`, which represents all HTTP methods are allowed. /// /// Method names are case sensitive, so these values are also case-sensitive. - /// (See + /// (See https://www.rfc-editor.org/rfc/rfc2616#section-5.1.1) /// /// 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 + /// (See https://fetch.spec.whatwg.org/#cors-safelisted-method) The /// CORS-safelisted methods are always allowed, regardless of whether they /// are specified in the `AllowMethods` field. /// @@ -734,7 +734,7 @@ pub struct HttpRouteRulesBackendRefsFiltersCors { /// `Expires` /// `Last-Modified` /// `Pragma` - /// (See + /// (See https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name) /// The CORS-safelisted response headers are exposed to client by default. /// /// When an HTTP header name is specified using the `ExposeHeaders` field, @@ -778,7 +778,7 @@ pub struct HttpRouteRulesBackendRefsFiltersCors { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersExternalAuth { +pub struct HTTPRouteRulesBackendRefsFiltersExternalAuth { /// BackendRef is a reference to a backend to send authorization /// requests to. /// @@ -789,7 +789,7 @@ pub struct HttpRouteRulesBackendRefsFiltersExternalAuth { /// implementation to supply the TLS details to be used to connect to that /// backend. #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// ForwardBody controls if requests to the authorization server should include /// the body of the client request; and if so, how big that body is allowed /// to be. @@ -808,28 +808,28 @@ pub struct HttpRouteRulesBackendRefsFiltersExternalAuth { skip_serializing_if = "Option::is_none", rename = "forwardBody" )] - pub forward_body: Option, + pub forward_body: Option, /// GRPCAuthConfig contains configuration for communication with ext_authz /// protocol-speaking backends. /// /// If unset, implementations must assume the default behavior for each /// included field is intended. #[serde(default, skip_serializing_if = "Option::is_none")] - pub grpc: Option, + pub grpc: Option, /// HTTPAuthConfig contains configuration for communication with HTTP-speaking /// backends. /// /// If unset, implementations must assume the default behavior for each /// included field is intended. #[serde(default, skip_serializing_if = "Option::is_none")] - pub http: Option, + pub http: Option, /// ExternalAuthProtocol describes which protocol to use when communicating with an /// ext_authz authorization server. /// /// When this is set to GRPC, each backend must use the Envoy ext_authz protocol /// on the port specified in `backendRefs`. Requests and responses are defined /// in the protobufs explained at: - /// + /// https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/auth/v3/external_auth.proto /// /// When this is set to HTTP, each backend must respond with a `200` status /// code in on a successful authorization. Any other code is considered @@ -838,68 +838,7 @@ pub struct HttpRouteRulesBackendRefsFiltersExternalAuth { /// Feature Names: /// GRPC Support - HTTPRouteExternalAuthGRPC /// HTTP Support - HTTPRouteExternalAuthHTTP - pub protocol: HttpRouteRulesBackendRefsFiltersExternalAuthProtocol, -} -/// 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 - /// - /// - /// 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>, + pub protocol: HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -911,7 +850,7 @@ pub struct HttpRouteRulesBackendRefsFiltersRequestHeaderModifier { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersRequestMirror { +pub struct HTTPRouteRulesBackendRefsFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -936,14 +875,14 @@ pub struct HttpRouteRulesBackendRefsFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// 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, + 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). @@ -953,257 +892,6 @@ pub struct HttpRouteRulesBackendRefsFiltersRequestMirror { #[serde(default, skip_serializing_if = "Option::is_none")] pub percent: 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, -} -/// 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 - /// - /// - /// 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>, -} -/// 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, -} /// 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 @@ -1211,13 +899,13 @@ pub struct HttpRouteRulesBackendRefsFiltersUrlRewritePath { /// 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 { +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, + 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 @@ -1245,7 +933,7 @@ pub struct HttpRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "externalAuth" )] - pub external_auth: Option, + pub external_auth: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -1255,7 +943,7 @@ pub struct HttpRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier" )] - pub request_header_modifier: Option, + 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. @@ -1270,7 +958,7 @@ pub struct HttpRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -1280,7 +968,7 @@ pub struct HttpRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestRedirect" )] - pub request_redirect: Option, + pub request_redirect: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -1290,7 +978,7 @@ pub struct HttpRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier" )] - pub response_header_modifier: Option, + 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: /// @@ -1324,7 +1012,7 @@ pub struct HttpRouteRulesFilters { /// Accepted Condition for the Route to `status: False`, with a /// Reason of `UnsupportedValue`. #[serde(rename = "type")] - pub r#type: HttpRouteRulesBackendRefsFiltersType, + pub r#type: HTTPFilterType, /// URLRewrite defines a schema for a filter that modifies a request during forwarding. /// /// Support: Extended @@ -1333,14 +1021,14 @@ pub struct HttpRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "urlRewrite" )] - pub url_rewrite: Option, + 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 { +pub struct HTTPRouteRulesFiltersCors { /// AllowCredentials indicates whether the actual cross-origin request allows /// to include credentials. /// @@ -1407,13 +1095,13 @@ pub struct HttpRouteRulesFiltersCors { /// value `*`, which represents all HTTP methods are allowed. /// /// Method names are case sensitive, so these values are also case-sensitive. - /// (See + /// (See https://www.rfc-editor.org/rfc/rfc2616#section-5.1.1) /// /// 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 + /// (See https://fetch.spec.whatwg.org/#cors-safelisted-method) The /// CORS-safelisted methods are always allowed, regardless of whether they /// are specified in the `AllowMethods` field. /// @@ -1518,7 +1206,7 @@ pub struct HttpRouteRulesFiltersCors { /// `Expires` /// `Last-Modified` /// `Pragma` - /// (See + /// (See https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name) /// The CORS-safelisted response headers are exposed to client by default. /// /// When an HTTP header name is specified using the `ExposeHeaders` field, @@ -1562,7 +1250,7 @@ pub struct HttpRouteRulesFiltersCors { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesFiltersExternalAuth { +pub struct HTTPRouteRulesFiltersExternalAuth { /// BackendRef is a reference to a backend to send authorization /// requests to. /// @@ -1573,7 +1261,7 @@ pub struct HttpRouteRulesFiltersExternalAuth { /// implementation to supply the TLS details to be used to connect to that /// backend. #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// ForwardBody controls if requests to the authorization server should include /// the body of the client request; and if so, how big that body is allowed /// to be. @@ -1592,28 +1280,28 @@ pub struct HttpRouteRulesFiltersExternalAuth { skip_serializing_if = "Option::is_none", rename = "forwardBody" )] - pub forward_body: Option, + pub forward_body: Option, /// GRPCAuthConfig contains configuration for communication with ext_authz /// protocol-speaking backends. /// /// If unset, implementations must assume the default behavior for each /// included field is intended. #[serde(default, skip_serializing_if = "Option::is_none")] - pub grpc: Option, + pub grpc: Option, /// HTTPAuthConfig contains configuration for communication with HTTP-speaking /// backends. /// /// If unset, implementations must assume the default behavior for each /// included field is intended. #[serde(default, skip_serializing_if = "Option::is_none")] - pub http: Option, + pub http: Option, /// ExternalAuthProtocol describes which protocol to use when communicating with an /// ext_authz authorization server. /// /// When this is set to GRPC, each backend must use the Envoy ext_authz protocol /// on the port specified in `backendRefs`. Requests and responses are defined /// in the protobufs explained at: - /// + /// https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/auth/v3/external_auth.proto /// /// When this is set to HTTP, each backend must respond with a `200` status /// code in on a successful authorization. Any other code is considered @@ -1622,68 +1310,7 @@ pub struct HttpRouteRulesFiltersExternalAuth { /// Feature Names: /// GRPC Support - HTTPRouteExternalAuthGRPC /// HTTP Support - HTTPRouteExternalAuthHTTP - pub protocol: HttpRouteRulesBackendRefsFiltersExternalAuthProtocol, -} -/// 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 - /// - /// - /// 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>, + pub protocol: HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -1695,7 +1322,7 @@ pub struct HttpRouteRulesFiltersRequestHeaderModifier { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesFiltersRequestMirror { +pub struct HTTPRouteRulesFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -1720,14 +1347,14 @@ pub struct HttpRouteRulesFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// 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, + 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). @@ -1737,257 +1364,6 @@ pub struct HttpRouteRulesFiltersRequestMirror { #[serde(default, skip_serializing_if = "Option::is_none")] pub percent: 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, -} -/// 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 - /// - /// - /// 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>, -} -/// 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, -} /// 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. @@ -2006,23 +1382,23 @@ pub struct HttpRouteRulesFiltersUrlRewritePath { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesMatches { +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>, + 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, + 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, + 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. @@ -2033,41 +1409,7 @@ pub struct HttpRouteRulesMatches { 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 - /// - /// 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: - /// 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, + 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 @@ -2087,7 +1429,7 @@ pub struct HttpRouteRulesMatchesHeaders { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesMatchesMethod { +pub enum HTTPMethodMatch { #[serde(rename = "GET")] Get, #[serde(rename = "HEAD")] @@ -2110,14 +1452,14 @@ pub enum HttpRouteRulesMatchesMethod { /// 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 { +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, + pub r#type: Option, /// Value of the HTTP path to match against. #[serde(default, skip_serializing_if = "Option::is_none")] pub value: Option, @@ -2125,53 +1467,16 @@ pub struct HttpRouteRulesMatchesPath { /// 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 { +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 - /// - /// - /// 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, -} /// Retry defines the configuration for when to retry an HTTP request. /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesRetry { +pub struct HTTPRouteRulesRetry { /// Attempts specifies the maximum number of times an individual request /// from the gateway to a backend should be retried. /// @@ -2229,103 +1534,11 @@ pub struct HttpRouteRulesRetry { #[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. - /// - /// Defaults to "Session". - /// - /// Support: Core for "Session" type - /// - /// Support: Extended for "Permanent" type - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "lifetimeType" - )] - pub lifetime_type: 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 HttpRouteRulesTimeouts { +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. @@ -2376,66 +1589,3 @@ pub struct HttpRouteRulesTimeouts { #[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 the controller does not have access to. - 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: HttpRouteParentRefs, -} diff --git a/gateway-api/src/apis/experimental/referencegrants.rs b/gateway-api/src/apis/experimental/referencegrants.rs index 70f0bbc..4a3e15e 100644 --- a/gateway-api/src/apis/experimental/referencegrants.rs +++ b/gateway-api/src/apis/experimental/referencegrants.rs @@ -2,7 +2,7 @@ #[allow(unused_imports)] mod prelude { - pub use kube::CustomResource; + pub use kube_derive::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } diff --git a/gateway-api/src/apis/experimental/tcproutes.rs b/gateway-api/src/apis/experimental/tcproutes.rs index 1003493..8bdf31b 100644 --- a/gateway-api/src/apis/experimental/tcproutes.rs +++ b/gateway-api/src/apis/experimental/tcproutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -18,10 +18,10 @@ use self::prelude::*; plural = "tcproutes" )] #[kube(namespaced)] -#[kube(status = "TcpRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct TcpRouteSpec { +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 @@ -88,9 +88,9 @@ pub struct TcpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + pub parent_refs: Option>, /// Rules are a list of TCP matchers and actions. - pub rules: Vec, + 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 @@ -110,91 +110,3 @@ pub struct TcpRouteSpec { )] 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 the controller does not have access to. - 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: HttpRouteParentRefs, -} diff --git a/gateway-api/src/apis/experimental/tlsroutes.rs b/gateway-api/src/apis/experimental/tlsroutes.rs index 0f3b3ee..404e10d 100644 --- a/gateway-api/src/apis/experimental/tlsroutes.rs +++ b/gateway-api/src/apis/experimental/tlsroutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -18,10 +18,10 @@ use self::prelude::*; plural = "tlsroutes" )] #[kube(namespaced)] -#[kube(status = "TlsRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct TlsRouteSpec { +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: @@ -122,9 +122,9 @@ pub struct TlsRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + pub parent_refs: Option>, /// Rules are a list of actions. - pub rules: Vec, + 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 @@ -144,94 +144,3 @@ pub struct TlsRouteSpec { )] 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 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(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 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 the controller does not have access to. - 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: HttpRouteParentRefs, -} diff --git a/gateway-api/src/apis/experimental/udproutes.rs b/gateway-api/src/apis/experimental/udproutes.rs index d99e324..2015192 100644 --- a/gateway-api/src/apis/experimental/udproutes.rs +++ b/gateway-api/src/apis/experimental/udproutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -18,10 +18,10 @@ use self::prelude::*; plural = "udproutes" )] #[kube(namespaced)] -#[kube(status = "UdpRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct UdpRouteSpec { +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 @@ -88,9 +88,9 @@ pub struct UdpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + pub parent_refs: Option>, /// Rules are a list of UDP matchers and actions. - pub rules: Vec, + 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 @@ -110,91 +110,3 @@ pub struct UdpRouteSpec { )] 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 the controller does not have access to. - 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: HttpRouteParentRefs, -} diff --git a/gateway-api/src/apis/standard/common.rs b/gateway-api/src/apis/standard/common.rs index ddc002c..9e18c8c 100644 --- a/gateway-api/src/apis/standard/common.rs +++ b/gateway-api/src/apis/standard/common.rs @@ -10,45 +10,45 @@ mod prelude { } use self::prelude::*; #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GrpcRouteRulesBackendRefsFiltersType { +pub enum GRPCFilterType { ResponseHeaderModifier, RequestHeaderModifier, RequestMirror, ExtensionRef, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectPathType { - ReplaceFullPath, - ReplacePrefixMatch, +pub enum HTTPFilterType { + RequestHeaderModifier, + ResponseHeaderModifier, + RequestMirror, + RequestRedirect, + #[serde(rename = "URLRewrite")] + UrlRewrite, + ExtensionRef, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectScheme { - #[serde(rename = "http")] - Http, - #[serde(rename = "https")] - Https, +pub enum HeaderMatchType { + Exact, + RegularExpression, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode { +pub enum RedirectStatusCode { #[serde(rename = "301")] r#_301, #[serde(rename = "302")] r#_302, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesBackendRefsFiltersType { - RequestHeaderModifier, - ResponseHeaderModifier, - RequestMirror, - RequestRedirect, - #[serde(rename = "URLRewrite")] - UrlRewrite, - ExtensionRef, +pub enum RequestOperationType { + ReplaceFullPath, + ReplacePrefixMatch, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesMatchesHeadersType { - Exact, - RegularExpression, +pub enum RequestRedirectScheme { + #[serde(rename = "http")] + Http, + #[serde(rename = "https")] + Https, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct GatewayInfrastructureParametersReference { @@ -57,7 +57,24 @@ pub struct GatewayInfrastructureParametersReference { pub name: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteParentRefs { +pub struct HTTPHeader { + pub name: String, + pub value: String, +} +#[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, +} +#[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 ParentReference { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -75,12 +92,7 @@ pub struct HttpRouteParentRefs { pub section_name: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd { - pub name: String, - pub value: String, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef { +pub struct RequestMirrorReference { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -92,14 +104,71 @@ pub struct HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef { pub port: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersRequestMirrorFraction { +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 denominator: Option, - pub numerator: i32, + 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 Kind { +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 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 RequestRedirect { #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - pub kind: String, + 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 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, } diff --git a/gateway-api/src/apis/standard/gatewayclasses.rs b/gateway-api/src/apis/standard/gatewayclasses.rs index 52e236c..a1d9b17 100644 --- a/gateway-api/src/apis/standard/gatewayclasses.rs +++ b/gateway-api/src/apis/standard/gatewayclasses.rs @@ -3,7 +3,7 @@ #[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}; } diff --git a/gateway-api/src/apis/standard/gateways.rs b/gateway-api/src/apis/standard/gateways.rs index 0dff4a6..18af475 100644 --- a/gateway-api/src/apis/standard/gateways.rs +++ b/gateway-api/src/apis/standard/gateways.rs @@ -4,7 +4,7 @@ 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}; pub use std::collections::BTreeMap; diff --git a/gateway-api/src/apis/standard/grpcroutes.rs b/gateway-api/src/apis/standard/grpcroutes.rs index 543ed17..9458ac3 100644 --- a/gateway-api/src/apis/standard/grpcroutes.rs +++ b/gateway-api/src/apis/standard/grpcroutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -18,10 +18,10 @@ use self::prelude::*; plural = "grpcroutes" )] #[kube(namespaced)] -#[kube(status = "GrpcRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct GrpcRouteSpec { +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: @@ -129,16 +129,16 @@ pub struct GrpcRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, + 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 GrpcRouteRules { +pub struct GRPCRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -172,7 +172,7 @@ pub struct GrpcRouteRules { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -198,7 +198,7 @@ pub struct GrpcRouteRules { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -249,7 +249,7 @@ pub struct GrpcRouteRules { /// 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>, + 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 @@ -263,14 +263,14 @@ pub struct GrpcRouteRules { /// namespace's owner to accept the reference. See the ReferenceGrant /// documentation for details. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GrpcRouteRulesBackendRefs { +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>, + 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")] @@ -334,7 +334,7 @@ pub struct GrpcRouteRulesBackendRefs { /// 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 { +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 @@ -358,7 +358,7 @@ pub struct GrpcRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier" )] - pub request_header_modifier: Option, + 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. @@ -373,7 +373,7 @@ pub struct GrpcRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -383,7 +383,7 @@ pub struct GrpcRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier" )] - pub response_header_modifier: Option, + 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: /// @@ -409,68 +409,7 @@ pub struct GrpcRouteRulesBackendRefsFilters { /// 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, -} -/// 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 - /// - /// - /// 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>, + pub r#type: GRPCFilterType, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -482,7 +421,7 @@ pub struct GrpcRouteRulesBackendRefsFiltersRequestHeaderModifier { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GrpcRouteRulesBackendRefsFiltersRequestMirror { +pub struct GRPCRouteRulesBackendRefsFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -507,14 +446,14 @@ pub struct GrpcRouteRulesBackendRefsFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef, + pub backend_ref: RequestMirrorReference, /// 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, + 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). @@ -524,67 +463,6 @@ pub struct GrpcRouteRulesBackendRefsFiltersRequestMirror { #[serde(default, skip_serializing_if = "Option::is_none")] pub percent: 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 - /// - /// - /// 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>, -} /// 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 @@ -592,7 +470,7 @@ pub struct GrpcRouteRulesBackendRefsFiltersResponseHeaderModifier { /// 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 { +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 @@ -616,7 +494,7 @@ pub struct GrpcRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier" )] - pub request_header_modifier: Option, + 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. @@ -631,7 +509,7 @@ pub struct GrpcRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -641,7 +519,7 @@ pub struct GrpcRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier" )] - pub response_header_modifier: Option, + 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: /// @@ -667,68 +545,7 @@ pub struct GrpcRouteRulesFilters { /// 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, -} -/// 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 - /// - /// - /// 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>, + pub r#type: GRPCFilterType, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -740,7 +557,7 @@ pub struct GrpcRouteRulesFiltersRequestHeaderModifier { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GrpcRouteRulesFiltersRequestMirror { +pub struct GRPCRouteRulesFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -765,14 +582,14 @@ pub struct GrpcRouteRulesFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef, + pub backend_ref: RequestMirrorReference, /// 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, + 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). @@ -782,67 +599,6 @@ pub struct GrpcRouteRulesFiltersRequestMirror { #[serde(default, skip_serializing_if = "Option::is_none")] pub percent: 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 - /// - /// - /// 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>, -} /// 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. @@ -861,39 +617,21 @@ pub struct GrpcRouteRulesFiltersResponseHeaderModifier { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GrpcRouteRulesMatches { +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>, + 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, + 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 GrpcRouteRulesMatchesMethod { +pub struct GRPCMethodMatch { /// Value of the method to match against. If left empty or omitted, will /// match all services. /// @@ -913,68 +651,5 @@ pub struct GrpcRouteRulesMatchesMethod { /// /// 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 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 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. - 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: HttpRouteParentRefs, + pub r#type: Option, } diff --git a/gateway-api/src/apis/standard/httproutes.rs b/gateway-api/src/apis/standard/httproutes.rs index d5bb0b5..18a3972 100644 --- a/gateway-api/src/apis/standard/httproutes.rs +++ b/gateway-api/src/apis/standard/httproutes.rs @@ -4,7 +4,7 @@ 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}; } @@ -18,10 +18,10 @@ use self::prelude::*; plural = "httproutes" )] #[kube(namespaced)] -#[kube(status = "HttpRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct HttpRouteSpec { +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 @@ -132,16 +132,16 @@ pub struct HttpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, + 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 HttpRouteRules { +pub struct HTTPRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -182,7 +182,7 @@ pub struct HttpRouteRules { skip_serializing_if = "Option::is_none", rename = "backendRefs" )] - pub backend_refs: Option>, + pub backend_refs: Option>, /// Filters define the filters that are applied to requests that match /// this rule. /// @@ -220,7 +220,7 @@ pub struct HttpRouteRules { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -278,7 +278,7 @@ pub struct HttpRouteRules { /// 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>, + 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 @@ -288,7 +288,7 @@ pub struct HttpRouteRules { /// /// Support: Extended #[serde(default, skip_serializing_if = "Option::is_none")] - pub timeouts: Option, + pub timeouts: Option, } /// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. /// @@ -297,14 +297,14 @@ pub struct HttpRouteRules { /// namespace's owner to accept the reference. See the ReferenceGrant /// documentation for details. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefs { +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>, + 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")] @@ -368,7 +368,7 @@ pub struct HttpRouteRulesBackendRefs { /// 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 { +pub struct HTTPRouteBackendFilter { /// 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 @@ -392,7 +392,7 @@ pub struct HttpRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier" )] - pub request_header_modifier: Option, + 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. @@ -407,7 +407,7 @@ pub struct HttpRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -417,7 +417,7 @@ pub struct HttpRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestRedirect" )] - pub request_redirect: Option, + pub request_redirect: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -427,7 +427,7 @@ pub struct HttpRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier" )] - pub response_header_modifier: Option, + 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: /// @@ -461,7 +461,7 @@ pub struct HttpRouteRulesBackendRefsFilters { /// Accepted Condition for the Route to `status: False`, with a /// Reason of `UnsupportedValue`. #[serde(rename = "type")] - pub r#type: HttpRouteRulesBackendRefsFiltersType, + pub r#type: HTTPFilterType, /// URLRewrite defines a schema for a filter that modifies a request during forwarding. /// /// Support: Extended @@ -470,68 +470,7 @@ pub struct HttpRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "urlRewrite" )] - pub url_rewrite: Option, -} -/// 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 - /// - /// - /// 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>, + pub url_rewrite: Option, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -543,7 +482,7 @@ pub struct HttpRouteRulesBackendRefsFiltersRequestHeaderModifier { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersRequestMirror { +pub struct HTTPRouteRulesBackendRefsFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -568,14 +507,14 @@ pub struct HttpRouteRulesBackendRefsFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef, + pub backend_ref: RequestMirrorReference, /// 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, + 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). @@ -585,257 +524,6 @@ pub struct HttpRouteRulesBackendRefsFiltersRequestMirror { #[serde(default, skip_serializing_if = "Option::is_none")] pub percent: 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, -} -/// 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 - /// - /// - /// 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>, -} -/// 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, -} /// 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 @@ -843,7 +531,7 @@ pub struct HttpRouteRulesBackendRefsFiltersUrlRewritePath { /// 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 { +pub struct HTTPRouteFilter { /// 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 @@ -867,7 +555,7 @@ pub struct HttpRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier" )] - pub request_header_modifier: Option, + 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. @@ -882,7 +570,7 @@ pub struct HttpRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -892,7 +580,7 @@ pub struct HttpRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestRedirect" )] - pub request_redirect: Option, + pub request_redirect: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -902,7 +590,7 @@ pub struct HttpRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier" )] - pub response_header_modifier: Option, + 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: /// @@ -936,7 +624,7 @@ pub struct HttpRouteRulesFilters { /// Accepted Condition for the Route to `status: False`, with a /// Reason of `UnsupportedValue`. #[serde(rename = "type")] - pub r#type: HttpRouteRulesBackendRefsFiltersType, + pub r#type: HTTPFilterType, /// URLRewrite defines a schema for a filter that modifies a request during forwarding. /// /// Support: Extended @@ -945,68 +633,7 @@ pub struct HttpRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "urlRewrite" )] - pub url_rewrite: Option, -} -/// 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 - /// - /// - /// 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>, + pub url_rewrite: Option, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -1018,7 +645,7 @@ pub struct HttpRouteRulesFiltersRequestHeaderModifier { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesFiltersRequestMirror { +pub struct HTTPRouteRulesFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -1043,14 +670,14 @@ pub struct HttpRouteRulesFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef, + pub backend_ref: RequestMirrorReference, /// 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, + 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). @@ -1060,257 +687,6 @@ pub struct HttpRouteRulesFiltersRequestMirror { #[serde(default, skip_serializing_if = "Option::is_none")] pub percent: 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, -} -/// 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 - /// - /// - /// 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>, -} -/// 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: HttpRouteRulesBackendRefsFiltersRequestRedirectPathType, -} /// 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. @@ -1329,23 +705,23 @@ pub struct HttpRouteRulesFiltersUrlRewritePath { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesMatches { +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>, + 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, + 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, + 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. @@ -1356,41 +732,7 @@ pub struct HttpRouteRulesMatches { 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 - /// - /// 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: - /// 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, + 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 @@ -1410,7 +752,7 @@ pub struct HttpRouteRulesMatchesHeaders { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesMatchesMethod { +pub enum HTTPMethodMatch { #[serde(rename = "GET")] Get, #[serde(rename = "HEAD")] @@ -1433,14 +775,14 @@ pub enum HttpRouteRulesMatchesMethod { /// 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 { +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, + pub r#type: Option, /// Value of the HTTP path to match against. #[serde(default, skip_serializing_if = "Option::is_none")] pub value: Option, @@ -1448,53 +790,16 @@ pub struct HttpRouteRulesMatchesPath { /// 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 { +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 - /// - /// - /// 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, -} /// 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 { +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. @@ -1545,66 +850,3 @@ pub struct HttpRouteRulesTimeouts { #[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 the controller does not have access to. - 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: HttpRouteParentRefs, -} diff --git a/gateway-api/src/apis/standard/referencegrants.rs b/gateway-api/src/apis/standard/referencegrants.rs index 70f0bbc..4a3e15e 100644 --- a/gateway-api/src/apis/standard/referencegrants.rs +++ b/gateway-api/src/apis/standard/referencegrants.rs @@ -2,7 +2,7 @@ #[allow(unused_imports)] mod prelude { - pub use kube::CustomResource; + pub use kube_derive::CustomResource; pub use schemars::JsonSchema; pub use serde::{Deserialize, Serialize}; } From d9e3acc865e12a827bac5c84253745152ff2ad31 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:27:29 -0400 Subject: [PATCH 51/95] fix: test imports Signed-off-by: Shane Utt --- gateway-api/src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gateway-api/src/lib.rs b/gateway-api/src/lib.rs index 91a761e..8099714 100644 --- a/gateway-api/src/lib.rs +++ b/gateway-api/src/lib.rs @@ -27,14 +27,13 @@ mod tests { use tower::ServiceBuilder; use uuid::Uuid; - use crate::common::GatewayAddress; use crate::{ apis::standard::constants::{ GatewayConditionReason, GatewayConditionType, ListenerConditionReason, ListenerConditionType, }, apis::standard::gatewayclasses::{GatewayClass, GatewayClassSpec}, - apis::standard::gateways::{Gateway, GatewaySpec, GatewayStatus, GatewayStatusListeners}, + apis::standard::gateways::{Gateway, GatewaySpec, GatewayStatus, GatewayStatusAddresses, GatewayStatusListeners}, }; // ------------------------------------------------------------------------- @@ -89,7 +88,7 @@ mod tests { assert!(gw.metadata.uid.is_some()); let gw_status = GatewayStatus { - addresses: Some(vec![GatewayAddress::default()]), + addresses: Some(vec![GatewayStatusAddresses::default()]), listeners: Some(vec![GatewayStatusListeners { name: "tcp".into(), attached_routes: 0, From f9f6c5b43d160ed12cca839f20aca6e20d7c7002 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:53:08 -0400 Subject: [PATCH 52/95] chore: cargo cleanup Signed-off-by: Shane Utt --- Cargo.lock | 2 +- type-reducer/Cargo.toml | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d57abf4..7675ee2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1710,7 +1710,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "type-reducer" -version = "0.1.0" +version = "0.16.0" dependencies = [ "clap", "itertools", diff --git a/type-reducer/Cargo.toml b/type-reducer/Cargo.toml index a521d3a..46dc93a 100644 --- a/type-reducer/Cargo.toml +++ b/type-reducer/Cargo.toml @@ -1,8 +1,9 @@ [package] name = "type-reducer" -version = "0.1.0" -edition = "2024" -authors = ["Dawid Nowak nowakd@gmail.com"] + +version.workspace = true +edition.workspace = true +authors.workspace = true [dependencies] syn = { version = "2", features = [ From 247325f808cbadd04abe22b52e498b4ed80ea6e7 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 16:54:22 -0400 Subject: [PATCH 53/95] docs: update CHANGELOG for v0.17.0 Signed-off-by: Shane Utt --- gateway-api/CHANGELOG.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/gateway-api/CHANGELOG.md b/gateway-api/CHANGELOG.md index 401e38c..c02573c 100644 --- a/gateway-api/CHANGELOG.md +++ b/gateway-api/CHANGELOG.md @@ -2,15 +2,30 @@ ## Next +Supports: Gateway API `v1.4.0` + +### Changes + +* Updated to [kube](https://github.com/kube-rs/kube) `v2.0.1` +* Updated to Gateway API `v1.4.0` + +## 0.17.0 + +Supports: Gateway API `v1.2.1` + >[!IMPORTANT] Breaking change -### Changed -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. +### 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 Gateway API `v1.2.1` ## 0.16.0 ### Changed + Initial release. All types are generated with Kopium. From d7e89e50e6092ce384025cca4c6af5d3216da5bd Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 18:28:57 -0400 Subject: [PATCH 54/95] docs: generalize crate author Signed-off-by: Shane Utt --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b4ae364..4c1a218 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["gateway-api", "gateway-api/examples", "xtask", "type-reducer"] resolver = "2" [workspace.package] -authors = ["Shane Utt "] +authors = ["kube-rs project (https://kube.rs)"] edition = "2024" license = "MIT" version = "0.16.0" From 7b79c9147467e131f157aa66c0666d57381825c6 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 21 Oct 2025 18:31:50 -0400 Subject: [PATCH 55/95] docs: cleanup README.md Signed-off-by: Shane Utt --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7727dcb..dea7cef 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,13 @@ ## Usage -Basic usage involves using a [kube-rs] [Client] to perform operations on +Basic usage involves using a [kube-rs Client] to perform operations on [Gateway API resources]. You can either use a basic `Client` to perform operations, or you can build a [Controller]. See the `gateway-api/examples/` -directory for detailed (and specific) usage examples. +directory for examples. -[kube-rs]:https://github.com/kube-rs/kube +[kube-rs Client]:https://docs.rs/kube/latest/kube/struct.Client.html [Gateway API resources]:https://gateway-api.sigs.k8s.io/api-types/gateway/ -[Client]:https://docs.rs/kube/latest/kube/struct.Client.html [Controller]:https://kube.rs/controllers/intro/ ## Development @@ -51,13 +50,13 @@ which you can then commit. ## Contributions +For questions and general discussion, please use the [discussion board]. + Contributions are welcome. Please create an issue describing what changes are desired prior to creating a PR. Please check our [project board] to see what work has been accepted and is -in need of an owner. The `next` column will hold high priority items. - -For questions and general discussion, please use the [discussion board]. +in need of an owner. The `next` column contains high priority items. [project board]:https://github.com/orgs/kube-rs/projects/3 [discussion board]:https://github.com/kube-rs/gateway-api-rs/discussions From 6a4abd60901e2cbcf85122374cc063273724d0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20Tom=C3=A9=20Santana?= Date: Thu, 23 Oct 2025 08:23:27 -0300 Subject: [PATCH 56/95] Route condition reason (#194) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphael Tomé Santana --- .../src/apis/experimental/constants.rs | 29 ++++++++++++++++ gateway-api/src/apis/standard/constants.rs | 33 +++++++++++++++++++ update.sh | 6 ++++ xtask/src/main.rs | 4 +++ 4 files changed, 72 insertions(+) diff --git a/gateway-api/src/apis/experimental/constants.rs b/gateway-api/src/apis/experimental/constants.rs index 65653d9..5304179 100644 --- a/gateway-api/src/apis/experimental/constants.rs +++ b/gateway-api/src/apis/experimental/constants.rs @@ -91,3 +91,32 @@ impl std::fmt::Display for ListenerConditionReason { 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/apis/standard/constants.rs b/gateway-api/src/apis/standard/constants.rs index 0403176..ecb0768 100644 --- a/gateway-api/src/apis/standard/constants.rs +++ b/gateway-api/src/apis/standard/constants.rs @@ -88,3 +88,36 @@ impl std::fmt::Display for ListenerConditionReason { 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/update.sh b/update.sh index 0852e28..0afe3d6 100755 --- a/update.sh +++ b/update.sh @@ -84,10 +84,13 @@ 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 @@ -122,10 +125,13 @@ 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 diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 875b406..aef81cc 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -31,6 +31,8 @@ fn gen_condition_constants() -> Result<(), DynError> { 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")?; let mut scope = Scope::new(); gen_const_enums(&mut scope, gateway_class_condition_types); @@ -39,6 +41,8 @@ fn gen_condition_constants() -> Result<(), DynError> { 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); println!("{}", gen_generated_file_warning()); println!("{}", scope.to_string()); Ok(()) From 21cc95aa2108cc44b3e36621629aa8c2bee34720 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Oct 2025 11:33:02 -0400 Subject: [PATCH 57/95] chore(deps): bump syn from 2.0.107 to 2.0.108 (#195) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7675ee2..3f23a3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1469,9 +1469,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.107" +version = "2.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b" +checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" dependencies = [ "proc-macro2", "quote", From 711945d995c7be05fb103d42b0579074e22c0771 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Oct 2025 15:37:07 +0000 Subject: [PATCH 58/95] chore(deps): bump proc-macro2 from 1.0.101 to 1.0.103 (#196) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f23a3d..caf7589 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1049,9 +1049,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] From 3ed8fbe1d14638ae1d14923d317b56c94e764146 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 20:24:50 -0400 Subject: [PATCH 59/95] feat: add cleanup to update.sh Signed-off-by: Shane Utt --- update.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/update.sh b/update.sh index 0afe3d6..9353eee 100755 --- a/update.sh +++ b/update.sh @@ -211,3 +211,15 @@ sed -i '/#\[kube(status = "UDPRouteStatus")\]/c\#\[kube(status = "RouteStatus")\ sed -i '/#\[kube(status = "TCPRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tcproutes.rs cargo fmt +echo "API Generation complete" + +echo "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 "Cleanup complete" From a5106b1ca1eb71ce200e32add23fd7fd54cb8d67 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 20:26:18 -0400 Subject: [PATCH 60/95] chore: cleanup unused use generators Signed-off-by: Shane Utt --- update.sh | 6 ++---- xtask/src/main.rs | 31 ++----------------------------- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/update.sh b/update.sh index 9353eee..4a40729 100755 --- a/update.sh +++ b/update.sh @@ -167,8 +167,7 @@ ENUMS=( ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} -echo "use super::common::*;" > $APIS_DIR/standard/enum_defaults.rs -GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $APIS_DIR/standard/enum_defaults.rs +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults > $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 @@ -201,8 +200,7 @@ ENUMS=( ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") ENUMS_WITH_DEFAULTS=${ENUMS_WITH_DEFAULTS:1} -echo "use super::common::*;" > $APIS_DIR/experimental/enum_defaults.rs -GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults >> $APIS_DIR/experimental/enum_defaults.rs +GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults > $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 diff --git a/xtask/src/main.rs b/xtask/src/main.rs index aef81cc..3508423 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -87,8 +87,6 @@ fn gen_enum_defaults() -> Result<(), DynError> { 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![]; for (e, d) in enums_with_defaults { // The `fn default()` function. @@ -100,28 +98,12 @@ 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); - } } + // Print the common use statement first + println!("use super::common::*;"); 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); - } - if !grpcroute_enums.is_empty() { - let use_grpc_stmt = gen_use_stmt(grpcroute_enums, "grpcroutes".to_string()); - println!("{}\n", use_grpc_stmt); - } - println!("{}", scope.to_string()); Ok(()) } @@ -130,15 +112,6 @@ 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 { let mut enums_with_defaults = BTreeMap::new(); env_var_val.split(',').for_each(|enum_with_default| { From 673cc0b3d5d0b4f7c45d1d463921b83d102c2c46 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 20:26:43 -0400 Subject: [PATCH 61/95] fix: cargo fmt Signed-off-by: Shane Utt --- gateway-api/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway-api/src/lib.rs b/gateway-api/src/lib.rs index 8099714..41ea42d 100644 --- a/gateway-api/src/lib.rs +++ b/gateway-api/src/lib.rs @@ -33,7 +33,9 @@ mod tests { ListenerConditionType, }, apis::standard::gatewayclasses::{GatewayClass, GatewayClassSpec}, - apis::standard::gateways::{Gateway, GatewaySpec, GatewayStatus, GatewayStatusAddresses, GatewayStatusListeners}, + apis::standard::gateways::{ + Gateway, GatewaySpec, GatewayStatus, GatewayStatusAddresses, GatewayStatusListeners, + }, }; // ------------------------------------------------------------------------- From 772c7058032c7a7051369b1374b2e15a4c74e88e Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 20:27:06 -0400 Subject: [PATCH 62/95] chore: cleanup blank space Signed-off-by: Shane Utt --- update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.sh b/update.sh index 4a40729..9bb131c 100755 --- a/update.sh +++ b/update.sh @@ -162,7 +162,7 @@ cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/standa ENUMS=( GRPCFilterType=RequestHeaderModifier RequestOperationType=ReplaceFullPath - HTTPFilterType=RequestHeaderModifier + HTTPFilterType=RequestHeaderModifier ) ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") From 62cd824f12eda99006e7f681eb9d6e964ab5e761 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 20:28:07 -0400 Subject: [PATCH 63/95] chore: update types for new kopium gen Signed-off-by: Shane Utt --- type-reducer/README.md | 34 +-- .../experimental_customized_mapped_names.txt | 214 +++++++++--------- .../experimental_ignorable_mapped_names.txt | 4 +- .../experimental_reduced_types_pass_3.txt | 6 +- .../experimental_reduced_types_pass_4.txt | 8 +- .../experimental_rename_only_mapped_names.txt | 26 +-- .../standard_customized_mapped_names.txt | 154 ++++++------- .../standard_reduced_types_pass_3.txt | 6 +- .../standard_rename_only_mapped_names.txt | 26 +-- update.sh | 48 ++-- 10 files changed, 263 insertions(+), 263 deletions(-) diff --git a/type-reducer/README.md b/type-reducer/README.md index aac0c1a..ac94ab9 100644 --- a/type-reducer/README.md +++ b/type-reducer/README.md @@ -11,18 +11,18 @@ 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. +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| +|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierSet|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierAdd|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierSet|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|HttpRouteRulesBackendRefsFiltersRequestHeaderModifierAdd|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|HttpRouteRulesBackendRefsFiltersRequestHeaderModifierSet|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|HttpRouteRulesBackendRefsFiltersResponseHeaderModifierAdd|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| +|HttpRouteRulesBackendRefsFiltersResponseHeaderModifierSet|->|GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd| ##### After the change. @@ -31,14 +31,14 @@ On subsequent runs, the algorithm will use HTTPHeader as new name for all those | Kopium generated names | | User selected name| |------------------------|--|-------------------| -|GRPCRouteRulesBackendRefsFiltersRequestHeaderModifierAdd|->|HTTPHeader| -|GRPCRouteRulesBackendRefsFiltersRequestHeaderModifierSet|->|HTTPHeader| -|GRPCRouteRulesBackendRefsFiltersResponseHeaderModifierAdd|->|HTTPHeader| -|GRPCRouteRulesBackendRefsFiltersResponseHeaderModifierSet|->|HTTPHeader| -|HTTPRouteRulesBackendRefsFiltersRequestHeaderModifierAdd|->|HTTPHeader| -|HTTPRouteRulesBackendRefsFiltersRequestHeaderModifierSet|->|HTTPHeader| -|HTTPRouteRulesBackendRefsFiltersResponseHeaderModifierAdd|->|HTTPHeader| -|HTTPRouteRulesBackendRefsFiltersResponseHeaderModifierSet|->|HTTPHeader| +|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 diff --git a/type-reducer/experimental_customized_mapped_names.txt b/type-reducer/experimental_customized_mapped_names.txt index 245e344..6703855 100644 --- a/type-reducer/experimental_customized_mapped_names.txt +++ b/type-reducer/experimental_customized_mapped_names.txt @@ -1,119 +1,119 @@ -GRPCRouteRulesBackendRefsFiltersType->GRPCFilterType -GRPCRouteRulesFiltersType->GRPCFilterType -GRPCRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction -GRPCRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction -HTTPRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction -HTTPRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction -GRPCRouteRulesSessionPersistenceCookieConfigLifetimeType->PersistenceCookieConfigLifetime -HTTPRouteRulesSessionPersistenceCookieConfigLifetimeType->PersistenceCookieConfigLifetime -GRPCRouteRulesSessionPersistenceType->SessionPersistenceType -HTTPRouteRulesSessionPersistenceType->SessionPersistenceType +GrpcRouteRulesBackendRefsFiltersType->GRPCFilterType +GrpcRouteRulesFiltersType->GRPCFilterType +GrpcRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +GrpcRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +GrpcRouteRulesSessionPersistenceCookieConfigLifetimeType->PersistenceCookieConfigLifetime +HttpRouteRulesSessionPersistenceCookieConfigLifetimeType->PersistenceCookieConfigLifetime +GrpcRouteRulesSessionPersistenceType->SessionPersistenceType +HttpRouteRulesSessionPersistenceType->SessionPersistenceType GatewayAddresses->GatewayAddress GatewayStatusAddresses->GatewayAddress GatewayBackendTlsClientCertificateRef->BackendTlsClientCertificateReference GatewayListenersTlsCertificateRefs->BackendTlsClientCertificateReference GatewayClassParametersRef->ParametersReference GatewayListenersTlsFrontendValidationCaCertificateRefs->ParametersReference -GRPCRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference -GRPCRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference +GrpcRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference +GrpcRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference GatewayInfrastructureParametersRef->GatewayInfrastructureParametersReference -HTTPRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference -HTTPRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference -HTTPRouteRulesBackendRefsFiltersType->HTTPFilterType -HTTPRouteRulesFiltersType->HTTPFilterType -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 -GRPCRouteRulesMatchesHeadersType->HeaderMatchType -GRPCRouteRulesMatchesMethodType->HeaderMatchType -HTTPRouteRulesMatchesHeadersType->HeaderMatchType -HTTPRouteRulesMatchesQueryParamsType->HeaderMatchType +HttpRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference +HttpRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference +HttpRouteRulesBackendRefsFiltersType->HTTPFilterType +HttpRouteRulesFiltersType->HTTPFilterType +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 +GrpcRouteRulesMatchesHeadersType->HeaderMatchType +GrpcRouteRulesMatchesMethodType->HeaderMatchType +HttpRouteRulesMatchesHeadersType->HeaderMatchType +HttpRouteRulesMatchesQueryParamsType->HeaderMatchType GatewayListenersAllowedRoutesKinds->Kind GatewayStatusListenersSupportedKinds->Kind -HTTPRouteRulesBackendRefsFiltersRequestRedirectStatusCode->RedirectStatusCode -HTTPRouteRulesFiltersRequestRedirectStatusCode->RedirectStatusCode -GRPCRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference -GRPCRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference -HTTPRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference -HTTPRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference -HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType->RequestOperationType -HTTPRouteRulesBackendRefsFiltersUrlRewritePathType->RequestOperationType -HTTPRouteRulesFiltersRequestRedirectPathType->RequestOperationType -HTTPRouteRulesFiltersUrlRewritePathType->RequestOperationType -HTTPRouteRulesBackendRefsFiltersRequestRedirectScheme->RequestRedirectScheme -HTTPRouteRulesFiltersRequestRedirectScheme->RequestRedirectScheme -GRPCRouteParentRefs->ParentReference -GRPCRouteStatusParentsParentRef->ParentReference -HTTPRouteParentRefs->ParentReference -HTTPRouteStatusParentsParentRef->ParentReference -TCPRouteParentRefs->ParentReference -TCPRouteStatusParentsParentRef->ParentReference -TLSRouteParentRefs->ParentReference -TLSRouteStatusParentsParentRef->ParentReference -UDPRouteParentRefs->ParentReference -UDPRouteStatusParentsParentRef->ParentReference -TCPRouteRulesBackendRefs->BackendReference -TLSRouteRulesBackendRefs->BackendReference -UDPRouteRulesBackendRefs->BackendReference +HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode->RedirectStatusCode +HttpRouteRulesFiltersRequestRedirectStatusCode->RedirectStatusCode +GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference +GrpcRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference +HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference +HttpRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference +HttpRouteRulesBackendRefsFiltersRequestRedirectPathType->RequestOperationType +HttpRouteRulesBackendRefsFiltersUrlRewritePathType->RequestOperationType +HttpRouteRulesFiltersRequestRedirectPathType->RequestOperationType +HttpRouteRulesFiltersUrlRewritePathType->RequestOperationType +HttpRouteRulesBackendRefsFiltersRequestRedirectScheme->RequestRedirectScheme +HttpRouteRulesFiltersRequestRedirectScheme->RequestRedirectScheme +GrpcRouteParentRefs->ParentReference +GrpcRouteStatusParentsParentRef->ParentReference +HttpRouteParentRefs->ParentReference +HttpRouteStatusParentsParentRef->ParentReference +TcpRouteParentRefs->ParentReference +TcpRouteStatusParentsParentRef->ParentReference +TlsRouteParentRefs->ParentReference +TlsRouteStatusParentsParentRef->ParentReference +UdpRouteParentRefs->ParentReference +UdpRouteStatusParentsParentRef->ParentReference +TcpRouteRulesBackendRefs->BackendReference +TlsRouteRulesBackendRefs->BackendReference +UdpRouteRulesBackendRefs->BackendReference #### Pass 2 -GRPCRouteRulesSessionPersistenceCookieConfig->SessionPersistenceCookieConfig -HTTPRouteRulesSessionPersistenceCookieConfig->SessionPersistenceCookieConfig -GRPCRouteRulesMatchesHeaders->HeaderMatch -HTTPRouteRulesMatchesHeaders->HeaderMatch -HTTPRouteRulesMatchesQueryParams->HeaderMatch -GRPCRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier -GRPCRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier -GRPCRouteRulesFiltersRequestHeaderModifier->HeaderModifier -GRPCRouteRulesFiltersResponseHeaderModifier->HeaderModifier -HTTPRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier -HTTPRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier -HTTPRouteRulesFiltersRequestHeaderModifier->HeaderModifier -HTTPRouteRulesFiltersResponseHeaderModifier->HeaderModifier -GRPCRouteRulesBackendRefsFiltersRequestMirror->RequestMirror -GRPCRouteRulesFiltersRequestMirror->RequestMirror -HTTPRouteRulesBackendRefsFiltersRequestMirror->RequestMirror -HTTPRouteRulesFiltersRequestMirror->RequestMirror -HTTPRouteRulesBackendRefsFiltersRequestRedirectPath->RequestRedirectPath -HTTPRouteRulesBackendRefsFiltersUrlRewritePath->RequestRedirectPath -HTTPRouteRulesFiltersRequestRedirectPath->RequestRedirectPath -HTTPRouteRulesFiltersUrlRewritePath->RequestRedirectPath -TCPRouteRules->CommonRouteRule -TLSRouteRules->CommonRouteRule -UDPRouteRules->CommonRouteRule -GRPCRouteStatusParents->ParentRouteStatus -HTTPRouteStatusParents->ParentRouteStatus -TCPRouteStatusParents->ParentRouteStatus -TLSRouteStatusParents->ParentRouteStatus -UDPRouteStatusParents->ParentRouteStatus +GrpcRouteRulesSessionPersistenceCookieConfig->SessionPersistenceCookieConfig +HttpRouteRulesSessionPersistenceCookieConfig->SessionPersistenceCookieConfig +GrpcRouteRulesMatchesHeaders->HeaderMatch +HttpRouteRulesMatchesHeaders->HeaderMatch +HttpRouteRulesMatchesQueryParams->HeaderMatch +GrpcRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier +GrpcRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier +GrpcRouteRulesFiltersRequestHeaderModifier->HeaderModifier +GrpcRouteRulesFiltersResponseHeaderModifier->HeaderModifier +HttpRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier +HttpRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier +HttpRouteRulesFiltersRequestHeaderModifier->HeaderModifier +HttpRouteRulesFiltersResponseHeaderModifier->HeaderModifier +GrpcRouteRulesBackendRefsFiltersRequestMirror->RequestMirror +GrpcRouteRulesFiltersRequestMirror->RequestMirror +HttpRouteRulesBackendRefsFiltersRequestMirror->RequestMirror +HttpRouteRulesFiltersRequestMirror->RequestMirror +HttpRouteRulesBackendRefsFiltersRequestRedirectPath->RequestRedirectPath +HttpRouteRulesBackendRefsFiltersUrlRewritePath->RequestRedirectPath +HttpRouteRulesFiltersRequestRedirectPath->RequestRedirectPath +HttpRouteRulesFiltersUrlRewritePath->RequestRedirectPath +TcpRouteRules->CommonRouteRule +TlsRouteRules->CommonRouteRule +UdpRouteRules->CommonRouteRule +GrpcRouteStatusParents->ParentRouteStatus +HttpRouteStatusParents->ParentRouteStatus +TcpRouteStatusParents->ParentRouteStatus +TlsRouteStatusParents->ParentRouteStatus +UdpRouteStatusParents->ParentRouteStatus #### Pass 3 -GRPCRouteRulesBackendRefsFilters->GRPCRouteFilter -GRPCRouteRulesFilters->GRPCRouteFilter -GRPCRouteRulesSessionPersistence->SessionPersistence -HTTPRouteRulesSessionPersistence->SessionPersistence -HTTPRouteRulesBackendRefsFiltersRequestRedirect->HTTPRouteRequestRedirect -HTTPRouteRulesFiltersRequestRedirect->HTTPRouteRequestRedirect -HTTPRouteRulesBackendRefsFiltersUrlRewrite->HTTPRouteUrlRewrite -HTTPRouteRulesFiltersUrlRewrite->HTTPRouteUrlRewrite -TCPRouteSpec->RouteSpec -UDPRouteSpec->RouteSpec -GRPCRouteStatus->RouteStatus -HTTPRouteStatus->RouteStatus -TCPRouteStatus->RouteStatus -TLSRouteStatus->RouteStatus -UDPRouteStatus->RouteStatus +GrpcRouteRulesBackendRefsFilters->GrpcRouteFilter +GrpcRouteRulesFilters->GrpcRouteFilter +GrpcRouteRulesSessionPersistence->SessionPersistence +HttpRouteRulesSessionPersistence->SessionPersistence +HttpRouteRulesBackendRefsFiltersRequestRedirect->HttpRouteRequestRedirect +HttpRouteRulesFiltersRequestRedirect->HttpRouteRequestRedirect +HttpRouteRulesBackendRefsFiltersUrlRewrite->HttpRouteUrlRewrite +HttpRouteRulesFiltersUrlRewrite->HttpRouteUrlRewrite +TcpRouteSpec->RouteSpec +UdpRouteSpec->RouteSpec +GrpcRouteStatus->RouteStatus +HttpRouteStatus->RouteStatus +TcpRouteStatus->RouteStatus +TlsRouteStatus->RouteStatus +UdpRouteStatus->RouteStatus #### Pass 4 -HTTPRouteRulesBackendRefsFilters->HTTPRouteBackendFilters -HTTPRouteRulesFilters->HTTPRouteRulesBackendRefsFilters +HttpRouteRulesBackendRefsFilters->HttpRouteBackendFilters +HttpRouteRulesFilters->HttpRouteRulesBackendRefsFilters diff --git a/type-reducer/experimental_ignorable_mapped_names.txt b/type-reducer/experimental_ignorable_mapped_names.txt index b278bf5..79cdc4f 100644 --- a/type-reducer/experimental_ignorable_mapped_names.txt +++ b/type-reducer/experimental_ignorable_mapped_names.txt @@ -1,2 +1,2 @@ -TCPRouteSpec->RouteSpec -UDPRouteSpec->RouteSpec +TcpRouteSpec->RouteSpec +UdpRouteSpec->RouteSpec diff --git a/type-reducer/experimental_reduced_types_pass_3.txt b/type-reducer/experimental_reduced_types_pass_3.txt index 2c06609..9b81525 100644 --- a/type-reducer/experimental_reduced_types_pass_3.txt +++ b/type-reducer/experimental_reduced_types_pass_3.txt @@ -26,8 +26,8 @@ RequestRedirectPath ParentRouteStatus CommonRouteRule #### Pass 3 -GRPCRouteFilter -HTTPRouteRequestRedirect -HTTPRouteUrlRewrite +GrpcRouteFilter +HttpRouteRequestRedirect +HttpRouteUrlRewrite RouteStatus SessionPersistence diff --git a/type-reducer/experimental_reduced_types_pass_4.txt b/type-reducer/experimental_reduced_types_pass_4.txt index 2d40c18..0834e9c 100644 --- a/type-reducer/experimental_reduced_types_pass_4.txt +++ b/type-reducer/experimental_reduced_types_pass_4.txt @@ -26,10 +26,10 @@ RequestRedirectPath ParentRouteStatus CommonRouteRule #### Pass 3 -GRPCRouteFilter -HTTPRouteRequestRedirect -HTTPRouteUrlRewrite +GrpcRouteFilter +HttpRouteRequestRedirect +HttpRouteUrlRewrite RouteStatus SessionPersistence #### Pass 4 -HTTPRouteBackendFilters +HttpRouteBackendFilters diff --git a/type-reducer/experimental_rename_only_mapped_names.txt b/type-reducer/experimental_rename_only_mapped_names.txt index b8c7e41..c551c34 100644 --- a/type-reducer/experimental_rename_only_mapped_names.txt +++ b/type-reducer/experimental_rename_only_mapped_names.txt @@ -1,14 +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 +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/standard_customized_mapped_names.txt b/type-reducer/standard_customized_mapped_names.txt index 7e4ca88..0ffb3bb 100644 --- a/type-reducer/standard_customized_mapped_names.txt +++ b/type-reducer/standard_customized_mapped_names.txt @@ -1,84 +1,84 @@ -GRPCRouteRulesBackendRefsFiltersType->GRPCFilterType -GRPCRouteRulesFiltersType->GRPCFilterType +GrpcRouteRulesBackendRefsFiltersType->GRPCFilterType +GrpcRouteRulesFiltersType->GRPCFilterType GatewayAddresses->GatewayAddress GatewayStatusAddresses->GatewayAddress -GRPCRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference -GRPCRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference +GrpcRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference +GrpcRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference GatewayInfrastructureParametersRef->GatewayInfrastructureParametersReference -HTTPRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference -HTTPRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference +HttpRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference +HttpRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference GatewayListenersAllowedRoutesKinds->Kind GatewayStatusListenersSupportedKinds->Kind -GRPCRouteParentRefs->ParentReference -GRPCRouteStatusParentsParentRef->ParentReference -HTTPRouteParentRefs->ParentReference -HTTPRouteStatusParentsParentRef->ParentReference -GRPCRouteRulesBackendRefsFiltersExtensionRef->FilterExtensionReference -GRPCRouteRulesFiltersExtensionRef->FilterExtensionReference -HTTPRouteRulesBackendRefsFiltersExtensionRef->FilterExtensionReference -HTTPRouteRulesFiltersExtensionRef->FilterExtensionReference -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->RequestMirrorReference -GRPCRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference -HTTPRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference -HTTPRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference -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 +GrpcRouteParentRefs->ParentReference +GrpcRouteStatusParentsParentRef->ParentReference +HttpRouteParentRefs->ParentReference +HttpRouteStatusParentsParentRef->ParentReference +GrpcRouteRulesBackendRefsFiltersExtensionRef->FilterExtensionReference +GrpcRouteRulesFiltersExtensionRef->FilterExtensionReference +HttpRouteRulesBackendRefsFiltersExtensionRef->FilterExtensionReference +HttpRouteRulesFiltersExtensionRef->FilterExtensionReference +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->RequestMirrorReference +GrpcRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference +HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference +HttpRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference +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 +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 #### Pass 3 -GRPCRouteRulesBackendRefsFilters->GRPCRouteFilter -GRPCRouteRulesFilters->GRPCRouteFilter -HTTPRouteRulesBackendRefsFiltersRequestRedirect->HTTPRouteRequestRedirect -HTTPRouteRulesFiltersRequestRedirect->HTTPRouteRequestRedirect -HTTPRouteRulesBackendRefsFiltersUrlRewrite->HTTPRouteUrlRewrite -HTTPRouteRulesFiltersUrlRewrite->HTTPRouteUrlRewrite -GRPCRouteStatus->RouteStatus -HTTPRouteStatus->RouteStatus +GrpcRouteRulesBackendRefsFilters->GrpcRouteFilter +GrpcRouteRulesFilters->GrpcRouteFilter +HttpRouteRulesBackendRefsFiltersRequestRedirect->HttpRouteRequestRedirect +HttpRouteRulesFiltersRequestRedirect->HttpRouteRequestRedirect +HttpRouteRulesBackendRefsFiltersUrlRewrite->HttpRouteUrlRewrite +HttpRouteRulesFiltersUrlRewrite->HttpRouteUrlRewrite +GrpcRouteStatus->RouteStatus +HttpRouteStatus->RouteStatus diff --git a/type-reducer/standard_reduced_types_pass_3.txt b/type-reducer/standard_reduced_types_pass_3.txt index 3b5cbd3..c2cea00 100644 --- a/type-reducer/standard_reduced_types_pass_3.txt +++ b/type-reducer/standard_reduced_types_pass_3.txt @@ -20,7 +20,7 @@ RequestMirror RequestRedirectPath ParentRouteStatus #### Pass 3 -GRPCRouteFilter -HTTPRouteRequestRedirect -HTTPRouteUrlRewrite +GrpcRouteFilter +HttpRouteRequestRedirect +HttpRouteUrlRewrite RouteStatus diff --git a/type-reducer/standard_rename_only_mapped_names.txt b/type-reducer/standard_rename_only_mapped_names.txt index b8c7e41..c551c34 100644 --- a/type-reducer/standard_rename_only_mapped_names.txt +++ b/type-reducer/standard_rename_only_mapped_names.txt @@ -1,14 +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 +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 index 9bb131c..84f9689 100755 --- a/update.sh +++ b/update.sh @@ -60,14 +60,14 @@ 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 + HttpRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesFiltersType=RequestHeaderModifier + HttpRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersType=RequestHeaderModifier + GrpcRouteRulesFiltersType=RequestHeaderModifier + GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier ) # Create a comma separated string out of $ENUMS. @@ -106,15 +106,15 @@ 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 + HttpRouteRulesFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesFiltersType=RequestHeaderModifier + HttpRouteRulesBackendRefsFiltersRequestRedirectPathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersUrlRewritePathType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersType=RequestHeaderModifier + HttpRouteRulesBackendRefsFiltersExternalAuthProtocol=Http + GrpcRouteRulesFiltersType=RequestHeaderModifier + GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier ) ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") @@ -169,8 +169,8 @@ 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 -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 = "GrpcRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/grpcroutes.rs +sed -i '/#\[kube(status = "HttpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/standard/httproutes.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 @@ -202,11 +202,11 @@ 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 -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 = "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 "API Generation complete" From d9d53be62570fd7458033076a372a2c359cbb280 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 20:28:21 -0400 Subject: [PATCH 64/95] feat: add default for ext auth proto Signed-off-by: Shane Utt --- update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/update.sh b/update.sh index 84f9689..2da042e 100755 --- a/update.sh +++ b/update.sh @@ -195,7 +195,8 @@ cargo run --manifest-path type-reducer/Cargo.toml -- --apis-dir $APIS_DIR/experi ENUMS=( GRPCFilterType=RequestHeaderModifier RequestOperationType=ReplaceFullPath - HTTPFilterType=RequestHeaderModifier + HttpRouteRulesBackendRefsFiltersExternalAuthProtocol=Http + HTTPFilterType=RequestHeaderModifier ) ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") From e8ea77c1c93c7c33919f907ff5ad5b49984b33eb Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 20:29:37 -0400 Subject: [PATCH 65/95] chore: run generators Signed-off-by: Shane Utt --- gateway-api/src/apis/experimental/common.rs | 22 ++--- .../src/apis/experimental/constants.rs | 2 - .../src/apis/experimental/enum_defaults.rs | 8 +- .../src/apis/experimental/grpcroutes.rs | 30 +++--- .../src/apis/experimental/httproutes.rs | 94 +++++++++---------- .../src/apis/experimental/tcproutes.rs | 2 +- .../src/apis/experimental/tlsroutes.rs | 2 +- .../src/apis/experimental/udproutes.rs | 2 +- gateway-api/src/apis/standard/common.rs | 4 +- gateway-api/src/apis/standard/constants.rs | 2 - gateway-api/src/apis/standard/grpcroutes.rs | 30 +++--- gateway-api/src/apis/standard/httproutes.rs | 38 ++++---- 12 files changed, 116 insertions(+), 120 deletions(-) diff --git a/gateway-api/src/apis/experimental/common.rs b/gateway-api/src/apis/experimental/common.rs index 891864d..3e5f602 100644 --- a/gateway-api/src/apis/experimental/common.rs +++ b/gateway-api/src/apis/experimental/common.rs @@ -40,18 +40,18 @@ pub enum HTTPFilterType { ExternalAuth, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol { +pub enum HeaderMatchType { + Exact, + RegularExpression, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum HttpRouteRulesBackendRefsFiltersExternalAuthProtocol { #[serde(rename = "HTTP")] Http, #[serde(rename = "GRPC")] Grpc, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HeaderMatchType { - Exact, - RegularExpression, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum PersistenceCookieConfigLifetime { Permanent, Session, @@ -123,7 +123,7 @@ pub struct HTTPHeader { pub value: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef { +pub struct HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -135,12 +135,12 @@ pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef { pub port: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthForwardBody { +pub struct HttpRouteRulesBackendRefsFiltersExternalAuthForwardBody { #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxSize")] pub max_size: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthGrpc { +pub struct HttpRouteRulesBackendRefsFiltersExternalAuthGrpc { #[serde( default, skip_serializing_if = "Option::is_none", @@ -149,7 +149,7 @@ pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthGrpc { pub allowed_headers: Option>, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthHttp { +pub struct HttpRouteRulesBackendRefsFiltersExternalAuthHttp { #[serde( default, skip_serializing_if = "Option::is_none", @@ -278,7 +278,7 @@ pub struct RequestRedirect { pub status_code: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteUrlRewrite { +pub struct HttpRouteUrlRewrite { #[serde(default, skip_serializing_if = "Option::is_none")] pub hostname: Option, #[serde(default, skip_serializing_if = "Option::is_none")] diff --git a/gateway-api/src/apis/experimental/constants.rs b/gateway-api/src/apis/experimental/constants.rs index 5304179..8995c8a 100644 --- a/gateway-api/src/apis/experimental/constants.rs +++ b/gateway-api/src/apis/experimental/constants.rs @@ -91,7 +91,6 @@ impl std::fmt::Display for ListenerConditionReason { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum RouteConditionType { Accepted, @@ -102,7 +101,6 @@ impl std::fmt::Display for RouteConditionType { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum RouteConditionReason { Accepted, diff --git a/gateway-api/src/apis/experimental/enum_defaults.rs b/gateway-api/src/apis/experimental/enum_defaults.rs index b72bd03..f22f158 100644 --- a/gateway-api/src/apis/experimental/enum_defaults.rs +++ b/gateway-api/src/apis/experimental/enum_defaults.rs @@ -13,14 +13,14 @@ impl Default for HTTPFilterType { } } -impl Default for RequestOperationType { +impl Default for HttpRouteRulesBackendRefsFiltersExternalAuthProtocol { fn default() -> Self { - RequestOperationType::ReplaceFullPath + HttpRouteRulesBackendRefsFiltersExternalAuthProtocol::Http } } -impl Default for HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol { +impl Default for RequestOperationType { fn default() -> Self { - HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol::Http + RequestOperationType::ReplaceFullPath } } diff --git a/gateway-api/src/apis/experimental/grpcroutes.rs b/gateway-api/src/apis/experimental/grpcroutes.rs index 840600a..46be258 100644 --- a/gateway-api/src/apis/experimental/grpcroutes.rs +++ b/gateway-api/src/apis/experimental/grpcroutes.rs @@ -21,7 +21,7 @@ use self::prelude::*; #[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct GRPCRouteSpec { +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: @@ -143,7 +143,7 @@ pub struct GRPCRouteSpec { 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>, + 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 @@ -167,7 +167,7 @@ pub struct GRPCRouteSpec { /// 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 { +pub struct GrpcRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -227,7 +227,7 @@ pub struct GRPCRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -278,7 +278,7 @@ pub struct GRPCRouteRule { /// 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>, + 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 @@ -324,7 +324,7 @@ pub struct GRPCBackendReference { /// 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>, + 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")] @@ -388,7 +388,7 @@ pub struct GRPCBackendReference { /// 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 { +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 @@ -427,7 +427,7 @@ pub struct GRPCRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -475,7 +475,7 @@ pub struct GRPCRouteRulesBackendRefsFilters { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestMirror { +pub struct GrpcRouteRulesBackendRefsFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -500,7 +500,7 @@ pub struct GRPCRouteRulesBackendRefsFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// Fraction represents the fraction of requests that should be /// mirrored to BackendRef. /// @@ -524,7 +524,7 @@ pub struct GRPCRouteRulesBackendRefsFiltersRequestMirror { /// 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 { +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 @@ -563,7 +563,7 @@ pub struct GRPCRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -611,7 +611,7 @@ pub struct GRPCRouteRulesFilters { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestMirror { +pub struct GrpcRouteRulesFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -636,7 +636,7 @@ pub struct GRPCRouteRulesFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// Fraction represents the fraction of requests that should be /// mirrored to BackendRef. /// @@ -671,7 +671,7 @@ pub struct GRPCRouteRulesFiltersRequestMirror { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteMatch { +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. diff --git a/gateway-api/src/apis/experimental/httproutes.rs b/gateway-api/src/apis/experimental/httproutes.rs index 20d6837..16b9159 100644 --- a/gateway-api/src/apis/experimental/httproutes.rs +++ b/gateway-api/src/apis/experimental/httproutes.rs @@ -21,7 +21,7 @@ use self::prelude::*; #[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct HTTPRouteSpec { +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 @@ -146,7 +146,7 @@ pub struct HTTPRouteSpec { 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>, + 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 @@ -170,7 +170,7 @@ pub struct HTTPRouteSpec { /// 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 { +pub struct HttpRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -249,7 +249,7 @@ pub struct HTTPRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -317,7 +317,7 @@ pub struct HTTPRouteRule { /// /// Support: Extended #[serde(default, skip_serializing_if = "Option::is_none")] - pub retry: Option, + pub retry: Option, /// SessionPersistence defines and configures session persistence /// for the route rule. /// @@ -332,7 +332,7 @@ pub struct HTTPRouteRule { /// /// Support: Extended #[serde(default, skip_serializing_if = "Option::is_none")] - pub timeouts: Option, + pub timeouts: Option, } /// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. /// @@ -363,7 +363,7 @@ pub struct HTTPBackendReference { /// 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>, + 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")] @@ -427,13 +427,13 @@ pub struct HTTPBackendReference { /// 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 { +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, + 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 @@ -461,7 +461,7 @@ pub struct HTTPRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "externalAuth" )] - pub external_auth: Option, + pub external_auth: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -486,7 +486,7 @@ pub struct HTTPRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -549,14 +549,14 @@ pub struct HTTPRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "urlRewrite" )] - pub url_rewrite: Option, + 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 { +pub struct HttpRouteRulesBackendRefsFiltersCors { /// AllowCredentials indicates whether the actual cross-origin request allows /// to include credentials. /// @@ -623,13 +623,13 @@ pub struct HTTPRouteRulesBackendRefsFiltersCors { /// value `*`, which represents all HTTP methods are allowed. /// /// Method names are case sensitive, so these values are also case-sensitive. - /// (See https://www.rfc-editor.org/rfc/rfc2616#section-5.1.1) + /// (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 https://fetch.spec.whatwg.org/#cors-safelisted-method) The + /// (See The /// CORS-safelisted methods are always allowed, regardless of whether they /// are specified in the `AllowMethods` field. /// @@ -734,7 +734,7 @@ pub struct HTTPRouteRulesBackendRefsFiltersCors { /// `Expires` /// `Last-Modified` /// `Pragma` - /// (See https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name) + /// (See /// The CORS-safelisted response headers are exposed to client by default. /// /// When an HTTP header name is specified using the `ExposeHeaders` field, @@ -778,7 +778,7 @@ pub struct HTTPRouteRulesBackendRefsFiltersCors { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersExternalAuth { +pub struct HttpRouteRulesBackendRefsFiltersExternalAuth { /// BackendRef is a reference to a backend to send authorization /// requests to. /// @@ -789,7 +789,7 @@ pub struct HTTPRouteRulesBackendRefsFiltersExternalAuth { /// implementation to supply the TLS details to be used to connect to that /// backend. #[serde(rename = "backendRef")] - pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// ForwardBody controls if requests to the authorization server should include /// the body of the client request; and if so, how big that body is allowed /// to be. @@ -808,28 +808,28 @@ pub struct HTTPRouteRulesBackendRefsFiltersExternalAuth { skip_serializing_if = "Option::is_none", rename = "forwardBody" )] - pub forward_body: Option, + pub forward_body: Option, /// GRPCAuthConfig contains configuration for communication with ext_authz /// protocol-speaking backends. /// /// If unset, implementations must assume the default behavior for each /// included field is intended. #[serde(default, skip_serializing_if = "Option::is_none")] - pub grpc: Option, + pub grpc: Option, /// HTTPAuthConfig contains configuration for communication with HTTP-speaking /// backends. /// /// If unset, implementations must assume the default behavior for each /// included field is intended. #[serde(default, skip_serializing_if = "Option::is_none")] - pub http: Option, + pub http: Option, /// ExternalAuthProtocol describes which protocol to use when communicating with an /// ext_authz authorization server. /// /// When this is set to GRPC, each backend must use the Envoy ext_authz protocol /// on the port specified in `backendRefs`. Requests and responses are defined /// in the protobufs explained at: - /// https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/auth/v3/external_auth.proto + /// /// /// When this is set to HTTP, each backend must respond with a `200` status /// code in on a successful authorization. Any other code is considered @@ -838,7 +838,7 @@ pub struct HTTPRouteRulesBackendRefsFiltersExternalAuth { /// Feature Names: /// GRPC Support - HTTPRouteExternalAuthGRPC /// HTTP Support - HTTPRouteExternalAuthHTTP - pub protocol: HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol, + pub protocol: HttpRouteRulesBackendRefsFiltersExternalAuthProtocol, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -850,7 +850,7 @@ pub struct HTTPRouteRulesBackendRefsFiltersExternalAuth { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestMirror { +pub struct HttpRouteRulesBackendRefsFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -875,7 +875,7 @@ pub struct HTTPRouteRulesBackendRefsFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// Fraction represents the fraction of requests that should be /// mirrored to BackendRef. /// @@ -899,13 +899,13 @@ pub struct HTTPRouteRulesBackendRefsFiltersRequestMirror { /// 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 { +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, + 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 @@ -933,7 +933,7 @@ pub struct HTTPRouteFilter { skip_serializing_if = "Option::is_none", rename = "externalAuth" )] - pub external_auth: Option, + pub external_auth: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -958,7 +958,7 @@ pub struct HTTPRouteFilter { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -1021,14 +1021,14 @@ pub struct HTTPRouteFilter { skip_serializing_if = "Option::is_none", rename = "urlRewrite" )] - pub url_rewrite: Option, + 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 { +pub struct HttpRouteRulesFiltersCors { /// AllowCredentials indicates whether the actual cross-origin request allows /// to include credentials. /// @@ -1095,13 +1095,13 @@ pub struct HTTPRouteRulesFiltersCors { /// value `*`, which represents all HTTP methods are allowed. /// /// Method names are case sensitive, so these values are also case-sensitive. - /// (See https://www.rfc-editor.org/rfc/rfc2616#section-5.1.1) + /// (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 https://fetch.spec.whatwg.org/#cors-safelisted-method) The + /// (See The /// CORS-safelisted methods are always allowed, regardless of whether they /// are specified in the `AllowMethods` field. /// @@ -1206,7 +1206,7 @@ pub struct HTTPRouteRulesFiltersCors { /// `Expires` /// `Last-Modified` /// `Pragma` - /// (See https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name) + /// (See /// The CORS-safelisted response headers are exposed to client by default. /// /// When an HTTP header name is specified using the `ExposeHeaders` field, @@ -1250,7 +1250,7 @@ pub struct HTTPRouteRulesFiltersCors { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersExternalAuth { +pub struct HttpRouteRulesFiltersExternalAuth { /// BackendRef is a reference to a backend to send authorization /// requests to. /// @@ -1261,7 +1261,7 @@ pub struct HTTPRouteRulesFiltersExternalAuth { /// implementation to supply the TLS details to be used to connect to that /// backend. #[serde(rename = "backendRef")] - pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// ForwardBody controls if requests to the authorization server should include /// the body of the client request; and if so, how big that body is allowed /// to be. @@ -1280,28 +1280,28 @@ pub struct HTTPRouteRulesFiltersExternalAuth { skip_serializing_if = "Option::is_none", rename = "forwardBody" )] - pub forward_body: Option, + pub forward_body: Option, /// GRPCAuthConfig contains configuration for communication with ext_authz /// protocol-speaking backends. /// /// If unset, implementations must assume the default behavior for each /// included field is intended. #[serde(default, skip_serializing_if = "Option::is_none")] - pub grpc: Option, + pub grpc: Option, /// HTTPAuthConfig contains configuration for communication with HTTP-speaking /// backends. /// /// If unset, implementations must assume the default behavior for each /// included field is intended. #[serde(default, skip_serializing_if = "Option::is_none")] - pub http: Option, + pub http: Option, /// ExternalAuthProtocol describes which protocol to use when communicating with an /// ext_authz authorization server. /// /// When this is set to GRPC, each backend must use the Envoy ext_authz protocol /// on the port specified in `backendRefs`. Requests and responses are defined /// in the protobufs explained at: - /// https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/auth/v3/external_auth.proto + /// /// /// When this is set to HTTP, each backend must respond with a `200` status /// code in on a successful authorization. Any other code is considered @@ -1310,7 +1310,7 @@ pub struct HTTPRouteRulesFiltersExternalAuth { /// Feature Names: /// GRPC Support - HTTPRouteExternalAuthGRPC /// HTTP Support - HTTPRouteExternalAuthHTTP - pub protocol: HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol, + pub protocol: HttpRouteRulesBackendRefsFiltersExternalAuthProtocol, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -1322,7 +1322,7 @@ pub struct HTTPRouteRulesFiltersExternalAuth { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestMirror { +pub struct HttpRouteRulesFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -1347,7 +1347,7 @@ pub struct HTTPRouteRulesFiltersRequestMirror { /// /// Support: Implementation-specific for any other resource #[serde(rename = "backendRef")] - pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, /// Fraction represents the fraction of requests that should be /// mirrored to BackendRef. /// @@ -1459,7 +1459,7 @@ pub struct PathMatch { /// /// Support: Implementation-specific (RegularExpression) #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, + pub r#type: Option, /// Value of the HTTP path to match against. #[serde(default, skip_serializing_if = "Option::is_none")] pub value: Option, @@ -1467,7 +1467,7 @@ pub struct PathMatch { /// 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 { +pub enum HttpRouteRulesMatchesPathType { Exact, PathPrefix, RegularExpression, @@ -1476,7 +1476,7 @@ pub enum HTTPRouteRulesMatchesPathType { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesRetry { +pub struct HttpRouteRulesRetry { /// Attempts specifies the maximum number of times an individual request /// from the gateway to a backend should be retried. /// @@ -1538,7 +1538,7 @@ pub struct HTTPRouteRulesRetry { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteTimeout { +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. diff --git a/gateway-api/src/apis/experimental/tcproutes.rs b/gateway-api/src/apis/experimental/tcproutes.rs index 8bdf31b..a4b960a 100644 --- a/gateway-api/src/apis/experimental/tcproutes.rs +++ b/gateway-api/src/apis/experimental/tcproutes.rs @@ -21,7 +21,7 @@ use self::prelude::*; #[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct TCPRouteSpec { +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 diff --git a/gateway-api/src/apis/experimental/tlsroutes.rs b/gateway-api/src/apis/experimental/tlsroutes.rs index 404e10d..7072cf8 100644 --- a/gateway-api/src/apis/experimental/tlsroutes.rs +++ b/gateway-api/src/apis/experimental/tlsroutes.rs @@ -21,7 +21,7 @@ use self::prelude::*; #[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct TLSRouteSpec { +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: diff --git a/gateway-api/src/apis/experimental/udproutes.rs b/gateway-api/src/apis/experimental/udproutes.rs index 2015192..abc39e6 100644 --- a/gateway-api/src/apis/experimental/udproutes.rs +++ b/gateway-api/src/apis/experimental/udproutes.rs @@ -21,7 +21,7 @@ use self::prelude::*; #[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct UDPRouteSpec { +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 diff --git a/gateway-api/src/apis/standard/common.rs b/gateway-api/src/apis/standard/common.rs index 9e18c8c..6e1e7b1 100644 --- a/gateway-api/src/apis/standard/common.rs +++ b/gateway-api/src/apis/standard/common.rs @@ -62,7 +62,7 @@ pub struct HTTPHeader { pub value: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestMirrorFraction { +pub struct HttpRouteRulesBackendRefsFiltersRequestMirrorFraction { #[serde(default, skip_serializing_if = "Option::is_none")] pub denominator: Option, pub numerator: i32, @@ -162,7 +162,7 @@ pub struct RequestRedirect { pub status_code: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteUrlRewrite { +pub struct HttpRouteUrlRewrite { #[serde(default, skip_serializing_if = "Option::is_none")] pub hostname: Option, #[serde(default, skip_serializing_if = "Option::is_none")] diff --git a/gateway-api/src/apis/standard/constants.rs b/gateway-api/src/apis/standard/constants.rs index ecb0768..bf2a178 100644 --- a/gateway-api/src/apis/standard/constants.rs +++ b/gateway-api/src/apis/standard/constants.rs @@ -88,7 +88,6 @@ impl std::fmt::Display for ListenerConditionReason { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum RouteConditionType { Accepted, @@ -100,7 +99,6 @@ impl std::fmt::Display for RouteConditionType { write!(f, "{:?}", self) } } - #[derive(Debug, PartialEq, Eq)] pub enum RouteConditionReason { Accepted, diff --git a/gateway-api/src/apis/standard/grpcroutes.rs b/gateway-api/src/apis/standard/grpcroutes.rs index 9458ac3..bf60661 100644 --- a/gateway-api/src/apis/standard/grpcroutes.rs +++ b/gateway-api/src/apis/standard/grpcroutes.rs @@ -21,7 +21,7 @@ use self::prelude::*; #[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct GRPCRouteSpec { +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: @@ -132,13 +132,13 @@ pub struct GRPCRouteSpec { 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>, + 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 { +pub struct GrpcRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -198,7 +198,7 @@ pub struct GRPCRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -249,7 +249,7 @@ pub struct GRPCRouteRule { /// 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>, + 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 @@ -270,7 +270,7 @@ pub struct GRPCBackendReference { /// 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>, + 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")] @@ -334,7 +334,7 @@ pub struct GRPCBackendReference { /// 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 { +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 @@ -373,7 +373,7 @@ pub struct GRPCRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -421,7 +421,7 @@ pub struct GRPCRouteRulesBackendRefsFilters { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesBackendRefsFiltersRequestMirror { +pub struct GrpcRouteRulesBackendRefsFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -453,7 +453,7 @@ pub struct GRPCRouteRulesBackendRefsFiltersRequestMirror { /// 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, + 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). @@ -470,7 +470,7 @@ pub struct GRPCRouteRulesBackendRefsFiltersRequestMirror { /// 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 { +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 @@ -509,7 +509,7 @@ pub struct GRPCRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -557,7 +557,7 @@ pub struct GRPCRouteRulesFilters { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteRulesFiltersRequestMirror { +pub struct GrpcRouteRulesFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -589,7 +589,7 @@ pub struct GRPCRouteRulesFiltersRequestMirror { /// 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, + 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). @@ -617,7 +617,7 @@ pub struct GRPCRouteRulesFiltersRequestMirror { /// /// ``` #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GRPCRouteMatch { +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. diff --git a/gateway-api/src/apis/standard/httproutes.rs b/gateway-api/src/apis/standard/httproutes.rs index 18a3972..0058ca0 100644 --- a/gateway-api/src/apis/standard/httproutes.rs +++ b/gateway-api/src/apis/standard/httproutes.rs @@ -21,7 +21,7 @@ use self::prelude::*; #[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] -pub struct HTTPRouteSpec { +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 @@ -135,13 +135,13 @@ pub struct HTTPRouteSpec { 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>, + 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 { +pub struct HttpRouteRule { /// BackendRefs defines the backend(s) where matching requests should be /// sent. /// @@ -220,7 +220,7 @@ pub struct HTTPRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -288,7 +288,7 @@ pub struct HTTPRouteRule { /// /// Support: Extended #[serde(default, skip_serializing_if = "Option::is_none")] - pub timeouts: Option, + pub timeouts: Option, } /// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. /// @@ -304,7 +304,7 @@ pub struct HTTPBackendReference { /// 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>, + 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")] @@ -368,7 +368,7 @@ pub struct HTTPBackendReference { /// 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 { +pub struct HttpRouteBackendFilter { /// 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 @@ -407,7 +407,7 @@ pub struct HTTPRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -470,7 +470,7 @@ pub struct HTTPRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "urlRewrite" )] - pub url_rewrite: Option, + pub url_rewrite: Option, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -482,7 +482,7 @@ pub struct HTTPRouteBackendFilter { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesBackendRefsFiltersRequestMirror { +pub struct HttpRouteRulesBackendRefsFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -514,7 +514,7 @@ pub struct HTTPRouteRulesBackendRefsFiltersRequestMirror { /// 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, + 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). @@ -531,7 +531,7 @@ pub struct HTTPRouteRulesBackendRefsFiltersRequestMirror { /// 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 { +pub struct HttpRouteFilter { /// 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 @@ -570,7 +570,7 @@ pub struct HTTPRouteFilter { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -633,7 +633,7 @@ pub struct HTTPRouteFilter { skip_serializing_if = "Option::is_none", rename = "urlRewrite" )] - pub url_rewrite: Option, + pub url_rewrite: Option, } /// RequestMirror defines a schema for a filter that mirrors requests. /// Requests are sent to the specified destination, but responses from @@ -645,7 +645,7 @@ pub struct HTTPRouteFilter { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteRulesFiltersRequestMirror { +pub struct HttpRouteRulesFiltersRequestMirror { /// BackendRef references a resource where mirrored requests are sent. /// /// Mirrored requests must be sent only to a single destination endpoint @@ -677,7 +677,7 @@ pub struct HTTPRouteRulesFiltersRequestMirror { /// 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, + 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). @@ -782,7 +782,7 @@ pub struct PathMatch { /// /// Support: Implementation-specific (RegularExpression) #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] - pub r#type: Option, + pub r#type: Option, /// Value of the HTTP path to match against. #[serde(default, skip_serializing_if = "Option::is_none")] pub value: Option, @@ -790,7 +790,7 @@ pub struct PathMatch { /// 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 { +pub enum HttpRouteRulesMatchesPathType { Exact, PathPrefix, RegularExpression, @@ -799,7 +799,7 @@ pub enum HTTPRouteRulesMatchesPathType { /// /// Support: Extended #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPRouteTimeout { +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. From b49d618f407d35590ffceee06e61a0fe0c598394 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 20:40:50 -0400 Subject: [PATCH 66/95] test: check more types in integration test Signed-off-by: Shane Utt --- gateway-api/src/lib.rs | 198 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 195 insertions(+), 3 deletions(-) diff --git a/gateway-api/src/lib.rs b/gateway-api/src/lib.rs index 41ea42d..739cf7e 100644 --- a/gateway-api/src/lib.rs +++ b/gateway-api/src/lib.rs @@ -28,14 +28,20 @@ mod tests { use uuid::Uuid; use crate::{ + apis::standard::common::{ParentReference, ParentRouteStatus, RouteStatus}, apis::standard::constants::{ GatewayConditionReason, GatewayConditionType, ListenerConditionReason, - ListenerConditionType, + ListenerConditionType, RouteConditionReason, RouteConditionType, }, apis::standard::gatewayclasses::{GatewayClass, GatewayClassSpec}, apis::standard::gateways::{ Gateway, GatewaySpec, GatewayStatus, GatewayStatusAddresses, GatewayStatusListeners, }, + apis::standard::grpcroutes::GrpcRouteSpec, + apis::standard::httproutes::HttpRouteSpec, + apis::standard::referencegrants::{ + ReferenceGrantFrom, ReferenceGrantSpec, ReferenceGrantTo, + }, }; // ------------------------------------------------------------------------- @@ -44,7 +50,7 @@ mod tests { #[ignore] #[tokio::test] - async fn deploy_gateway() -> Result<(), Error> { + async fn deploy_resources() -> Result<(), Error> { let (client, cluster) = get_client().await?; let info = client.apiserver_version().await?; @@ -114,7 +120,7 @@ mod tests { }]), }; - gw = Api::default_namespaced(client) + gw = Api::default_namespaced(client.clone()) .patch_status( gw.metadata.name.clone().unwrap().as_str(), &PatchParams::default(), @@ -129,6 +135,162 @@ mod tests { assert!(gw.status.clone().unwrap().listeners.is_some()); assert!(gw.status.clone().unwrap().conditions.is_some()); + let mut http_route = crate::apis::standard::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: "test-controller".to_string(), + conditions: vec![Condition { + last_transition_time: Time(Utc::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::apis::standard::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: "test-controller".to_string(), + conditions: vec![Condition { + last_transition_time: Time(Utc::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::apis::standard::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(()) } @@ -191,6 +353,36 @@ mod tests { .create(&PostParams::default(), &gw_crd) .await?; + let mut http_route_crd = crate::apis::standard::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::apis::standard::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::apis::standard::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(()) } From 334c199b497b5205f48828eb3579d3aba1fe7f28 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 21:07:34 -0400 Subject: [PATCH 67/95] chore: add personal TODO lists to .gitignore Signed-off-by: Shane Utt --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 689db3c..1415097 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target *.txt +TODO From cc4d8510bad0b063a6a6541da8c82e81f86e137e Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 21:07:56 -0400 Subject: [PATCH 68/95] test: add testing against upstream standard CRDs Signed-off-by: Shane Utt --- gateway-api/src/lib.rs | 114 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 102 insertions(+), 12 deletions(-) diff --git a/gateway-api/src/lib.rs b/gateway-api/src/lib.rs index 739cf7e..deb32b9 100644 --- a/gateway-api/src/lib.rs +++ b/gateway-api/src/lib.rs @@ -12,7 +12,7 @@ pub use apis::experimental; 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}; @@ -35,7 +35,8 @@ mod tests { }, apis::standard::gatewayclasses::{GatewayClass, GatewayClassSpec}, apis::standard::gateways::{ - Gateway, GatewaySpec, GatewayStatus, GatewayStatusAddresses, GatewayStatusListeners, + Gateway, GatewayListeners, GatewaySpec, GatewayStatus, GatewayStatusAddresses, + GatewayStatusListeners, }, apis::standard::grpcroutes::GrpcRouteSpec, apis::standard::httproutes::HttpRouteSpec, @@ -44,14 +45,34 @@ mod tests { }, }; + const DEFAULT_GATEWAY_API_VERSION: &str = "v1.4.0"; + // ------------------------------------------------------------------------- // Tests // ------------------------------------------------------------------------- #[ignore] #[tokio::test] - async fn deploy_resources() -> 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!( + "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!( @@ -59,10 +80,22 @@ mod tests { 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, }, @@ -83,7 +116,16 @@ 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, }, status: None, }; @@ -96,9 +138,12 @@ mod tests { assert!(gw.metadata.uid.is_some()); let gw_status = GatewayStatus { - addresses: Some(vec![GatewayStatusAddresses::default()]), + addresses: Some(vec![GatewayStatusAddresses { + r#type: Some("IPAddress".to_string()), + value: "10.0.0.1".to_string(), + }]), listeners: Some(vec![GatewayStatusListeners { - name: "tcp".into(), + name: "http".into(), attached_routes: 0, supported_kinds: vec![], conditions: vec![Condition { @@ -171,7 +216,7 @@ mod tests { section_name: None, port: None, }, - controller_name: "test-controller".to_string(), + controller_name: "example.com/gateway-controller".to_string(), conditions: vec![Condition { last_transition_time: Time(Utc::now()), message: "testing http route".to_string(), @@ -232,7 +277,7 @@ mod tests { section_name: None, port: None, }, - controller_name: "test-controller".to_string(), + controller_name: "example.com/gateway-controller".to_string(), conditions: vec![Condition { last_transition_time: Time(Utc::now()), message: "testing grpc route".to_string(), @@ -310,7 +355,7 @@ mod tests { } } - 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)?; @@ -327,11 +372,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([( From 54fb4fbad0b91492191af7ec5e9f5d218abcb360 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 21:15:02 -0400 Subject: [PATCH 69/95] chore: change gwapi version var name in update.sh Signed-off-by: Shane Utt --- update.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/update.sh b/update.sh index 2da042e..cb1ec74 100755 --- a/update.sh +++ b/update.sh @@ -2,7 +2,8 @@ # ------------------------------------------------------------------------------ # This script will automatically generate API updates for new Gateway API -# releases. Update the $VERSION to the new release version before executing. +# releases. Update the $GATEWAY_API_VERSION to the new release version before +# executing. # # This script requires kopium, which can be installed with: # @@ -13,7 +14,8 @@ set -eou pipefail -VERSION="v1.4.0" +GATEWAY_API_VERSION="v1.4.0" +echo "Using Gateway API version ${GATEWAY_API_VERSION}" STANDARD_APIS=( gatewayclasses @@ -53,7 +55,7 @@ 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 + 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 @@ -99,7 +101,7 @@ 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 + 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 From 35694e97898037fb6976d8d32c1353f9af5685f5 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 21:15:33 -0400 Subject: [PATCH 70/95] feat: add a kopium version check to update.sh Signed-off-by: Shane Utt --- update.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/update.sh b/update.sh index cb1ec74..abd0ea5 100755 --- a/update.sh +++ b/update.sh @@ -15,6 +15,26 @@ set -eou pipefail GATEWAY_API_VERSION="v1.4.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=( From efe59a3b0a212e2c30103a088f77c38cb901b13b Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 21:16:25 -0400 Subject: [PATCH 71/95] test: add generator checks to CI Signed-off-by: Shane Utt --- .github/workflows/test.yaml | 93 +++++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6ea7a24..07e8c27 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -3,54 +3,77 @@ name: tests on: pull_request: branches: - - '*' + - "*" push: branches: - - 'main' + - "main" tags: - - '*' + - "*" workflow_dispatch: {} jobs: - unit-tests: + generators: 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: 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 From 7af45499a8bd52b75133046a9eb6ec7ac16db32a Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 21:31:30 -0400 Subject: [PATCH 72/95] fix: sort directory entries for deterministic generation order Signed-off-by: Shane Utt --- type-reducer/experimental_ignorable_mapped_names.txt | 2 ++ type-reducer/src/main.rs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/type-reducer/experimental_ignorable_mapped_names.txt b/type-reducer/experimental_ignorable_mapped_names.txt index 79cdc4f..b38f712 100644 --- a/type-reducer/experimental_ignorable_mapped_names.txt +++ b/type-reducer/experimental_ignorable_mapped_names.txt @@ -1,2 +1,4 @@ TcpRouteSpec->RouteSpec UdpRouteSpec->RouteSpec +GrpcRouteRulesFilters->GrpcRouteFilter +GrpcRouteRulesBackendRefsFilters->GrpcRouteFilter diff --git a/type-reducer/src/main.rs b/type-reducer/src/main.rs index 8f8684c..9e2f99e 100644 --- a/type-reducer/src/main.rs +++ b/type-reducer/src/main.rs @@ -266,11 +266,11 @@ fn create_visitors<'a>( ) -> Result, syn::File)>, Box> { let mut visitors = vec![]; - for dir_entry in fs::read_dir(apis_dir)? { - let Ok(dir_entry) = dir_entry else { - continue; - }; + // 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() { if name.ends_with(".rs") && name != "mod.rs" { info!("Adding file {:?}", dir_entry.path()); From a1defee3c582217ba9fed46ede042a8470a8432c Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 22:25:59 -0400 Subject: [PATCH 73/95] fix: typo for ParentRef in type-reducer conf Signed-off-by: Shane Utt --- type-reducer/standard_reduced_types_pass_2.txt | 2 +- type-reducer/standard_reduced_types_pass_3.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/type-reducer/standard_reduced_types_pass_2.txt b/type-reducer/standard_reduced_types_pass_2.txt index 145b480..2e86418 100644 --- a/type-reducer/standard_reduced_types_pass_2.txt +++ b/type-reducer/standard_reduced_types_pass_2.txt @@ -3,7 +3,7 @@ GRPCFilterType GatewayAddress GatewayInfrastructureParametersReference Kind -ParentReferenceerence +ParentReference FilterExtensionReference HTTPHeader RequestMirrorReference diff --git a/type-reducer/standard_reduced_types_pass_3.txt b/type-reducer/standard_reduced_types_pass_3.txt index c2cea00..2f75a65 100644 --- a/type-reducer/standard_reduced_types_pass_3.txt +++ b/type-reducer/standard_reduced_types_pass_3.txt @@ -3,7 +3,7 @@ GRPCFilterType GatewayAddress GatewayInfrastructureParametersReference Kind -ParentReferenceerence +ParentReference FilterExtensionReference HTTPHeader RequestMirrorReference From fcf5e23ddf8ff69311a4227f5f2475b8b51d7ca2 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 22:27:25 -0400 Subject: [PATCH 74/95] fix: use BackendObjectReference for combined ref type Signed-off-by: Shane Utt --- type-reducer/experimental_customized_mapped_names.txt | 8 ++++---- type-reducer/experimental_reduced_types_pass_1.txt | 2 +- type-reducer/experimental_reduced_types_pass_2.txt | 2 +- type-reducer/experimental_reduced_types_pass_3.txt | 2 +- type-reducer/experimental_reduced_types_pass_4.txt | 2 +- type-reducer/standard_customized_mapped_names.txt | 8 ++++---- type-reducer/standard_reduced_types_pass_1.txt | 2 +- type-reducer/standard_reduced_types_pass_2.txt | 2 +- type-reducer/standard_reduced_types_pass_3.txt | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/type-reducer/experimental_customized_mapped_names.txt b/type-reducer/experimental_customized_mapped_names.txt index 6703855..d781b46 100644 --- a/type-reducer/experimental_customized_mapped_names.txt +++ b/type-reducer/experimental_customized_mapped_names.txt @@ -45,10 +45,10 @@ GatewayListenersAllowedRoutesKinds->Kind GatewayStatusListenersSupportedKinds->Kind HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode->RedirectStatusCode HttpRouteRulesFiltersRequestRedirectStatusCode->RedirectStatusCode -GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference -GrpcRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference -HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference -HttpRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference +GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference +GrpcRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference +HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference +HttpRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference HttpRouteRulesBackendRefsFiltersRequestRedirectPathType->RequestOperationType HttpRouteRulesBackendRefsFiltersUrlRewritePathType->RequestOperationType HttpRouteRulesFiltersRequestRedirectPathType->RequestOperationType diff --git a/type-reducer/experimental_reduced_types_pass_1.txt b/type-reducer/experimental_reduced_types_pass_1.txt index 9fe55af..5a97edc 100644 --- a/type-reducer/experimental_reduced_types_pass_1.txt +++ b/type-reducer/experimental_reduced_types_pass_1.txt @@ -12,7 +12,7 @@ HTTPHeader HeaderMatchType Kind RedirectStatusCode -RequestMirrorReference +BackendObjectReference RequestOperationType RequestRedirectScheme ParentReference diff --git a/type-reducer/experimental_reduced_types_pass_2.txt b/type-reducer/experimental_reduced_types_pass_2.txt index 402636a..69a5e9a 100644 --- a/type-reducer/experimental_reduced_types_pass_2.txt +++ b/type-reducer/experimental_reduced_types_pass_2.txt @@ -12,7 +12,7 @@ HTTPHeader HeaderMatchType Kind RedirectStatusCode -RequestMirrorReference +BackendObjectReference RequestOperationType RequestRedirectScheme ParentReference diff --git a/type-reducer/experimental_reduced_types_pass_3.txt b/type-reducer/experimental_reduced_types_pass_3.txt index 9b81525..7dff0f6 100644 --- a/type-reducer/experimental_reduced_types_pass_3.txt +++ b/type-reducer/experimental_reduced_types_pass_3.txt @@ -12,7 +12,7 @@ HTTPHeader HeaderMatchType Kind RedirectStatusCode -RequestMirrorReference +BackendObjectReference RequestOperationType RequestRedirectScheme ParentReference diff --git a/type-reducer/experimental_reduced_types_pass_4.txt b/type-reducer/experimental_reduced_types_pass_4.txt index 0834e9c..5fbcf04 100644 --- a/type-reducer/experimental_reduced_types_pass_4.txt +++ b/type-reducer/experimental_reduced_types_pass_4.txt @@ -12,7 +12,7 @@ HTTPHeader HeaderMatchType Kind RedirectStatusCode -RequestMirrorReference +BackendObjectReference RequestOperationType RequestRedirectScheme ParentReference diff --git a/type-reducer/standard_customized_mapped_names.txt b/type-reducer/standard_customized_mapped_names.txt index 0ffb3bb..673d6e9 100644 --- a/type-reducer/standard_customized_mapped_names.txt +++ b/type-reducer/standard_customized_mapped_names.txt @@ -33,10 +33,10 @@ HttpRouteRulesFiltersRequestHeaderModifierAdd->HTTPHeader HttpRouteRulesFiltersRequestHeaderModifierSet->HTTPHeader HttpRouteRulesFiltersResponseHeaderModifierAdd->HTTPHeader HttpRouteRulesFiltersResponseHeaderModifierSet->HTTPHeader -GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference -GrpcRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference -HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->RequestMirrorReference -HttpRouteRulesFiltersRequestMirrorBackendRef->RequestMirrorReference +GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference +GrpcRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference +HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference +HttpRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference HttpRouteRulesBackendRefsFiltersRequestRedirectPathType->RequestOperationType HttpRouteRulesBackendRefsFiltersUrlRewritePathType->RequestOperationType HttpRouteRulesFiltersRequestRedirectPathType->RequestOperationType diff --git a/type-reducer/standard_reduced_types_pass_1.txt b/type-reducer/standard_reduced_types_pass_1.txt index 312e0e4..3e46252 100644 --- a/type-reducer/standard_reduced_types_pass_1.txt +++ b/type-reducer/standard_reduced_types_pass_1.txt @@ -6,7 +6,7 @@ Kind ParentReference FilterExtensionReference HTTPHeader -RequestMirrorReference +BackendObjectReference RequestOperationType RequestRedirectScheme RedirectStatusCode diff --git a/type-reducer/standard_reduced_types_pass_2.txt b/type-reducer/standard_reduced_types_pass_2.txt index 2e86418..9e2371e 100644 --- a/type-reducer/standard_reduced_types_pass_2.txt +++ b/type-reducer/standard_reduced_types_pass_2.txt @@ -6,7 +6,7 @@ Kind ParentReference FilterExtensionReference HTTPHeader -RequestMirrorReference +BackendObjectReference RequestOperationType RequestRedirectScheme RedirectStatusCode diff --git a/type-reducer/standard_reduced_types_pass_3.txt b/type-reducer/standard_reduced_types_pass_3.txt index 2f75a65..5099dcd 100644 --- a/type-reducer/standard_reduced_types_pass_3.txt +++ b/type-reducer/standard_reduced_types_pass_3.txt @@ -6,7 +6,7 @@ Kind ParentReference FilterExtensionReference HTTPHeader -RequestMirrorReference +BackendObjectReference RequestOperationType RequestRedirectScheme RedirectStatusCode From c3de8224fa44d18a64988fff2ca8632783c0dd7a Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 22:27:53 -0400 Subject: [PATCH 75/95] fix: add combined RequestMirrorFraction type for HTTPRoute and GRPCRoute Signed-off-by: Shane Utt --- type-reducer/experimental_customized_mapped_names.txt | 4 ++++ type-reducer/standard_customized_mapped_names.txt | 4 ++++ type-reducer/standard_reduced_types_pass_1.txt | 1 + type-reducer/standard_reduced_types_pass_2.txt | 1 + type-reducer/standard_reduced_types_pass_3.txt | 1 + 5 files changed, 11 insertions(+) diff --git a/type-reducer/experimental_customized_mapped_names.txt b/type-reducer/experimental_customized_mapped_names.txt index d781b46..e041d84 100644 --- a/type-reducer/experimental_customized_mapped_names.txt +++ b/type-reducer/experimental_customized_mapped_names.txt @@ -49,6 +49,10 @@ GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference GrpcRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference HttpRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference +GrpcRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +GrpcRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction HttpRouteRulesBackendRefsFiltersRequestRedirectPathType->RequestOperationType HttpRouteRulesBackendRefsFiltersUrlRewritePathType->RequestOperationType HttpRouteRulesFiltersRequestRedirectPathType->RequestOperationType diff --git a/type-reducer/standard_customized_mapped_names.txt b/type-reducer/standard_customized_mapped_names.txt index 673d6e9..9a6aaa3 100644 --- a/type-reducer/standard_customized_mapped_names.txt +++ b/type-reducer/standard_customized_mapped_names.txt @@ -37,6 +37,10 @@ GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference GrpcRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference HttpRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference +GrpcRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +GrpcRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction +HttpRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction HttpRouteRulesBackendRefsFiltersRequestRedirectPathType->RequestOperationType HttpRouteRulesBackendRefsFiltersUrlRewritePathType->RequestOperationType HttpRouteRulesFiltersRequestRedirectPathType->RequestOperationType diff --git a/type-reducer/standard_reduced_types_pass_1.txt b/type-reducer/standard_reduced_types_pass_1.txt index 3e46252..39be6d8 100644 --- a/type-reducer/standard_reduced_types_pass_1.txt +++ b/type-reducer/standard_reduced_types_pass_1.txt @@ -7,6 +7,7 @@ ParentReference FilterExtensionReference HTTPHeader BackendObjectReference +RequestMirrorFraction RequestOperationType RequestRedirectScheme RedirectStatusCode diff --git a/type-reducer/standard_reduced_types_pass_2.txt b/type-reducer/standard_reduced_types_pass_2.txt index 9e2371e..b5e5487 100644 --- a/type-reducer/standard_reduced_types_pass_2.txt +++ b/type-reducer/standard_reduced_types_pass_2.txt @@ -7,6 +7,7 @@ ParentReference FilterExtensionReference HTTPHeader BackendObjectReference +RequestMirrorFraction RequestOperationType RequestRedirectScheme RedirectStatusCode diff --git a/type-reducer/standard_reduced_types_pass_3.txt b/type-reducer/standard_reduced_types_pass_3.txt index 5099dcd..4577515 100644 --- a/type-reducer/standard_reduced_types_pass_3.txt +++ b/type-reducer/standard_reduced_types_pass_3.txt @@ -7,6 +7,7 @@ ParentReference FilterExtensionReference HTTPHeader BackendObjectReference +RequestMirrorFraction RequestOperationType RequestRedirectScheme RedirectStatusCode From 3042703542630b836d4eff7d48d07253c51c288f Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 22:28:10 -0400 Subject: [PATCH 76/95] chore: run generators Signed-off-by: Shane Utt --- gateway-api/src/apis/experimental/common.rs | 33 ++- .../src/apis/experimental/grpcroutes.rs | 108 +------ .../src/apis/experimental/httproutes.rs | 112 +------ gateway-api/src/apis/standard/common.rs | 68 ++++- gateway-api/src/apis/standard/grpcroutes.rs | 276 +----------------- gateway-api/src/apis/standard/httproutes.rs | 108 +------ 6 files changed, 84 insertions(+), 621 deletions(-) diff --git a/gateway-api/src/apis/experimental/common.rs b/gateway-api/src/apis/experimental/common.rs index 3e5f602..7ad4f9b 100644 --- a/gateway-api/src/apis/experimental/common.rs +++ b/gateway-api/src/apis/experimental/common.rs @@ -81,6 +81,18 @@ pub enum SessionPersistenceType { Header, } #[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 BackendReference { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, @@ -123,18 +135,6 @@ pub struct HTTPHeader { pub value: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef { - #[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 HttpRouteRulesBackendRefsFiltersExternalAuthForwardBody { #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxSize")] pub max_size: Option, @@ -235,6 +235,15 @@ pub struct ParentRouteStatus { 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, diff --git a/gateway-api/src/apis/experimental/grpcroutes.rs b/gateway-api/src/apis/experimental/grpcroutes.rs index 46be258..59dbbcb 100644 --- a/gateway-api/src/apis/experimental/grpcroutes.rs +++ b/gateway-api/src/apis/experimental/grpcroutes.rs @@ -427,7 +427,7 @@ pub struct GrpcRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -465,58 +465,6 @@ pub struct GrpcRouteRulesBackendRefsFilters { #[serde(rename = "type")] pub r#type: GRPCFilterType, } -/// 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: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, - /// 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, -} /// 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 @@ -563,7 +511,7 @@ pub struct GrpcRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -601,58 +549,6 @@ pub struct GrpcRouteRulesFilters { #[serde(rename = "type")] pub r#type: GRPCFilterType, } -/// 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: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, - /// 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, -} /// 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. diff --git a/gateway-api/src/apis/experimental/httproutes.rs b/gateway-api/src/apis/experimental/httproutes.rs index 16b9159..e85b0c6 100644 --- a/gateway-api/src/apis/experimental/httproutes.rs +++ b/gateway-api/src/apis/experimental/httproutes.rs @@ -486,7 +486,7 @@ pub struct HttpRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -789,7 +789,7 @@ pub struct HttpRouteRulesBackendRefsFiltersExternalAuth { /// implementation to supply the TLS details to be used to connect to that /// backend. #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: BackendObjectReference, /// ForwardBody controls if requests to the authorization server should include /// the body of the client request; and if so, how big that body is allowed /// to be. @@ -840,58 +840,6 @@ pub struct HttpRouteRulesBackendRefsFiltersExternalAuth { /// HTTP Support - HTTPRouteExternalAuthHTTP pub protocol: HttpRouteRulesBackendRefsFiltersExternalAuthProtocol, } -/// 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: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, - /// 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, -} /// 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 @@ -958,7 +906,7 @@ pub struct HttpRouteFilter { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -1261,7 +1209,7 @@ pub struct HttpRouteRulesFiltersExternalAuth { /// implementation to supply the TLS details to be used to connect to that /// backend. #[serde(rename = "backendRef")] - pub backend_ref: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, + pub backend_ref: BackendObjectReference, /// ForwardBody controls if requests to the authorization server should include /// the body of the client request; and if so, how big that body is allowed /// to be. @@ -1312,58 +1260,6 @@ pub struct HttpRouteRulesFiltersExternalAuth { /// HTTP Support - HTTPRouteExternalAuthHTTP pub protocol: HttpRouteRulesBackendRefsFiltersExternalAuthProtocol, } -/// 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: HttpRouteRulesBackendRefsFiltersExternalAuthBackendRef, - /// 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, -} /// 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. diff --git a/gateway-api/src/apis/standard/common.rs b/gateway-api/src/apis/standard/common.rs index 6e1e7b1..1dfb50f 100644 --- a/gateway-api/src/apis/standard/common.rs +++ b/gateway-api/src/apis/standard/common.rs @@ -51,6 +51,18 @@ pub enum RequestRedirectScheme { Https, } #[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 GatewayInfrastructureParametersReference { pub group: String, pub kind: String, @@ -62,12 +74,6 @@ pub struct HTTPHeader { pub value: String, } #[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, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct Kind { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, @@ -92,16 +98,10 @@ pub struct ParentReference { pub section_name: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct RequestMirrorReference { - #[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, +pub struct RequestMirrorFraction { #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, + pub denominator: Option, + pub numerator: i32, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct HeaderMatch { @@ -128,6 +128,15 @@ pub struct ParentRouteStatus { 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, @@ -145,6 +154,35 @@ pub struct RequestRedirectPath { pub r#type: RequestOperationType, } #[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 RequestRedirect { #[serde(default, skip_serializing_if = "Option::is_none")] pub hostname: Option, diff --git a/gateway-api/src/apis/standard/grpcroutes.rs b/gateway-api/src/apis/standard/grpcroutes.rs index bf60661..df1713b 100644 --- a/gateway-api/src/apis/standard/grpcroutes.rs +++ b/gateway-api/src/apis/standard/grpcroutes.rs @@ -198,7 +198,7 @@ pub struct GrpcRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -270,7 +270,7 @@ pub struct GRPCBackendReference { /// 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>, + 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")] @@ -327,278 +327,6 @@ pub struct GRPCBackendReference { #[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: GRPCFilterType, -} -/// 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: RequestMirrorReference, - /// 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, -} -/// 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: GRPCFilterType, -} -/// 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: RequestMirrorReference, - /// 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, -} /// 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. diff --git a/gateway-api/src/apis/standard/httproutes.rs b/gateway-api/src/apis/standard/httproutes.rs index 0058ca0..7ef2118 100644 --- a/gateway-api/src/apis/standard/httproutes.rs +++ b/gateway-api/src/apis/standard/httproutes.rs @@ -407,7 +407,7 @@ pub struct HttpRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -472,58 +472,6 @@ pub struct HttpRouteBackendFilter { )] pub url_rewrite: 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 -#[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: RequestMirrorReference, - /// 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, -} /// 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 @@ -570,7 +518,7 @@ pub struct HttpRouteFilter { skip_serializing_if = "Option::is_none", rename = "requestMirror" )] - pub request_mirror: Option, + pub request_mirror: Option, /// RequestRedirect defines a schema for a filter that responds to the /// request with an HTTP redirection. /// @@ -635,58 +583,6 @@ pub struct HttpRouteFilter { )] pub url_rewrite: 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 -#[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: RequestMirrorReference, - /// 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, -} /// 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. From dee97b623308cd2acd909ccdb02a57951e922c74 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 22:30:00 -0400 Subject: [PATCH 77/95] chore: cargo update Signed-off-by: Shane Utt --- Cargo.lock | 74 ++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index caf7589..b134eb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 4 [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] @@ -114,9 +114,9 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cc" -version = "1.2.41" +version = "1.2.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7" +checksum = "739eb0f94557554b3ca9a86d2d37bebd49c5e6d0c1d2bda35ba5bdac830befc2" dependencies = [ "find-msvc-tools", "shlex", @@ -140,9 +140,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.50" +version = "4.5.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623" +checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5" dependencies = [ "clap_builder", "clap_derive", @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.50" +version = "4.5.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0" +checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a" dependencies = [ "anstream", "anstyle", @@ -285,9 +285,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41953f86f8a05768a6cda24def994fd2f424b04ec5c719cf89989779f199071" +checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" dependencies = [ "powerfmt", ] @@ -524,11 +524,11 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "home" -version = "0.5.11" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -693,9 +693,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" -version = "0.3.81" +version = "0.3.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305" +checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" dependencies = [ "once_cell", "wasm-bindgen", @@ -1180,9 +1180,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.33" +version = "0.23.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "751e04a496ca00bb97a5e043158d23d66b5aabf2e1d5aa2a0aaebb1aafe6f82c" +checksum = "6a9586e9ee2b4f8fab52a0048ca7334d7024eef48e2cb9407e3497bb7cab7fa7" dependencies = [ "log", "once_cell", @@ -1207,18 +1207,18 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +checksum = "94182ad936a0c91c324cd46c6511b9510ed16af436d7b5bab34beab0afd55f7a" dependencies = [ "zeroize", ] [[package]] name = "rustls-webpki" -version = "0.103.7" +version = "0.103.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10b3f4191e8a80e6b43eebabfac91e5dcecebb27a71f04e820c47ec41d314bf" +checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" dependencies = [ "ring", "rustls-pki-types", @@ -1808,9 +1808,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.104" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d" +checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" dependencies = [ "cfg-if", "once_cell", @@ -1819,25 +1819,11 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - [[package]] name = "wasm-bindgen-macro" -version = "0.2.104" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119" +checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1845,22 +1831,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.104" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" +checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" dependencies = [ + "bumpalo", "proc-macro2", "quote", "syn", - "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.104" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1" +checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" dependencies = [ "unicode-ident", ] From fbb4ed44f6c1acb7d9aa90d7a3b58217451d9e99 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 22:54:11 -0400 Subject: [PATCH 78/95] fix: typo in update.sh Signed-off-by: Shane Utt --- update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.sh b/update.sh index abd0ea5..c579005 100755 --- a/update.sh +++ b/update.sh @@ -96,7 +96,7 @@ 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. +# 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 From 84468d20826b6b26ac21a36a970076b440654032 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Wed, 29 Oct 2025 23:07:56 -0400 Subject: [PATCH 79/95] fix: print enums with defaults during generation Signed-off-by: Shane Utt --- xtask/src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 3508423..84406bb 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -122,5 +122,7 @@ fn get_enums_with_defaults_map(env_var_val: String) -> BTreeMap ); }); + eprintln!("Enums with defaults: {:#?}", &enums_with_defaults); + enums_with_defaults } From 845bd035f65cf1cc1b4becd4f9e7302890894818 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Thu, 30 Oct 2025 09:39:29 -0400 Subject: [PATCH 80/95] docs: add v0.18.0 and v0.19.0 to the CHANGELOG.md Signed-off-by: Shane Utt --- gateway-api/CHANGELOG.md | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/gateway-api/CHANGELOG.md b/gateway-api/CHANGELOG.md index c02573c..6b69549 100644 --- a/gateway-api/CHANGELOG.md +++ b/gateway-api/CHANGELOG.md @@ -4,28 +4,39 @@ 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.17.0 +## 0.19.0 -Supports: Gateway API `v1.2.1` +Supports: Gateway API `v1.4.0` ->[!IMPORTANT] -Breaking change +### Changes -### Breaking Changes +* Updated to Gateway API `v1.4.0` +* Adds support for `BackendTLSPolicy` -* 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. +## 0.18.0 + +Supports: Gateway API `v1.2.1` ### Changes -* Updated to Gateway API `v1.2.1` +* Updated to [kube](https://github.com/kube-rs/kube) `v2.0.1` ## 0.16.0 -### Changed +Supports: Gateway API `v1.2.1` + +### Changes Initial release. All types are generated with Kopium. From b429098f56bba15a4cf88a9076872d7aec0e34b9 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Thu, 30 Oct 2025 09:51:25 -0400 Subject: [PATCH 81/95] chore: bump version to 0.19.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4c1a218..313100e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ resolver = "2" authors = ["kube-rs project (https://kube.rs)"] edition = "2024" license = "MIT" -version = "0.16.0" +version = "0.19.0" [workspace.dependencies] anyhow = "1.0.100" From d12cb0b90f9124c777fa9737de5b6de6bb27668e Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Thu, 30 Oct 2025 09:52:30 -0400 Subject: [PATCH 82/95] chore: cargo update --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b134eb6..2b7acfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -336,7 +336,7 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "enum_default_generator" -version = "0.16.0" +version = "0.19.0" dependencies = [ "codegen", ] @@ -435,7 +435,7 @@ dependencies = [ [[package]] name = "gateway-api" -version = "0.16.0" +version = "0.19.0" dependencies = [ "anyhow", "delegate", @@ -457,7 +457,7 @@ dependencies = [ [[package]] name = "gateway-api-examples" -version = "0.16.0" +version = "0.19.0" dependencies = [ "anyhow", "gateway-api", @@ -1710,7 +1710,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "type-reducer" -version = "0.16.0" +version = "0.19.0" dependencies = [ "clap", "itertools", @@ -1736,9 +1736,9 @@ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-ident" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "unsafe-libyaml" From bacb6b918e80b37644ab246b1be86640aab26db2 Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Thu, 30 Oct 2025 10:04:31 -0400 Subject: [PATCH 83/95] docs: update README.md --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dea7cef..e42a383 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,16 @@ ## Usage -Basic usage involves using a [kube-rs Client] to perform operations on -[Gateway API resources]. You can either use a basic `Client` to perform -operations, or you can build a [Controller]. See the `gateway-api/examples/` -directory for 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 Client]:https://docs.rs/kube/latest/kube/struct.Client.html +[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 From f0c0deb721263bc4c02bec995fffe02ecbf08a1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Nov 2025 16:38:38 -0500 Subject: [PATCH 84/95] chore(deps): bump schemars from 1.0.4 to 1.0.5 (#198) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b7acfe..c19ed36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1248,9 +1248,9 @@ dependencies = [ [[package]] name = "schemars" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +checksum = "1317c3bf3e7df961da95b0a56a172a02abead31276215a0497241a7624b487ce" dependencies = [ "dyn-clone", "ref-cast", @@ -1261,9 +1261,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80" +checksum = "5f760a6150d45dd66ec044983c124595ae76912e77ed0b44124cb3e415cce5d9" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 313100e..2d88db2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ kube-derive = { version = "2.0.1" } k8s-openapi = { version = "0.26.0" } once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.8" } -schemars = "1.0.4" +schemars = "1.0.5" serde_json = "1.0.145" serde = { version = "1.0.228", features = ["derive"] } serde_yaml = "0.9.34" From d100d006c9df6d9807a3af668c69fc1b4f415a5b Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 13 Jan 2026 08:02:04 -0500 Subject: [PATCH 85/95] chore: upgrade dependencies Signed-off-by: Shane Utt --- Cargo.lock | 294 +++++++++++++++++++++++++++++------------------------ Cargo.toml | 20 ++-- 2 files changed, 173 insertions(+), 141 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c19ed36..665b184 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,22 +43,22 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.10" +version = "3.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -102,21 +102,21 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.19.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" [[package]] name = "cc" -version = "1.2.43" +version = "1.2.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "739eb0f94557554b3ca9a86d2d37bebd49c5e6d0c1d2bda35ba5bdac830befc2" +checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3" dependencies = [ "find-msvc-tools", "shlex", @@ -140,9 +140,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.51" +version = "4.5.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5" +checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" dependencies = [ "clap_builder", "clap_derive", @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.51" +version = "4.5.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a" +checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" dependencies = [ "anstream", "anstyle", @@ -174,9 +174,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" +checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32" [[package]] name = "codegen" @@ -229,9 +229,9 @@ dependencies = [ [[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", @@ -274,9 +274,9 @@ dependencies = [ [[package]] name = "delegate" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6178a82cf56c836a3ba61a7935cdb1c49bfaa6fa4327cd5bf554a503087de26b" +checksum = "780eb241654bf097afb00fc5f054a09b687dad862e485fdcf8399bb056565370" dependencies = [ "proc-macro2", "quote", @@ -294,21 +294,22 @@ dependencies = [ [[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", ] @@ -347,11 +348,21 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + [[package]] name = "find-msvc-tools" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" +checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" [[package]] name = "fnv" @@ -473,9 +484,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.9" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -483,9 +494,9 @@ 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", @@ -512,9 +523,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" [[package]] name = "heck" @@ -533,12 +544,11 @@ dependencies = [ [[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", ] @@ -573,9 +583,9 @@ checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "hyper" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" dependencies = [ "atomic-waker", "bytes", @@ -625,9 +635,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.17" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" +checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" dependencies = [ "bytes", "futures-channel", @@ -662,12 +672,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.12.0" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown 0.16.1", ] [[package]] @@ -687,15 +697,15 @@ dependencies = [ [[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 = "js-sys" -version = "0.3.82" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" dependencies = [ "once_cell", "wasm-bindgen", @@ -716,9 +726,9 @@ dependencies = [ [[package]] name = "k8s-openapi" -version = "0.26.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d13f06d5326a915becaffabdfab75051b8cdc260c2a5c06c0e90226ede89a692" +checksum = "06d9e5e61dd037cdc51da0d7e2b2be10f497478ea7e120d85dad632adb99882b" dependencies = [ "base64", "chrono", @@ -814,9 +824,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.177" +version = "0.2.180" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" [[package]] name = "lock_api" @@ -829,11 +839,11 @@ dependencies = [ [[package]] name = "log" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" dependencies = [ - "serde", + "serde_core", ] [[package]] @@ -850,9 +860,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mio" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" dependencies = [ "libc", "wasi", @@ -915,9 +925,9 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "openssl-probe" -version = "0.1.6" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +checksum = "9f50d9b3dabb09ecd771ad0aa242ca6894994c130308ca3d7684634df8037391" [[package]] name = "ordered-float" @@ -969,9 +979,9 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pest" -version = "2.8.3" +version = "2.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "989e7521a040efde50c3ab6bbadafbe15ab6dc042686926be59ac35d74607df4" +checksum = "2c9eb05c21a464ea704b53158d358a31e6425db2f63a1a7312268b05fe2b75f7" dependencies = [ "memchr", "ucd-trie", @@ -979,9 +989,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.8.3" +version = "2.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187da9a3030dbafabbbfb20cb323b976dc7b7ce91fcd84f2f74d6e31d378e2de" +checksum = "68f9dbced329c441fa79d80472764b1a2c7e57123553b8519b36663a2fb234ed" dependencies = [ "pest", "pest_generator", @@ -989,9 +999,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.3" +version = "2.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b401d98f5757ebe97a26085998d6c0eecec4995cad6ab7fc30ffdf4b052843" +checksum = "3bb96d5051a78f44f43c8f712d8e810adb0ebf923fc9ed2655a7f66f63ba8ee5" dependencies = [ "pest", "pest_meta", @@ -1002,9 +1012,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.8.3" +version = "2.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f27a2cfee9f9039c4d86faa5af122a0ac3851441a34865b8a043b46be0065a" +checksum = "602113b5b5e8621770cfd490cfd90b9f84ab29bd2b0e49ad83eb6d186cef2365" dependencies = [ "pest", "sha2", @@ -1049,18 +1059,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.103" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.41" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" +checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" dependencies = [ "proc-macro2", ] @@ -1093,9 +1103,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" dependencies = [ "getrandom 0.3.4", ] @@ -1172,17 +1182,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_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + [[package]] name = "rustls" -version = "0.23.34" +version = "0.23.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9586e9ee2b4f8fab52a0048ca7334d7024eef48e2cb9407e3497bb7cab7fa7" +checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b" dependencies = [ "log", "once_cell", @@ -1195,9 +1214,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923" +checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63" dependencies = [ "openssl-probe", "rustls-pki-types", @@ -1207,9 +1226,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.13.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94182ad936a0c91c324cd46c6511b9510ed16af436d7b5bab34beab0afd55f7a" +checksum = "21e6f2ab2928ca4291b86736a8bd920a277a399bba1589409d72154ff87c1282" dependencies = [ "zeroize", ] @@ -1233,9 +1252,9 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" [[package]] name = "schannel" @@ -1248,9 +1267,9 @@ dependencies = [ [[package]] name = "schemars" -version = "1.0.5" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1317c3bf3e7df961da95b0a56a172a02abead31276215a0497241a7624b487ce" +checksum = "54e910108742c57a770f492731f99be216a52fadd361b06c8fb59d74ccc267d2" dependencies = [ "dyn-clone", "ref-cast", @@ -1261,9 +1280,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "1.0.5" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f760a6150d45dd66ec044983c124595ae76912e77ed0b44124cb3e415cce5d9" +checksum = "4908ad288c5035a8eb12cfdf0d49270def0a268ee162b75eeee0f85d155a7c45" dependencies = [ "proc-macro2", "quote", @@ -1309,6 +1328,12 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + [[package]] name = "serde" version = "1.0.228" @@ -1362,15 +1387,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.145" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ "itoa", "memchr", - "ryu", "serde", "serde_core", + "zmij", ] [[package]] @@ -1379,7 +1404,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.12.0", + "indexmap 2.13.0", "itoa", "ryu", "serde", @@ -1414,10 +1439,11 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.6" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" dependencies = [ + "errno", "libc", ] @@ -1469,9 +1495,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.108" +version = "2.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" dependencies = [ "proc-macro2", "quote", @@ -1515,9 +1541,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.44" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" +checksum = "f9e442fc33d7fdb45aa9bfeb312c095964abdf596f7567261062b2a7107aaabd" dependencies = [ "deranged", "itoa", @@ -1525,22 +1551,22 @@ dependencies = [ "num-conv", "num_threads", "powerfmt", - "serde", + "serde_core", "time-core", "time-macros", ] [[package]] name = "time-core" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b" +checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca" [[package]] name = "time-macros" -version = "0.2.24" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3" +checksum = "71e552d1249bf61ac2a52db88179fd0673def1e1ad8243a00d9ec9ed71fee3dd" dependencies = [ "num-conv", "time-core", @@ -1548,9 +1574,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.48.0" +version = "1.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" dependencies = [ "bytes", "libc", @@ -1586,9 +1612,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.16" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" dependencies = [ "bytes", "futures-core", @@ -1599,9 +1625,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", @@ -1616,9 +1642,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", @@ -1646,9 +1672,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", @@ -1658,9 +1684,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", @@ -1669,9 +1695,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", @@ -1690,9 +1716,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.20" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ "nu-ansi-term", "sharded-slab", @@ -1760,9 +1786,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.18.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" +checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" dependencies = [ "getrandom 0.3.4", "js-sys", @@ -1808,9 +1834,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" dependencies = [ "cfg-if", "once_cell", @@ -1821,9 +1847,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1831,9 +1857,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" dependencies = [ "bumpalo", "proc-macro2", @@ -1844,9 +1870,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" dependencies = [ "unicode-ident", ] @@ -2030,18 +2056,18 @@ checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "zerocopy" -version = "0.8.27" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +checksum = "668f5168d10b9ee831de31933dc111a459c97ec93225beb307aed970d1372dfd" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.27" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +checksum = "2c7962b26b0a8685668b671ee4b54d007a67d4eaf05fda79ac0ecf41e32270f1" dependencies = [ "proc-macro2", "quote", @@ -2053,3 +2079,9 @@ name = "zeroize" version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zmij" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea" diff --git a/Cargo.toml b/Cargo.toml index 2d88db2..81a2bdd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,20 +10,20 @@ version = "0.19.0" [workspace.dependencies] anyhow = "1.0.100" -delegate = "0.13.4" -hyper-util = "0.1.17" +delegate = "0.13.5" +hyper-util = "0.1.19" kube = { version = "2.0.1", default-features = false } kube-core = { version = "2.0.1", default-features = false } kube-derive = { version = "2.0.1" } -k8s-openapi = { version = "0.26.0" } +k8s-openapi = { version = "0.26.1" } once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.8" } -schemars = "1.0.5" -serde_json = "1.0.145" +schemars = "1.2.0" +serde_json = "1.0.149" serde = { version = "1.0.228", features = ["derive"] } serde_yaml = "0.9.34" -tokio = { version = "1.48.0", features = ["full"] } -tower = { version = "0.5.2", features = ["limit"] } -tracing = "0.1.41" -tracing-subscriber = "0.3.20" -uuid = { version = "1.18.1", 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"] } From 6924040959d5f9bd3a8d7ddbc2e7753b5ec7f0ba Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Tue, 13 Jan 2026 08:36:02 -0500 Subject: [PATCH 86/95] feat: add cargo lockfile check to CI Signed-off-by: Shane Utt --- .github/workflows/test.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 07e8c27..0f5a583 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,8 +12,34 @@ on: workflow_dispatch: {} jobs: + 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 From 3a3dd3b9fff1035b7b45bf20de7e572912395197 Mon Sep 17 00:00:00 2001 From: moulin-louis Date: Tue, 13 Jan 2026 18:38:59 +0100 Subject: [PATCH 87/95] Upgrade kube-rs and k8s-openapi (#205) Signed-off-by: lomoulin Co-authored-by: lomoulin --- Cargo.lock | 116 +++++++++++++++++++++++------------------ Cargo.toml | 10 ++-- gateway-api/src/lib.rs | 10 ++-- 3 files changed, 74 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 665b184..a13b895 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,16 +128,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" -[[package]] -name = "chrono" -version = "0.4.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" -dependencies = [ - "num-traits", - "serde", -] - [[package]] name = "clap" version = "4.5.54" @@ -239,9 +229,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.21.3" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" dependencies = [ "darling_core", "darling_macro", @@ -249,11 +239,10 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.21.3" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" dependencies = [ - "fnv", "ident_case", "proc-macro2", "quote", @@ -263,9 +252,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.21.3" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ "darling_core", "quote", @@ -337,7 +326,7 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "enum_default_generator" -version = "0.19.0" +version = "0.20.0" dependencies = [ "codegen", ] @@ -364,12 +353,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "form_urlencoded" version = "1.2.2" @@ -446,7 +429,7 @@ dependencies = [ [[package]] name = "gateway-api" -version = "0.19.0" +version = "0.20.0" dependencies = [ "anyhow", "delegate", @@ -468,7 +451,7 @@ dependencies = [ [[package]] name = "gateway-api-examples" -version = "0.19.0" +version = "0.20.0" dependencies = [ "anyhow", "gateway-api", @@ -533,15 +516,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "home" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" -dependencies = [ - "windows-sys 0.61.2", -] - [[package]] name = "http" version = "1.4.0" @@ -701,6 +675,30 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" +[[package]] +name = "jiff" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67e8da4c49d6d9909fe03361f9b620f58898859f5c7aded68351e85e71ecf50" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0c84ee7f197eca9a86c6fd6cb771e55eb991632f15f2bc3ca6ec838929e6e78" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "js-sys" version = "0.3.83" @@ -713,9 +711,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", @@ -726,12 +724,12 @@ dependencies = [ [[package]] name = "k8s-openapi" -version = "0.26.1" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06d9e5e61dd037cdc51da0d7e2b2be10f497478ea7e120d85dad632adb99882b" +checksum = "05a6d6f3611ad1d21732adbd7a2e921f598af6c92d71ae6e2620da4b67ee1f0d" dependencies = [ "base64", - "chrono", + "jiff", "schemars", "serde", "serde_json", @@ -739,9 +737,9 @@ dependencies = [ [[package]] name = "kube" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e7bb0b6a46502cc20e4575b6ff401af45cfea150b34ba272a3410b78aa014e" +checksum = "0dae7229247e4215781e5c5104a056e1e2163943e577f9084cf8bba7b5248f7a" dependencies = [ "k8s-openapi", "kube-client", @@ -750,16 +748,14 @@ dependencies = [ [[package]] name = "kube-client" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4987d57a184d2b5294fdad3d7fc7f278899469d21a4da39a8f6ca16426567a36" +checksum = "010875e291a9c0a4e076f4f9c35b97d82fd2372cb3bc713252c3d08b7e73ce5b" dependencies = [ "base64", "bytes", - "chrono", "either", "futures", - "home", "http", "http-body", "http-body-util", @@ -767,6 +763,7 @@ dependencies = [ "hyper-rustls", "hyper-timeout", "hyper-util", + "jiff", "jsonpath-rust", "k8s-openapi", "kube-core", @@ -786,14 +783,14 @@ dependencies = [ [[package]] name = "kube-core" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914bbb770e7bb721a06e3538c0edd2babed46447d128f7c21caa68747060ee73" +checksum = "1ac76281aa698dd34111e25b21f5f6561932a30feabab5357152be273f8a81bb" dependencies = [ - "chrono", "derive_more", "form_urlencoded", "http", + "jiff", "k8s-openapi", "schemars", "serde", @@ -804,9 +801,9 @@ dependencies = [ [[package]] name = "kube-derive" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03dee8252be137772a6ab3508b81cd797dee62ee771112a2453bc85cbbe150d2" +checksum = "599c09721efcccc0e6a26e93df28c587da60ff5e099c657626fff2af0ae4cbb8" dependencies = [ "darling", "proc-macro2", @@ -1032,6 +1029,21 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "portable-atomic" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f89776e4d69bb58bc6993e99ffa1d11f228b839984854c7daeb5d37f87cbe950" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -1736,7 +1748,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "type-reducer" -version = "0.19.0" +version = "0.20.0" dependencies = [ "clap", "itertools", diff --git a/Cargo.toml b/Cargo.toml index 81a2bdd..9483733 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,16 +6,16 @@ resolver = "2" authors = ["kube-rs project (https://kube.rs)"] edition = "2024" license = "MIT" -version = "0.19.0" +version = "0.20.0" [workspace.dependencies] anyhow = "1.0.100" delegate = "0.13.5" hyper-util = "0.1.19" -kube = { version = "2.0.1", default-features = false } -kube-core = { version = "2.0.1", default-features = false } -kube-derive = { version = "2.0.1" } -k8s-openapi = { version = "0.26.1" } +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" } once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.8" } schemars = "1.2.0" diff --git a/gateway-api/src/lib.rs b/gateway-api/src/lib.rs index deb32b9..f5e16ea 100644 --- a/gateway-api/src/lib.rs +++ b/gateway-api/src/lib.rs @@ -16,7 +16,7 @@ mod tests { 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}; @@ -147,7 +147,7 @@ mod tests { attached_routes: 0, supported_kinds: vec![], conditions: vec![Condition { - last_transition_time: Time(Utc::now()), + last_transition_time: Time(Timestamp::now()), message: "testing gateway".to_string(), observed_generation: Some(1), reason: ListenerConditionReason::Programmed.to_string(), @@ -156,7 +156,7 @@ mod tests { }], }]), conditions: Some(vec![Condition { - last_transition_time: Time(Utc::now()), + last_transition_time: Time(Timestamp::now()), message: "testing gateway".to_string(), observed_generation: Some(1), reason: GatewayConditionReason::Programmed.to_string(), @@ -218,7 +218,7 @@ mod tests { }, controller_name: "example.com/gateway-controller".to_string(), conditions: vec![Condition { - last_transition_time: Time(Utc::now()), + last_transition_time: Time(Timestamp::now()), message: "testing http route".to_string(), observed_generation: Some(1), reason: RouteConditionReason::Accepted.to_string(), @@ -279,7 +279,7 @@ mod tests { }, controller_name: "example.com/gateway-controller".to_string(), conditions: vec![Condition { - last_transition_time: Time(Utc::now()), + last_transition_time: Time(Timestamp::now()), message: "testing grpc route".to_string(), observed_generation: Some(1), reason: RouteConditionReason::Accepted.to_string(), From 3fd26cf4e3f103047e9b4985f9aab6be2c6775af Mon Sep 17 00:00:00 2001 From: Nitishkumar Singh Date: Thu, 15 Jan 2026 20:37:17 +0530 Subject: [PATCH 88/95] Inference Extension support (#204) Signed-off-by: Nitishkumar Singh --- .gitattributes | 2 +- Cargo.lock | 42 ++- Cargo.toml | 2 +- Makefile | 3 +- README.md | 13 +- extensions/inference/Cargo.toml | 52 ++++ .../inference/src/apis/experimental/common.rs | 11 + .../apis/experimental/inferenceobjectives.rs | 72 +++++ .../src/apis/experimental/inferencepools.rs | 133 +++++++++ .../inference/src/apis/experimental/mod.rs | 5 + extensions/inference/src/apis/mod.rs | 2 + .../inference/src/apis/standard/common.rs | 15 + .../src/apis/standard/inferencepools.rs | 163 +++++++++++ extensions/inference/src/apis/standard/mod.rs | 4 + extensions/inference/src/lib.rs | 258 ++++++++++++++++++ scripts/generators/extensions/inference.sh | 99 +++++++ update.sh => scripts/generators/gateway.sh | 6 +- type-reducer/README.md | 2 +- .../experimental_customized_mapped_names.txt | 1 + .../experimental_reduced_types_pass_0.txt | 1 + .../experimental_rename_only_mapped_names.txt | 5 + .../standard_customized_mapped_names.txt | 3 + .../standard_reduced_types_pass_0.txt | 1 + .../standard_rename_only_mapped_names.txt | 5 + xtask/src/main.rs | 53 ++-- 25 files changed, 913 insertions(+), 40 deletions(-) create mode 100644 extensions/inference/Cargo.toml create mode 100644 extensions/inference/src/apis/experimental/common.rs create mode 100644 extensions/inference/src/apis/experimental/inferenceobjectives.rs create mode 100644 extensions/inference/src/apis/experimental/inferencepools.rs create mode 100644 extensions/inference/src/apis/experimental/mod.rs create mode 100644 extensions/inference/src/apis/mod.rs create mode 100644 extensions/inference/src/apis/standard/common.rs create mode 100644 extensions/inference/src/apis/standard/inferencepools.rs create mode 100644 extensions/inference/src/apis/standard/mod.rs create mode 100644 extensions/inference/src/lib.rs create mode 100755 scripts/generators/extensions/inference.sh rename update.sh => scripts/generators/gateway.sh (99%) create mode 100644 type-reducer/extension/inference/experimental_customized_mapped_names.txt create mode 100644 type-reducer/extension/inference/experimental_reduced_types_pass_0.txt create mode 100644 type-reducer/extension/inference/experimental_rename_only_mapped_names.txt create mode 100644 type-reducer/extension/inference/standard_customized_mapped_names.txt create mode 100644 type-reducer/extension/inference/standard_reduced_types_pass_0.txt create mode 100644 type-reducer/extension/inference/standard_rename_only_mapped_names.txt diff --git a/.gitattributes b/.gitattributes index b2f54a8..28c3e1e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,3 @@ Cargo.lock linguist-generated=false Makefile linguist-detectable=false -update.sh linguist-detectable=false +scripts/generators/** linguist-detectable=false diff --git a/Cargo.lock b/Cargo.lock index a13b895..6c90a98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -654,6 +654,28 @@ dependencies = [ "hashbrown 0.16.1", ] +[[package]] +name = "inference-extension-api" +version = "0.20.0" +dependencies = [ + "anyhow", + "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 = "is_terminal_polyfill" version = "1.70.2" @@ -701,9 +723,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.83" +version = "0.3.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" +checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" dependencies = [ "once_cell", "wasm-bindgen", @@ -1846,9 +1868,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" +checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" dependencies = [ "cfg-if", "once_cell", @@ -1859,9 +1881,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" +checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1869,9 +1891,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" +checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" dependencies = [ "bumpalo", "proc-macro2", @@ -1882,9 +1904,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" +checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" dependencies = [ "unicode-ident", ] diff --git a/Cargo.toml b/Cargo.toml index 9483733..de830cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["gateway-api", "gateway-api/examples", "xtask", "type-reducer"] +members = ["gateway-api", "gateway-api/examples", "xtask", "type-reducer", "extensions/inference"] resolver = "2" [workspace.package] 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 e42a383..082a336 100644 --- a/README.md +++ b/README.md @@ -31,17 +31,22 @@ so you can create a [Gateway API Implementation] in Rust. See the ## 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.22.5 ``` -After which you can run the `update.sh` script: +After which you can run the generator scripts for gateway api or extensions placed under `scripts/generators` folder: +### Gateway API Generator Script ```console -$ ./update.sh +$ ./scripts/generators/gateway.sh +``` + +### Gateway Inference Extension Generator Script +```console +$ ./scripts/generators/extensions/inference.sh ``` Check for errors and/or a non-zero exit code, but upon success you should see diff --git a/extensions/inference/Cargo.toml b/extensions/inference/Cargo.toml new file mode 100644 index 0000000..c936b8e --- /dev/null +++ b/extensions/inference/Cargo.toml @@ -0,0 +1,52 @@ +[package] +name = "inference-extension-api" +description = "Kubernetes Gateway API Inference Extension bindings in Rust" +categories = ["api-bindings"] +keywords = ["kubernetes", "inference-extension-api"] + +homepage = "https://docs.rs/crate/inference-extension-api/" +readme = "../README.md" +repository = "https://github.com/kube-rs/gateway-api-rs/extensions/inference" + +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, 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 + +[dev-dependencies] +k8s-openapi = { workspace = true, features = ["v1_32", "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_32"] + +[features] +default = ["standard", "experimental"] +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/extensions/inference/src/apis/experimental/common.rs b/extensions/inference/src/apis/experimental/common.rs new file mode 100644 index 0000000..cdaf5e6 --- /dev/null +++ b/extensions/inference/src/apis/experimental/common.rs @@ -0,0 +1,11 @@ +// 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::*; diff --git a/extensions/inference/src/apis/experimental/inferenceobjectives.rs b/extensions/inference/src/apis/experimental/inferenceobjectives.rs new file mode 100644 index 0000000..16bf8d5 --- /dev/null +++ b/extensions/inference/src/apis/experimental/inferenceobjectives.rs @@ -0,0 +1,72 @@ +// 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}; +} +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 = "InferenceObjectiveStatus")] +#[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: InferenceObjectivePoolRef, + /// 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, +} +/// PoolRef is a reference to the inference pool, the pool must exist in the same namespace. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceObjectivePoolRef { + /// Group is the group of the referent. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is kind of the referent. For example "InferencePool". + #[serde(default, skip_serializing_if = "Option::is_none")] + pub kind: Option, + /// Name is the name of the referent. + pub name: String, +} +/// InferenceObjectiveStatus defines the observed state of InferenceObjective +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct InferenceObjectiveStatus { + /// Conditions track the state of the InferenceObjective. + /// + /// Known condition types are: + /// + /// * "Accepted" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub conditions: Option>, +} diff --git a/extensions/inference/src/apis/experimental/inferencepools.rs b/extensions/inference/src/apis/experimental/inferencepools.rs new file mode 100644 index 0000000..c6bce56 --- /dev/null +++ b/extensions/inference/src/apis/experimental/inferencepools.rs @@ -0,0 +1,133 @@ +// 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: ExtensionRef, + /// 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 ExtensionRef { + /// 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 ExtensionFailureMode { + 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 InferencePoolParent { + /// 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: ParentRef, +} +/// GatewayRef indicates the gateway that observed state of InferencePool. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ParentRef { + /// Group is the group of the referent. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Kind is kind of the referent. For example "Gateway". + #[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 referent. If not present, + /// the namespace of the referent is assumed to be the same as + /// the namespace of the referring object. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub namespace: Option, +} diff --git a/extensions/inference/src/apis/experimental/mod.rs b/extensions/inference/src/apis/experimental/mod.rs new file mode 100644 index 0000000..cbccce9 --- /dev/null +++ b/extensions/inference/src/apis/experimental/mod.rs @@ -0,0 +1,5 @@ +// WARNING: generated file - manual changes will be overriden + +pub mod common; +pub mod inferenceobjectives; +pub mod inferencepools; diff --git a/extensions/inference/src/apis/mod.rs b/extensions/inference/src/apis/mod.rs new file mode 100644 index 0000000..7651e9f --- /dev/null +++ b/extensions/inference/src/apis/mod.rs @@ -0,0 +1,2 @@ +pub mod experimental; +pub mod standard; diff --git a/extensions/inference/src/apis/standard/common.rs b/extensions/inference/src/apis/standard/common.rs new file mode 100644 index 0000000..5ffd87f --- /dev/null +++ b/extensions/inference/src/apis/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 EndPointPort { + pub number: i32, +} diff --git a/extensions/inference/src/apis/standard/inferencepools.rs b/extensions/inference/src/apis/standard/inferencepools.rs new file mode 100644 index 0000000..eb36c54 --- /dev/null +++ b/extensions/inference/src/apis/standard/inferencepools.rs @@ -0,0 +1,163 @@ +// 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: ExtensionRef, + /// 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. + /// Currently, the list may only include a single port definition. + #[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 ExtensionRef { + /// 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 ExtensionFailureMode { + 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 InferencePoolParent { + /// 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>, + /// 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: ParentRef, +} +/// 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 ParentRef { + /// 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/extensions/inference/src/apis/standard/mod.rs b/extensions/inference/src/apis/standard/mod.rs new file mode 100644 index 0000000..c7b2180 --- /dev/null +++ b/extensions/inference/src/apis/standard/mod.rs @@ -0,0 +1,4 @@ +// WARNING: generated file - manual changes will be overriden + +pub mod common; +pub mod inferencepools; diff --git a/extensions/inference/src/lib.rs b/extensions/inference/src/lib.rs new file mode 100644 index 0000000..02ad1bf --- /dev/null +++ b/extensions/inference/src/lib.rs @@ -0,0 +1,258 @@ +pub mod apis; + +#[cfg(feature = "standard")] +pub use apis::standard::*; + +#[cfg(feature = "experimental")] +pub use apis::experimental; + +#[cfg(test)] +mod tests { + use std::collections::BTreeMap; + use std::process::Command; + + use anyhow::{Error, Ok}; + use hyper_util::client::legacy::Client as HTTPClient; + use hyper_util::rt::TokioExecutor; + use kube::Client as KubeClient; + use kube::api::PostParams; + use kube::config::{KubeConfigOptions, Kubeconfig}; + use kube::core::ObjectMeta; + use kube::{Api, Config, CustomResourceExt, client::ConfigExt}; + use tower::BoxError; + use tower::ServiceBuilder; + use uuid::Uuid; + + use crate::apis::standard::common::EndPointPort; + use crate::apis::standard::inferencepools::{ + ExtensionFailureMode, ExtensionRef, InferencePool, InferencePoolSelector, InferencePoolSpec, + }; + + const DEFAULT_INFERENCE_EXT_VERSION: &str = "v1.0.2"; + + // ------------------------------------------------------------------------- + // 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 + ); + + // CRDS were not reflecting in kubernetes api server, hence wait was added + std::thread::sleep(std::time::Duration::from_secs(2)); + 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 + ); + + // CRDS were not reflecting in kubernetes api server, hence wait was added + std::thread::sleep(std::time::Duration::from_secs(2)); + 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 inf_pool = InferencePool { + metadata: ObjectMeta::default(), + spec: InferencePoolSpec { + endpoint_picker_ref: ExtensionRef { + failure_mode: Some(ExtensionFailureMode::FailClose), + group: None, + kind: None, + name: String::from("test-extension-name"), + port: Some(EndPointPort { number: 80 }), + }, + selector: InferencePoolSelector { + match_labels: BTreeMap::from([(String::from("app"), String::from("test-app"))]), + }, + target_ports: vec![EndPointPort { number: 80 }], + }, + status: None, + }; + inf_pool.metadata.name = Some("test-inference-pool".to_string()); + + inf_pool = Api::default_namespaced(client.clone()) + .create(&PostParams::default(), &inf_pool) + .await?; + + assert!(inf_pool.metadata.name.is_some()); + assert!(inf_pool.metadata.uid.is_some()); + assert!(inf_pool.spec.endpoint_picker_ref.failure_mode.is_some()); + assert!(inf_pool.spec.endpoint_picker_ref.port.is_some()); + assert!(inf_pool.spec.selector.match_labels.len() > 0); + + 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_INFERENCE_EXT_VERSION") + .unwrap_or_else(|_| DEFAULT_INFERENCE_EXT_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_INFERENCE_EXT_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-inference-extension/releases/download/{}/manifests.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 inf_pool_crd = InferencePool::crd(); + inf_pool_crd.metadata.annotations = Some(std::collections::BTreeMap::from([( + "api-approved.kubernetes.io".to_string(), + "https://github.com/kubernetes-sigs/gateway-api-inference-extension/pull/1173" + .to_string(), + )])); + + Api::all(client.clone()) + .create(&PostParams::default(), &inf_pool_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/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/update.sh b/scripts/generators/gateway.sh similarity index 99% rename from update.sh rename to scripts/generators/gateway.sh index c579005..2b5b5f9 100755 --- a/update.sh +++ b/scripts/generators/gateway.sh @@ -232,9 +232,9 @@ sed -i '/#\[kube(status = "UdpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\ sed -i '/#\[kube(status = "TcpRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tcproutes.rs cargo fmt -echo "API Generation complete" +echo "Gateway API Generation complete" -echo "Cleaning up temporary files" +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 @@ -243,4 +243,4 @@ rm -f experimental_mapped_types_to_names_phase_*.txt rm -f mapped_names.txt rm -f mapped_types_to_names.txt set +x -echo "Cleanup complete" +echo "Gateway API Cleanup complete" \ No newline at end of file diff --git a/type-reducer/README.md b/type-reducer/README.md index ac94ab9..ce271b7 100644 --- a/type-reducer/README.md +++ b/type-reducer/README.md @@ -44,5 +44,5 @@ On subsequent runs, the algorithm will use HTTPHeader as new name for all those ### 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. Check [update.sh](../update.sh) for more details on how to use it. +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/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/xtask/src/main.rs b/xtask/src/main.rs index 84406bb..cf8f866 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,25 +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")?; - let route_condition_types = env::var("ROUTE_CONDITION_CONSTANTS")?; - let route_reason_types = env::var("ROUTE_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); - gen_const_enums(&mut scope, route_condition_types); - gen_const_enums(&mut scope, route_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(()) From e4b9fd322bb0a9787181ac256a9646d111db0e04 Mon Sep 17 00:00:00 2001 From: Dawid Nowak Date: Mon, 2 Mar 2026 21:01:23 +0000 Subject: [PATCH 89/95] Hacky fixes for compilation issues Signed-off-by: Dawid Nowak --- .../apis/experimental/backendtlspolicies.rs | 354 +++++++++++ gateway-api/src/apis/experimental/common.rs | 88 +-- .../src/apis/experimental/enum_defaults.rs | 7 + gateway-api/src/apis/experimental/gateways.rs | 261 ++++---- .../src/apis/experimental/grpcroutes.rs | 75 ++- .../src/apis/experimental/httproutes.rs | 193 ++++-- .../src/apis/experimental/listenersets.rs | 318 ++++++++++ gateway-api/src/apis/experimental/mod.rs | 2 + .../src/apis/experimental/referencegrants.rs | 2 +- .../src/apis/experimental/tcproutes.rs | 67 ++- .../src/apis/experimental/tlsroutes.rs | 95 ++- .../src/apis/experimental/udproutes.rs | 67 ++- .../src/apis/standard/backendtlspolicies.rs | 354 +++++++++++ gateway-api/src/apis/standard/common.rs | 133 +++-- .../src/apis/standard/enum_defaults.rs | 7 + .../src/apis/standard/gatewayclasses.rs | 33 +- gateway-api/src/apis/standard/gateways.rs | 457 ++++++++++---- gateway-api/src/apis/standard/grpcroutes.rs | 243 +++++++- gateway-api/src/apis/standard/httproutes.rs | 563 +++++++++++++++++- gateway-api/src/apis/standard/listenersets.rs | 318 ++++++++++ gateway-api/src/apis/standard/mod.rs | 3 + .../src/apis/standard/referencegrants.rs | 2 +- gateway-api/src/apis/standard/tlsroutes.rs | 248 ++++++++ scripts/generators/gateway.sh | 35 +- .../standard_customized_mapped_names.txt | 2 + 25 files changed, 3471 insertions(+), 456 deletions(-) create mode 100644 gateway-api/src/apis/experimental/backendtlspolicies.rs create mode 100644 gateway-api/src/apis/experimental/listenersets.rs create mode 100644 gateway-api/src/apis/standard/backendtlspolicies.rs create mode 100644 gateway-api/src/apis/standard/listenersets.rs create mode 100644 gateway-api/src/apis/standard/tlsroutes.rs diff --git a/gateway-api/src/apis/experimental/backendtlspolicies.rs b/gateway-api/src/apis/experimental/backendtlspolicies.rs new file mode 100644 index 0000000..9c9b0b5 --- /dev/null +++ b/gateway-api/src/apis/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: BackendTlsPolicyStatusAncestorsAncestorRef, + /// 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/apis/experimental/common.rs b/gateway-api/src/apis/experimental/common.rs index 7ad4f9b..fd790dc 100644 --- a/gateway-api/src/apis/experimental/common.rs +++ b/gateway-api/src/apis/experimental/common.rs @@ -22,6 +22,17 @@ pub enum GatewayDefaultScope { None, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GatewayListenersAllowedRoutesNamespacesFrom { + All, + Selector, + Same, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GatewayListenersTlsMode { + Terminate, + Passthrough, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum GatewayTlsFrontendDefaultValidationMode { AllowValidOnly, AllowInsecureFallback, @@ -62,6 +73,12 @@ pub enum RedirectStatusCode { 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 { @@ -117,19 +134,37 @@ pub struct BackendTlsClientCertificateReference { pub namespace: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayAllowedListenersNamespacesSelectorMatchExpressions { - pub key: String, - pub operator: String, +pub struct BackendTlsPolicyStatusAncestorsAncestorRef { #[serde(default, skip_serializing_if = "Option::is_none")] - pub values: Option>, + 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 GatewayInfrastructureParametersReference { +pub struct BackendTlsPolicyValidationCaCertificateRefs { pub group: String, pub kind: String, pub name: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAllowedListenersNamespacesSelectorMatchExpressions { + 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 HTTPHeader { pub name: String, pub value: String, @@ -180,24 +215,6 @@ pub struct ParametersReference { pub namespace: 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 RequestMirrorFraction { #[serde(default, skip_serializing_if = "Option::is_none")] pub denominator: Option, @@ -211,6 +228,19 @@ pub struct CommonRouteRule { pub name: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatusListeners { + #[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 HeaderMatch { pub name: String, #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] @@ -227,14 +257,6 @@ pub struct HeaderModifier { pub set: 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, @@ -294,10 +316,6 @@ pub struct HttpRouteUrlRewrite { 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 SessionPersistence { #[serde( default, diff --git a/gateway-api/src/apis/experimental/enum_defaults.rs b/gateway-api/src/apis/experimental/enum_defaults.rs index f22f158..7cc81b3 100644 --- a/gateway-api/src/apis/experimental/enum_defaults.rs +++ b/gateway-api/src/apis/experimental/enum_defaults.rs @@ -1,6 +1,12 @@ use super::common::*; // WARNING: generated file - manual changes will be overriden +impl Default for BackendTlsPolicyValidationSubjectAltNamesType { + fn default() -> Self { + BackendTlsPolicyValidationSubjectAltNamesType::Hostname + } +} + impl Default for GRPCFilterType { fn default() -> Self { GRPCFilterType::RequestHeaderModifier @@ -24,3 +30,4 @@ impl Default for RequestOperationType { RequestOperationType::ReplaceFullPath } } +use crate::experimental::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType; diff --git a/gateway-api/src/apis/experimental/gateways.rs b/gateway-api/src/apis/experimental/gateways.rs index dbbe13a..531c54f 100644 --- a/gateway-api/src/apis/experimental/gateways.rs +++ b/gateway-api/src/apis/experimental/gateways.rs @@ -46,7 +46,7 @@ pub struct GatewaySpec { #[serde(default, skip_serializing_if = "Option::is_none")] pub addresses: Option>, /// AllowedListeners defines which ListenerSets can be attached to this Gateway. - /// While this feature is experimental, the default value is to allow no ListenerSets. + /// The default value is to allow no ListenerSets. #[serde( default, skip_serializing_if = "Option::is_none", @@ -270,16 +270,16 @@ pub struct GatewayAddresses { pub value: Option, } /// AllowedListeners defines which ListenerSets can be attached to this Gateway. -/// While this feature is experimental, the default value is to allow no ListenerSets. +/// 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. - /// While this feature is experimental, the default value is to allow no ListenerSets. + /// 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. -/// While this feature is experimental, the default value is to allow no ListenerSets. +/// 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 @@ -290,7 +290,7 @@ pub struct GatewayAllowedListenersNamespaces { /// * All: ListenerSets in all namespaces may be attached to this Gateway. /// * None: Only listeners defined in the Gateway's spec are allowed /// - /// While this feature is experimental, the default value None + /// 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, @@ -300,7 +300,7 @@ pub struct GatewayAllowedListenersNamespaces { pub selector: Option, } /// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. -/// While this feature is experimental, the default value is to allow no ListenerSets. +/// The default value is to allow no ListenerSets. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum GatewayAllowedListenersNamespacesFrom { All, @@ -379,7 +379,7 @@ pub struct GatewayInfrastructure { skip_serializing_if = "Option::is_none", rename = "parametersRef" )] - pub parameters_ref: Option, + pub parameters_ref: Option, } /// Listener embodies the concept of a logical endpoint where a Gateway accepts /// network connections. @@ -446,7 +446,7 @@ pub struct GatewayListeners { /// the Gateway SHOULD return a 421. /// * If the current Listener (selected by SNI matching during ClientHello) /// does not match the Host: - /// * If another Listener does match the Host the Gateway SHOULD return a + /// * If another Listener does match the Host, the Gateway SHOULD return a /// 421. /// * If no other Listener matches the Host, the Gateway MUST return a /// 404. @@ -563,16 +563,6 @@ pub struct GatewayListenersAllowedRoutesNamespaces { #[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". @@ -668,22 +658,6 @@ pub struct GatewayListenersTls { #[serde(default, skip_serializing_if = "Option::is_none")] pub options: 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 ListenerTLSConfig 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, -} /// TLS specifies frontend and backend tls configuration for entire gateway. /// /// Support: Extended @@ -714,19 +688,30 @@ pub struct GatewayTls { /// Support: Core #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct GatewayTlsBackend { - /// 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. - /// - /// Support: Core + /// 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", @@ -780,27 +765,49 @@ pub struct GatewayTlsFrontendDefault { /// Support: Core #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct GatewayTlsFrontendDefaultValidation { - /// 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 certificate in a ConfigMap - /// with different keys or 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. + /// CACertificateRefs contains one or more references to Kubernetes + /// objects that contain a PEM-encoded TLS CA certificate bundle, which + /// is used as a trust anchor to validate the certificates presented by + /// the client. + /// + /// 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 on all matching HTTPS listeners 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 on all matching HTTPS listeners must be set to + /// `InvalidCACertificateKind` and the Message of the Condition must explain + /// which kind of resource is unknown or unsupported. + /// + /// * It refers to a resource in another namespace UNLESS there is a + /// ReferenceGrant in the target namespace that allows the CA + /// certificate to be attached. If a ReferenceGrant does not allow this + /// reference, the `ResolvedRefs` on all matching HTTPS listeners condition + /// MUST be set 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. + /// + /// In all cases, the implementation MUST ensure that the `ResolvedRefs` + /// condition is set to `status: False` on all targeted listeners (i.e., + /// listeners serving HTTPS on a matching port). The condition MUST + /// include a Reason and Message that indicate the cause of the error. If + /// ALL CACertificateRefs are invalid, the implementation MUST also ensure + /// the `Accepted` condition on the listener is set to `status: False`, with + /// the Reason `NoValidCACertificate`. + /// 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, other kinds + /// of resources, or a single reference that includes multiple certificates. #[serde(rename = "caCertificateRefs")] pub ca_certificate_refs: Vec, /// FrontendValidationMode defines the mode for validating the client certificate. @@ -861,27 +868,49 @@ pub struct GatewayTlsFrontendPerPortTls { /// Support: Core #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct GatewayTlsFrontendPerPortTlsValidation { - /// 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 certificate in a ConfigMap - /// with different keys or 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. + /// CACertificateRefs contains one or more references to Kubernetes + /// objects that contain a PEM-encoded TLS CA certificate bundle, which + /// is used as a trust anchor to validate the certificates presented by + /// the client. + /// + /// 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 on all matching HTTPS listeners 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 on all matching HTTPS listeners must be set to + /// `InvalidCACertificateKind` and the Message of the Condition must explain + /// which kind of resource is unknown or unsupported. + /// + /// * It refers to a resource in another namespace UNLESS there is a + /// ReferenceGrant in the target namespace that allows the CA + /// certificate to be attached. If a ReferenceGrant does not allow this + /// reference, the `ResolvedRefs` on all matching HTTPS listeners condition + /// MUST be set 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. + /// + /// In all cases, the implementation MUST ensure that the `ResolvedRefs` + /// condition is set to `status: False` on all targeted listeners (i.e., + /// listeners serving HTTPS on a matching port). The condition MUST + /// include a Reason and Message that indicate the cause of the error. If + /// ALL CACertificateRefs are invalid, the implementation MUST also ensure + /// the `Accepted` condition on the listener is set to `status: False`, with + /// the Reason `NoValidCACertificate`. + /// 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, other kinds + /// of resources, or a single reference that includes multiple certificates. #[serde(rename = "caCertificateRefs")] pub ca_certificate_refs: Vec, /// FrontendValidationMode defines the mode for validating the client certificate. @@ -917,6 +946,22 @@ pub struct GatewayStatus { /// * 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 @@ -947,41 +992,3 @@ pub struct GatewayStatusAddresses { /// 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, -} diff --git a/gateway-api/src/apis/experimental/grpcroutes.rs b/gateway-api/src/apis/experimental/grpcroutes.rs index 59dbbcb..199a379 100644 --- a/gateway-api/src/apis/experimental/grpcroutes.rs +++ b/gateway-api/src/apis/experimental/grpcroutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "grpcroutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "GrpcRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct GrpcRouteSpec { @@ -140,7 +140,7 @@ pub struct GrpcRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, @@ -402,7 +402,7 @@ pub struct GrpcRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + pub extension_ref: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -486,7 +486,7 @@ pub struct GrpcRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + pub extension_ref: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -561,8 +561,8 @@ pub struct GrpcRouteRulesFilters { /// - method: /// type: Exact /// service: "foo" -/// headers: -/// - name: "version" +/// - headers: +/// name: "version" /// value "v1" /// /// ``` @@ -603,3 +603,66 @@ pub struct GRPCMethodMatch { #[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 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 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: BackendTlsPolicyStatusAncestorsAncestorRef, +} diff --git a/gateway-api/src/apis/experimental/httproutes.rs b/gateway-api/src/apis/experimental/httproutes.rs index e85b0c6..bd575a1 100644 --- a/gateway-api/src/apis/experimental/httproutes.rs +++ b/gateway-api/src/apis/experimental/httproutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "httproutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "HttpRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct HttpRouteSpec { @@ -143,7 +143,7 @@ pub struct HttpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, @@ -447,7 +447,7 @@ pub struct HttpRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + 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. @@ -577,7 +577,7 @@ pub struct HttpRouteRulesBackendRefsFiltersCors { /// AllowHeaders indicates which HTTP request headers are supported for /// accessing the requested resource. /// - /// Header names are not case sensitive. + /// 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 (","). @@ -596,18 +596,21 @@ pub struct HttpRouteRulesBackendRefsFiltersCors { /// client side. /// /// A wildcard indicates that the requests with all HTTP headers are allowed. - /// The `Access-Control-Allow-Headers` response header can only use `*` - /// wildcard as value when the `AllowCredentials` field is false or omitted. - /// - /// When the `AllowCredentials` field is true and `AllowHeaders` field - /// specified with the `*` wildcard, the gateway must specify one or more + /// 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. A Gateway - /// implementation may choose to add implementation-specific default headers. + /// response header, instead of specifying the `*` wildcard. /// /// Support: Extended #[serde( @@ -622,7 +625,7 @@ pub struct HttpRouteRulesBackendRefsFiltersCors { /// 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. + /// 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` @@ -642,18 +645,21 @@ pub struct HttpRouteRulesBackendRefsFiltersCors { /// `Access-Control-Allow-Methods`, it will present an error on the client /// side. /// - /// The `Access-Control-Allow-Methods` response header can only use `*` - /// wildcard as value when the `AllowCredentials` field is false or omitted. + /// 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 `AllowCredentials` field is true and `AllowMethods` field + /// 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. A Gateway implementation may - /// choose to add implementation-specific default methods. + /// instead of specifying the `*` wildcard. /// /// Support: Extended #[serde( @@ -704,10 +710,19 @@ pub struct HttpRouteRulesBackendRefsFiltersCors { /// the CORS headers. The cross-origin request fails on the client side. /// Therefore, the client doesn't attempt the actual cross-origin request. /// - /// The `Access-Control-Allow-Origin` response header can only use `*` - /// wildcard as value when the `AllowCredentials` field is false or omitted. + /// 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 `AllowCredentials` field is true and `AllowOrigins` field + /// 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 @@ -741,14 +756,18 @@ pub struct HttpRouteRulesBackendRefsFiltersCors { /// this additional header will be exposed as part of the response to the /// client. /// - /// Header names are not case sensitive. + /// 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 `AllowCredentials` field is false or omitted. + /// 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( @@ -766,6 +785,9 @@ pub struct HttpRouteRulesBackendRefsFiltersCors { /// /// 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, } @@ -867,7 +889,7 @@ pub struct HttpRouteFilter { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + 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. @@ -997,7 +1019,7 @@ pub struct HttpRouteRulesFiltersCors { /// AllowHeaders indicates which HTTP request headers are supported for /// accessing the requested resource. /// - /// Header names are not case sensitive. + /// 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 (","). @@ -1016,18 +1038,21 @@ pub struct HttpRouteRulesFiltersCors { /// client side. /// /// A wildcard indicates that the requests with all HTTP headers are allowed. - /// The `Access-Control-Allow-Headers` response header can only use `*` - /// wildcard as value when the `AllowCredentials` field is false or omitted. - /// - /// When the `AllowCredentials` field is true and `AllowHeaders` field - /// specified with the `*` wildcard, the gateway must specify one or more + /// 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. A Gateway - /// implementation may choose to add implementation-specific default headers. + /// response header, instead of specifying the `*` wildcard. /// /// Support: Extended #[serde( @@ -1042,7 +1067,7 @@ pub struct HttpRouteRulesFiltersCors { /// 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. + /// 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` @@ -1062,18 +1087,21 @@ pub struct HttpRouteRulesFiltersCors { /// `Access-Control-Allow-Methods`, it will present an error on the client /// side. /// - /// The `Access-Control-Allow-Methods` response header can only use `*` - /// wildcard as value when the `AllowCredentials` field is false or omitted. + /// 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 `AllowCredentials` field is true and `AllowMethods` field + /// 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. A Gateway implementation may - /// choose to add implementation-specific default methods. + /// instead of specifying the `*` wildcard. /// /// Support: Extended #[serde( @@ -1124,10 +1152,19 @@ pub struct HttpRouteRulesFiltersCors { /// the CORS headers. The cross-origin request fails on the client side. /// Therefore, the client doesn't attempt the actual cross-origin request. /// - /// The `Access-Control-Allow-Origin` response header can only use `*` - /// wildcard as value when the `AllowCredentials` field is false or omitted. + /// 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 `AllowCredentials` field is true and `AllowOrigins` field + /// 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 @@ -1161,14 +1198,18 @@ pub struct HttpRouteRulesFiltersCors { /// this additional header will be exposed as part of the response to the /// client. /// - /// Header names are not case sensitive. + /// 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 `AllowCredentials` field is false or omitted. + /// 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( @@ -1186,6 +1227,9 @@ pub struct HttpRouteRulesFiltersCors { /// /// 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, } @@ -1391,7 +1435,7 @@ pub struct HttpRouteRulesRetry { /// 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. + /// to be retriable. /// /// An implementation MAY use an exponential or alternative backoff strategy /// for subsequent retry attempts, MAY cap the maximum backoff duration to @@ -1485,3 +1529,66 @@ pub struct HttpRouteTimeout { #[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: BackendTlsPolicyStatusAncestorsAncestorRef, +} diff --git a/gateway-api/src/apis/experimental/listenersets.rs b/gateway-api/src/apis/experimental/listenersets.rs new file mode 100644 index 0000000..e7341f9 --- /dev/null +++ b/gateway-api/src/apis/experimental/listenersets.rs @@ -0,0 +1,318 @@ +// 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: BackendTlsClientCertificateReference, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetListeners { + /// 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. + #[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`. + #[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 + /// ListenerSet. + /// + /// Name is not required to be unique across a Gateway and ListenerSets. + /// Routes can attach to a Listener by having a ListenerSet as a parentRef + /// and setting the SectionName + pub name: String, + /// Port is the network port. Multiple listeners may use the + /// same port, subject to the Listener compatibility rules. + pub port: i32, + /// Protocol specifies the network protocol this listener expects to receive. + 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 ListenerTLSConfig 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. + #[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. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetListenersAllowedRoutes { + /// 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, +} +/// 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 ListenerSetListenersAllowedRoutesNamespaces { + /// 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, +} +/// 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 ListenerSetListenersAllowedRoutesNamespacesSelector { + /// 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>, +} +/// 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 ListenerTLSConfig 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. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetListenersTls { + /// 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>, +} +/// 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/apis/experimental/mod.rs b/gateway-api/src/apis/experimental/mod.rs index 67cff9c..44336b0 100644 --- a/gateway-api/src/apis/experimental/mod.rs +++ b/gateway-api/src/apis/experimental/mod.rs @@ -1,5 +1,6 @@ // WARNING: generated file - manual changes will be overriden +pub mod backendtlspolicies; pub mod common; pub mod constants; pub mod enum_defaults; @@ -7,6 +8,7 @@ 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/apis/experimental/referencegrants.rs b/gateway-api/src/apis/experimental/referencegrants.rs index 4a3e15e..6eb6981 100644 --- a/gateway-api/src/apis/experimental/referencegrants.rs +++ b/gateway-api/src/apis/experimental/referencegrants.rs @@ -11,7 +11,7 @@ use self::prelude::*; #[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] #[kube( group = "gateway.networking.k8s.io", - version = "v1beta1", + version = "v1", kind = "ReferenceGrant", plural = "referencegrants" )] diff --git a/gateway-api/src/apis/experimental/tcproutes.rs b/gateway-api/src/apis/experimental/tcproutes.rs index a4b960a..0e1f524 100644 --- a/gateway-api/src/apis/experimental/tcproutes.rs +++ b/gateway-api/src/apis/experimental/tcproutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "tcproutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "TcpRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct TcpRouteSpec { @@ -88,7 +88,7 @@ pub struct TcpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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 @@ -110,3 +110,66 @@ pub struct TcpRouteSpec { )] pub use_default_gateways: 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: BackendTlsPolicyStatusAncestorsAncestorRef, +} diff --git a/gateway-api/src/apis/experimental/tlsroutes.rs b/gateway-api/src/apis/experimental/tlsroutes.rs index 7072cf8..a2950c4 100644 --- a/gateway-api/src/apis/experimental/tlsroutes.rs +++ b/gateway-api/src/apis/experimental/tlsroutes.rs @@ -13,12 +13,12 @@ use self::prelude::*; #[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] #[kube( group = "gateway.networking.k8s.io", - version = "v1alpha3", + version = "v1", kind = "TLSRoute", plural = "tlsroutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "TlsRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct TlsRouteSpec { @@ -29,32 +29,6 @@ pub struct TlsRouteSpec { /// 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. - /// - /// 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 specified at least one of `test.example.com` or - /// `*.example.com`. - /// * A Listener with `*.example.com` as the hostname matches TLSRoutes - /// that 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 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 @@ -122,7 +96,7 @@ pub struct TlsRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + pub parent_refs: Option>, /// Rules are a list of actions. pub rules: Vec, /// UseDefaultGateways indicates the default Gateway scope to use for this @@ -144,3 +118,66 @@ pub struct TlsRouteSpec { )] pub use_default_gateways: 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: BackendTlsPolicyStatusAncestorsAncestorRef, +} diff --git a/gateway-api/src/apis/experimental/udproutes.rs b/gateway-api/src/apis/experimental/udproutes.rs index abc39e6..4e3a24e 100644 --- a/gateway-api/src/apis/experimental/udproutes.rs +++ b/gateway-api/src/apis/experimental/udproutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "udproutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "UdpRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct UdpRouteSpec { @@ -88,7 +88,7 @@ pub struct UdpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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 @@ -110,3 +110,66 @@ pub struct UdpRouteSpec { )] pub use_default_gateways: 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: BackendTlsPolicyStatusAncestorsAncestorRef, +} diff --git a/gateway-api/src/apis/standard/backendtlspolicies.rs b/gateway-api/src/apis/standard/backendtlspolicies.rs new file mode 100644 index 0000000..9c9b0b5 --- /dev/null +++ b/gateway-api/src/apis/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: BackendTlsPolicyStatusAncestorsAncestorRef, + /// 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/apis/standard/common.rs b/gateway-api/src/apis/standard/common.rs index 1dfb50f..f39aa1f 100644 --- a/gateway-api/src/apis/standard/common.rs +++ b/gateway-api/src/apis/standard/common.rs @@ -17,6 +17,22 @@ pub enum GRPCFilterType { ExtensionRef, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GatewayListenersAllowedRoutesNamespacesFrom { + All, + Selector, + Same, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GatewayListenersTlsMode { + Terminate, + Passthrough, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum GatewayTlsFrontendDefaultValidationMode { + AllowValidOnly, + AllowInsecureFallback, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum HTTPFilterType { RequestHeaderModifier, ResponseHeaderModifier, @@ -25,6 +41,8 @@ pub enum HTTPFilterType { #[serde(rename = "URLRewrite")] UrlRewrite, ExtensionRef, + #[serde(rename = "CORS")] + Cors, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum HeaderMatchType { @@ -37,6 +55,12 @@ pub enum RedirectStatusCode { 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 { @@ -63,24 +87,46 @@ pub struct BackendObjectReference { pub port: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayInfrastructureParametersReference { - pub group: String, - pub kind: String, +pub struct BackendTlsPolicyStatusAncestorsAncestorRef { + #[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 HTTPHeader { +pub struct BackendTlsPolicyValidationCaCertificateRefs { + pub group: String, + pub kind: String, pub name: String, - pub value: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct Kind { +pub struct GatewayAllowedListenersNamespacesSelectorMatchExpressions { + pub key: String, + pub operator: String, #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, + pub values: Option>, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayClassParametersRef { + 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 ParentReference { +pub struct GatewayListenersTlsCertificateRefs { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -88,14 +134,17 @@ pub struct ParentReference { 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 port: Option, - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "sectionName" - )] - pub section_name: Option, + pub group: Option, + pub kind: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct RequestMirrorFraction { @@ -104,6 +153,19 @@ pub struct RequestMirrorFraction { pub numerator: i32, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayStatusListeners { + #[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 HeaderMatch { pub name: String, #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] @@ -120,14 +182,6 @@ pub struct HeaderModifier { pub set: 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, @@ -154,35 +208,6 @@ pub struct RequestRedirectPath { pub r#type: RequestOperationType, } #[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 RequestRedirect { #[serde(default, skip_serializing_if = "Option::is_none")] pub hostname: Option, @@ -206,7 +231,3 @@ pub struct HttpRouteUrlRewrite { #[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, -} diff --git a/gateway-api/src/apis/standard/enum_defaults.rs b/gateway-api/src/apis/standard/enum_defaults.rs index fe4f3ae..2973164 100644 --- a/gateway-api/src/apis/standard/enum_defaults.rs +++ b/gateway-api/src/apis/standard/enum_defaults.rs @@ -1,6 +1,12 @@ use super::common::*; // WARNING: generated file - manual changes will be overriden +impl Default for BackendTlsPolicyValidationSubjectAltNamesType { + fn default() -> Self { + BackendTlsPolicyValidationSubjectAltNamesType::Hostname + } +} + impl Default for GRPCFilterType { fn default() -> Self { GRPCFilterType::RequestHeaderModifier @@ -18,3 +24,4 @@ impl Default for RequestOperationType { RequestOperationType::ReplaceFullPath } } +use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType; diff --git a/gateway-api/src/apis/standard/gatewayclasses.rs b/gateway-api/src/apis/standard/gatewayclasses.rs index a1d9b17..4f8272b 100644 --- a/gateway-api/src/apis/standard/gatewayclasses.rs +++ b/gateway-api/src/apis/standard/gatewayclasses.rs @@ -1,5 +1,6 @@ // 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; @@ -58,38 +59,6 @@ pub struct GatewayClassSpec { )] 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 diff --git a/gateway-api/src/apis/standard/gateways.rs b/gateway-api/src/apis/standard/gateways.rs index 18af475..cabe176 100644 --- a/gateway-api/src/apis/standard/gateways.rs +++ b/gateway-api/src/apis/standard/gateways.rs @@ -45,6 +45,14 @@ pub struct GatewaySpec { /// 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")] @@ -216,6 +224,11 @@ pub struct GatewaySpec { /// /// 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)] @@ -233,6 +246,67 @@ pub struct GatewayAddresses { #[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, +} +/// 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". +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayAllowedListenersNamespacesSelector { + /// 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>, +} /// Infrastructure defines infrastructure level attributes about this Gateway instance. /// /// Support: Extended @@ -282,7 +356,7 @@ pub struct GatewayInfrastructure { skip_serializing_if = "Option::is_none", rename = "parametersRef" )] - pub parameters_ref: Option, + pub parameters_ref: Option, } /// Listener embodies the concept of a logical endpoint where a Gateway accepts /// network connections. @@ -349,7 +423,7 @@ pub struct GatewayListeners { /// the Gateway SHOULD return a 421. /// * If the current Listener (selected by SNI matching during ClientHello) /// does not match the Host: - /// * If another Listener does match the Host the Gateway SHOULD return a + /// * If another Listener does match the Host, the Gateway SHOULD return a /// 421. /// * If no other Listener matches the Host, the Gateway MUST return a /// 404. @@ -466,16 +540,6 @@ pub struct GatewayListenersAllowedRoutesNamespaces { #[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". @@ -489,8 +553,7 @@ pub struct GatewayListenersAllowedRoutesNamespacesSelector { skip_serializing_if = "Option::is_none", rename = "matchExpressions" )] - pub match_expressions: - Option>, + 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. @@ -501,22 +564,6 @@ pub struct GatewayListenersAllowedRoutesNamespacesSelector { )] 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". @@ -588,53 +635,279 @@ pub struct GatewayListenersTls { #[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. +/// TLS specifies frontend and backend tls configuration for entire gateway. /// -/// 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. +/// Support: Extended #[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. +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 group: Option, - /// Kind is kind of the referent. For example "Secret". + pub backend: Option, + /// Frontend describes TLS config when client connects to Gateway. + /// Support: Core #[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. + 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 namespace: Option, + pub validation: 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". +/// 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. /// -/// The association of SNIs to Certificate defined in ListenerTLSConfig is -/// defined based on the Hostname field for this listener. +/// Support: Core +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendDefaultValidation { + /// CACertificateRefs contains one or more references to Kubernetes + /// objects that contain a PEM-encoded TLS CA certificate bundle, which + /// is used as a trust anchor to validate the certificates presented by + /// the client. + /// + /// 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 on all matching HTTPS listeners 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 on all matching HTTPS listeners must be set to + /// `InvalidCACertificateKind` and the Message of the Condition must explain + /// which kind of resource is unknown or unsupported. + /// + /// * It refers to a resource in another namespace UNLESS there is a + /// ReferenceGrant in the target namespace that allows the CA + /// certificate to be attached. If a ReferenceGrant does not allow this + /// reference, the `ResolvedRefs` on all matching HTTPS listeners condition + /// MUST be set 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. + /// + /// In all cases, the implementation MUST ensure that the `ResolvedRefs` + /// condition is set to `status: False` on all targeted listeners (i.e., + /// listeners serving HTTPS on a matching port). The condition MUST + /// include a Reason and Message that indicate the cause of the error. If + /// ALL CACertificateRefs are invalid, the implementation MUST also ensure + /// the `Accepted` condition on the listener is set to `status: False`, with + /// the Reason `NoValidCACertificate`. + /// 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, other kinds + /// of resources, or a single reference that includes multiple certificates. + #[serde(rename = "caCertificateRefs")] + pub ca_certificate_refs: Vec, + /// FrontendValidationMode defines the mode for validating the client certificate. + /// There are two possible modes: + /// + /// - AllowValidOnly: In this mode, the gateway will accept connections only if + /// the client presents a valid certificate. This certificate must successfully + /// pass validation against the CA certificates specified in `CACertificateRefs`. + /// - AllowInsecureFallback: In this mode, the gateway will accept connections + /// even if the client certificate is not presented or fails verification. + /// + /// This approach delegates client authorization to the backend and introduce + /// a significant security risk. It should be used in testing environments or + /// on a temporary basis in non-testing environments. + /// + /// Defaults to AllowValidOnly. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: 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. /// -/// 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 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, +} +/// 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 -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayListenersTlsMode { - Terminate, - Passthrough, +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct GatewayTlsFrontendPerPortTlsValidation { + /// CACertificateRefs contains one or more references to Kubernetes + /// objects that contain a PEM-encoded TLS CA certificate bundle, which + /// is used as a trust anchor to validate the certificates presented by + /// the client. + /// + /// 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 on all matching HTTPS listeners 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 on all matching HTTPS listeners must be set to + /// `InvalidCACertificateKind` and the Message of the Condition must explain + /// which kind of resource is unknown or unsupported. + /// + /// * It refers to a resource in another namespace UNLESS there is a + /// ReferenceGrant in the target namespace that allows the CA + /// certificate to be attached. If a ReferenceGrant does not allow this + /// reference, the `ResolvedRefs` on all matching HTTPS listeners condition + /// MUST be set 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. + /// + /// In all cases, the implementation MUST ensure that the `ResolvedRefs` + /// condition is set to `status: False` on all targeted listeners (i.e., + /// listeners serving HTTPS on a matching port). The condition MUST + /// include a Reason and Message that indicate the cause of the error. If + /// ALL CACertificateRefs are invalid, the implementation MUST also ensure + /// the `Accepted` condition on the listener is set to `status: False`, with + /// the Reason `NoValidCACertificate`. + /// 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, other kinds + /// of resources, or a single reference that includes multiple certificates. + #[serde(rename = "caCertificateRefs")] + pub ca_certificate_refs: Vec, + /// FrontendValidationMode defines the mode for validating the client certificate. + /// There are two possible modes: + /// + /// - AllowValidOnly: In this mode, the gateway will accept connections only if + /// the client presents a valid certificate. This certificate must successfully + /// pass validation against the CA certificates specified in `CACertificateRefs`. + /// - AllowInsecureFallback: In this mode, the gateway will accept connections + /// even if the client certificate is not presented or fails verification. + /// + /// This approach delegates client authorization to the backend and introduce + /// a significant security risk. It should be used in testing environments or + /// on a temporary basis in non-testing environments. + /// + /// Defaults to AllowValidOnly. + /// + /// Support: Core + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mode: Option, } /// Status defines the current state of Gateway. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] @@ -650,6 +923,22 @@ pub struct GatewayStatus { /// * 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 @@ -680,41 +969,3 @@ pub struct GatewayStatusAddresses { /// 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, -} diff --git a/gateway-api/src/apis/standard/grpcroutes.rs b/gateway-api/src/apis/standard/grpcroutes.rs index df1713b..d35eae4 100644 --- a/gateway-api/src/apis/standard/grpcroutes.rs +++ b/gateway-api/src/apis/standard/grpcroutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "grpcroutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "GrpcRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct GrpcRouteSpec { @@ -129,7 +129,7 @@ pub struct GrpcRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, @@ -198,7 +198,7 @@ pub struct GrpcRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -270,7 +270,7 @@ pub struct GRPCBackendReference { /// 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>, + 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")] @@ -327,6 +327,174 @@ pub struct GRPCBackendReference { #[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: GRPCFilterType, +} +/// 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: GRPCFilterType, +} /// 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. @@ -339,8 +507,8 @@ pub struct GRPCBackendReference { /// - method: /// type: Exact /// service: "foo" -/// headers: -/// - name: "version" +/// - headers: +/// name: "version" /// value "v1" /// /// ``` @@ -381,3 +549,66 @@ pub struct GRPCMethodMatch { #[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 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 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: BackendTlsPolicyStatusAncestorsAncestorRef, +} diff --git a/gateway-api/src/apis/standard/httproutes.rs b/gateway-api/src/apis/standard/httproutes.rs index 7ef2118..6aeb7c4 100644 --- a/gateway-api/src/apis/standard/httproutes.rs +++ b/gateway-api/src/apis/standard/httproutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "httproutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "HttpRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct HttpRouteSpec { @@ -132,7 +132,7 @@ pub struct HttpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, @@ -369,6 +369,12 @@ pub struct HTTPBackendReference { /// 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 @@ -382,7 +388,7 @@ pub struct HttpRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + pub extension_ref: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -472,6 +478,246 @@ pub struct HttpRouteBackendFilter { )] 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 @@ -480,6 +726,12 @@ pub struct HttpRouteBackendFilter { /// 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 @@ -493,7 +745,7 @@ pub struct HttpRouteFilter { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + pub extension_ref: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -583,6 +835,246 @@ pub struct HttpRouteFilter { )] 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. @@ -746,3 +1238,66 @@ pub struct HttpRouteTimeout { #[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: BackendTlsPolicyStatusAncestorsAncestorRef, +} diff --git a/gateway-api/src/apis/standard/listenersets.rs b/gateway-api/src/apis/standard/listenersets.rs new file mode 100644 index 0000000..e45552c --- /dev/null +++ b/gateway-api/src/apis/standard/listenersets.rs @@ -0,0 +1,318 @@ +// 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: GatewayListenersTlsCertificateRefs, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetListeners { + /// 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. + #[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`. + #[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 + /// ListenerSet. + /// + /// Name is not required to be unique across a Gateway and ListenerSets. + /// Routes can attach to a Listener by having a ListenerSet as a parentRef + /// and setting the SectionName + pub name: String, + /// Port is the network port. Multiple listeners may use the + /// same port, subject to the Listener compatibility rules. + pub port: i32, + /// Protocol specifies the network protocol this listener expects to receive. + 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 ListenerTLSConfig 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. + #[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. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetListenersAllowedRoutes { + /// 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, +} +/// 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 ListenerSetListenersAllowedRoutesNamespaces { + /// 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, +} +/// 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 ListenerSetListenersAllowedRoutesNamespacesSelector { + /// 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>, +} +/// 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 ListenerTLSConfig 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. +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct ListenerSetListenersTls { + /// 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>, +} +/// 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/apis/standard/mod.rs b/gateway-api/src/apis/standard/mod.rs index d6ed9b1..a5b451a 100644 --- a/gateway-api/src/apis/standard/mod.rs +++ b/gateway-api/src/apis/standard/mod.rs @@ -1,5 +1,6 @@ // WARNING: generated file - manual changes will be overriden +pub mod backendtlspolicies; pub mod common; pub mod constants; pub mod enum_defaults; @@ -7,4 +8,6 @@ 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/apis/standard/referencegrants.rs b/gateway-api/src/apis/standard/referencegrants.rs index 4a3e15e..6eb6981 100644 --- a/gateway-api/src/apis/standard/referencegrants.rs +++ b/gateway-api/src/apis/standard/referencegrants.rs @@ -11,7 +11,7 @@ use self::prelude::*; #[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] #[kube( group = "gateway.networking.k8s.io", - version = "v1beta1", + version = "v1", kind = "ReferenceGrant", plural = "referencegrants" )] diff --git a/gateway-api/src/apis/standard/tlsroutes.rs b/gateway-api/src/apis/standard/tlsroutes.rs new file mode 100644 index 0000000..ab93f5a --- /dev/null +++ b/gateway-api/src/apis/standard/tlsroutes.rs @@ -0,0 +1,248 @@ +// 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. + #[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, +} +/// 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: BackendTlsPolicyStatusAncestorsAncestorRef, +} diff --git a/scripts/generators/gateway.sh b/scripts/generators/gateway.sh index 2b5b5f9..f19e222 100755 --- a/scripts/generators/gateway.sh +++ b/scripts/generators/gateway.sh @@ -14,7 +14,7 @@ set -eou pipefail -GATEWAY_API_VERSION="v1.4.0" +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 "") @@ -43,6 +43,9 @@ STANDARD_APIS=( httproutes referencegrants grpcroutes + backendtlspolicies + listenersets + tlsroutes ) EXPERIMENTAL_APIS=( @@ -54,6 +57,8 @@ EXPERIMENTAL_APIS=( tcproutes tlsroutes udproutes + backendtlspolicies + listenersets ) export APIS_DIR='gateway-api/src/apis' @@ -90,6 +95,7 @@ ENUMS=( HttpRouteRulesBackendRefsFiltersType=RequestHeaderModifier GrpcRouteRulesFiltersType=RequestHeaderModifier GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier + BackendTlsPolicyValidationSubjectAltNamesType=Hostname ) # Create a comma separated string out of $ENUMS. @@ -100,6 +106,7 @@ 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 "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" @@ -137,6 +144,9 @@ ENUMS=( HttpRouteRulesBackendRefsFiltersExternalAuthProtocol=Http GrpcRouteRulesFiltersType=RequestHeaderModifier GrpcRouteRulesBackendRefsFiltersType=RequestHeaderModifier + BackendTlsPolicyValidationSubjectAltNamesType=Hostname + HttpRouteRulesFiltersExternalAuthProtocol=Http + ) ENUMS_WITH_DEFAULTS=$(printf ",%s" "${ENUMS[@]}") @@ -185,14 +195,18 @@ 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 -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 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 @@ -219,17 +233,20 @@ ENUMS=( 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 -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 +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" @@ -243,4 +260,4 @@ 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" \ No newline at end of file +echo "Gateway API Cleanup complete" diff --git a/type-reducer/standard_customized_mapped_names.txt b/type-reducer/standard_customized_mapped_names.txt index 9a6aaa3..1a82f56 100644 --- a/type-reducer/standard_customized_mapped_names.txt +++ b/type-reducer/standard_customized_mapped_names.txt @@ -86,3 +86,5 @@ HttpRouteRulesBackendRefsFiltersUrlRewrite->HttpRouteUrlRewrite HttpRouteRulesFiltersUrlRewrite->HttpRouteUrlRewrite GrpcRouteStatus->RouteStatus HttpRouteStatus->RouteStatus +TlsRouteStatus->RouteStatus + From 27c37245e35ab2ba5ee672840183576a90c5727d Mon Sep 17 00:00:00 2001 From: Dawid Nowak Date: Tue, 3 Mar 2026 15:08:18 +0000 Subject: [PATCH 90/95] Fixing type derivation for new types Signed-off-by: Dawid Nowak --- Cargo.lock | 493 ++++++++++++------ .../apis/experimental/backendtlspolicies.rs | 4 +- gateway-api/src/apis/experimental/common.rs | 220 ++++---- .../src/apis/experimental/gatewayclasses.rs | 2 +- gateway-api/src/apis/experimental/gateways.rs | 273 +--------- .../src/apis/experimental/grpcroutes.rs | 157 +++--- .../src/apis/experimental/httproutes.rs | 165 +++--- .../src/apis/experimental/listenersets.rs | 101 +--- .../src/apis/experimental/tcproutes.rs | 90 +--- .../src/apis/experimental/tlsroutes.rs | 90 +--- .../src/apis/experimental/udproutes.rs | 90 +--- .../src/apis/standard/backendtlspolicies.rs | 4 +- gateway-api/src/apis/standard/common.rs | 170 ++++-- .../src/apis/standard/gatewayclasses.rs | 2 +- gateway-api/src/apis/standard/gateways.rs | 273 +--------- gateway-api/src/apis/standard/grpcroutes.rs | 239 +-------- gateway-api/src/apis/standard/httproutes.rs | 71 +-- gateway-api/src/apis/standard/listenersets.rs | 101 +--- gateway-api/src/apis/standard/tlsroutes.rs | 67 +-- gateway-api/src/lib.rs | 12 +- scripts/generators/gateway.sh | 21 +- .../experimental_customized_mapped_names.txt | 108 ++-- .../experimental_reduced_types_pass_1.txt | 24 +- .../experimental_reduced_types_pass_2.txt | 27 +- .../experimental_reduced_types_pass_3.txt | 27 +- .../experimental_reduced_types_pass_4.txt | 29 +- .../standard_customized_mapped_names.txt | 37 +- .../standard_reduced_types_pass_1.txt | 22 +- .../standard_reduced_types_pass_2.txt | 22 +- .../standard_reduced_types_pass_3.txt | 1 + 30 files changed, 1051 insertions(+), 1891 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c90a98..a58e486 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,9 +63,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.100" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" [[package]] name = "atomic-waker" @@ -87,9 +87,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" [[package]] name = "block-buffer" @@ -102,21 +102,21 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.19.1" +version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" [[package]] name = "bytes" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" [[package]] name = "cc" -version = "1.2.52" +version = "1.2.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" dependencies = [ "find-msvc-tools", "shlex", @@ -130,9 +130,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "clap" -version = "4.5.54" +version = "4.5.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" dependencies = [ "clap_builder", "clap_derive", @@ -140,9 +140,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.54" +version = "4.5.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" dependencies = [ "anstream", "anstyle", @@ -152,9 +152,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.49" +version = "4.5.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" +checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" dependencies = [ "heck", "proc-macro2", @@ -164,9 +164,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" [[package]] name = "codegen" @@ -185,11 +185,11 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "colored" -version = "3.0.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e" +checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -274,9 +274,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.5.5" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" dependencies = [ "powerfmt", ] @@ -349,9 +349,15 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.7" +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 = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "form_urlencoded" @@ -364,9 +370,9 @@ dependencies = [ [[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", @@ -378,9 +384,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", @@ -388,33 +394,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", @@ -423,7 +429,6 @@ dependencies = [ "futures-task", "memchr", "pin-project-lite", - "pin-utils", "slab", ] @@ -494,8 +499,21 @@ checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", "libc", - "r-efi", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", "wasip2", + "wasip3", ] [[package]] @@ -504,6 +522,15 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + [[package]] name = "hashbrown" version = "0.16.1" @@ -609,13 +636,12 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ "bytes", "futures-channel", - "futures-core", "futures-util", "http", "http-body", @@ -628,6 +654,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" @@ -652,6 +684,8 @@ checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", "hashbrown 0.16.1", + "serde", + "serde_core", ] [[package]] @@ -699,9 +733,9 @@ checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] name = "jiff" -version = "0.2.18" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67e8da4c49d6d9909fe03361f9b620f58898859f5c7aded68351e85e71ecf50" +checksum = "819b44bc7c87d9117eb522f14d46e918add69ff12713c475946b0a29363ed1c2" dependencies = [ "jiff-static", "log", @@ -712,9 +746,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.18" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c84ee7f197eca9a86c6fd6cb771e55eb991632f15f2bc3ca6ec838929e6e78" +checksum = "470252db18ecc35fd766c0891b1e3ec6cbbcd62507e85276c01bf75d8e94d4a1" dependencies = [ "proc-macro2", "quote", @@ -723,9 +757,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.85" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" dependencies = [ "once_cell", "wasm-bindgen", @@ -759,9 +793,9 @@ dependencies = [ [[package]] name = "kube" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dae7229247e4215781e5c5104a056e1e2163943e577f9084cf8bba7b5248f7a" +checksum = "f96b537b4c4f61fc183594edbecbbefa3037e403feac0701bb24e6eff78e0034" dependencies = [ "k8s-openapi", "kube-client", @@ -770,9 +804,9 @@ dependencies = [ [[package]] name = "kube-client" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "010875e291a9c0a4e076f4f9c35b97d82fd2372cb3bc713252c3d08b7e73ce5b" +checksum = "af97b8b696eb737e5694f087c498ca725b172c2a5bc3a6916328d160225537ee" dependencies = [ "base64", "bytes", @@ -805,9 +839,9 @@ dependencies = [ [[package]] name = "kube-core" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac76281aa698dd34111e25b21f5f6561932a30feabab5357152be273f8a81bb" +checksum = "e7aeade7d2e9f165f96b3c1749ff01a8e2dc7ea954bd333bcfcecc37d5226bdd" dependencies = [ "derive_more", "form_urlencoded", @@ -823,9 +857,9 @@ dependencies = [ [[package]] name = "kube-derive" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599c09721efcccc0e6a26e93df28c587da60ff5e099c657626fff2af0ae4cbb8" +checksum = "c98f59f4e68864624a0b993a1cc2424439ab7238eaede5c299e89943e2a093ff" dependencies = [ "darling", "proc-macro2", @@ -841,11 +875,17 @@ 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.180" +version = "0.2.182" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" +checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" [[package]] name = "lock_api" @@ -867,9 +907,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.6" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "mime" @@ -908,9 +948,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" [[package]] name = "num-traits" @@ -944,9 +984,9 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "openssl-probe" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f50d9b3dabb09ecd771ad0aa242ca6894994c130308ca3d7684634df8037391" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" [[package]] name = "ordered-float" @@ -998,9 +1038,9 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pest" -version = "2.8.5" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9eb05c21a464ea704b53158d358a31e6425db2f63a1a7312268b05fe2b75f7" +checksum = "e0848c601009d37dfa3430c4666e147e49cdcf1b92ecd3e63657d8a5f19da662" dependencies = [ "memchr", "ucd-trie", @@ -1008,9 +1048,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.8.5" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f9dbced329c441fa79d80472764b1a2c7e57123553b8519b36663a2fb234ed" +checksum = "11f486f1ea21e6c10ed15d5a7c77165d0ee443402f0780849d1768e7d9d6fe77" dependencies = [ "pest", "pest_generator", @@ -1018,9 +1058,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.5" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bb96d5051a78f44f43c8f712d8e810adb0ebf923fc9ed2655a7f66f63ba8ee5" +checksum = "8040c4647b13b210a963c1ed407c1ff4fdfa01c31d6d2a098218702e6664f94f" dependencies = [ "pest", "pest_meta", @@ -1031,9 +1071,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.8.5" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602113b5b5e8621770cfd490cfd90b9f84ab29bd2b0e49ad83eb6d186cef2365" +checksum = "89815c69d36021a140146f26659a81d6c2afa33d216d736dd4be5381a7362220" dependencies = [ "pest", "sha2", @@ -1041,9 +1081,9 @@ dependencies = [ [[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" @@ -1053,15 +1093,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "portable-atomic" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f89776e4d69bb58bc6993e99ffa1d11f228b839984854c7daeb5d37f87cbe950" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" [[package]] name = "portable-atomic-util" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +checksum = "7a9db96d7fa8782dd8c15ce32ffe8680bbd1e978a43bf51a34d39483540495f5" dependencies = [ "portable-atomic", ] @@ -1093,18 +1133,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.43" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" dependencies = [ "proc-macro2", ] @@ -1115,6 +1155,12 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + [[package]] name = "rand" version = "0.9.2" @@ -1175,9 +1221,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.12.2" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" dependencies = [ "aho-corasick", "memchr", @@ -1187,9 +1233,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", @@ -1198,15 +1244,15 @@ dependencies = [ [[package]] name = "regex-lite" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d942b98df5e658f56f20d592c7f868833fe38115e65c33003d8cd224b0155da" +checksum = "cab834c73d247e67f4fae452806d17d3c7501756d98c8808d7c9c7aa7d18f973" [[package]] name = "regex-syntax" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" [[package]] name = "ring" @@ -1233,9 +1279,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.36" +version = "0.23.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b" +checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" dependencies = [ "log", "once_cell", @@ -1260,18 +1306,18 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e6f2ab2928ca4291b86736a8bd920a277a399bba1589409d72154ff87c1282" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" dependencies = [ "zeroize", ] [[package]] name = "rustls-webpki" -version = "0.103.8" +version = "0.103.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" +checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" dependencies = [ "ring", "rustls-pki-types", @@ -1286,9 +1332,9 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "schannel" @@ -1301,9 +1347,9 @@ dependencies = [ [[package]] name = "schemars" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54e910108742c57a770f492731f99be216a52fadd361b06c8fb59d74ccc267d2" +checksum = "a2b42f36aa1cd011945615b92222f6bf73c599a102a300334cd7f8dbeec726cc" dependencies = [ "dyn-clone", "ref-cast", @@ -1314,9 +1360,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4908ad288c5035a8eb12cfdf0d49270def0a268ee162b75eeee0f85d155a7c45" +checksum = "7d115b50f4aaeea07e79c1912f645c7513d81715d0420f8bc77a18c6260b307f" dependencies = [ "proc-macro2", "quote", @@ -1341,9 +1387,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "3.5.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ "bitflags", "core-foundation", @@ -1354,9 +1400,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.15.0" +version = "2.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" dependencies = [ "core-foundation-sys", "libc", @@ -1483,9 +1529,9 @@ dependencies = [ [[package]] name = "simple_logger" -version = "5.1.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291bee647ce7310b0ea721bfd7e0525517b4468eb7c7e15eb8bd774343179702" +checksum = "c7038d0e96661bf9ce647e1a6f6ef6d6f3663f66d9bf741abf14ba4876071c17" dependencies = [ "colored", "log", @@ -1495,9 +1541,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" @@ -1507,9 +1553,9 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" dependencies = [ "libc", "windows-sys 0.60.2", @@ -1529,9 +1575,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.114" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -1546,18 +1592,18 @@ checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" [[package]] name = "thiserror" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", @@ -1575,9 +1621,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.45" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9e442fc33d7fdb45aa9bfeb312c095964abdf596f7567261062b2a7107aaabd" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" dependencies = [ "deranged", "itoa", @@ -1592,15 +1638,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" [[package]] name = "time-macros" -version = "0.2.25" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e552d1249bf61ac2a52db88179fd0673def1e1ad8243a00d9ec9ed71fee3dd" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" dependencies = [ "num-conv", "time-core", @@ -1608,9 +1654,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.49.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" dependencies = [ "bytes", "libc", @@ -1625,9 +1671,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.6.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" dependencies = [ "proc-macro2", "quote", @@ -1687,6 +1733,7 @@ dependencies = [ "http-body", "mime", "pin-project-lite", + "tower", "tower-layer", "tower-service", "tracing", @@ -1796,9 +1843,15 @@ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-ident" -version = "1.0.22" +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 = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "unsafe-libyaml" @@ -1820,11 +1873,11 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.19.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" +checksum = "b672338555252d43fd2240c714dc444b8c6fb0a5c5335e65a07bba7742735ddb" dependencies = [ - "getrandom 0.3.4", + "getrandom 0.4.2", "js-sys", "rand", "wasm-bindgen", @@ -1859,18 +1912,27 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasip2" -version = "1.0.1+wasi-0.2.4" +version = "1.0.2+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +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 = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" dependencies = [ "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.108" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" dependencies = [ "cfg-if", "once_cell", @@ -1881,9 +1943,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.108" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1891,9 +1953,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.108" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" dependencies = [ "bumpalo", "proc-macro2", @@ -1904,33 +1966,58 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.108" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" dependencies = [ "unicode-ident", ] [[package]] -name = "windows-link" -version = "0.2.1" +name = "wasm-encoder" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] [[package]] -name = "windows-sys" -version = "0.52.0" +name = "wasm-metadata" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" dependencies = [ - "windows-targets 0.52.6", + "anyhow", + "indexmap 2.13.0", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +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" -version = "0.59.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets 0.52.6", ] @@ -2084,24 +2171,106 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "wit-bindgen" -version = "0.46.0" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +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 = "zerocopy" -version = "0.8.33" +version = "0.8.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668f5168d10b9ee831de31933dc111a459c97ec93225beb307aed970d1372dfd" +checksum = "a789c6e490b576db9f7e6b6d661bcc9799f7c0ac8352f56ea20193b2681532e5" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.33" +version = "0.8.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c7962b26b0a8685668b671ee4b54d007a67d4eaf05fda79ac0ecf41e32270f1" +checksum = "f65c489a7071a749c849713807783f70672b28094011623e200cb86dcb835953" dependencies = [ "proc-macro2", "quote", @@ -2116,6 +2285,6 @@ checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" [[package]] name = "zmij" -version = "1.0.14" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/gateway-api/src/apis/experimental/backendtlspolicies.rs b/gateway-api/src/apis/experimental/backendtlspolicies.rs index 9c9b0b5..10c7b7e 100644 --- a/gateway-api/src/apis/experimental/backendtlspolicies.rs +++ b/gateway-api/src/apis/experimental/backendtlspolicies.rs @@ -184,7 +184,7 @@ pub struct BackendTlsPolicyValidation { skip_serializing_if = "Option::is_none", rename = "caCertificateRefs" )] - pub ca_certificate_refs: Option>, + pub ca_certificate_refs: Option>, /// Hostname is used for two purposes in the connection between Gateways and /// backends: /// @@ -333,7 +333,7 @@ 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: BackendTlsPolicyStatusAncestorsAncestorRef, + 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 diff --git a/gateway-api/src/apis/experimental/common.rs b/gateway-api/src/apis/experimental/common.rs index fd790dc..2885040 100644 --- a/gateway-api/src/apis/experimental/common.rs +++ b/gateway-api/src/apis/experimental/common.rs @@ -10,6 +10,12 @@ mod prelude { } use self::prelude::*; #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] +pub enum AllowedRoutesNamespaces { + All, + Selector, + Same, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum GRPCFilterType { ResponseHeaderModifier, RequestHeaderModifier, @@ -22,20 +28,14 @@ pub enum GatewayDefaultScope { None, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayListenersAllowedRoutesNamespacesFrom { - All, - Selector, - Same, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayListenersTlsMode { - Terminate, - Passthrough, +pub enum GrpcRouteRulesSessionPersistenceCookieConfigLifetimeType { + Permanent, + Session, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayTlsFrontendDefaultValidationMode { - AllowValidOnly, - AllowInsecureFallback, +pub enum GrpcRouteRulesSessionPersistenceType { + Cookie, + Header, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum HTTPFilterType { @@ -63,11 +63,6 @@ pub enum HttpRouteRulesBackendRefsFiltersExternalAuthProtocol { Grpc, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum PersistenceCookieConfigLifetime { - Permanent, - Session, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum RedirectStatusCode { #[serde(rename = "301")] r#_301, @@ -93,24 +88,17 @@ pub enum RequestRedirectScheme { Https, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum SessionPersistenceType { - Cookie, - Header, +pub enum TlsMode { + Terminate, + Passthrough, } -#[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, PartialEq)] +pub enum TlsValidationMode { + AllowValidOnly, + AllowInsecureFallback, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct BackendReference { +pub struct BackendObjectReference { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -120,49 +108,20 @@ pub struct BackendReference { 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 BackendTlsClientCertificateReference { - #[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 BackendTlsPolicyStatusAncestorsAncestorRef { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, +pub struct ExtensionParametersReference { + pub group: String, + pub kind: String, 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 BackendTlsPolicyValidationCaCertificateRefs { +pub struct GatewayParametersRef { pub group: String, pub kind: String, pub name: String, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayAllowedListenersNamespacesSelectorMatchExpressions { - pub key: String, - pub operator: String, #[serde(default, skip_serializing_if = "Option::is_none")] - pub values: Option>, + pub namespace: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct HTTPHeader { @@ -207,9 +166,36 @@ pub struct Kind { pub kind: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct ParametersReference { - pub group: String, - pub kind: String, +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, @@ -221,11 +207,46 @@ pub struct RequestMirrorFraction { pub numerator: i32, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct CommonRouteRule { - #[serde(rename = "backendRefs")] - pub backend_refs: Vec, +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 GatewayAllowedListenersNamespacesSelector { + #[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 GatewayListenersTls { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "certificateRefs" + )] + pub certificate_refs: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - pub name: Option, + pub mode: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub options: Option>, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct GatewayStatusListeners { @@ -241,6 +262,13 @@ pub struct GatewayStatusListeners { pub supported_kinds: Option>, } #[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")] @@ -257,6 +285,14 @@ pub struct HeaderModifier { pub set: 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, @@ -283,15 +319,6 @@ pub struct RequestRedirectPath { pub r#type: RequestOperationType, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct SessionPersistenceCookieConfig { - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "lifetimeType" - )] - pub lifetime_type: Option, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct RequestRedirect { #[serde(default, skip_serializing_if = "Option::is_none")] pub hostname: Option, @@ -316,31 +343,6 @@ pub struct HttpRouteUrlRewrite { 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, +pub struct RouteStatus { + pub parents: Vec, } diff --git a/gateway-api/src/apis/experimental/gatewayclasses.rs b/gateway-api/src/apis/experimental/gatewayclasses.rs index 35ac3b0..2c224a1 100644 --- a/gateway-api/src/apis/experimental/gatewayclasses.rs +++ b/gateway-api/src/apis/experimental/gatewayclasses.rs @@ -57,7 +57,7 @@ pub struct GatewayClassSpec { skip_serializing_if = "Option::is_none", rename = "parametersRef" )] - pub parameters_ref: Option, + pub parameters_ref: Option, } /// Status defines the current state of GatewayClass. /// diff --git a/gateway-api/src/apis/experimental/gateways.rs b/gateway-api/src/apis/experimental/gateways.rs index 531c54f..85d3351 100644 --- a/gateway-api/src/apis/experimental/gateways.rs +++ b/gateway-api/src/apis/experimental/gateways.rs @@ -308,28 +308,6 @@ pub enum GatewayAllowedListenersNamespacesFrom { Same, None, } -/// 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". -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayAllowedListenersNamespacesSelector { - /// 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>, -} /// Infrastructure defines infrastructure level attributes about this Gateway instance. /// /// Support: Extended @@ -379,7 +357,7 @@ pub struct GatewayInfrastructure { skip_serializing_if = "Option::is_none", rename = "parametersRef" )] - pub parameters_ref: Option, + pub parameters_ref: Option, } /// Listener embodies the concept of a logical endpoint where a Gateway accepts /// network connections. @@ -554,109 +532,14 @@ pub struct GatewayListenersAllowedRoutesNamespaces { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub from: Option, + 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, -} -/// 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>, -} -/// 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 ListenerTLSConfig 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>, + pub selector: Option, } /// TLS specifies frontend and backend tls configuration for entire gateway. /// @@ -717,7 +600,7 @@ pub struct GatewayTlsBackend { skip_serializing_if = "Option::is_none", rename = "clientCertificateRef" )] - pub client_certificate_ref: Option, + pub client_certificate_ref: Option, } /// Frontend describes TLS config when client connects to Gateway. /// Support: Core @@ -756,79 +639,6 @@ pub struct GatewayTlsFrontendDefault { #[serde(default, skip_serializing_if = "Option::is_none")] pub validation: Option, } -/// 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 -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayTlsFrontendDefaultValidation { - /// CACertificateRefs contains one or more references to Kubernetes - /// objects that contain a PEM-encoded TLS CA certificate bundle, which - /// is used as a trust anchor to validate the certificates presented by - /// the client. - /// - /// 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 on all matching HTTPS listeners 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 on all matching HTTPS listeners must be set to - /// `InvalidCACertificateKind` and the Message of the Condition must explain - /// which kind of resource is unknown or unsupported. - /// - /// * It refers to a resource in another namespace UNLESS there is a - /// ReferenceGrant in the target namespace that allows the CA - /// certificate to be attached. If a ReferenceGrant does not allow this - /// reference, the `ResolvedRefs` on all matching HTTPS listeners condition - /// MUST be set 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. - /// - /// In all cases, the implementation MUST ensure that the `ResolvedRefs` - /// condition is set to `status: False` on all targeted listeners (i.e., - /// listeners serving HTTPS on a matching port). The condition MUST - /// include a Reason and Message that indicate the cause of the error. If - /// ALL CACertificateRefs are invalid, the implementation MUST also ensure - /// the `Accepted` condition on the listener is set to `status: False`, with - /// the Reason `NoValidCACertificate`. - /// 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, other kinds - /// of resources, or a single reference that includes multiple certificates. - #[serde(rename = "caCertificateRefs")] - pub ca_certificate_refs: Vec, - /// FrontendValidationMode defines the mode for validating the client certificate. - /// There are two possible modes: - /// - /// - AllowValidOnly: In this mode, the gateway will accept connections only if - /// the client presents a valid certificate. This certificate must successfully - /// pass validation against the CA certificates specified in `CACertificateRefs`. - /// - AllowInsecureFallback: In this mode, the gateway will accept connections - /// even if the client certificate is not presented or fails verification. - /// - /// This approach delegates client authorization to the backend and introduce - /// a significant security risk. It should be used in testing environments or - /// on a temporary basis in non-testing environments. - /// - /// Defaults to AllowValidOnly. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub mode: 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 @@ -857,80 +667,7 @@ pub struct GatewayTlsFrontendPerPortTls { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub validation: Option, -} -/// 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 -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayTlsFrontendPerPortTlsValidation { - /// CACertificateRefs contains one or more references to Kubernetes - /// objects that contain a PEM-encoded TLS CA certificate bundle, which - /// is used as a trust anchor to validate the certificates presented by - /// the client. - /// - /// 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 on all matching HTTPS listeners 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 on all matching HTTPS listeners must be set to - /// `InvalidCACertificateKind` and the Message of the Condition must explain - /// which kind of resource is unknown or unsupported. - /// - /// * It refers to a resource in another namespace UNLESS there is a - /// ReferenceGrant in the target namespace that allows the CA - /// certificate to be attached. If a ReferenceGrant does not allow this - /// reference, the `ResolvedRefs` on all matching HTTPS listeners condition - /// MUST be set 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. - /// - /// In all cases, the implementation MUST ensure that the `ResolvedRefs` - /// condition is set to `status: False` on all targeted listeners (i.e., - /// listeners serving HTTPS on a matching port). The condition MUST - /// include a Reason and Message that indicate the cause of the error. If - /// ALL CACertificateRefs are invalid, the implementation MUST also ensure - /// the `Accepted` condition on the listener is set to `status: False`, with - /// the Reason `NoValidCACertificate`. - /// 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, other kinds - /// of resources, or a single reference that includes multiple certificates. - #[serde(rename = "caCertificateRefs")] - pub ca_certificate_refs: Vec, - /// FrontendValidationMode defines the mode for validating the client certificate. - /// There are two possible modes: - /// - /// - AllowValidOnly: In this mode, the gateway will accept connections only if - /// the client presents a valid certificate. This certificate must successfully - /// pass validation against the CA certificates specified in `CACertificateRefs`. - /// - AllowInsecureFallback: In this mode, the gateway will accept connections - /// even if the client certificate is not presented or fails verification. - /// - /// This approach delegates client authorization to the backend and introduce - /// a significant security risk. It should be used in testing environments or - /// on a temporary basis in non-testing environments. - /// - /// Defaults to AllowValidOnly. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub mode: Option, + pub validation: Option, } /// Status defines the current state of Gateway. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] diff --git a/gateway-api/src/apis/experimental/grpcroutes.rs b/gateway-api/src/apis/experimental/grpcroutes.rs index 199a379..1290efd 100644 --- a/gateway-api/src/apis/experimental/grpcroutes.rs +++ b/gateway-api/src/apis/experimental/grpcroutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "grpcroutes" )] #[kube(namespaced)] -#[kube(status = "GrpcRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct GrpcRouteSpec { @@ -140,7 +140,7 @@ pub struct GrpcRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, @@ -293,7 +293,7 @@ pub struct GrpcRouteRule { skip_serializing_if = "Option::is_none", rename = "sessionPersistence" )] - pub session_persistence: Option, + pub session_persistence: Option, } /// GRPCBackendRef defines how a GRPCRoute forwards a gRPC request. /// @@ -402,7 +402,7 @@ pub struct GrpcRouteRulesBackendRefsFilters { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + pub extension_ref: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -486,7 +486,7 @@ pub struct GrpcRouteRulesFilters { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + pub extension_ref: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -603,66 +603,95 @@ pub struct GRPCMethodMatch { #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] pub r#type: Option, } -/// Status defines the current state of GRPCRoute. +/// SessionPersistence defines and configures session persistence +/// for the route rule. +/// +/// Support: Extended #[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, +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 of 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, } -/// RouteParentStatus describes the status of a route with respect to an -/// associated Parent. +/// CookieConfig provides configuration settings that are specific +/// to cookie-based session persistence. +/// +/// Support: Core #[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 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: BackendTlsPolicyStatusAncestorsAncestorRef, +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. + /// + /// Defaults to "Session". + /// + /// Support: Core for "Session" type + /// + /// Support: Extended for "Permanent" type + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "lifetimeType" + )] + pub lifetime_type: Option, } diff --git a/gateway-api/src/apis/experimental/httproutes.rs b/gateway-api/src/apis/experimental/httproutes.rs index bd575a1..2496e1d 100644 --- a/gateway-api/src/apis/experimental/httproutes.rs +++ b/gateway-api/src/apis/experimental/httproutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "httproutes" )] #[kube(namespaced)] -#[kube(status = "HttpRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct HttpRouteSpec { @@ -143,7 +143,7 @@ pub struct HttpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, @@ -327,7 +327,7 @@ pub struct HttpRouteRule { skip_serializing_if = "Option::is_none", rename = "sessionPersistence" )] - pub session_persistence: Option, + pub session_persistence: Option, /// Timeouts defines the timeouts that can be configured for an HTTP request. /// /// Support: Extended @@ -447,7 +447,7 @@ pub struct HttpRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + 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. @@ -889,7 +889,7 @@ pub struct HttpRouteFilter { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + 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. @@ -1474,6 +1474,98 @@ pub struct HttpRouteRulesRetry { #[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 of 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. + /// + /// Defaults to "Session". + /// + /// Support: Core for "Session" type + /// + /// Support: Extended for "Permanent" type + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "lifetimeType" + )] + pub lifetime_type: Option, +} /// Timeouts defines the timeouts that can be configured for an HTTP request. /// /// Support: Extended @@ -1529,66 +1621,3 @@ pub struct HttpRouteTimeout { #[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: BackendTlsPolicyStatusAncestorsAncestorRef, -} diff --git a/gateway-api/src/apis/experimental/listenersets.rs b/gateway-api/src/apis/experimental/listenersets.rs index e7341f9..1d9df7c 100644 --- a/gateway-api/src/apis/experimental/listenersets.rs +++ b/gateway-api/src/apis/experimental/listenersets.rs @@ -52,7 +52,7 @@ pub struct ListenerSetSpec { pub listeners: Vec, /// ParentRef references the Gateway that the listeners are attached to. #[serde(rename = "parentRef")] - pub parent_ref: BackendTlsClientCertificateReference, + pub parent_ref: Reference, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct ListenerSetListeners { @@ -132,7 +132,7 @@ pub struct ListenerSetListeners { /// The GatewayClass MUST use the longest matching SNI out of all /// available certificates for any TLS handshake. #[serde(default, skip_serializing_if = "Option::is_none")] - pub tls: Option, + 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 @@ -194,107 +194,14 @@ pub struct ListenerSetListenersAllowedRoutesNamespaces { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub from: Option, + 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, -} -/// 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 ListenerSetListenersAllowedRoutesNamespacesSelector { - /// 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>, -} -/// 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 ListenerTLSConfig 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. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct ListenerSetListenersTls { - /// 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>, + pub selector: Option, } /// Status defines the current state of ListenerSet. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] diff --git a/gateway-api/src/apis/experimental/tcproutes.rs b/gateway-api/src/apis/experimental/tcproutes.rs index 0e1f524..6adcdcb 100644 --- a/gateway-api/src/apis/experimental/tcproutes.rs +++ b/gateway-api/src/apis/experimental/tcproutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "tcproutes" )] #[kube(namespaced)] -#[kube(status = "TcpRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct TcpRouteSpec { @@ -88,9 +88,9 @@ pub struct TcpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + pub parent_refs: Option>, /// Rules are a list of TCP matchers and actions. - pub rules: Vec, + 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 @@ -110,66 +110,28 @@ pub struct TcpRouteSpec { )] pub use_default_gateways: Option, } -/// Status defines the current state of TCPRoute. +/// TCPRouteRule is the configuration for a given rule. #[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: BackendTlsPolicyStatusAncestorsAncestorRef, +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, } diff --git a/gateway-api/src/apis/experimental/tlsroutes.rs b/gateway-api/src/apis/experimental/tlsroutes.rs index a2950c4..11a337d 100644 --- a/gateway-api/src/apis/experimental/tlsroutes.rs +++ b/gateway-api/src/apis/experimental/tlsroutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "tlsroutes" )] #[kube(namespaced)] -#[kube(status = "TlsRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct TlsRouteSpec { @@ -96,9 +96,9 @@ pub struct TlsRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + pub parent_refs: Option>, /// Rules are a list of actions. - pub rules: Vec, + 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 @@ -118,66 +118,28 @@ pub struct TlsRouteSpec { )] pub use_default_gateways: Option, } -/// Status defines the current state of TLSRoute. +/// TLSRouteRule is the configuration for a given rule. #[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: BackendTlsPolicyStatusAncestorsAncestorRef, +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, } diff --git a/gateway-api/src/apis/experimental/udproutes.rs b/gateway-api/src/apis/experimental/udproutes.rs index 4e3a24e..e547c94 100644 --- a/gateway-api/src/apis/experimental/udproutes.rs +++ b/gateway-api/src/apis/experimental/udproutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "udproutes" )] #[kube(namespaced)] -#[kube(status = "UdpRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct UdpRouteSpec { @@ -88,9 +88,9 @@ pub struct UdpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + pub parent_refs: Option>, /// Rules are a list of UDP matchers and actions. - pub rules: Vec, + 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 @@ -110,66 +110,28 @@ pub struct UdpRouteSpec { )] pub use_default_gateways: Option, } -/// Status defines the current state of UDPRoute. +/// UDPRouteRule is the configuration for a given rule. #[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: BackendTlsPolicyStatusAncestorsAncestorRef, +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, } diff --git a/gateway-api/src/apis/standard/backendtlspolicies.rs b/gateway-api/src/apis/standard/backendtlspolicies.rs index 9c9b0b5..10c7b7e 100644 --- a/gateway-api/src/apis/standard/backendtlspolicies.rs +++ b/gateway-api/src/apis/standard/backendtlspolicies.rs @@ -184,7 +184,7 @@ pub struct BackendTlsPolicyValidation { skip_serializing_if = "Option::is_none", rename = "caCertificateRefs" )] - pub ca_certificate_refs: Option>, + pub ca_certificate_refs: Option>, /// Hostname is used for two purposes in the connection between Gateways and /// backends: /// @@ -333,7 +333,7 @@ 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: BackendTlsPolicyStatusAncestorsAncestorRef, + 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 diff --git a/gateway-api/src/apis/standard/common.rs b/gateway-api/src/apis/standard/common.rs index f39aa1f..647636e 100644 --- a/gateway-api/src/apis/standard/common.rs +++ b/gateway-api/src/apis/standard/common.rs @@ -10,27 +10,17 @@ mod prelude { } use self::prelude::*; #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GRPCFilterType { - ResponseHeaderModifier, - RequestHeaderModifier, - RequestMirror, - ExtensionRef, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayListenersAllowedRoutesNamespacesFrom { +pub enum AllowedRoutesNamespaces { All, Selector, Same, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayListenersTlsMode { - Terminate, - Passthrough, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayTlsFrontendDefaultValidationMode { - AllowValidOnly, - AllowInsecureFallback, +pub enum GRPCFilterType { + ResponseHeaderModifier, + RequestHeaderModifier, + RequestMirror, + ExtensionRef, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum HTTPFilterType { @@ -74,6 +64,16 @@ pub enum RequestRedirectScheme { #[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")] @@ -87,46 +87,57 @@ pub struct BackendObjectReference { pub port: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct BackendTlsPolicyStatusAncestorsAncestorRef { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, +pub struct ExtensionParametersReference { + pub group: String, + pub kind: String, 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 BackendTlsPolicyValidationCaCertificateRefs { +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 GatewayAllowedListenersNamespacesSelectorMatchExpressions { +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 GatewayClassParametersRef { - pub group: String, - pub kind: String, +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 GatewayListenersTlsCertificateRefs { +pub struct Reference { #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -136,21 +147,38 @@ pub struct GatewayListenersTlsCertificateRefs { pub namespace: Option, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HTTPHeader { - pub name: String, - pub value: String, +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 Kind { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - pub kind: String, +pub struct GatewayAllowedListenersNamespacesSelector { + #[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 RequestMirrorFraction { +pub struct GatewayListenersTls { + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "certificateRefs" + )] + pub certificate_refs: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - pub denominator: Option, - pub numerator: i32, + pub mode: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub options: Option>, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct GatewayStatusListeners { @@ -166,6 +194,13 @@ pub struct GatewayStatusListeners { pub supported_kinds: Option>, } #[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")] @@ -182,6 +217,14 @@ pub struct HeaderModifier { pub set: 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, @@ -208,6 +251,35 @@ pub struct RequestRedirectPath { pub r#type: RequestOperationType, } #[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 RequestRedirect { #[serde(default, skip_serializing_if = "Option::is_none")] pub hostname: Option, @@ -231,3 +303,7 @@ pub struct HttpRouteUrlRewrite { #[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, +} diff --git a/gateway-api/src/apis/standard/gatewayclasses.rs b/gateway-api/src/apis/standard/gatewayclasses.rs index 4f8272b..2c224a1 100644 --- a/gateway-api/src/apis/standard/gatewayclasses.rs +++ b/gateway-api/src/apis/standard/gatewayclasses.rs @@ -57,7 +57,7 @@ pub struct GatewayClassSpec { skip_serializing_if = "Option::is_none", rename = "parametersRef" )] - pub parameters_ref: Option, + pub parameters_ref: Option, } /// Status defines the current state of GatewayClass. /// diff --git a/gateway-api/src/apis/standard/gateways.rs b/gateway-api/src/apis/standard/gateways.rs index cabe176..8ff7f1e 100644 --- a/gateway-api/src/apis/standard/gateways.rs +++ b/gateway-api/src/apis/standard/gateways.rs @@ -285,28 +285,6 @@ pub enum GatewayAllowedListenersNamespacesFrom { Same, None, } -/// 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". -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayAllowedListenersNamespacesSelector { - /// 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>, -} /// Infrastructure defines infrastructure level attributes about this Gateway instance. /// /// Support: Extended @@ -356,7 +334,7 @@ pub struct GatewayInfrastructure { skip_serializing_if = "Option::is_none", rename = "parametersRef" )] - pub parameters_ref: Option, + pub parameters_ref: Option, } /// Listener embodies the concept of a logical endpoint where a Gateway accepts /// network connections. @@ -531,109 +509,14 @@ pub struct GatewayListenersAllowedRoutesNamespaces { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub from: Option, + 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, -} -/// 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>, -} -/// 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 ListenerTLSConfig 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>, + pub selector: Option, } /// TLS specifies frontend and backend tls configuration for entire gateway. /// @@ -694,7 +577,7 @@ pub struct GatewayTlsBackend { skip_serializing_if = "Option::is_none", rename = "clientCertificateRef" )] - pub client_certificate_ref: Option, + pub client_certificate_ref: Option, } /// Frontend describes TLS config when client connects to Gateway. /// Support: Core @@ -733,79 +616,6 @@ pub struct GatewayTlsFrontendDefault { #[serde(default, skip_serializing_if = "Option::is_none")] pub validation: Option, } -/// 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 -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayTlsFrontendDefaultValidation { - /// CACertificateRefs contains one or more references to Kubernetes - /// objects that contain a PEM-encoded TLS CA certificate bundle, which - /// is used as a trust anchor to validate the certificates presented by - /// the client. - /// - /// 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 on all matching HTTPS listeners 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 on all matching HTTPS listeners must be set to - /// `InvalidCACertificateKind` and the Message of the Condition must explain - /// which kind of resource is unknown or unsupported. - /// - /// * It refers to a resource in another namespace UNLESS there is a - /// ReferenceGrant in the target namespace that allows the CA - /// certificate to be attached. If a ReferenceGrant does not allow this - /// reference, the `ResolvedRefs` on all matching HTTPS listeners condition - /// MUST be set 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. - /// - /// In all cases, the implementation MUST ensure that the `ResolvedRefs` - /// condition is set to `status: False` on all targeted listeners (i.e., - /// listeners serving HTTPS on a matching port). The condition MUST - /// include a Reason and Message that indicate the cause of the error. If - /// ALL CACertificateRefs are invalid, the implementation MUST also ensure - /// the `Accepted` condition on the listener is set to `status: False`, with - /// the Reason `NoValidCACertificate`. - /// 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, other kinds - /// of resources, or a single reference that includes multiple certificates. - #[serde(rename = "caCertificateRefs")] - pub ca_certificate_refs: Vec, - /// FrontendValidationMode defines the mode for validating the client certificate. - /// There are two possible modes: - /// - /// - AllowValidOnly: In this mode, the gateway will accept connections only if - /// the client presents a valid certificate. This certificate must successfully - /// pass validation against the CA certificates specified in `CACertificateRefs`. - /// - AllowInsecureFallback: In this mode, the gateway will accept connections - /// even if the client certificate is not presented or fails verification. - /// - /// This approach delegates client authorization to the backend and introduce - /// a significant security risk. It should be used in testing environments or - /// on a temporary basis in non-testing environments. - /// - /// Defaults to AllowValidOnly. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub mode: 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 @@ -834,80 +644,7 @@ pub struct GatewayTlsFrontendPerPortTls { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub validation: Option, -} -/// 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 -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayTlsFrontendPerPortTlsValidation { - /// CACertificateRefs contains one or more references to Kubernetes - /// objects that contain a PEM-encoded TLS CA certificate bundle, which - /// is used as a trust anchor to validate the certificates presented by - /// the client. - /// - /// 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 on all matching HTTPS listeners 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 on all matching HTTPS listeners must be set to - /// `InvalidCACertificateKind` and the Message of the Condition must explain - /// which kind of resource is unknown or unsupported. - /// - /// * It refers to a resource in another namespace UNLESS there is a - /// ReferenceGrant in the target namespace that allows the CA - /// certificate to be attached. If a ReferenceGrant does not allow this - /// reference, the `ResolvedRefs` on all matching HTTPS listeners condition - /// MUST be set 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. - /// - /// In all cases, the implementation MUST ensure that the `ResolvedRefs` - /// condition is set to `status: False` on all targeted listeners (i.e., - /// listeners serving HTTPS on a matching port). The condition MUST - /// include a Reason and Message that indicate the cause of the error. If - /// ALL CACertificateRefs are invalid, the implementation MUST also ensure - /// the `Accepted` condition on the listener is set to `status: False`, with - /// the Reason `NoValidCACertificate`. - /// 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, other kinds - /// of resources, or a single reference that includes multiple certificates. - #[serde(rename = "caCertificateRefs")] - pub ca_certificate_refs: Vec, - /// FrontendValidationMode defines the mode for validating the client certificate. - /// There are two possible modes: - /// - /// - AllowValidOnly: In this mode, the gateway will accept connections only if - /// the client presents a valid certificate. This certificate must successfully - /// pass validation against the CA certificates specified in `CACertificateRefs`. - /// - AllowInsecureFallback: In this mode, the gateway will accept connections - /// even if the client certificate is not presented or fails verification. - /// - /// This approach delegates client authorization to the backend and introduce - /// a significant security risk. It should be used in testing environments or - /// on a temporary basis in non-testing environments. - /// - /// Defaults to AllowValidOnly. - /// - /// Support: Core - #[serde(default, skip_serializing_if = "Option::is_none")] - pub mode: Option, + pub validation: Option, } /// Status defines the current state of Gateway. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] diff --git a/gateway-api/src/apis/standard/grpcroutes.rs b/gateway-api/src/apis/standard/grpcroutes.rs index d35eae4..5cb1d24 100644 --- a/gateway-api/src/apis/standard/grpcroutes.rs +++ b/gateway-api/src/apis/standard/grpcroutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "grpcroutes" )] #[kube(namespaced)] -#[kube(status = "GrpcRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct GrpcRouteSpec { @@ -129,7 +129,7 @@ pub struct GrpcRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, @@ -198,7 +198,7 @@ pub struct GrpcRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -270,7 +270,7 @@ pub struct GRPCBackendReference { /// 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>, + 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")] @@ -327,174 +327,6 @@ pub struct GRPCBackendReference { #[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: GRPCFilterType, -} -/// 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: GRPCFilterType, -} /// 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. @@ -549,66 +381,3 @@ pub struct GRPCMethodMatch { #[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 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 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: BackendTlsPolicyStatusAncestorsAncestorRef, -} diff --git a/gateway-api/src/apis/standard/httproutes.rs b/gateway-api/src/apis/standard/httproutes.rs index 6aeb7c4..788536f 100644 --- a/gateway-api/src/apis/standard/httproutes.rs +++ b/gateway-api/src/apis/standard/httproutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "httproutes" )] #[kube(namespaced)] -#[kube(status = "HttpRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct HttpRouteSpec { @@ -132,7 +132,7 @@ pub struct HttpRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + 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>, @@ -388,7 +388,7 @@ pub struct HttpRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + pub extension_ref: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -745,7 +745,7 @@ pub struct HttpRouteFilter { skip_serializing_if = "Option::is_none", rename = "extensionRef" )] - pub extension_ref: Option, + pub extension_ref: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -1238,66 +1238,3 @@ pub struct HttpRouteTimeout { #[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: BackendTlsPolicyStatusAncestorsAncestorRef, -} diff --git a/gateway-api/src/apis/standard/listenersets.rs b/gateway-api/src/apis/standard/listenersets.rs index e45552c..1d9df7c 100644 --- a/gateway-api/src/apis/standard/listenersets.rs +++ b/gateway-api/src/apis/standard/listenersets.rs @@ -52,7 +52,7 @@ pub struct ListenerSetSpec { pub listeners: Vec, /// ParentRef references the Gateway that the listeners are attached to. #[serde(rename = "parentRef")] - pub parent_ref: GatewayListenersTlsCertificateRefs, + pub parent_ref: Reference, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct ListenerSetListeners { @@ -132,7 +132,7 @@ pub struct ListenerSetListeners { /// The GatewayClass MUST use the longest matching SNI out of all /// available certificates for any TLS handshake. #[serde(default, skip_serializing_if = "Option::is_none")] - pub tls: Option, + 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 @@ -194,107 +194,14 @@ pub struct ListenerSetListenersAllowedRoutesNamespaces { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub from: Option, + 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, -} -/// 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 ListenerSetListenersAllowedRoutesNamespacesSelector { - /// 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>, -} -/// 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 ListenerTLSConfig 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. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct ListenerSetListenersTls { - /// 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>, + pub selector: Option, } /// Status defines the current state of ListenerSet. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] diff --git a/gateway-api/src/apis/standard/tlsroutes.rs b/gateway-api/src/apis/standard/tlsroutes.rs index ab93f5a..f0f07d6 100644 --- a/gateway-api/src/apis/standard/tlsroutes.rs +++ b/gateway-api/src/apis/standard/tlsroutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "tlsroutes" )] #[kube(namespaced)] -#[kube(status = "TlsRouteStatus")] +#[kube(status = "RouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct TlsRouteSpec { @@ -85,7 +85,7 @@ pub struct TlsRouteSpec { skip_serializing_if = "Option::is_none", rename = "parentRefs" )] - pub parent_refs: Option>, + pub parent_refs: Option>, /// Rules are a list of actions. pub rules: Vec, } @@ -183,66 +183,3 @@ pub struct TlsRouteRulesBackendRefs { #[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 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: BackendTlsPolicyStatusAncestorsAncestorRef, -} diff --git a/gateway-api/src/lib.rs b/gateway-api/src/lib.rs index f5e16ea..c8a0733 100644 --- a/gateway-api/src/lib.rs +++ b/gateway-api/src/lib.rs @@ -28,7 +28,9 @@ mod tests { use uuid::Uuid; use crate::{ - apis::standard::common::{ParentReference, ParentRouteStatus, RouteStatus}, + apis::standard::common::{ + GatewayStatusListeners, ParentReference, ParentRouteStatus, RouteStatus, + }, apis::standard::constants::{ GatewayConditionReason, GatewayConditionType, ListenerConditionReason, ListenerConditionType, RouteConditionReason, RouteConditionType, @@ -36,7 +38,6 @@ mod tests { apis::standard::gatewayclasses::{GatewayClass, GatewayClassSpec}, apis::standard::gateways::{ Gateway, GatewayListeners, GatewaySpec, GatewayStatus, GatewayStatusAddresses, - GatewayStatusListeners, }, apis::standard::grpcroutes::GrpcRouteSpec, apis::standard::httproutes::HttpRouteSpec, @@ -45,7 +46,7 @@ mod tests { }, }; - const DEFAULT_GATEWAY_API_VERSION: &str = "v1.4.0"; + const DEFAULT_GATEWAY_API_VERSION: &str = "v1.5.0"; // ------------------------------------------------------------------------- // Tests @@ -126,6 +127,8 @@ mod tests { }], addresses: None, infrastructure: None, + allowed_listeners: None, + tls: None, }, status: None, }; @@ -145,7 +148,7 @@ mod tests { listeners: Some(vec![GatewayStatusListeners { name: "http".into(), attached_routes: 0, - supported_kinds: vec![], + supported_kinds: None, conditions: vec![Condition { last_transition_time: Time(Timestamp::now()), message: "testing gateway".to_string(), @@ -163,6 +166,7 @@ mod tests { status: "True".to_string(), type_: GatewayConditionType::Programmed.to_string(), }]), + attached_listener_sets: None, }; gw = Api::default_namespaced(client.clone()) diff --git a/scripts/generators/gateway.sh b/scripts/generators/gateway.sh index f19e222..1681240 100755 --- a/scripts/generators/gateway.sh +++ b/scripts/generators/gateway.sh @@ -186,6 +186,11 @@ 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 @@ -203,9 +208,9 @@ 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 +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 @@ -242,11 +247,11 @@ GATEWAY_API_ENUMS=${ENUMS_WITH_DEFAULTS} cargo xtask gen_enum_defaults > $APIS_D 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 = "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" diff --git a/type-reducer/experimental_customized_mapped_names.txt b/type-reducer/experimental_customized_mapped_names.txt index e041d84..440ffc7 100644 --- a/type-reducer/experimental_customized_mapped_names.txt +++ b/type-reducer/experimental_customized_mapped_names.txt @@ -1,26 +1,40 @@ GrpcRouteRulesBackendRefsFiltersType->GRPCFilterType GrpcRouteRulesFiltersType->GRPCFilterType -GrpcRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction -GrpcRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction -HttpRouteRulesBackendRefsFiltersRequestMirrorFraction->RequestMirrorFraction -HttpRouteRulesFiltersRequestMirrorFraction->RequestMirrorFraction -GrpcRouteRulesSessionPersistenceCookieConfigLifetimeType->PersistenceCookieConfigLifetime -HttpRouteRulesSessionPersistenceCookieConfigLifetimeType->PersistenceCookieConfigLifetime -GrpcRouteRulesSessionPersistenceType->SessionPersistenceType -HttpRouteRulesSessionPersistenceType->SessionPersistenceType GatewayAddresses->GatewayAddress GatewayStatusAddresses->GatewayAddress -GatewayBackendTlsClientCertificateRef->BackendTlsClientCertificateReference -GatewayListenersTlsCertificateRefs->BackendTlsClientCertificateReference -GatewayClassParametersRef->ParametersReference -GatewayListenersTlsFrontendValidationCaCertificateRefs->ParametersReference -GrpcRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference -GrpcRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference -GatewayInfrastructureParametersRef->GatewayInfrastructureParametersReference -HttpRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference -HttpRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference -HttpRouteRulesBackendRefsFiltersType->HTTPFilterType -HttpRouteRulesFiltersType->HTTPFilterType +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->AllowedRoutesNamespaces +ListenerSetListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespaces +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 @@ -37,14 +51,6 @@ HttpRouteRulesFiltersRequestHeaderModifierAdd->HTTPHeader HttpRouteRulesFiltersRequestHeaderModifierSet->HTTPHeader HttpRouteRulesFiltersResponseHeaderModifierAdd->HTTPHeader HttpRouteRulesFiltersResponseHeaderModifierSet->HTTPHeader -GrpcRouteRulesMatchesHeadersType->HeaderMatchType -GrpcRouteRulesMatchesMethodType->HeaderMatchType -HttpRouteRulesMatchesHeadersType->HeaderMatchType -HttpRouteRulesMatchesQueryParamsType->HeaderMatchType -GatewayListenersAllowedRoutesKinds->Kind -GatewayStatusListenersSupportedKinds->Kind -HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode->RedirectStatusCode -HttpRouteRulesFiltersRequestRedirectStatusCode->RedirectStatusCode GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference GrpcRouteRulesFiltersRequestMirrorBackendRef->BackendObjectReference HttpRouteRulesBackendRefsFiltersRequestMirrorBackendRef->BackendObjectReference @@ -59,25 +65,15 @@ HttpRouteRulesFiltersRequestRedirectPathType->RequestOperationType HttpRouteRulesFiltersUrlRewritePathType->RequestOperationType HttpRouteRulesBackendRefsFiltersRequestRedirectScheme->RequestRedirectScheme HttpRouteRulesFiltersRequestRedirectScheme->RequestRedirectScheme -GrpcRouteParentRefs->ParentReference -GrpcRouteStatusParentsParentRef->ParentReference -HttpRouteParentRefs->ParentReference -HttpRouteStatusParentsParentRef->ParentReference -TcpRouteParentRefs->ParentReference -TcpRouteStatusParentsParentRef->ParentReference -TlsRouteParentRefs->ParentReference -TlsRouteStatusParentsParentRef->ParentReference -UdpRouteParentRefs->ParentReference -UdpRouteStatusParentsParentRef->ParentReference -TcpRouteRulesBackendRefs->BackendReference -TlsRouteRulesBackendRefs->BackendReference -UdpRouteRulesBackendRefs->BackendReference +HttpRouteRulesBackendRefsFiltersRequestRedirectStatusCode->RedirectStatusCode +HttpRouteRulesFiltersRequestRedirectStatusCode->RedirectStatusCode +HttpRouteRulesBackendRefsFiltersType->HTTPFilterType +HttpRouteRulesFiltersType->HTTPFilterType +GrpcRouteRulesMatchesHeadersType->HeaderMatchType +GrpcRouteRulesMatchesMethodType->HeaderMatchType +HttpRouteRulesMatchesHeadersType->HeaderMatchType +HttpRouteRulesMatchesQueryParamsType->HeaderMatchType #### Pass 2 -GrpcRouteRulesSessionPersistenceCookieConfig->SessionPersistenceCookieConfig -HttpRouteRulesSessionPersistenceCookieConfig->SessionPersistenceCookieConfig -GrpcRouteRulesMatchesHeaders->HeaderMatch -HttpRouteRulesMatchesHeaders->HeaderMatch -HttpRouteRulesMatchesQueryParams->HeaderMatch GrpcRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier GrpcRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier GrpcRouteRulesFiltersRequestHeaderModifier->HeaderModifier @@ -86,6 +82,11 @@ HttpRouteRulesBackendRefsFiltersRequestHeaderModifier->HeaderModifier HttpRouteRulesBackendRefsFiltersResponseHeaderModifier->HeaderModifier HttpRouteRulesFiltersRequestHeaderModifier->HeaderModifier HttpRouteRulesFiltersResponseHeaderModifier->HeaderModifier +GrpcRouteRulesMatchesHeaders->HeaderMatch +HttpRouteRulesMatchesHeaders->HeaderMatch +HttpRouteRulesMatchesQueryParams->HeaderMatch +GrpcRouteStatusParents->ParentRouteStatus +HttpRouteStatusParents->ParentRouteStatus GrpcRouteRulesBackendRefsFiltersRequestMirror->RequestMirror GrpcRouteRulesFiltersRequestMirror->RequestMirror HttpRouteRulesBackendRefsFiltersRequestMirror->RequestMirror @@ -94,30 +95,13 @@ HttpRouteRulesBackendRefsFiltersRequestRedirectPath->RequestRedirectPath HttpRouteRulesBackendRefsFiltersUrlRewritePath->RequestRedirectPath HttpRouteRulesFiltersRequestRedirectPath->RequestRedirectPath HttpRouteRulesFiltersUrlRewritePath->RequestRedirectPath -TcpRouteRules->CommonRouteRule -TlsRouteRules->CommonRouteRule -UdpRouteRules->CommonRouteRule -GrpcRouteStatusParents->ParentRouteStatus -HttpRouteStatusParents->ParentRouteStatus -TcpRouteStatusParents->ParentRouteStatus -TlsRouteStatusParents->ParentRouteStatus -UdpRouteStatusParents->ParentRouteStatus #### Pass 3 GrpcRouteRulesBackendRefsFilters->GrpcRouteFilter GrpcRouteRulesFilters->GrpcRouteFilter -GrpcRouteRulesSessionPersistence->SessionPersistence -HttpRouteRulesSessionPersistence->SessionPersistence HttpRouteRulesBackendRefsFiltersRequestRedirect->HttpRouteRequestRedirect HttpRouteRulesFiltersRequestRedirect->HttpRouteRequestRedirect HttpRouteRulesBackendRefsFiltersUrlRewrite->HttpRouteUrlRewrite HttpRouteRulesFiltersUrlRewrite->HttpRouteUrlRewrite -TcpRouteSpec->RouteSpec -UdpRouteSpec->RouteSpec GrpcRouteStatus->RouteStatus HttpRouteStatus->RouteStatus -TcpRouteStatus->RouteStatus TlsRouteStatus->RouteStatus -UdpRouteStatus->RouteStatus -#### Pass 4 -HttpRouteRulesBackendRefsFilters->HttpRouteBackendFilters -HttpRouteRulesFilters->HttpRouteRulesBackendRefsFilters diff --git a/type-reducer/experimental_reduced_types_pass_1.txt b/type-reducer/experimental_reduced_types_pass_1.txt index 5a97edc..ddbc093 100644 --- a/type-reducer/experimental_reduced_types_pass_1.txt +++ b/type-reducer/experimental_reduced_types_pass_1.txt @@ -1,19 +1,23 @@ +AllowedRoutesNamespaces +BackendObjectReference Condition -GRPCFilterType -RequestMirrorFraction -PersistenceCookieConfigLifetime -SessionPersistenceType +ExtensionParametersReference +FilterExtensionReference +FiltersType GatewayAddress -BackendTlsClientCertificateReference -ParametersReference GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType HTTPFilterType HTTPHeader -HeaderMatchType Kind +MatchExpressions +ParentReference RedirectStatusCode -BackendObjectReference +Reference +RequestMirrorFraction RequestOperationType RequestRedirectScheme -ParentReference -BackendReference +TlsMode +TlsValidationMode diff --git a/type-reducer/experimental_reduced_types_pass_2.txt b/type-reducer/experimental_reduced_types_pass_2.txt index 69a5e9a..eed6614 100644 --- a/type-reducer/experimental_reduced_types_pass_2.txt +++ b/type-reducer/experimental_reduced_types_pass_2.txt @@ -1,27 +1,30 @@ +AllowedRoutesNamespaces +BackendObjectReference Condition -GRPCFilterType -RequestMirrorFraction -PersistenceCookieConfigLifetime -SessionPersistenceType +ExtensionParametersReference +FilterExtensionReference +FiltersType GatewayAddress -BackendTlsClientCertificateReference -ParametersReference GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType HTTPFilterType HTTPHeader -HeaderMatchType Kind +MatchExpressions +ParentReference RedirectStatusCode -BackendObjectReference +Reference +RequestMirrorFraction RequestOperationType RequestRedirectScheme -ParentReference -BackendReference +TlsMode +TlsValidationMode #### Pass 2 -SessionPersistenceCookieConfig +MatchingHeaders HeaderModifier HeaderMatch RequestMirror RequestRedirectPath ParentRouteStatus -CommonRouteRule diff --git a/type-reducer/experimental_reduced_types_pass_3.txt b/type-reducer/experimental_reduced_types_pass_3.txt index 7dff0f6..499f06c 100644 --- a/type-reducer/experimental_reduced_types_pass_3.txt +++ b/type-reducer/experimental_reduced_types_pass_3.txt @@ -1,30 +1,33 @@ +AllowedRoutesNamespaces +BackendObjectReference Condition -GRPCFilterType -RequestMirrorFraction -PersistenceCookieConfigLifetime -SessionPersistenceType +ExtensionParametersReference +FilterExtensionReference +FiltersType GatewayAddress -BackendTlsClientCertificateReference -ParametersReference GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType HTTPFilterType HTTPHeader -HeaderMatchType Kind +MatchExpressions +ParentReference RedirectStatusCode -BackendObjectReference +Reference +RequestMirrorFraction RequestOperationType RequestRedirectScheme -ParentReference -BackendReference +TlsMode +TlsValidationMode #### Pass 2 -SessionPersistenceCookieConfig +MatchingHeaders HeaderModifier HeaderMatch RequestMirror RequestRedirectPath ParentRouteStatus -CommonRouteRule #### Pass 3 GrpcRouteFilter HttpRouteRequestRedirect diff --git a/type-reducer/experimental_reduced_types_pass_4.txt b/type-reducer/experimental_reduced_types_pass_4.txt index 5fbcf04..499f06c 100644 --- a/type-reducer/experimental_reduced_types_pass_4.txt +++ b/type-reducer/experimental_reduced_types_pass_4.txt @@ -1,35 +1,36 @@ +AllowedRoutesNamespaces +BackendObjectReference Condition -GRPCFilterType -RequestMirrorFraction -PersistenceCookieConfigLifetime -SessionPersistenceType +ExtensionParametersReference +FilterExtensionReference +FiltersType GatewayAddress -BackendTlsClientCertificateReference -ParametersReference GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType HTTPFilterType HTTPHeader -HeaderMatchType Kind +MatchExpressions +ParentReference RedirectStatusCode -BackendObjectReference +Reference +RequestMirrorFraction RequestOperationType RequestRedirectScheme -ParentReference -BackendReference +TlsMode +TlsValidationMode #### Pass 2 -SessionPersistenceCookieConfig +MatchingHeaders HeaderModifier HeaderMatch RequestMirror RequestRedirectPath ParentRouteStatus -CommonRouteRule #### Pass 3 GrpcRouteFilter HttpRouteRequestRedirect HttpRouteUrlRewrite RouteStatus SessionPersistence -#### Pass 4 -HttpRouteBackendFilters diff --git a/type-reducer/standard_customized_mapped_names.txt b/type-reducer/standard_customized_mapped_names.txt index 1a82f56..440ffc7 100644 --- a/type-reducer/standard_customized_mapped_names.txt +++ b/type-reducer/standard_customized_mapped_names.txt @@ -2,21 +2,39 @@ GrpcRouteRulesBackendRefsFiltersType->GRPCFilterType GrpcRouteRulesFiltersType->GRPCFilterType GatewayAddresses->GatewayAddress GatewayStatusAddresses->GatewayAddress -GrpcRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference -GrpcRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference -GatewayInfrastructureParametersRef->GatewayInfrastructureParametersReference -HttpRouteRulesBackendRefsFiltersExtensionRef->GatewayInfrastructureParametersReference -HttpRouteRulesFiltersExtensionRef->GatewayInfrastructureParametersReference +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->AllowedRoutesNamespaces +ListenerSetListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespaces +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 -GrpcRouteRulesBackendRefsFiltersExtensionRef->FilterExtensionReference -GrpcRouteRulesFiltersExtensionRef->FilterExtensionReference -HttpRouteRulesBackendRefsFiltersExtensionRef->FilterExtensionReference -HttpRouteRulesFiltersExtensionRef->FilterExtensionReference +TlsRouteParentRefs->ParentReference +TlsRouteStatusParentsParentRef->ParentReference GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd->HTTPHeader GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierSet->HTTPHeader GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierAdd->HTTPHeader @@ -87,4 +105,3 @@ HttpRouteRulesFiltersUrlRewrite->HttpRouteUrlRewrite GrpcRouteStatus->RouteStatus HttpRouteStatus->RouteStatus TlsRouteStatus->RouteStatus - diff --git a/type-reducer/standard_reduced_types_pass_1.txt b/type-reducer/standard_reduced_types_pass_1.txt index 39be6d8..ddbc093 100644 --- a/type-reducer/standard_reduced_types_pass_1.txt +++ b/type-reducer/standard_reduced_types_pass_1.txt @@ -1,15 +1,23 @@ +AllowedRoutesNamespaces +BackendObjectReference Condition -GRPCFilterType +ExtensionParametersReference +FilterExtensionReference +FiltersType GatewayAddress GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader Kind +MatchExpressions ParentReference -FilterExtensionReference -HTTPHeader -BackendObjectReference +RedirectStatusCode +Reference RequestMirrorFraction RequestOperationType RequestRedirectScheme -RedirectStatusCode -FiltersType -HeaderMatchType +TlsMode +TlsValidationMode diff --git a/type-reducer/standard_reduced_types_pass_2.txt b/type-reducer/standard_reduced_types_pass_2.txt index b5e5487..eed6614 100644 --- a/type-reducer/standard_reduced_types_pass_2.txt +++ b/type-reducer/standard_reduced_types_pass_2.txt @@ -1,18 +1,26 @@ +AllowedRoutesNamespaces +BackendObjectReference Condition -GRPCFilterType +ExtensionParametersReference +FilterExtensionReference +FiltersType GatewayAddress GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader Kind +MatchExpressions ParentReference -FilterExtensionReference -HTTPHeader -BackendObjectReference +RedirectStatusCode +Reference RequestMirrorFraction RequestOperationType RequestRedirectScheme -RedirectStatusCode -FiltersType -HeaderMatchType +TlsMode +TlsValidationMode #### Pass 2 MatchingHeaders HeaderModifier diff --git a/type-reducer/standard_reduced_types_pass_3.txt b/type-reducer/standard_reduced_types_pass_3.txt index 4577515..21109c8 100644 --- a/type-reducer/standard_reduced_types_pass_3.txt +++ b/type-reducer/standard_reduced_types_pass_3.txt @@ -25,3 +25,4 @@ GrpcRouteFilter HttpRouteRequestRedirect HttpRouteUrlRewrite RouteStatus + From 43509f49d29a194f4389e4641d9cc0b5aa4df9c2 Mon Sep 17 00:00:00 2001 From: Dawid Nowak Date: Tue, 3 Mar 2026 20:36:01 +0000 Subject: [PATCH 91/95] Fixing type derivation for new types Signed-off-by: Dawid Nowak --- extensions/inference/Cargo.toml | 4 ++-- gateway-api/Cargo.toml | 4 ++-- gateway-api/examples/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/inference/Cargo.toml b/extensions/inference/Cargo.toml index c936b8e..933e55d 100644 --- a/extensions/inference/Cargo.toml +++ b/extensions/inference/Cargo.toml @@ -27,7 +27,7 @@ serde.workspace = true serde_yaml.workspace = true [dev-dependencies] -k8s-openapi = { workspace = true, features = ["v1_32", "schemars"] } +k8s-openapi = { workspace = true, features = ["v1_33", "schemars"] } kube = { workspace = true, features = ["client", "rustls-tls", "ring"] } anyhow.workspace = true @@ -37,7 +37,7 @@ tower.workspace = true uuid.workspace = true [package.metadata.docs.rs] -features = ["k8s-openapi/v1_32"] +features = ["k8s-openapi/v1_33"] [features] default = ["standard", "experimental"] diff --git a/gateway-api/Cargo.toml b/gateway-api/Cargo.toml index 7543302..ae63063 100644 --- a/gateway-api/Cargo.toml +++ b/gateway-api/Cargo.toml @@ -27,7 +27,7 @@ serde.workspace = true serde_yaml.workspace = true [dev-dependencies] -k8s-openapi = { workspace = true, features = ["v1_32", "schemars"] } +k8s-openapi = { workspace = true, features = ["v1_33", "schemars"] } kube = { workspace = true, features = ["client", "rustls-tls", "ring"] } anyhow.workspace = true @@ -37,7 +37,7 @@ tower.workspace = true uuid.workspace = true [package.metadata.docs.rs] -features = ["k8s-openapi/v1_32"] +features = ["k8s-openapi/v1_33"] [features] default = ["standard", "experimental"] diff --git a/gateway-api/examples/Cargo.toml b/gateway-api/examples/Cargo.toml index 379cda4..fb392c9 100644 --- a/gateway-api/examples/Cargo.toml +++ b/gateway-api/examples/Cargo.toml @@ -24,7 +24,7 @@ tracing-subscriber.workspace = true uuid.workspace = true [features] -default = [ "k8s-openapi/v1_32" ] +default = [ "k8s-openapi/v1_33" ] [[bin]] name = "gep2257" From 5d536873e0cbee9d0f17123b4d874e2ee99e742e Mon Sep 17 00:00:00 2001 From: Dawid Nowak Date: Wed, 4 Mar 2026 16:56:15 +0000 Subject: [PATCH 92/95] For time being reducing and renaming has been removed --- gateway-api/src/lib.rs | 31 ++-- scripts/generators/gateway_generator.sh | 191 ++++++++++++++++++++++++ xtask/src/main.rs | 20 ++- 3 files changed, 228 insertions(+), 14 deletions(-) create mode 100755 scripts/generators/gateway_generator.sh diff --git a/gateway-api/src/lib.rs b/gateway-api/src/lib.rs index c8a0733..7cea5ec 100644 --- a/gateway-api/src/lib.rs +++ b/gateway-api/src/lib.rs @@ -27,10 +27,9 @@ mod tests { use tower::ServiceBuilder; use uuid::Uuid; + use crate::gateways::GatewayStatusListeners; + use crate::{ - apis::standard::common::{ - GatewayStatusListeners, ParentReference, ParentRouteStatus, RouteStatus, - }, apis::standard::constants::{ GatewayConditionReason, GatewayConditionType, ListenerConditionReason, ListenerConditionType, RouteConditionReason, RouteConditionType, @@ -39,8 +38,14 @@ mod tests { apis::standard::gateways::{ Gateway, GatewayListeners, GatewaySpec, GatewayStatus, GatewayStatusAddresses, }, - apis::standard::grpcroutes::GrpcRouteSpec, - apis::standard::httproutes::HttpRouteSpec, + apis::standard::grpcroutes::{ + GrpcRouteParentRefs, GrpcRouteSpec, GrpcRouteStatus, GrpcRouteStatusParents, + GrpcRouteStatusParentsParentRef, + }, + apis::standard::httproutes::{ + HttpRouteParentRefs, HttpRouteSpec, HttpRouteStatus, HttpRouteStatusParents, + HttpRouteStatusParentsParentRef, + }, apis::standard::referencegrants::{ ReferenceGrantFrom, ReferenceGrantSpec, ReferenceGrantTo, }, @@ -188,7 +193,7 @@ mod tests { metadata: ObjectMeta::default(), spec: HttpRouteSpec { hostnames: Some(vec!["example.com".to_string()]), - parent_refs: Some(vec![ParentReference { + parent_refs: Some(vec![HttpRouteParentRefs { group: Some("gateway.networking.k8s.io".to_string()), kind: Some("Gateway".to_string()), namespace: Some("default".to_string()), @@ -210,9 +215,9 @@ mod tests { 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 { + let http_route_status = HttpRouteStatus { + parents: vec![HttpRouteStatusParents { + parent_ref: HttpRouteStatusParentsParentRef { group: Some("gateway.networking.k8s.io".to_string()), kind: Some("Gateway".to_string()), namespace: Some("default".to_string()), @@ -249,7 +254,7 @@ mod tests { metadata: ObjectMeta::default(), spec: GrpcRouteSpec { hostnames: Some(vec!["grpc.example.com".to_string()]), - parent_refs: Some(vec![ParentReference { + parent_refs: Some(vec![GrpcRouteParentRefs { group: Some("gateway.networking.k8s.io".to_string()), kind: Some("Gateway".to_string()), namespace: Some("default".to_string()), @@ -271,9 +276,9 @@ mod tests { 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 { + let grpc_route_status = GrpcRouteStatus { + parents: vec![GrpcRouteStatusParents { + parent_ref: GrpcRouteStatusParentsParentRef { group: Some("gateway.networking.k8s.io".to_string()), kind: Some("Gateway".to_string()), namespace: Some("default".to_string()), diff --git a/scripts/generators/gateway_generator.sh b/scripts/generators/gateway_generator.sh new file mode 100755 index 0000000..52724a8 --- /dev/null +++ b/scripts/generators/gateway_generator.sh @@ -0,0 +1,191 @@ +#!/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. +echo "use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/standard/enum_defaults.rs +cargo fmt + + + + + + +ENUMS=( + GRPCFilterType=RequestHeaderModifier + RequestOperationType=ReplaceFullPath + HttpRouteRulesBackendRefsFiltersExternalAuthProtocol=Http + HTTPFilterType=RequestHeaderModifier + BackendTlsPolicyValidationSubjectAltNamesType=Hostname +) + +echo "use crate::experimental::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/experimental/enum_defaults.rs + +cargo fmt +echo "Gateway API Generation complete" + diff --git a/xtask/src/main.rs b/xtask/src/main.rs index cf8f866..64fdfa3 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -116,9 +116,27 @@ fn gen_enum_defaults() -> Result<(), DynError> { } // Print the common use statement first - println!("use super::common::*;"); + //println!("use super::common::*;"); + println!("{}", gen_generated_file_warning()); + // + println!( + r#"#[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::*; + }} + use prelude::*; + "# + ); + println!("{}", scope.to_string()); Ok(()) } From 275019dda94ddb8ffc36f29c207840fb76039749 Mon Sep 17 00:00:00 2001 From: Dawid Nowak Date: Thu, 5 Mar 2026 19:32:05 +0000 Subject: [PATCH 93/95] Major refactoring Signed-off-by: Dawid Nowak --- Cargo.lock | 275 +--- Cargo.toml | 10 +- .../inference/src/apis/experimental/common.rs | 11 - extensions/inference/src/lib.rs | 258 --- gateway-api-inference-extension/Cargo.toml | 45 + gateway-api-inference-extension/Cargo.toml~ | 45 + .../src/experimental/common.rs | 34 + .../src/experimental/enum_defaults.rs | 17 + .../experimental/inferencemodelrewrites.rs | 85 + .../src}/experimental/inferenceobjectives.rs | 28 +- .../src/experimental/inferencepoolimports.rs | 103 ++ .../src}/experimental/inferencepools.rs | 31 +- .../src}/experimental/mod.rs | 4 +- gateway-api-inference-extension/src/lib.rs | 9 + gateway-api-inference-extension/src/lib.rs~ | 527 ++++++ .../src}/mod.rs | 0 .../src}/standard/common.rs | 2 +- .../src/standard/enum_defaults.rs | 16 + .../src}/standard/inferencepools.rs | 42 +- .../src}/standard/mod.rs | 2 +- gateway-api-with-extensions/CHANGELOG.md | 42 + .../Cargo.toml | 16 +- gateway-api-with-extensions/Cargo.toml~ | 54 + .../examples/Cargo.toml | 31 + .../examples/gep2257.rs | 37 + gateway-api-with-extensions/src/duration.rs | 724 ++++++++ .../src}/experimental/backendtlspolicies.rs | 0 .../src/experimental/common.rs | 458 ++++++ .../src}/experimental/constants.rs | 0 .../src/experimental/enum_defaults.rs | 123 ++ .../src/experimental/gatewayclasses.rs | 83 + .../src/experimental/gateways.rs | 561 +++++++ .../src}/experimental/grpcroutes.rs | 325 +--- .../src}/experimental/httproutes.rs | 311 +--- .../experimental/inferencemodelrewrites.rs | 85 + .../src/experimental/inferenceobjectives.rs | 50 + .../src/experimental/inferencepoolimports.rs | 97 ++ .../src/experimental/inferencepools.rs | 116 ++ .../src/experimental/listenersets.rs | 121 ++ .../src/experimental/mod.rs | 18 + .../src}/experimental/referencegrants.rs | 0 .../src}/experimental/tcproutes.rs | 67 +- .../src}/experimental/tlsroutes.rs | 67 +- .../src}/experimental/udproutes.rs | 67 +- gateway-api-with-extensions/src/lib.rs | 527 ++++++ .../src}/mod.rs | 0 .../src}/standard/backendtlspolicies.rs | 0 .../src/standard}/common.rs | 197 ++- .../src}/standard/constants.rs | 0 .../src/standard/enum_defaults.rs | 102 ++ .../src/standard}/gatewayclasses.rs | 0 .../src}/standard/gateways.rs | 188 +-- .../src}/standard/grpcroutes.rs | 0 .../src}/standard/httproutes.rs | 4 +- .../src/standard/inferencepools.rs | 158 ++ .../src/standard/listenersets.rs | 76 + .../src/standard/mod.rs | 13 + .../src}/standard/referencegrants.rs | 0 .../src}/standard/tlsroutes.rs | 0 gateway-api/Cargo.toml | 26 +- .../src/apis/experimental/enum_defaults.rs | 33 - .../src/apis/experimental/listenersets.rs | 225 --- .../src/apis/standard/enum_defaults.rs | 27 - gateway-api/src/apis/standard/listenersets.rs | 225 --- gateway-api/src/duration.rs | 2 +- .../src/experimental/backendtlspolicies.rs | 354 ++++ gateway-api/src/experimental/common.rs | 441 +++++ gateway-api/src/experimental/constants.rs | 120 ++ gateway-api/src/experimental/enum_defaults.rs | 116 ++ .../gatewayclasses.rs | 0 gateway-api/src/experimental/gateways.rs | 561 +++++++ gateway-api/src/experimental/grpcroutes.rs | 500 ++++++ gateway-api/src/experimental/httproutes.rs | 1452 +++++++++++++++++ gateway-api/src/experimental/listenersets.rs | 121 ++ .../src/{apis => }/experimental/mod.rs | 1 - .../src/experimental/referencegrants.rs | 87 + gateway-api/src/experimental/tcproutes.rs | 200 +++ gateway-api/src/experimental/tlsroutes.rs | 208 +++ gateway-api/src/experimental/udproutes.rs | 200 +++ gateway-api/src/lib.rs | 69 +- gateway-api/src/mod.rs | 2 + .../src/standard/backendtlspolicies.rs | 354 ++++ gateway-api/src/{apis => }/standard/common.rs | 138 +- gateway-api/src/standard/constants.rs | 121 ++ gateway-api/src/standard/enum_defaults.rs | 96 ++ gateway-api/src/standard/gatewayclasses.rs | 89 + .../experimental => standard}/gateways.rs | 211 +-- gateway-api/src/standard/grpcroutes.rs | 383 +++++ gateway-api/src/standard/httproutes.rs | 1240 ++++++++++++++ gateway-api/src/standard/listenersets.rs | 76 + gateway-api/src/{apis => }/standard/mod.rs | 1 - gateway-api/src/standard/referencegrants.rs | 87 + gateway-api/src/standard/tlsroutes.rs | 185 +++ scripts/generators/enums_generator.sh | 18 + .../generators/experimental_enum_names.txt | 38 + .../experimental_inference_enum_names.txt | 2 + scripts/generators/gateway_experimental.sh | 170 ++ scripts/generators/gateway_generator.sh | 95 +- scripts/generators/gateway_standard.sh | 161 ++ scripts/generators/generate_all.sh | 4 + scripts/generators/generate_gateway.sh | 46 + .../generate_gateway_with_extensions.sh | 54 + scripts/generators/generate_inference_only.sh | 41 + scripts/generators/inference_generator.sh | 55 + .../reduced_experimental_enum_names.txt | 16 + ...uced_experimental_inference_enum_names.txt | 1 + .../reduced_standard_enum_names.txt | 13 + .../reduced_standard_inference_enum_names.txt | 1 + scripts/generators/reducer.sh | 35 + scripts/generators/standard_enum_names.txt | 26 + .../standard_inference_enum_names.txt | 0 .../experimental_customized_mapped_names.txt | 62 +- .../experimental_ignorable_mapped_names.txt | 2 + .../experimental_reduced_types_pass_1.txt | 17 +- .../experimental_reduced_types_pass_2.txt | 22 +- .../experimental_reduced_types_pass_3.txt | 29 +- .../experimental_reduced_types_pass_4.txt | 30 +- .../experimental_reduced_types_pass_5.txt | 48 + type-reducer/one_liners.txt | 1 + ...d_experimental_customized_mapped_names.txt | 119 ++ ...orted_standard_customized_mapped_names.txt | 107 ++ ...nique_standard_customized_mapped_names.txt | 107 ++ type-reducer/src/main.rs | 29 +- .../standard_customized_mapped_names.txt | 24 +- .../standard_reduced_types_pass_1.txt | 2 +- .../standard_reduced_types_pass_2.txt | 5 +- .../standard_reduced_types_pass_3.txt | 29 +- .../standard_reduced_types_pass_4.txt | 47 + .../standard_reduced_types_pass_5.txt | 45 + xtask/src/main.rs | 157 +- 130 files changed, 13589 insertions(+), 2282 deletions(-) delete mode 100644 extensions/inference/src/apis/experimental/common.rs delete mode 100644 extensions/inference/src/lib.rs create mode 100644 gateway-api-inference-extension/Cargo.toml create mode 100644 gateway-api-inference-extension/Cargo.toml~ create mode 100644 gateway-api-inference-extension/src/experimental/common.rs create mode 100644 gateway-api-inference-extension/src/experimental/enum_defaults.rs create mode 100644 gateway-api-inference-extension/src/experimental/inferencemodelrewrites.rs rename {extensions/inference/src/apis => gateway-api-inference-extension/src}/experimental/inferenceobjectives.rs (70%) create mode 100644 gateway-api-inference-extension/src/experimental/inferencepoolimports.rs rename {extensions/inference/src/apis => gateway-api-inference-extension/src}/experimental/inferencepools.rs (81%) rename {extensions/inference/src/apis => gateway-api-inference-extension/src}/experimental/mod.rs (60%) create mode 100644 gateway-api-inference-extension/src/lib.rs create mode 100644 gateway-api-inference-extension/src/lib.rs~ rename {extensions/inference/src/apis => gateway-api-inference-extension/src}/mod.rs (100%) rename {extensions/inference/src/apis => gateway-api-inference-extension/src}/standard/common.rs (90%) create mode 100644 gateway-api-inference-extension/src/standard/enum_defaults.rs rename {extensions/inference/src/apis => gateway-api-inference-extension/src}/standard/inferencepools.rs (82%) rename {extensions/inference/src/apis => gateway-api-inference-extension/src}/standard/mod.rs (81%) create mode 100644 gateway-api-with-extensions/CHANGELOG.md rename {extensions/inference => gateway-api-with-extensions}/Cargo.toml (75%) create mode 100644 gateway-api-with-extensions/Cargo.toml~ create mode 100644 gateway-api-with-extensions/examples/Cargo.toml create mode 100644 gateway-api-with-extensions/examples/gep2257.rs create mode 100644 gateway-api-with-extensions/src/duration.rs rename {gateway-api/src/apis => gateway-api-with-extensions/src}/experimental/backendtlspolicies.rs (100%) create mode 100644 gateway-api-with-extensions/src/experimental/common.rs rename {gateway-api/src/apis => gateway-api-with-extensions/src}/experimental/constants.rs (100%) create mode 100644 gateway-api-with-extensions/src/experimental/enum_defaults.rs create mode 100644 gateway-api-with-extensions/src/experimental/gatewayclasses.rs create mode 100644 gateway-api-with-extensions/src/experimental/gateways.rs rename {gateway-api/src/apis => gateway-api-with-extensions/src}/experimental/grpcroutes.rs (65%) rename {gateway-api/src/apis => gateway-api-with-extensions/src}/experimental/httproutes.rs (86%) create mode 100644 gateway-api-with-extensions/src/experimental/inferencemodelrewrites.rs create mode 100644 gateway-api-with-extensions/src/experimental/inferenceobjectives.rs create mode 100644 gateway-api-with-extensions/src/experimental/inferencepoolimports.rs create mode 100644 gateway-api-with-extensions/src/experimental/inferencepools.rs create mode 100644 gateway-api-with-extensions/src/experimental/listenersets.rs create mode 100644 gateway-api-with-extensions/src/experimental/mod.rs rename {gateway-api/src/apis => gateway-api-with-extensions/src}/experimental/referencegrants.rs (100%) rename {gateway-api/src/apis => gateway-api-with-extensions/src}/experimental/tcproutes.rs (65%) rename {gateway-api/src/apis => gateway-api-with-extensions/src}/experimental/tlsroutes.rs (67%) rename {gateway-api/src/apis => gateway-api-with-extensions/src}/experimental/udproutes.rs (65%) create mode 100644 gateway-api-with-extensions/src/lib.rs rename {gateway-api/src/apis => gateway-api-with-extensions/src}/mod.rs (100%) rename {gateway-api/src/apis => gateway-api-with-extensions/src}/standard/backendtlspolicies.rs (100%) rename {gateway-api/src/apis/experimental => gateway-api-with-extensions/src/standard}/common.rs (86%) rename {gateway-api/src/apis => gateway-api-with-extensions/src}/standard/constants.rs (100%) create mode 100644 gateway-api-with-extensions/src/standard/enum_defaults.rs rename {gateway-api/src/apis/experimental => gateway-api-with-extensions/src/standard}/gatewayclasses.rs (100%) rename {gateway-api/src/apis => gateway-api-with-extensions/src}/standard/gateways.rs (73%) rename {gateway-api/src/apis => gateway-api-with-extensions/src}/standard/grpcroutes.rs (100%) rename {gateway-api/src/apis => gateway-api-with-extensions/src}/standard/httproutes.rs (99%) create mode 100644 gateway-api-with-extensions/src/standard/inferencepools.rs create mode 100644 gateway-api-with-extensions/src/standard/listenersets.rs create mode 100644 gateway-api-with-extensions/src/standard/mod.rs rename {gateway-api/src/apis => gateway-api-with-extensions/src}/standard/referencegrants.rs (100%) rename {gateway-api/src/apis => gateway-api-with-extensions/src}/standard/tlsroutes.rs (100%) delete mode 100644 gateway-api/src/apis/experimental/enum_defaults.rs delete mode 100644 gateway-api/src/apis/experimental/listenersets.rs delete mode 100644 gateway-api/src/apis/standard/enum_defaults.rs delete mode 100644 gateway-api/src/apis/standard/listenersets.rs create mode 100644 gateway-api/src/experimental/backendtlspolicies.rs create mode 100644 gateway-api/src/experimental/common.rs create mode 100644 gateway-api/src/experimental/constants.rs create mode 100644 gateway-api/src/experimental/enum_defaults.rs rename gateway-api/src/{apis/standard => experimental}/gatewayclasses.rs (100%) create mode 100644 gateway-api/src/experimental/gateways.rs create mode 100644 gateway-api/src/experimental/grpcroutes.rs create mode 100644 gateway-api/src/experimental/httproutes.rs create mode 100644 gateway-api/src/experimental/listenersets.rs rename gateway-api/src/{apis => }/experimental/mod.rs (99%) create mode 100644 gateway-api/src/experimental/referencegrants.rs create mode 100644 gateway-api/src/experimental/tcproutes.rs create mode 100644 gateway-api/src/experimental/tlsroutes.rs create mode 100644 gateway-api/src/experimental/udproutes.rs create mode 100644 gateway-api/src/mod.rs create mode 100644 gateway-api/src/standard/backendtlspolicies.rs rename gateway-api/src/{apis => }/standard/common.rs (88%) create mode 100644 gateway-api/src/standard/constants.rs create mode 100644 gateway-api/src/standard/enum_defaults.rs create mode 100644 gateway-api/src/standard/gatewayclasses.rs rename gateway-api/src/{apis/experimental => standard}/gateways.rs (70%) create mode 100644 gateway-api/src/standard/grpcroutes.rs create mode 100644 gateway-api/src/standard/httproutes.rs create mode 100644 gateway-api/src/standard/listenersets.rs rename gateway-api/src/{apis => }/standard/mod.rs (99%) create mode 100644 gateway-api/src/standard/referencegrants.rs create mode 100644 gateway-api/src/standard/tlsroutes.rs create mode 100755 scripts/generators/enums_generator.sh create mode 100644 scripts/generators/experimental_enum_names.txt create mode 100644 scripts/generators/experimental_inference_enum_names.txt create mode 100755 scripts/generators/gateway_experimental.sh create mode 100755 scripts/generators/gateway_standard.sh create mode 100755 scripts/generators/generate_all.sh create mode 100755 scripts/generators/generate_gateway.sh create mode 100755 scripts/generators/generate_gateway_with_extensions.sh create mode 100755 scripts/generators/generate_inference_only.sh create mode 100755 scripts/generators/inference_generator.sh create mode 100644 scripts/generators/reduced_experimental_enum_names.txt create mode 100644 scripts/generators/reduced_experimental_inference_enum_names.txt create mode 100644 scripts/generators/reduced_standard_enum_names.txt create mode 100644 scripts/generators/reduced_standard_inference_enum_names.txt create mode 100755 scripts/generators/reducer.sh create mode 100644 scripts/generators/standard_enum_names.txt create mode 100644 scripts/generators/standard_inference_enum_names.txt create mode 100644 type-reducer/experimental_reduced_types_pass_5.txt create mode 100644 type-reducer/one_liners.txt create mode 100644 type-reducer/sorted_experimental_customized_mapped_names.txt create mode 100644 type-reducer/sorted_standard_customized_mapped_names.txt create mode 100644 type-reducer/sorted_unique_standard_customized_mapped_names.txt create mode 100644 type-reducer/standard_reduced_types_pass_4.txt create mode 100644 type-reducer/standard_reduced_types_pass_5.txt diff --git a/Cargo.lock b/Cargo.lock index a58e486..bb4edb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,6 +128,17 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "chacha20" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "rand_core", +] + [[package]] name = "clap" version = "4.5.60" @@ -217,6 +228,15 @@ 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.7" @@ -326,7 +346,7 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "enum_default_generator" -version = "0.20.0" +version = "0.21.0+gw150-ie140" dependencies = [ "codegen", ] @@ -434,11 +454,10 @@ dependencies = [ [[package]] name = "gateway-api" -version = "0.20.0" +version = "0.21.0+gw150-ie140" dependencies = [ - "anyhow", + "cfg-if", "delegate", - "hyper-util", "k8s-openapi", "kube", "kube-core", @@ -449,14 +468,11 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "tokio", - "tower", - "uuid", ] [[package]] name = "gateway-api-examples" -version = "0.20.0" +version = "0.21.0+gw150-ie140" dependencies = [ "anyhow", "gateway-api", @@ -470,6 +486,47 @@ dependencies = [ "uuid", ] +[[package]] +name = "gateway-api-inference-extension" +version = "0.21.0+gw150-ie140" +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.21.0+gw150-ie140" +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" @@ -491,18 +548,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "libc", - "r-efi 5.3.0", - "wasip2", -] - [[package]] name = "getrandom" version = "0.4.2" @@ -511,7 +556,8 @@ checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" dependencies = [ "cfg-if", "libc", - "r-efi 6.0.0", + "r-efi", + "rand_core", "wasip2", "wasip3", ] @@ -688,28 +734,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "inference-extension-api" -version = "0.20.0" -dependencies = [ - "anyhow", - "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 = "is_terminal_polyfill" version = "1.70.2" @@ -1112,15 +1136,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - [[package]] name = "prettyplease" version = "0.2.37" @@ -1149,12 +1164,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - [[package]] name = "r-efi" version = "6.0.0" @@ -1163,32 +1172,20 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" -dependencies = [ - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8" dependencies = [ - "ppv-lite86", + "chacha20", + "getrandom 0.4.2", "rand_core", ] [[package]] name = "rand_core" -version = "0.9.5" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" -dependencies = [ - "getrandom 0.3.4", -] +checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba" [[package]] name = "redox_syscall" @@ -1498,7 +1495,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", - "cpufeatures", + "cpufeatures 0.2.17", "digest", ] @@ -1553,12 +1550,12 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -1817,7 +1814,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "type-reducer" -version = "0.20.0" +version = "0.21.0+gw150-ie140" dependencies = [ "clap", "itertools", @@ -1873,9 +1870,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.21.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b672338555252d43fd2240c714dc444b8c6fb0a5c5335e65a07bba7742735ddb" +checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37" dependencies = [ "getrandom 0.4.2", "js-sys", @@ -2019,16 +2016,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets 0.53.5", + "windows-targets", ] [[package]] @@ -2046,31 +2034,14 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.53.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" -dependencies = [ - "windows-link", - "windows_aarch64_gnullvm 0.53.1", - "windows_aarch64_msvc 0.53.1", - "windows_i686_gnu 0.53.1", - "windows_i686_gnullvm 0.53.1", - "windows_i686_msvc 0.53.1", - "windows_x86_64_gnu 0.53.1", - "windows_x86_64_gnullvm 0.53.1", - "windows_x86_64_msvc 0.53.1", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] @@ -2079,96 +2050,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" - [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" -[[package]] -name = "windows_i686_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" - [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_i686_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" - [[package]] name = "wit-bindgen" version = "0.51.0" @@ -2257,26 +2180,6 @@ dependencies = [ "wasmparser", ] -[[package]] -name = "zerocopy" -version = "0.8.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a789c6e490b576db9f7e6b6d661bcc9799f7c0ac8352f56ea20193b2681532e5" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f65c489a7071a749c849713807783f70672b28094011623e200cb86dcb835953" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "zeroize" version = "1.8.2" diff --git a/Cargo.toml b/Cargo.toml index de830cc..fcfb2da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,14 @@ [workspace] -members = ["gateway-api", "gateway-api/examples", "xtask", "type-reducer", "extensions/inference"] +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 = ["kube-rs project (https://kube.rs)"] edition = "2024" license = "MIT" -version = "0.20.0" +version = "0.21.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.100" @@ -15,7 +17,7 @@ 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" } +k8s-openapi = { version = "0.27.0", features = ["v1_33"] } once_cell = "1.21.3" regex = { package = "regex-lite", version = "0.1.8" } schemars = "1.2.0" @@ -27,3 +29,5 @@ 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/extensions/inference/src/apis/experimental/common.rs b/extensions/inference/src/apis/experimental/common.rs deleted file mode 100644 index cdaf5e6..0000000 --- a/extensions/inference/src/apis/experimental/common.rs +++ /dev/null @@ -1,11 +0,0 @@ -// 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::*; diff --git a/extensions/inference/src/lib.rs b/extensions/inference/src/lib.rs deleted file mode 100644 index 02ad1bf..0000000 --- a/extensions/inference/src/lib.rs +++ /dev/null @@ -1,258 +0,0 @@ -pub mod apis; - -#[cfg(feature = "standard")] -pub use apis::standard::*; - -#[cfg(feature = "experimental")] -pub use apis::experimental; - -#[cfg(test)] -mod tests { - use std::collections::BTreeMap; - use std::process::Command; - - use anyhow::{Error, Ok}; - use hyper_util::client::legacy::Client as HTTPClient; - use hyper_util::rt::TokioExecutor; - use kube::Client as KubeClient; - use kube::api::PostParams; - use kube::config::{KubeConfigOptions, Kubeconfig}; - use kube::core::ObjectMeta; - use kube::{Api, Config, CustomResourceExt, client::ConfigExt}; - use tower::BoxError; - use tower::ServiceBuilder; - use uuid::Uuid; - - use crate::apis::standard::common::EndPointPort; - use crate::apis::standard::inferencepools::{ - ExtensionFailureMode, ExtensionRef, InferencePool, InferencePoolSelector, InferencePoolSpec, - }; - - const DEFAULT_INFERENCE_EXT_VERSION: &str = "v1.0.2"; - - // ------------------------------------------------------------------------- - // 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 - ); - - // CRDS were not reflecting in kubernetes api server, hence wait was added - std::thread::sleep(std::time::Duration::from_secs(2)); - 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 - ); - - // CRDS were not reflecting in kubernetes api server, hence wait was added - std::thread::sleep(std::time::Duration::from_secs(2)); - 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 inf_pool = InferencePool { - metadata: ObjectMeta::default(), - spec: InferencePoolSpec { - endpoint_picker_ref: ExtensionRef { - failure_mode: Some(ExtensionFailureMode::FailClose), - group: None, - kind: None, - name: String::from("test-extension-name"), - port: Some(EndPointPort { number: 80 }), - }, - selector: InferencePoolSelector { - match_labels: BTreeMap::from([(String::from("app"), String::from("test-app"))]), - }, - target_ports: vec![EndPointPort { number: 80 }], - }, - status: None, - }; - inf_pool.metadata.name = Some("test-inference-pool".to_string()); - - inf_pool = Api::default_namespaced(client.clone()) - .create(&PostParams::default(), &inf_pool) - .await?; - - assert!(inf_pool.metadata.name.is_some()); - assert!(inf_pool.metadata.uid.is_some()); - assert!(inf_pool.spec.endpoint_picker_ref.failure_mode.is_some()); - assert!(inf_pool.spec.endpoint_picker_ref.port.is_some()); - assert!(inf_pool.spec.selector.match_labels.len() > 0); - - 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_INFERENCE_EXT_VERSION") - .unwrap_or_else(|_| DEFAULT_INFERENCE_EXT_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_INFERENCE_EXT_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-inference-extension/releases/download/{}/manifests.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 inf_pool_crd = InferencePool::crd(); - inf_pool_crd.metadata.annotations = Some(std::collections::BTreeMap::from([( - "api-approved.kubernetes.io".to_string(), - "https://github.com/kubernetes-sigs/gateway-api-inference-extension/pull/1173" - .to_string(), - )])); - - Api::all(client.clone()) - .create(&PostParams::default(), &inf_pool_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-inference-extension/Cargo.toml b/gateway-api-inference-extension/Cargo.toml new file mode 100644 index 0000000..23bedb9 --- /dev/null +++ b/gateway-api-inference-extension/Cargo.toml @@ -0,0 +1,45 @@ +[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/kubvernor/gateway-api-rs" + +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, 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/Cargo.toml~ b/gateway-api-inference-extension/Cargo.toml~ new file mode 100644 index 0000000..3b3032c --- /dev/null +++ b/gateway-api-inference-extension/Cargo.toml~ @@ -0,0 +1,45 @@ +[package] +name = "gateway-api-inference-extension" +description = "Kubernetes Gateway API Inference Extensions 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/kubvernor/gateway-api-rs" + +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, 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/extensions/inference/src/apis/experimental/inferenceobjectives.rs b/gateway-api-inference-extension/src/experimental/inferenceobjectives.rs similarity index 70% rename from extensions/inference/src/apis/experimental/inferenceobjectives.rs rename to gateway-api-inference-extension/src/experimental/inferenceobjectives.rs index 16bf8d5..676439b 100644 --- a/extensions/inference/src/apis/experimental/inferenceobjectives.rs +++ b/gateway-api-inference-extension/src/experimental/inferenceobjectives.rs @@ -1,5 +1,6 @@ // 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; @@ -25,13 +26,13 @@ use self::prelude::*; plural = "inferenceobjectives" )] #[kube(namespaced)] -#[kube(status = "InferenceObjectiveStatus")] +#[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: InferenceObjectivePoolRef, + 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. @@ -47,26 +48,3 @@ pub struct InferenceObjectiveSpec { #[serde(default, skip_serializing_if = "Option::is_none")] pub priority: Option, } -/// PoolRef is a reference to the inference pool, the pool must exist in the same namespace. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct InferenceObjectivePoolRef { - /// Group is the group of the referent. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. For example "InferencePool". - #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, - /// Name is the name of the referent. - pub name: String, -} -/// InferenceObjectiveStatus defines the observed state of InferenceObjective -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct InferenceObjectiveStatus { - /// Conditions track the state of the InferenceObjective. - /// - /// Known condition types are: - /// - /// * "Accepted" - #[serde(default, skip_serializing_if = "Option::is_none")] - pub conditions: 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/extensions/inference/src/apis/experimental/inferencepools.rs b/gateway-api-inference-extension/src/experimental/inferencepools.rs similarity index 81% rename from extensions/inference/src/apis/experimental/inferencepools.rs rename to gateway-api-inference-extension/src/experimental/inferencepools.rs index c6bce56..f5d73de 100644 --- a/extensions/inference/src/apis/experimental/inferencepools.rs +++ b/gateway-api-inference-extension/src/experimental/inferencepools.rs @@ -25,7 +25,7 @@ use self::prelude::*; pub struct InferencePoolSpec { /// Extension configures an endpoint picker as an extension service. #[serde(rename = "extensionRef")] - pub extension_ref: 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 @@ -40,7 +40,7 @@ pub struct InferencePoolSpec { } /// Extension configures an endpoint picker as an extension service. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct ExtensionRef { +pub struct InferencePoolExtensionRef { /// Configures how the gateway handles the case when the extension is not responsive. /// Defaults to failClose. #[serde( @@ -48,7 +48,7 @@ pub struct ExtensionRef { skip_serializing_if = "Option::is_none", rename = "failureMode" )] - pub failure_mode: Option, + 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")] @@ -78,7 +78,7 @@ pub struct ExtensionRef { } /// Extension configures an endpoint picker as an extension service. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum ExtensionFailureMode { +pub enum InferencePoolExtensionRefFailureMode { FailOpen, FailClose, } @@ -97,11 +97,11 @@ pub struct InferencePoolStatus { /// - 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>, + pub parent: Option>, } /// PoolStatus defines the observed state of InferencePool from a Gateway. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct InferencePoolParent { +pub struct InferencePoolStatusParent { /// Conditions track the state of the InferencePool. /// /// Known condition types are: @@ -112,22 +112,5 @@ pub struct InferencePoolParent { pub conditions: Option>, /// GatewayRef indicates the gateway that observed state of InferencePool. #[serde(rename = "parentRef")] - pub parent_ref: ParentRef, -} -/// GatewayRef indicates the gateway that observed state of InferencePool. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct ParentRef { - /// Group is the group of the referent. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub group: Option, - /// Kind is kind of the referent. For example "Gateway". - #[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 referent. If not present, - /// the namespace of the referent is assumed to be the same as - /// the namespace of the referring object. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub namespace: Option, + pub parent_ref: InferencePoolImportStatusControllersParentsParentRef, } diff --git a/extensions/inference/src/apis/experimental/mod.rs b/gateway-api-inference-extension/src/experimental/mod.rs similarity index 60% rename from extensions/inference/src/apis/experimental/mod.rs rename to gateway-api-inference-extension/src/experimental/mod.rs index cbccce9..35a97f3 100644 --- a/extensions/inference/src/apis/experimental/mod.rs +++ b/gateway-api-inference-extension/src/experimental/mod.rs @@ -1,5 +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-inference-extension/src/lib.rs~ b/gateway-api-inference-extension/src/lib.rs~ new file mode 100644 index 0000000..43696e7 --- /dev/null +++ b/gateway-api-inference-extension/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/extensions/inference/src/apis/mod.rs b/gateway-api-inference-extension/src/mod.rs similarity index 100% rename from extensions/inference/src/apis/mod.rs rename to gateway-api-inference-extension/src/mod.rs diff --git a/extensions/inference/src/apis/standard/common.rs b/gateway-api-inference-extension/src/standard/common.rs similarity index 90% rename from extensions/inference/src/apis/standard/common.rs rename to gateway-api-inference-extension/src/standard/common.rs index 5ffd87f..e7ef280 100644 --- a/extensions/inference/src/apis/standard/common.rs +++ b/gateway-api-inference-extension/src/standard/common.rs @@ -10,6 +10,6 @@ mod prelude { } use self::prelude::*; #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct EndPointPort { +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/extensions/inference/src/apis/standard/inferencepools.rs b/gateway-api-inference-extension/src/standard/inferencepools.rs similarity index 82% rename from extensions/inference/src/apis/standard/inferencepools.rs rename to gateway-api-inference-extension/src/standard/inferencepools.rs index eb36c54..65fe40f 100644 --- a/extensions/inference/src/apis/standard/inferencepools.rs +++ b/gateway-api-inference-extension/src/standard/inferencepools.rs @@ -26,7 +26,7 @@ pub struct InferencePoolSpec { /// EndpointPickerRef is a reference to the Endpoint Picker extension and its /// associated configuration. #[serde(rename = "endpointPickerRef")] - pub endpoint_picker_ref: ExtensionRef, + 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. @@ -36,14 +36,15 @@ pub struct InferencePoolSpec { /// this configuration into a Service resource. pub selector: InferencePoolSelector, /// TargetPorts defines a list of ports that are exposed by this InferencePool. - /// Currently, the list may only include a single port definition. + /// Every port will be treated as a distinctive endpoint by EPP, + /// addressable as a 'podIP:portNumber' combination. #[serde(rename = "targetPorts")] - pub target_ports: Vec, + 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 ExtensionRef { +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( @@ -51,7 +52,7 @@ pub struct ExtensionRef { skip_serializing_if = "Option::is_none", rename = "failureMode" )] - pub failure_mode: Option, + 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")] @@ -78,12 +79,12 @@ pub struct ExtensionRef { /// 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, + 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 ExtensionFailureMode { +pub enum InferencePoolEndpointPickerRefFailureMode { FailOpen, FailClose, } @@ -115,11 +116,11 @@ pub struct InferencePoolStatus { /// 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>, + 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 InferencePoolParent { +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. @@ -130,17 +131,36 @@ pub struct InferencePoolParent { /// * "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: 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 ParentRef { +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")] diff --git a/extensions/inference/src/apis/standard/mod.rs b/gateway-api-inference-extension/src/standard/mod.rs similarity index 81% rename from extensions/inference/src/apis/standard/mod.rs rename to gateway-api-inference-extension/src/standard/mod.rs index c7b2180..d450098 100644 --- a/extensions/inference/src/apis/standard/mod.rs +++ b/gateway-api-inference-extension/src/standard/mod.rs @@ -1,4 +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/extensions/inference/Cargo.toml b/gateway-api-with-extensions/Cargo.toml similarity index 75% rename from extensions/inference/Cargo.toml rename to gateway-api-with-extensions/Cargo.toml index 933e55d..9014507 100644 --- a/extensions/inference/Cargo.toml +++ b/gateway-api-with-extensions/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "inference-extension-api" -description = "Kubernetes Gateway API Inference Extension bindings in Rust" +name = "gateway-api-with-extensions" +description = "Kubernetes Gateway API bindings in Rust" categories = ["api-bindings"] -keywords = ["kubernetes", "inference-extension-api"] +keywords = ["kubernetes", "gateway-api","gateway-api-inference-extension"] -homepage = "https://docs.rs/crate/inference-extension-api/" +homepage = "https://docs.rs/crate/gateway-api/" readme = "../README.md" -repository = "https://github.com/kube-rs/gateway-api-rs/extensions/inference" +repository = "https://github.com/kubvernor/gateway-api-rs" authors.workspace = true edition.workspace = true @@ -25,6 +25,7 @@ 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"] } @@ -40,9 +41,10 @@ uuid.workspace = true features = ["k8s-openapi/v1_33"] [features] -default = ["standard", "experimental"] +default = ["standard"] standard = [] -experimental = [] +experimental=[] + [lints.clippy] diff --git a/gateway-api-with-extensions/Cargo.toml~ b/gateway-api-with-extensions/Cargo.toml~ new file mode 100644 index 0000000..7f24fb9 --- /dev/null +++ b/gateway-api-with-extensions/Cargo.toml~ @@ -0,0 +1,54 @@ +[package] +name = "gateway-api" +description = "Kubernetes Gateway API bindings in Rust" +categories = ["api-bindings"] +keywords = ["kubernetes", "gateway-api"] + +homepage = "https://docs.rs/crate/gateway-api/" +readme = "../README.md" +repository = "https://github.com/kube-rs/gateway-api-rs" + +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, 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/src/apis/experimental/backendtlspolicies.rs b/gateway-api-with-extensions/src/experimental/backendtlspolicies.rs similarity index 100% rename from gateway-api/src/apis/experimental/backendtlspolicies.rs rename to gateway-api-with-extensions/src/experimental/backendtlspolicies.rs 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 100% rename from gateway-api/src/apis/experimental/constants.rs rename to gateway-api-with-extensions/src/experimental/constants.rs 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/grpcroutes.rs b/gateway-api-with-extensions/src/experimental/grpcroutes.rs similarity index 65% rename from gateway-api/src/apis/experimental/grpcroutes.rs rename to gateway-api-with-extensions/src/experimental/grpcroutes.rs index 1290efd..51ee5d8 100644 --- a/gateway-api/src/apis/experimental/grpcroutes.rs +++ b/gateway-api-with-extensions/src/experimental/grpcroutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "grpcroutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "GrpcRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct GrpcRouteSpec { @@ -161,7 +161,7 @@ pub struct GrpcRouteSpec { skip_serializing_if = "Option::is_none", rename = "useDefaultGateways" )] - pub use_default_gateways: Option, + pub use_default_gateways: Option, } /// GRPCRouteRule defines the semantics for matching a gRPC request based on /// conditions (matches), processing it (filters), and forwarding the request to @@ -227,7 +227,7 @@ pub struct GrpcRouteRule { /// /// Support: Core #[serde(default, skip_serializing_if = "Option::is_none")] - pub filters: Option>, + 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. @@ -293,7 +293,7 @@ pub struct GrpcRouteRule { skip_serializing_if = "Option::is_none", rename = "sessionPersistence" )] - pub session_persistence: Option, + pub session_persistence: Option, } /// GRPCBackendRef defines how a GRPCRoute forwards a gRPC request. /// @@ -324,7 +324,7 @@ pub struct GRPCBackendReference { /// 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>, + 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")] @@ -381,174 +381,6 @@ pub struct GRPCBackendReference { #[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: GRPCFilterType, -} -/// 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: GRPCFilterType, -} /// 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. @@ -603,95 +435,66 @@ pub struct GRPCMethodMatch { #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")] pub r#type: Option, } -/// SessionPersistence defines and configures session persistence -/// for the route rule. -/// -/// Support: Extended +/// Status defines the current state of GRPCRoute. #[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 of 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, +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, } -/// CookieConfig provides configuration settings that are specific -/// to cookie-based session persistence. -/// -/// Support: Core +/// RouteParentStatus describes the status of a route with respect to an +/// associated Parent. #[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. - /// - /// Defaults to "Session". - /// - /// Support: Core for "Session" type - /// - /// Support: Extended for "Permanent" type - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "lifetimeType" - )] - pub lifetime_type: Option, +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 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/apis/experimental/httproutes.rs b/gateway-api-with-extensions/src/experimental/httproutes.rs similarity index 86% rename from gateway-api/src/apis/experimental/httproutes.rs rename to gateway-api-with-extensions/src/experimental/httproutes.rs index 2496e1d..d8a98c8 100644 --- a/gateway-api/src/apis/experimental/httproutes.rs +++ b/gateway-api-with-extensions/src/experimental/httproutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "httproutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "HttpRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct HttpRouteSpec { @@ -164,7 +164,7 @@ pub struct HttpRouteSpec { skip_serializing_if = "Option::is_none", rename = "useDefaultGateways" )] - pub use_default_gateways: Option, + 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 @@ -327,7 +327,7 @@ pub struct HttpRouteRule { skip_serializing_if = "Option::is_none", rename = "sessionPersistence" )] - pub session_persistence: Option, + pub session_persistence: Option, /// Timeouts defines the timeouts that can be configured for an HTTP request. /// /// Support: Extended @@ -461,7 +461,7 @@ pub struct HttpRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "externalAuth" )] - pub external_auth: Option, + pub external_auth: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -496,7 +496,7 @@ pub struct HttpRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "requestRedirect" )] - pub request_redirect: Option, + pub request_redirect: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -791,77 +791,6 @@ pub struct HttpRouteRulesBackendRefsFiltersCors { #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] pub max_age: 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 -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersExternalAuth { - /// BackendRef is a reference to a backend to send authorization - /// requests to. - /// - /// The backend must speak the selected protocol (GRPC or HTTP) on the - /// referenced port. - /// - /// If the backend service requires TLS, use BackendTLSPolicy to tell the - /// implementation to supply the TLS details to be used to connect to that - /// backend. - #[serde(rename = "backendRef")] - pub backend_ref: BackendObjectReference, - /// ForwardBody controls if requests to the authorization server should include - /// the body of the client request; and if so, how big that body is allowed - /// to be. - /// - /// It is expected that implementations will buffer the request body up to - /// `forwardBody.maxSize` bytes. Bodies over that size must be rejected with a - /// 4xx series error (413 or 403 are common examples), and fail processing - /// of the filter. - /// - /// If unset, or `forwardBody.maxSize` is set to `0`, then the body will not - /// be forwarded. - /// - /// Feature Name: HTTPRouteExternalAuthForwardBody - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "forwardBody" - )] - pub forward_body: Option, - /// GRPCAuthConfig contains configuration for communication with ext_authz - /// protocol-speaking backends. - /// - /// If unset, implementations must assume the default behavior for each - /// included field is intended. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub grpc: Option, - /// HTTPAuthConfig contains configuration for communication with HTTP-speaking - /// backends. - /// - /// If unset, implementations must assume the default behavior for each - /// included field is intended. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub http: Option, - /// ExternalAuthProtocol describes which protocol to use when communicating with an - /// ext_authz authorization server. - /// - /// When this is set to GRPC, each backend must use the Envoy ext_authz protocol - /// on the port specified in `backendRefs`. Requests and responses are defined - /// in the protobufs explained at: - /// - /// - /// When this is set to HTTP, each backend must respond with a `200` status - /// code in on a successful authorization. Any other code is considered - /// an authorization failure. - /// - /// Feature Names: - /// GRPC Support - HTTPRouteExternalAuthGRPC - /// HTTP Support - HTTPRouteExternalAuthHTTP - pub protocol: HttpRouteRulesBackendRefsFiltersExternalAuthProtocol, -} /// 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 @@ -903,7 +832,7 @@ pub struct HttpRouteFilter { skip_serializing_if = "Option::is_none", rename = "externalAuth" )] - pub external_auth: Option, + pub external_auth: Option, /// RequestHeaderModifier defines a schema for a filter that modifies request /// headers. /// @@ -938,7 +867,7 @@ pub struct HttpRouteFilter { skip_serializing_if = "Option::is_none", rename = "requestRedirect" )] - pub request_redirect: Option, + pub request_redirect: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -1233,77 +1162,6 @@ pub struct HttpRouteRulesFiltersCors { #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")] pub max_age: 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 -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesFiltersExternalAuth { - /// BackendRef is a reference to a backend to send authorization - /// requests to. - /// - /// The backend must speak the selected protocol (GRPC or HTTP) on the - /// referenced port. - /// - /// If the backend service requires TLS, use BackendTLSPolicy to tell the - /// implementation to supply the TLS details to be used to connect to that - /// backend. - #[serde(rename = "backendRef")] - pub backend_ref: BackendObjectReference, - /// ForwardBody controls if requests to the authorization server should include - /// the body of the client request; and if so, how big that body is allowed - /// to be. - /// - /// It is expected that implementations will buffer the request body up to - /// `forwardBody.maxSize` bytes. Bodies over that size must be rejected with a - /// 4xx series error (413 or 403 are common examples), and fail processing - /// of the filter. - /// - /// If unset, or `forwardBody.maxSize` is set to `0`, then the body will not - /// be forwarded. - /// - /// Feature Name: HTTPRouteExternalAuthForwardBody - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "forwardBody" - )] - pub forward_body: Option, - /// GRPCAuthConfig contains configuration for communication with ext_authz - /// protocol-speaking backends. - /// - /// If unset, implementations must assume the default behavior for each - /// included field is intended. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub grpc: Option, - /// HTTPAuthConfig contains configuration for communication with HTTP-speaking - /// backends. - /// - /// If unset, implementations must assume the default behavior for each - /// included field is intended. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub http: Option, - /// ExternalAuthProtocol describes which protocol to use when communicating with an - /// ext_authz authorization server. - /// - /// When this is set to GRPC, each backend must use the Envoy ext_authz protocol - /// on the port specified in `backendRefs`. Requests and responses are defined - /// in the protobufs explained at: - /// - /// - /// When this is set to HTTP, each backend must respond with a `200` status - /// code in on a successful authorization. Any other code is considered - /// an authorization failure. - /// - /// Feature Names: - /// GRPC Support - HTTPRouteExternalAuthGRPC - /// HTTP Support - HTTPRouteExternalAuthHTTP - pub protocol: HttpRouteRulesBackendRefsFiltersExternalAuthProtocol, -} /// 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. @@ -1474,98 +1332,6 @@ pub struct HttpRouteRulesRetry { #[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 of 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. - /// - /// Defaults to "Session". - /// - /// Support: Core for "Session" type - /// - /// Support: Extended for "Permanent" type - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "lifetimeType" - )] - pub lifetime_type: Option, -} /// Timeouts defines the timeouts that can be configured for an HTTP request. /// /// Support: Extended @@ -1621,3 +1387,66 @@ pub struct HttpRouteTimeout { #[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/experimental/referencegrants.rs b/gateway-api-with-extensions/src/experimental/referencegrants.rs similarity index 100% rename from gateway-api/src/apis/experimental/referencegrants.rs rename to gateway-api-with-extensions/src/experimental/referencegrants.rs diff --git a/gateway-api/src/apis/experimental/tcproutes.rs b/gateway-api-with-extensions/src/experimental/tcproutes.rs similarity index 65% rename from gateway-api/src/apis/experimental/tcproutes.rs rename to gateway-api-with-extensions/src/experimental/tcproutes.rs index 6adcdcb..29652be 100644 --- a/gateway-api/src/apis/experimental/tcproutes.rs +++ b/gateway-api-with-extensions/src/experimental/tcproutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "tcproutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "TcpRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct TcpRouteSpec { @@ -108,7 +108,7 @@ pub struct TcpRouteSpec { skip_serializing_if = "Option::is_none", rename = "useDefaultGateways" )] - pub use_default_gateways: Option, + pub use_default_gateways: Option, } /// TCPRouteRule is the configuration for a given rule. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] @@ -135,3 +135,66 @@ pub struct TcpRouteRules { #[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/apis/experimental/tlsroutes.rs b/gateway-api-with-extensions/src/experimental/tlsroutes.rs similarity index 67% rename from gateway-api/src/apis/experimental/tlsroutes.rs rename to gateway-api-with-extensions/src/experimental/tlsroutes.rs index 11a337d..d9dc1af 100644 --- a/gateway-api/src/apis/experimental/tlsroutes.rs +++ b/gateway-api-with-extensions/src/experimental/tlsroutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "tlsroutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "TlsRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct TlsRouteSpec { @@ -116,7 +116,7 @@ pub struct TlsRouteSpec { skip_serializing_if = "Option::is_none", rename = "useDefaultGateways" )] - pub use_default_gateways: Option, + pub use_default_gateways: Option, } /// TLSRouteRule is the configuration for a given rule. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] @@ -143,3 +143,66 @@ pub struct TlsRouteRules { #[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/apis/experimental/udproutes.rs b/gateway-api-with-extensions/src/experimental/udproutes.rs similarity index 65% rename from gateway-api/src/apis/experimental/udproutes.rs rename to gateway-api-with-extensions/src/experimental/udproutes.rs index e547c94..0d0c996 100644 --- a/gateway-api/src/apis/experimental/udproutes.rs +++ b/gateway-api-with-extensions/src/experimental/udproutes.rs @@ -18,7 +18,7 @@ use self::prelude::*; plural = "udproutes" )] #[kube(namespaced)] -#[kube(status = "RouteStatus")] +#[kube(status = "UdpRouteStatus")] #[kube(derive = "Default")] #[kube(derive = "PartialEq")] pub struct UdpRouteSpec { @@ -108,7 +108,7 @@ pub struct UdpRouteSpec { skip_serializing_if = "Option::is_none", rename = "useDefaultGateways" )] - pub use_default_gateways: Option, + pub use_default_gateways: Option, } /// UDPRouteRule is the configuration for a given rule. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] @@ -135,3 +135,66 @@ pub struct UdpRouteRules { #[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/src/apis/mod.rs b/gateway-api-with-extensions/src/mod.rs similarity index 100% rename from gateway-api/src/apis/mod.rs rename to gateway-api-with-extensions/src/mod.rs diff --git a/gateway-api/src/apis/standard/backendtlspolicies.rs b/gateway-api-with-extensions/src/standard/backendtlspolicies.rs similarity index 100% rename from gateway-api/src/apis/standard/backendtlspolicies.rs rename to gateway-api-with-extensions/src/standard/backendtlspolicies.rs diff --git a/gateway-api/src/apis/experimental/common.rs b/gateway-api-with-extensions/src/standard/common.rs similarity index 86% rename from gateway-api/src/apis/experimental/common.rs rename to gateway-api-with-extensions/src/standard/common.rs index 2885040..9cd8633 100644 --- a/gateway-api/src/apis/experimental/common.rs +++ b/gateway-api-with-extensions/src/standard/common.rs @@ -10,7 +10,7 @@ mod prelude { } use self::prelude::*; #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum AllowedRoutesNamespaces { +pub enum AllowedRoutesNamespacesFrom { All, Selector, Same, @@ -23,21 +23,6 @@ pub enum GRPCFilterType { ExtensionRef, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GatewayDefaultScope { - All, - None, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GrpcRouteRulesSessionPersistenceCookieConfigLifetimeType { - Permanent, - Session, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum GrpcRouteRulesSessionPersistenceType { - Cookie, - Header, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum HTTPFilterType { RequestHeaderModifier, ResponseHeaderModifier, @@ -48,7 +33,6 @@ pub enum HTTPFilterType { ExtensionRef, #[serde(rename = "CORS")] Cors, - ExternalAuth, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum HeaderMatchType { @@ -56,13 +40,6 @@ pub enum HeaderMatchType { RegularExpression, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum HttpRouteRulesBackendRefsFiltersExternalAuthProtocol { - #[serde(rename = "HTTP")] - Http, - #[serde(rename = "GRPC")] - Grpc, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] pub enum RedirectStatusCode { #[serde(rename = "301")] r#_301, @@ -129,35 +106,8 @@ pub struct HTTPHeader { pub value: String, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersExternalAuthForwardBody { - #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxSize")] - pub max_size: Option, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersExternalAuthGrpc { - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "allowedHeaders" - )] - pub allowed_headers: Option>, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteRulesBackendRefsFiltersExternalAuthHttp { - #[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, +pub struct InferencePoolEndpointPickerRefPort { + pub number: i32, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] pub struct Kind { @@ -207,36 +157,43 @@ pub struct RequestMirrorFraction { 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, +pub struct GatewayTlsFrontendDefaultValidation { + #[serde(rename = "caCertificateRefs")] + pub ca_certificate_refs: Vec, #[serde(default, skip_serializing_if = "Option::is_none")] - pub kind: Option, + 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 namespace: Option, + pub add: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, + pub remove: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - pub weight: Option, + pub set: Option>, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayAllowedListenersNamespacesSelector { - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "matchExpressions" - )] - pub match_expressions: Option>, +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 = "matchLabels" + rename = "supportedKinds" )] - pub match_labels: Option>, + pub supported_kinds: Option>, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersTls { +pub struct ListenerTls { #[serde( default, skip_serializing_if = "Option::is_none", @@ -249,40 +206,19 @@ pub struct GatewayListenersTls { pub options: Option>, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayStatusListeners { - #[serde(rename = "attachedRoutes")] - pub attached_routes: i32, - pub conditions: Vec, - pub name: String, +pub struct NamespaceSelector { #[serde( default, skip_serializing_if = "Option::is_none", - rename = "supportedKinds" + rename = "matchExpressions" )] - pub supported_kinds: Option>, -} -#[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>, + 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 { @@ -319,7 +255,14 @@ pub struct RequestRedirectPath { pub r#type: RequestOperationType, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct RequestRedirect { +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")] @@ -336,6 +279,35 @@ pub struct RequestRedirect { 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, @@ -346,3 +318,26 @@ pub struct HttpRouteUrlRewrite { 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/apis/standard/constants.rs b/gateway-api-with-extensions/src/standard/constants.rs similarity index 100% rename from gateway-api/src/apis/standard/constants.rs rename to gateway-api-with-extensions/src/standard/constants.rs 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 100% rename from gateway-api/src/apis/experimental/gatewayclasses.rs rename to gateway-api-with-extensions/src/standard/gatewayclasses.rs diff --git a/gateway-api/src/apis/standard/gateways.rs b/gateway-api-with-extensions/src/standard/gateways.rs similarity index 73% rename from gateway-api/src/apis/standard/gateways.rs rename to gateway-api-with-extensions/src/standard/gateways.rs index 8ff7f1e..8d967c5 100644 --- a/gateway-api/src/apis/standard/gateways.rs +++ b/gateway-api-with-extensions/src/standard/gateways.rs @@ -223,7 +223,7 @@ pub struct GatewaySpec { /// In a future release the MinItems=1 requirement MAY be dropped. /// /// Support: Core - pub listeners: Vec, + pub listeners: Vec, /// TLS specifies frontend and backend tls configuration for entire gateway. /// /// Support: Extended @@ -274,7 +274,7 @@ pub struct GatewayAllowedListenersNamespaces { /// 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, + pub selector: Option, } /// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. /// The default value is to allow no ListenerSets. @@ -336,188 +336,6 @@ pub struct GatewayInfrastructure { )] pub parameters_ref: Option, } -/// 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 both the SNI and Host header. - /// Note that this does not require the SNI and Host header to be the same. - /// The semantics of this are described in more detail below. - /// - /// To ensure security, Section 11.1 of RFC-6066 emphasizes that server - /// implementations that rely on SNI hostname matching MUST also verify - /// hostnames within the application protocol. - /// - /// Section 9.1.2 of RFC-7540 provides a mechanism for servers to reject the - /// reuse of a connection by responding with the HTTP 421 Misdirected Request - /// status code. This indicates that the origin server has rejected the - /// request because it appears to have been misdirected. - /// - /// To detect misdirected requests, Gateways SHOULD match the authority of - /// the requests with all the SNI hostname(s) configured across all the - /// Gateway Listeners on the same port and protocol: - /// - /// * If another Listener has an exact match or more specific wildcard entry, - /// the Gateway SHOULD return a 421. - /// * If the current Listener (selected by SNI matching during ClientHello) - /// does not match the Host: - /// * If another Listener does match the Host, the Gateway SHOULD return a - /// 421. - /// * If no other Listener matches the Host, the Gateway MUST return a - /// 404. - /// - /// 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 ListenerTLSConfig 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, -} -/// 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, -} /// TLS specifies frontend and backend tls configuration for entire gateway. /// /// Support: Extended @@ -692,7 +510,7 @@ pub struct GatewayStatus { 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>, + pub listeners: Option>, } /// GatewayStatusAddress describes a network address that is bound to a Gateway. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] diff --git a/gateway-api/src/apis/standard/grpcroutes.rs b/gateway-api-with-extensions/src/standard/grpcroutes.rs similarity index 100% rename from gateway-api/src/apis/standard/grpcroutes.rs rename to gateway-api-with-extensions/src/standard/grpcroutes.rs diff --git a/gateway-api/src/apis/standard/httproutes.rs b/gateway-api-with-extensions/src/standard/httproutes.rs similarity index 99% rename from gateway-api/src/apis/standard/httproutes.rs rename to gateway-api-with-extensions/src/standard/httproutes.rs index 788536f..165be1d 100644 --- a/gateway-api/src/apis/standard/httproutes.rs +++ b/gateway-api-with-extensions/src/standard/httproutes.rs @@ -423,7 +423,7 @@ pub struct HttpRouteBackendFilter { skip_serializing_if = "Option::is_none", rename = "requestRedirect" )] - pub request_redirect: Option, + pub request_redirect: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// @@ -780,7 +780,7 @@ pub struct HttpRouteFilter { skip_serializing_if = "Option::is_none", rename = "requestRedirect" )] - pub request_redirect: Option, + pub request_redirect: Option, /// ResponseHeaderModifier defines a schema for a filter that modifies response /// headers. /// 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/standard/referencegrants.rs b/gateway-api-with-extensions/src/standard/referencegrants.rs similarity index 100% rename from gateway-api/src/apis/standard/referencegrants.rs rename to gateway-api-with-extensions/src/standard/referencegrants.rs diff --git a/gateway-api/src/apis/standard/tlsroutes.rs b/gateway-api-with-extensions/src/standard/tlsroutes.rs similarity index 100% rename from gateway-api/src/apis/standard/tlsroutes.rs rename to gateway-api-with-extensions/src/standard/tlsroutes.rs diff --git a/gateway-api/Cargo.toml b/gateway-api/Cargo.toml index ae63063..c447159 100644 --- a/gateway-api/Cargo.toml +++ b/gateway-api/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["kubernetes", "gateway-api"] homepage = "https://docs.rs/crate/gateway-api/" readme = "../README.md" -repository = "https://github.com/kube-rs/gateway-api-rs" +repository = "https://github.com/kubvernor/gateway-api-rs" authors.workspace = true edition.workspace = true @@ -25,24 +25,24 @@ 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"] } +# [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_33"] [features] -default = ["standard", "experimental"] +default = ["standard"] standard = [] -experimental = [] +experimental=[] + [lints.clippy] 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 7cc81b3..0000000 --- a/gateway-api/src/apis/experimental/enum_defaults.rs +++ /dev/null @@ -1,33 +0,0 @@ -use super::common::*; -// WARNING: generated file - manual changes will be overriden - -impl Default for BackendTlsPolicyValidationSubjectAltNamesType { - fn default() -> Self { - BackendTlsPolicyValidationSubjectAltNamesType::Hostname - } -} - -impl Default for GRPCFilterType { - fn default() -> Self { - GRPCFilterType::RequestHeaderModifier - } -} - -impl Default for HTTPFilterType { - fn default() -> Self { - HTTPFilterType::RequestHeaderModifier - } -} - -impl Default for HttpRouteRulesBackendRefsFiltersExternalAuthProtocol { - fn default() -> Self { - HttpRouteRulesBackendRefsFiltersExternalAuthProtocol::Http - } -} - -impl Default for RequestOperationType { - fn default() -> Self { - RequestOperationType::ReplaceFullPath - } -} -use crate::experimental::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType; diff --git a/gateway-api/src/apis/experimental/listenersets.rs b/gateway-api/src/apis/experimental/listenersets.rs deleted file mode 100644 index 1d9df7c..0000000 --- a/gateway-api/src/apis/experimental/listenersets.rs +++ /dev/null @@ -1,225 +0,0 @@ -// 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, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct ListenerSetListeners { - /// 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. - #[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`. - #[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 - /// ListenerSet. - /// - /// Name is not required to be unique across a Gateway and ListenerSets. - /// Routes can attach to a Listener by having a ListenerSet as a parentRef - /// and setting the SectionName - pub name: String, - /// Port is the network port. Multiple listeners may use the - /// same port, subject to the Listener compatibility rules. - pub port: i32, - /// Protocol specifies the network protocol this listener expects to receive. - 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 ListenerTLSConfig 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. - #[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. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct ListenerSetListenersAllowedRoutes { - /// 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, -} -/// 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 ListenerSetListenersAllowedRoutesNamespaces { - /// 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, -} -/// 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/apis/standard/enum_defaults.rs b/gateway-api/src/apis/standard/enum_defaults.rs deleted file mode 100644 index 2973164..0000000 --- a/gateway-api/src/apis/standard/enum_defaults.rs +++ /dev/null @@ -1,27 +0,0 @@ -use super::common::*; -// WARNING: generated file - manual changes will be overriden - -impl Default for BackendTlsPolicyValidationSubjectAltNamesType { - fn default() -> Self { - BackendTlsPolicyValidationSubjectAltNamesType::Hostname - } -} - -impl Default for GRPCFilterType { - fn default() -> Self { - GRPCFilterType::RequestHeaderModifier - } -} - -impl Default for HTTPFilterType { - fn default() -> Self { - HTTPFilterType::RequestHeaderModifier - } -} - -impl Default for RequestOperationType { - fn default() -> Self { - RequestOperationType::ReplaceFullPath - } -} -use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType; diff --git a/gateway-api/src/apis/standard/listenersets.rs b/gateway-api/src/apis/standard/listenersets.rs deleted file mode 100644 index 1d9df7c..0000000 --- a/gateway-api/src/apis/standard/listenersets.rs +++ /dev/null @@ -1,225 +0,0 @@ -// 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, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct ListenerSetListeners { - /// 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. - #[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`. - #[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 - /// ListenerSet. - /// - /// Name is not required to be unique across a Gateway and ListenerSets. - /// Routes can attach to a Listener by having a ListenerSet as a parentRef - /// and setting the SectionName - pub name: String, - /// Port is the network port. Multiple listeners may use the - /// same port, subject to the Listener compatibility rules. - pub port: i32, - /// Protocol specifies the network protocol this listener expects to receive. - 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 ListenerTLSConfig 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. - #[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. -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct ListenerSetListenersAllowedRoutes { - /// 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, -} -/// 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 ListenerSetListenersAllowedRoutesNamespaces { - /// 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, -} -/// 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/duration.rs b/gateway-api/src/duration.rs index c090600..087b0e8 100644 --- a/gateway-api/src/duration.rs +++ b/gateway-api/src/duration.rs @@ -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()); } 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/experimental/constants.rs b/gateway-api/src/experimental/constants.rs new file mode 100644 index 0000000..8995c8a --- /dev/null +++ b/gateway-api/src/experimental/constants.rs @@ -0,0 +1,120 @@ +// WARNING: generated file - manual changes will be overriden + +#[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, + InvalidParameters, + 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, + 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, +} +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 100% rename from gateway-api/src/apis/standard/gatewayclasses.rs rename to gateway-api/src/experimental/gatewayclasses.rs 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/experimental/grpcroutes.rs b/gateway-api/src/experimental/grpcroutes.rs new file mode 100644 index 0000000..51ee5d8 --- /dev/null +++ b/gateway-api/src/experimental/grpcroutes.rs @@ -0,0 +1,500 @@ +// 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 = "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>, + /// 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, +} +/// 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, + /// 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 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, +} +/// 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 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/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 99% rename from gateway-api/src/apis/experimental/mod.rs rename to gateway-api/src/experimental/mod.rs index 44336b0..a13a089 100644 --- a/gateway-api/src/apis/experimental/mod.rs +++ b/gateway-api/src/experimental/mod.rs @@ -1,5 +1,4 @@ // WARNING: generated file - manual changes will be overriden - pub mod backendtlspolicies; pub mod common; pub mod constants; 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 7cea5ec..43696e7 100644 --- a/gateway-api/src/lib.rs +++ b/gateway-api/src/lib.rs @@ -1,12 +1,15 @@ pub mod duration; pub use duration::Duration; -pub mod apis; -#[cfg(feature = "standard")] -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 { @@ -27,28 +30,18 @@ mod tests { use tower::ServiceBuilder; use uuid::Uuid; - use crate::gateways::GatewayStatusListeners; - + use crate::common::{ParentReference, ParentRouteStatus, RouteStatus}; use crate::{ - apis::standard::constants::{ + common::GatewayStatusListeners, + constants::{ GatewayConditionReason, GatewayConditionType, ListenerConditionReason, ListenerConditionType, RouteConditionReason, RouteConditionType, }, - apis::standard::gatewayclasses::{GatewayClass, GatewayClassSpec}, - apis::standard::gateways::{ - Gateway, GatewayListeners, GatewaySpec, GatewayStatus, GatewayStatusAddresses, - }, - apis::standard::grpcroutes::{ - GrpcRouteParentRefs, GrpcRouteSpec, GrpcRouteStatus, GrpcRouteStatusParents, - GrpcRouteStatusParentsParentRef, - }, - apis::standard::httproutes::{ - HttpRouteParentRefs, HttpRouteSpec, HttpRouteStatus, HttpRouteStatusParents, - HttpRouteStatusParentsParentRef, - }, - apis::standard::referencegrants::{ - ReferenceGrantFrom, ReferenceGrantSpec, ReferenceGrantTo, - }, + 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"; @@ -189,11 +182,11 @@ mod tests { assert!(gw.status.clone().unwrap().listeners.is_some()); assert!(gw.status.clone().unwrap().conditions.is_some()); - let mut http_route = crate::apis::standard::httproutes::HTTPRoute { + let mut http_route = crate::httproutes::HTTPRoute { metadata: ObjectMeta::default(), spec: HttpRouteSpec { hostnames: Some(vec!["example.com".to_string()]), - parent_refs: Some(vec![HttpRouteParentRefs { + parent_refs: Some(vec![ParentReference { group: Some("gateway.networking.k8s.io".to_string()), kind: Some("Gateway".to_string()), namespace: Some("default".to_string()), @@ -215,9 +208,9 @@ mod tests { assert!(http_route.spec.hostnames.is_some()); assert!(http_route.spec.parent_refs.is_some()); - let http_route_status = HttpRouteStatus { - parents: vec![HttpRouteStatusParents { - parent_ref: HttpRouteStatusParentsParentRef { + 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()), @@ -250,11 +243,11 @@ mod tests { assert!(http_route.status.is_some()); assert!(!http_route.status.clone().unwrap().parents.is_empty()); - let mut grpc_route = crate::apis::standard::grpcroutes::GRPCRoute { + let mut grpc_route = crate::grpcroutes::GRPCRoute { metadata: ObjectMeta::default(), spec: GrpcRouteSpec { hostnames: Some(vec!["grpc.example.com".to_string()]), - parent_refs: Some(vec![GrpcRouteParentRefs { + parent_refs: Some(vec![ParentReference { group: Some("gateway.networking.k8s.io".to_string()), kind: Some("Gateway".to_string()), namespace: Some("default".to_string()), @@ -276,9 +269,9 @@ mod tests { assert!(grpc_route.spec.hostnames.is_some()); assert!(grpc_route.spec.parent_refs.is_some()); - let grpc_route_status = GrpcRouteStatus { - parents: vec![GrpcRouteStatusParents { - parent_ref: GrpcRouteStatusParentsParentRef { + 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()), @@ -311,7 +304,7 @@ mod tests { assert!(grpc_route.status.is_some()); assert!(!grpc_route.status.clone().unwrap().parents.is_empty()); - let mut ref_grant = crate::apis::standard::referencegrants::ReferenceGrant { + let mut ref_grant = crate::referencegrants::ReferenceGrant { metadata: ObjectMeta::default(), spec: ReferenceGrantSpec { from: vec![ReferenceGrantFrom { @@ -452,7 +445,7 @@ mod tests { .create(&PostParams::default(), &gw_crd) .await?; - let mut http_route_crd = crate::apis::standard::httproutes::HTTPRoute::crd(); + 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(), @@ -462,7 +455,7 @@ mod tests { .create(&PostParams::default(), &http_route_crd) .await?; - let mut grpc_route_crd = crate::apis::standard::grpcroutes::GRPCRoute::crd(); + 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(), @@ -472,7 +465,7 @@ mod tests { .create(&PostParams::default(), &grpc_route_crd) .await?; - let mut ref_grant_crd = crate::apis::standard::referencegrants::ReferenceGrant::crd(); + 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(), 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/apis/standard/common.rs b/gateway-api/src/standard/common.rs similarity index 88% rename from gateway-api/src/apis/standard/common.rs rename to gateway-api/src/standard/common.rs index 647636e..7eb3f0c 100644 --- a/gateway-api/src/apis/standard/common.rs +++ b/gateway-api/src/standard/common.rs @@ -10,7 +10,7 @@ mod prelude { } use self::prelude::*; #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)] -pub enum AllowedRoutesNamespaces { +pub enum AllowedRoutesNamespacesFrom { All, Selector, Same, @@ -153,22 +153,43 @@ pub struct RequestMirrorFraction { pub numerator: i32, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayAllowedListenersNamespacesSelector { - #[serde( - default, - skip_serializing_if = "Option::is_none", - rename = "matchExpressions" - )] - pub match_expressions: Option>, +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 = "matchLabels" + rename = "supportedKinds" )] - pub match_labels: Option>, + pub supported_kinds: Option>, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayListenersTls { +pub struct ListenerTls { #[serde( default, skip_serializing_if = "Option::is_none", @@ -181,40 +202,19 @@ pub struct GatewayListenersTls { pub options: Option>, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct GatewayStatusListeners { - #[serde(rename = "attachedRoutes")] - pub attached_routes: i32, - pub conditions: Vec, - pub name: String, +pub struct NamespaceSelector { #[serde( default, skip_serializing_if = "Option::is_none", - rename = "supportedKinds" + rename = "matchExpressions" )] - pub supported_kinds: Option>, -} -#[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>, + 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 { @@ -251,6 +251,30 @@ pub struct RequestRedirectPath { 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, @@ -280,30 +304,36 @@ pub struct GrpcRouteFilter { pub r#type: GRPCFilterType, } #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct RequestRedirect { +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 port: Option, + pub kinds: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - pub scheme: Option, + pub namespaces: Option, +} +#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] +pub struct Listeners { #[serde( default, skip_serializing_if = "Option::is_none", - rename = "statusCode" + rename = "allowedRoutes" )] - pub status_code: Option, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct HttpRouteUrlRewrite { + 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 path: Option, -} -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] -pub struct RouteStatus { - pub parents: Vec, + 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/apis/experimental/gateways.rs b/gateway-api/src/standard/gateways.rs similarity index 70% rename from gateway-api/src/apis/experimental/gateways.rs rename to gateway-api/src/standard/gateways.rs index 85d3351..8d967c5 100644 --- a/gateway-api/src/apis/experimental/gateways.rs +++ b/gateway-api/src/standard/gateways.rs @@ -53,29 +53,6 @@ pub struct GatewaySpec { 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")] @@ -246,7 +223,7 @@ pub struct GatewaySpec { /// In a future release the MinItems=1 requirement MAY be dropped. /// /// Support: Core - pub listeners: Vec, + pub listeners: Vec, /// TLS specifies frontend and backend tls configuration for entire gateway. /// /// Support: Extended @@ -297,7 +274,7 @@ pub struct GatewayAllowedListenersNamespaces { /// 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, + pub selector: Option, } /// Namespaces defines which namespaces ListenerSets can be attached to this Gateway. /// The default value is to allow no ListenerSets. @@ -359,188 +336,6 @@ pub struct GatewayInfrastructure { )] pub parameters_ref: Option, } -/// 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 both the SNI and Host header. - /// Note that this does not require the SNI and Host header to be the same. - /// The semantics of this are described in more detail below. - /// - /// To ensure security, Section 11.1 of RFC-6066 emphasizes that server - /// implementations that rely on SNI hostname matching MUST also verify - /// hostnames within the application protocol. - /// - /// Section 9.1.2 of RFC-7540 provides a mechanism for servers to reject the - /// reuse of a connection by responding with the HTTP 421 Misdirected Request - /// status code. This indicates that the origin server has rejected the - /// request because it appears to have been misdirected. - /// - /// To detect misdirected requests, Gateways SHOULD match the authority of - /// the requests with all the SNI hostname(s) configured across all the - /// Gateway Listeners on the same port and protocol: - /// - /// * If another Listener has an exact match or more specific wildcard entry, - /// the Gateway SHOULD return a 421. - /// * If the current Listener (selected by SNI matching during ClientHello) - /// does not match the Host: - /// * If another Listener does match the Host, the Gateway SHOULD return a - /// 421. - /// * If no other Listener matches the Host, the Gateway MUST return a - /// 404. - /// - /// 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 ListenerTLSConfig 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, -} -/// 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, -} /// TLS specifies frontend and backend tls configuration for entire gateway. /// /// Support: Extended @@ -715,7 +510,7 @@ pub struct GatewayStatus { 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>, + pub listeners: Option>, } /// GatewayStatusAddress describes a network address that is bound to a Gateway. #[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)] 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/apis/standard/mod.rs b/gateway-api/src/standard/mod.rs similarity index 99% rename from gateway-api/src/apis/standard/mod.rs rename to gateway-api/src/standard/mod.rs index a5b451a..3aa2f59 100644 --- a/gateway-api/src/apis/standard/mod.rs +++ b/gateway-api/src/standard/mod.rs @@ -1,5 +1,4 @@ // WARNING: generated file - manual changes will be overriden - pub mod backendtlspolicies; pub mod common; pub mod constants; 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/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 index 52724a8..e5c1d9b 100755 --- a/scripts/generators/gateway_generator.sh +++ b/scripts/generators/gateway_generator.sh @@ -12,6 +12,8 @@ # See: https://github.com/kube-rs/kopium # ------------------------------------------------------------------------------ +echo "GENERATING GATEWAY API ONLY" + set -eou pipefail GATEWAY_API_VERSION="v1.5.0" @@ -61,10 +63,6 @@ EXPERIMENTAL_APIS=( 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; @@ -85,26 +83,26 @@ do 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 -) +# # 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} +# # 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 +# # 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" @@ -133,26 +131,26 @@ do 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 +# # 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 +# 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" @@ -172,20 +170,5 @@ echo "use crate::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesTy cargo fmt - - - - -ENUMS=( - GRPCFilterType=RequestHeaderModifier - RequestOperationType=ReplaceFullPath - HttpRouteRulesBackendRefsFiltersExternalAuthProtocol=Http - HTTPFilterType=RequestHeaderModifier - BackendTlsPolicyValidationSubjectAltNamesType=Hostname -) - -echo "use crate::experimental::backendtlspolicies::BackendTlsPolicyValidationSubjectAltNamesType;" >> $APIS_DIR/experimental/enum_defaults.rs - -cargo fmt -echo "Gateway API Generation complete" +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..531237f --- /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/experimental_customized_mapped_names.txt b/type-reducer/experimental_customized_mapped_names.txt index 440ffc7..fad2581 100644 --- a/type-reducer/experimental_customized_mapped_names.txt +++ b/type-reducer/experimental_customized_mapped_names.txt @@ -18,8 +18,8 @@ GatewayListenersAllowedRoutesKinds->Kind GatewayStatusListenersSupportedKinds->Kind ListenerSetListenersAllowedRoutesKinds->Kind ListenerSetStatusListenersSupportedKinds->Kind -GatewayListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespaces -ListenerSetListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespaces +GatewayListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespacesFrom +ListenerSetListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespacesFrom GatewayListenersTlsCertificateRefs->Reference GatewayTlsBackendClientCertificateRef->Reference ListenerSetListenersTlsCertificateRefs->Reference @@ -73,6 +73,31 @@ 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 @@ -95,6 +120,20 @@ 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 @@ -105,3 +144,22 @@ 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 index b38f712..c80e826 100644 --- a/type-reducer/experimental_ignorable_mapped_names.txt +++ b/type-reducer/experimental_ignorable_mapped_names.txt @@ -2,3 +2,5 @@ TcpRouteSpec->RouteSpec UdpRouteSpec->RouteSpec GrpcRouteRulesFilters->GrpcRouteFilter GrpcRouteRulesBackendRefsFilters->GrpcRouteFilter +GatewayClassStatusSupportedFeatures->GatewayClassStatusSupportedFeatures +InferencePoolImportStatusControllersExportingClusters->InferencePoolImportStatusControllersExportingClusters diff --git a/type-reducer/experimental_reduced_types_pass_1.txt b/type-reducer/experimental_reduced_types_pass_1.txt index ddbc093..315d9d7 100644 --- a/type-reducer/experimental_reduced_types_pass_1.txt +++ b/type-reducer/experimental_reduced_types_pass_1.txt @@ -1,16 +1,21 @@ -AllowedRoutesNamespaces +AllowedRoutesNamespacesFrom BackendObjectReference -Condition +CookieConfigLifetimeType +DefaultGateway +ExportingClusters ExtensionParametersReference -FilterExtensionReference -FiltersType +ExternalAuthGrpc +ExternalAuthHttp +ExternalAuthProtocol +ForwardBody GatewayAddress -GatewayInfrastructureParametersReference GatewayParametersRef GRPCFilterType HeaderMatchType HTTPFilterType HTTPHeader +InferencePoolRef +InferenceStatus Kind MatchExpressions ParentReference @@ -19,5 +24,7 @@ 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 index eed6614..d6a5e6d 100644 --- a/type-reducer/experimental_reduced_types_pass_2.txt +++ b/type-reducer/experimental_reduced_types_pass_2.txt @@ -1,16 +1,21 @@ -AllowedRoutesNamespaces +AllowedRoutesNamespacesFrom BackendObjectReference -Condition +CookieConfigLifetimeType +DefaultGateway +ExportingClusters ExtensionParametersReference -FilterExtensionReference -FiltersType +ExternalAuthGrpc +ExternalAuthHttp +ExternalAuthProtocol +ForwardBody GatewayAddress -GatewayInfrastructureParametersReference GatewayParametersRef GRPCFilterType HeaderMatchType HTTPFilterType HTTPHeader +InferencePoolRef +InferenceStatus Kind MatchExpressions ParentReference @@ -19,6 +24,8 @@ Reference RequestMirrorFraction RequestOperationType RequestRedirectScheme +SessionPersistenceType +SupportedFeatures TlsMode TlsValidationMode #### Pass 2 @@ -27,4 +34,9 @@ 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 index 499f06c..12e49e4 100644 --- a/type-reducer/experimental_reduced_types_pass_3.txt +++ b/type-reducer/experimental_reduced_types_pass_3.txt @@ -1,16 +1,21 @@ -AllowedRoutesNamespaces +AllowedRoutesNamespacesFrom BackendObjectReference -Condition +CookieConfigLifetimeType +DefaultGateway +ExportingClusters ExtensionParametersReference -FilterExtensionReference -FiltersType +ExternalAuthGrpc +ExternalAuthHttp +ExternalAuthProtocol +ForwardBody GatewayAddress -GatewayInfrastructureParametersReference GatewayParametersRef GRPCFilterType HeaderMatchType HTTPFilterType HTTPHeader +InferencePoolRef +InferenceStatus Kind MatchExpressions ParentReference @@ -19,18 +24,32 @@ 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 index 499f06c..82ea921 100644 --- a/type-reducer/experimental_reduced_types_pass_4.txt +++ b/type-reducer/experimental_reduced_types_pass_4.txt @@ -1,16 +1,21 @@ -AllowedRoutesNamespaces +AllowedRoutesNamespacesFrom BackendObjectReference -Condition +CookieConfigLifetimeType +DefaultGateway +ExportingClusters ExtensionParametersReference -FilterExtensionReference -FiltersType +ExternalAuthGrpc +ExternalAuthHttp +ExternalAuthProtocol +ForwardBody GatewayAddress -GatewayInfrastructureParametersReference GatewayParametersRef GRPCFilterType HeaderMatchType HTTPFilterType HTTPHeader +InferencePoolRef +InferenceStatus Kind MatchExpressions ParentReference @@ -19,18 +24,33 @@ 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/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/main.rs b/type-reducer/src/main.rs index 9e2f99e..5fb9487 100644 --- a/type-reducer/src/main.rs +++ b/type-reducer/src/main.rs @@ -271,20 +271,21 @@ fn create_visitors<'a>( entries.sort_by_key(|e| e.path()); for dir_entry in entries { - if let Ok(name) = dir_entry.file_name().into_string() { - if 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()) { - if 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)); - } - } + 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)); } } } diff --git a/type-reducer/standard_customized_mapped_names.txt b/type-reducer/standard_customized_mapped_names.txt index 440ffc7..3c92cc2 100644 --- a/type-reducer/standard_customized_mapped_names.txt +++ b/type-reducer/standard_customized_mapped_names.txt @@ -18,8 +18,8 @@ GatewayListenersAllowedRoutesKinds->Kind GatewayStatusListenersSupportedKinds->Kind ListenerSetListenersAllowedRoutesKinds->Kind ListenerSetStatusListenersSupportedKinds->Kind -GatewayListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespaces -ListenerSetListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespaces +GatewayListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespacesFrom +ListenerSetListenersAllowedRoutesNamespacesFrom->AllowedRoutesNamespacesFrom GatewayListenersTlsCertificateRefs->Reference GatewayTlsBackendClientCertificateRef->Reference ListenerSetListenersTlsCertificateRefs->Reference @@ -95,6 +95,14 @@ 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 @@ -105,3 +113,15 @@ 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_1.txt b/type-reducer/standard_reduced_types_pass_1.txt index ddbc093..4968375 100644 --- a/type-reducer/standard_reduced_types_pass_1.txt +++ b/type-reducer/standard_reduced_types_pass_1.txt @@ -1,4 +1,4 @@ -AllowedRoutesNamespaces +AllowedRoutesNamespacesFrom BackendObjectReference Condition ExtensionParametersReference diff --git a/type-reducer/standard_reduced_types_pass_2.txt b/type-reducer/standard_reduced_types_pass_2.txt index eed6614..f1a639a 100644 --- a/type-reducer/standard_reduced_types_pass_2.txt +++ b/type-reducer/standard_reduced_types_pass_2.txt @@ -1,4 +1,4 @@ -AllowedRoutesNamespaces +AllowedRoutesNamespacesFrom BackendObjectReference Condition ExtensionParametersReference @@ -28,3 +28,6 @@ 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 index 21109c8..7c45f52 100644 --- a/type-reducer/standard_reduced_types_pass_3.txt +++ b/type-reducer/standard_reduced_types_pass_3.txt @@ -1,18 +1,27 @@ Condition -GRPCFilterType +AllowedRoutesNamespacesFrom +BackendObjectReference +Condition +ExtensionParametersReference +FilterExtensionReference +FiltersType GatewayAddress GatewayInfrastructureParametersReference +GatewayParametersRef +GRPCFilterType +HeaderMatchType +HTTPFilterType +HTTPHeader Kind +MatchExpressions ParentReference -FilterExtensionReference -HTTPHeader -BackendObjectReference +RedirectStatusCode +Reference RequestMirrorFraction RequestOperationType RequestRedirectScheme -RedirectStatusCode -FiltersType -HeaderMatchType +TlsMode +TlsValidationMode #### Pass 2 MatchingHeaders HeaderModifier @@ -20,9 +29,15 @@ 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/xtask/src/main.rs b/xtask/src/main.rs index 64fdfa3..70cc7c6 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -98,12 +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 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)); @@ -115,29 +124,113 @@ fn gen_enum_defaults() -> Result<(), DynError> { .push_fn(func); } - // Print the common use statement first - //println!("use super::common::*;"); + 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()); - // - println!( - r#"#[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::*; - }} - use prelude::*; - "# - ); + 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 let Ok(true) = gw_api_reduced { + println!("{reduced}"); + } + println!("}}\nuse prelude::*;"); println!("{}", scope.to_string()); + println!("{}", inference_scope.to_string()); Ok(()) } @@ -145,17 +238,23 @@ fn gen_generated_file_warning() -> String { "// WARNING: generated file - manual changes will be overriden\n".into() } -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(), - ); - }); + 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); - enums_with_defaults + Ok(enums_with_defaults) } From 6dae8b31c0e294e87d7b941fe3f443dceb9cf69c Mon Sep 17 00:00:00 2001 From: Dawid Nowak Date: Fri, 6 Mar 2026 14:23:46 +0000 Subject: [PATCH 94/95] Major refactoring.. updating versions Signed-off-by: Dawid Nowak --- Cargo.lock | 12 ++--- Cargo.toml | 4 +- README.md | 9 +--- gateway-api-inference-extension/Cargo.toml | 3 +- gateway-api-with-extensions/Cargo.toml | 2 +- gateway-api/Cargo.toml | 3 +- scripts/generators/standard_enum_names.txt | 52 +++++++++++----------- 7 files changed, 41 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb4edb7..a753999 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -346,7 +346,7 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "enum_default_generator" -version = "0.21.0+gw150-ie140" +version = "0.22.0+gw150-ie140" dependencies = [ "codegen", ] @@ -454,7 +454,7 @@ dependencies = [ [[package]] name = "gateway-api" -version = "0.21.0+gw150-ie140" +version = "0.150.0" dependencies = [ "cfg-if", "delegate", @@ -472,7 +472,7 @@ dependencies = [ [[package]] name = "gateway-api-examples" -version = "0.21.0+gw150-ie140" +version = "0.22.0+gw150-ie140" dependencies = [ "anyhow", "gateway-api", @@ -488,7 +488,7 @@ dependencies = [ [[package]] name = "gateway-api-inference-extension" -version = "0.21.0+gw150-ie140" +version = "0.130.0" dependencies = [ "cfg-if", "delegate", @@ -506,7 +506,7 @@ dependencies = [ [[package]] name = "gateway-api-with-extensions" -version = "0.21.0+gw150-ie140" +version = "0.150.0+130" dependencies = [ "anyhow", "cfg-if", @@ -1814,7 +1814,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "type-reducer" -version = "0.21.0+gw150-ie140" +version = "0.22.0+gw150-ie140" dependencies = [ "clap", "itertools", diff --git a/Cargo.toml b/Cargo.toml index fcfb2da..0379d62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,10 +4,10 @@ members = ["gateway-api", "gateway-api-with-extensions", "gateway-api-inference- resolver = "2" [workspace.package] -authors = ["kube-rs project (https://kube.rs)"] +authors = ["kube-rs and kubvernor project (https://kube.rs)"] edition = "2024" license = "MIT" -version = "0.21.0+gw150-ie140" +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] diff --git a/README.md b/README.md index 082a336..88af3c9 100644 --- a/README.md +++ b/README.md @@ -37,17 +37,12 @@ Gateway API and Extensions. Make sure you install `kopium` locally in order to r $ cargo install kopium --version 0.22.5 ``` -After which you can run the generator scripts for gateway api or extensions placed under `scripts/generators` folder: -### Gateway API Generator Script +### Generate APIs ```console -$ ./scripts/generators/gateway.sh +$ ./scripts/generators/gateway_all.sh ``` -### Gateway Inference Extension Generator Script -```console -$ ./scripts/generators/extensions/inference.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 diff --git a/gateway-api-inference-extension/Cargo.toml b/gateway-api-inference-extension/Cargo.toml index 23bedb9..9406dc2 100644 --- a/gateway-api-inference-extension/Cargo.toml +++ b/gateway-api-inference-extension/Cargo.toml @@ -7,11 +7,12 @@ keywords = ["kubernetes", "gateway-api-inference-extension"] homepage = "https://docs.rs/crate/gateway-api/" readme = "../README.md" repository = "https://github.com/kubvernor/gateway-api-rs" +version= "0.130.0" authors.workspace = true edition.workspace = true license.workspace = true -version.workspace = true + [dependencies] delegate.workspace = true diff --git a/gateway-api-with-extensions/Cargo.toml b/gateway-api-with-extensions/Cargo.toml index 9014507..9ee3351 100644 --- a/gateway-api-with-extensions/Cargo.toml +++ b/gateway-api-with-extensions/Cargo.toml @@ -7,11 +7,11 @@ keywords = ["kubernetes", "gateway-api","gateway-api-inference-extension"] homepage = "https://docs.rs/crate/gateway-api/" readme = "../README.md" repository = "https://github.com/kubvernor/gateway-api-rs" +version = "0.150.0+130" authors.workspace = true edition.workspace = true license.workspace = true -version.workspace = true [dependencies] delegate.workspace = true diff --git a/gateway-api/Cargo.toml b/gateway-api/Cargo.toml index c447159..4ae04bd 100644 --- a/gateway-api/Cargo.toml +++ b/gateway-api/Cargo.toml @@ -7,11 +7,12 @@ keywords = ["kubernetes", "gateway-api"] homepage = "https://docs.rs/crate/gateway-api/" readme = "../README.md" repository = "https://github.com/kubvernor/gateway-api-rs" +version = "0.150.0" authors.workspace = true edition.workspace = true license.workspace = true -version.workspace = true + [dependencies] delegate.workspace = true diff --git a/scripts/generators/standard_enum_names.txt b/scripts/generators/standard_enum_names.txt index 531237f..9c4de96 100644 --- a/scripts/generators/standard_enum_names.txt +++ b/scripts/generators/standard_enum_names.txt @@ -1,26 +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 +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 From 8aca7a0ec75df1551fd41b170bff1f539afaf618 Mon Sep 17 00:00:00 2001 From: Dawid Nowak Date: Sun, 8 Mar 2026 16:07:57 +0000 Subject: [PATCH 95/95] Major refactoring.. updating versions Signed-off-by: Dawid Nowak --- Cargo.lock | 2 +- Cargo.toml | 2 +- gateway-api-inference-extension/Cargo.toml | 2 +- gateway-api-inference-extension/Cargo.toml~ | 45 -- gateway-api-inference-extension/src/lib.rs~ | 527 -------------------- gateway-api-with-extensions/Cargo.toml | 4 +- gateway-api-with-extensions/Cargo.toml~ | 54 -- gateway-api/Cargo.toml | 2 +- 8 files changed, 6 insertions(+), 632 deletions(-) delete mode 100644 gateway-api-inference-extension/Cargo.toml~ delete mode 100644 gateway-api-inference-extension/src/lib.rs~ delete mode 100644 gateway-api-with-extensions/Cargo.toml~ diff --git a/Cargo.lock b/Cargo.lock index a753999..28177cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -506,7 +506,7 @@ dependencies = [ [[package]] name = "gateway-api-with-extensions" -version = "0.150.0+130" +version = "0.150.130" dependencies = [ "anyhow", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 0379d62..c5e9172 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["gateway-api", "gateway-api-with-extensions", "gateway-api-inference- resolver = "2" [workspace.package] -authors = ["kube-rs and kubvernor project (https://kube.rs)"] +authors = ["kube-rs (https://kube.rs)"] edition = "2024" license = "MIT" version = "0.22.0+gw150-ie140" diff --git a/gateway-api-inference-extension/Cargo.toml b/gateway-api-inference-extension/Cargo.toml index 9406dc2..8b170d5 100644 --- a/gateway-api-inference-extension/Cargo.toml +++ b/gateway-api-inference-extension/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["kubernetes", "gateway-api-inference-extension"] homepage = "https://docs.rs/crate/gateway-api/" readme = "../README.md" -repository = "https://github.com/kubvernor/gateway-api-rs" +repository = "https://github.com/kube-rs/gateway-api-rs" version= "0.130.0" authors.workspace = true diff --git a/gateway-api-inference-extension/Cargo.toml~ b/gateway-api-inference-extension/Cargo.toml~ deleted file mode 100644 index 3b3032c..0000000 --- a/gateway-api-inference-extension/Cargo.toml~ +++ /dev/null @@ -1,45 +0,0 @@ -[package] -name = "gateway-api-inference-extension" -description = "Kubernetes Gateway API Inference Extensions 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/kubvernor/gateway-api-rs" - -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, 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/lib.rs~ b/gateway-api-inference-extension/src/lib.rs~ deleted file mode 100644 index 43696e7..0000000 --- a/gateway-api-inference-extension/src/lib.rs~ +++ /dev/null @@ -1,527 +0,0 @@ -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/Cargo.toml b/gateway-api-with-extensions/Cargo.toml index 9ee3351..edd70b5 100644 --- a/gateway-api-with-extensions/Cargo.toml +++ b/gateway-api-with-extensions/Cargo.toml @@ -6,8 +6,8 @@ keywords = ["kubernetes", "gateway-api","gateway-api-inference-extension"] homepage = "https://docs.rs/crate/gateway-api/" readme = "../README.md" -repository = "https://github.com/kubvernor/gateway-api-rs" -version = "0.150.0+130" +repository = "https://github.com/kube-rs/gateway-api-rs" +version = "0.150.130" authors.workspace = true edition.workspace = true diff --git a/gateway-api-with-extensions/Cargo.toml~ b/gateway-api-with-extensions/Cargo.toml~ deleted file mode 100644 index 7f24fb9..0000000 --- a/gateway-api-with-extensions/Cargo.toml~ +++ /dev/null @@ -1,54 +0,0 @@ -[package] -name = "gateway-api" -description = "Kubernetes Gateway API bindings in Rust" -categories = ["api-bindings"] -keywords = ["kubernetes", "gateway-api"] - -homepage = "https://docs.rs/crate/gateway-api/" -readme = "../README.md" -repository = "https://github.com/kube-rs/gateway-api-rs" - -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, 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/Cargo.toml b/gateway-api/Cargo.toml index 4ae04bd..65b870c 100644 --- a/gateway-api/Cargo.toml +++ b/gateway-api/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["kubernetes", "gateway-api"] homepage = "https://docs.rs/crate/gateway-api/" readme = "../README.md" -repository = "https://github.com/kubvernor/gateway-api-rs" +repository = "https://github.com/kube-rs/gateway-api-rs" version = "0.150.0" authors.workspace = true