diff --git a/Cargo.lock b/Cargo.lock index 6c23b21..7c06dfe 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]] @@ -761,9 +897,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" @@ -780,12 +916,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" @@ -795,9 +934,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", ] @@ -809,10 +948,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" @@ -823,6 +971,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" @@ -832,6 +986,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" @@ -847,6 +1010,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" @@ -888,7 +1057,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -909,9 +1078,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", @@ -920,9 +1089,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", @@ -930,9 +1099,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", @@ -943,11 +1112,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", ] @@ -964,6 +1132,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" @@ -973,6 +1147,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" @@ -993,9 +1177,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" @@ -1028,9 +1212,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", ] @@ -1086,15 +1270,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", @@ -1368,14 +1552,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" @@ -1406,9 +1599,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", @@ -1443,12 +1636,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]] @@ -1564,9 +1789,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", @@ -1614,6 +1839,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" @@ -1644,6 +1883,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" @@ -1679,9 +1924,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" @@ -1772,13 +2017,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]] @@ -1787,7 +2041,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]] @@ -1796,28 +2065,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" @@ -1830,24 +2117,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" @@ -1865,18 +2176,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 f808cf1..55038d4 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..6cf50a7 --- /dev/null +++ b/type-reducer/src/visitors.rs @@ -0,0 +1,219 @@ +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); + //debug!("Visiting Struct name == {:#?}", node); + 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..dd8ab10 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,79 @@ echo "pub mod constants;" >> $APIS_DIR/experimental/mod.rs # Format the code. cargo fmt + +export RUST_LOG=info + +echo " **** PHASE 1 ***** " +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