From 98af104bbdab544ab1d514267480b950bfdb8805 Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Tue, 10 Oct 2023 01:04:36 -0700 Subject: [PATCH] =?UTF-8?q?Rename:=20ConcatenateBytes=20=E2=9E=A1=EF=B8=8F?= =?UTF-8?q?=20Concatenate=20(#813)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We had this in an old PR (#639), but that got held up by some other functionality. This has been bugging me for ages, so I just wanted to take care of it. --- agones/src/sidecar.rs | 2 +- build.rs | 2 +- cloudbuild.yaml | 2 +- docs/src/SUMMARY.md | 2 +- .../quickstarts/agones-xonotic-relay.md | 2 +- .../quickstarts/agones-xonotic-xds.md | 2 +- docs/src/services/proxy/filters.md | 4 ++-- docs/src/services/proxy/filters/capture.md | 2 +- .../{concatenate_bytes.md => concatenate.md} | 12 +++++----- .../services/proxy/filters/token_router.md | 2 +- .../agones-xonotic-relay/client-token.yaml | 2 +- examples/agones-xonotic-xds/client-token.yaml | 2 +- .../v1alpha1/concatenate.proto} | 4 ++-- src/filters.rs | 4 ++-- .../{concatenate_bytes.rs => concatenate.rs} | 22 ++++++++--------- .../config.rs | 24 +++++++++---------- src/filters/set.rs | 4 ++-- src/lib.rs | 2 +- src/xds.rs | 8 +++---- .../{concatenate_bytes.rs => concatenate.rs} | 6 ++--- tests/filter_order.rs | 6 ++--- tests/match.rs | 6 ++--- 22 files changed, 61 insertions(+), 61 deletions(-) rename docs/src/services/proxy/filters/{concatenate_bytes.md => concatenate.md} (59%) rename proto/quilkin/filters/{concatenate_bytes/v1alpha1/concatenate_bytes.proto => concatenate/v1alpha1/concatenate.proto} (91%) rename src/filters/{concatenate_bytes.rs => concatenate.rs} (77%) rename src/filters/{concatenate_bytes => concatenate}/config.rs (76%) rename tests/{concatenate_bytes.rs => concatenate.rs} (93%) diff --git a/agones/src/sidecar.rs b/agones/src/sidecar.rs index 7aa54781c5..2acd6aa9e4 100644 --- a/agones/src/sidecar.rs +++ b/agones/src/sidecar.rs @@ -71,7 +71,7 @@ mod tests { let config = r#" version: v1alpha1 filters: - - name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes + - name: quilkin.filters.concatenate.v1alpha1.Concatenate config: on_read: APPEND on_write: DO_NOTHING diff --git a/build.rs b/build.rs index c308464e61..93f8903e69 100644 --- a/build.rs +++ b/build.rs @@ -36,7 +36,7 @@ fn main() -> Result<(), Box> { "proto/quilkin/config/v1alpha1/config.proto", "proto/quilkin/filters/capture/v1alpha1/capture.proto", "proto/quilkin/filters/compress/v1alpha1/compress.proto", - "proto/quilkin/filters/concatenate_bytes/v1alpha1/concatenate_bytes.proto", + "proto/quilkin/filters/concatenate/v1alpha1/concatenate.proto", "proto/quilkin/filters/debug/v1alpha1/debug.proto", "proto/quilkin/filters/drop/v1alpha1/drop.proto", "proto/quilkin/filters/firewall/v1alpha1/firewall.proto", diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 49d9b4a8ac..278669b592 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -106,4 +106,4 @@ substitutions: artifacts: images: - ${_REPOSITORY}quilkin -logsBucket: "gs://quilkin-build-logs" +# logsBucket: "gs://quilkin-build-logs" diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index ffee596de6..cadd6ade9a 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -16,7 +16,7 @@ - [Filters](./services/proxy/filters.md) - [Capture](./services/proxy/filters/capture.md) - [Compress](./services/proxy/filters/compress.md) - - [Concatenate Bytes](./services/proxy/filters/concatenate_bytes.md) + - [Concatenate](./services/proxy/filters/concatenate.md) - [Debug](./services/proxy/filters/debug.md) - [Drop](./services/proxy/filters/drop.md) - [Firewall](./services/proxy/filters/firewall.md) diff --git a/docs/src/deployment/quickstarts/agones-xonotic-relay.md b/docs/src/deployment/quickstarts/agones-xonotic-relay.md index c96ff869fd..18b88d5e20 100644 --- a/docs/src/deployment/quickstarts/agones-xonotic-relay.md +++ b/docs/src/deployment/quickstarts/agones-xonotic-relay.md @@ -277,7 +277,7 @@ quilkin-proxies LoadBalancer 10.109.0.12 35.246.94.14 7000:30174/UDP We have a [Quilkin config yaml](https://github.com/googleforgames/quilkin/blob/{{GITHUB_REF_NAME}}/examples/agones-xonotic-relay/client-token.yaml) file all ready for you, that is configured to append the routing token `456` to each packet that passes through it, via the power of a -[ConcatenateBytes](../../services/proxy/filters/concatenate_bytes.md) Filter. +[Concatenate](../../services/proxy/filters/concatenate.md) Filter. Download `client-token.yaml` locally, so you can edit it: diff --git a/docs/src/deployment/quickstarts/agones-xonotic-xds.md b/docs/src/deployment/quickstarts/agones-xonotic-xds.md index bd7aac8ab0..04aa949f2e 100644 --- a/docs/src/deployment/quickstarts/agones-xonotic-xds.md +++ b/docs/src/deployment/quickstarts/agones-xonotic-xds.md @@ -269,7 +269,7 @@ quilkin-proxies LoadBalancer 10.109.0.12 35.246.94.14 7000:30174/UDP We have a [Quilkin config yaml](https://github.com/googleforgames/quilkin/blob/{{GITHUB_REF_NAME}}/examples/agones-xonotic-xds/client-token.yaml) file all ready for you, that is configured to append the routing token `456` to each packet that passes through it, via the power of a -[ConcatenateBytes](../../services/proxy/filters/concatenate_bytes.md) Filter. +[Concatenate](../../services/proxy/filters/concatenate.md) Filter. Download `client-token.yaml` locally, so you can edit it: diff --git a/docs/src/services/proxy/filters.md b/docs/src/services/proxy/filters.md index 9f8f6a8e37..5319f0e9c0 100644 --- a/docs/src/services/proxy/filters.md +++ b/docs/src/services/proxy/filters.md @@ -92,8 +92,8 @@ Quilkin includes several filters out of the box. |----------------------------------------------------|-------------------------------------------------------------------------------------------------------------| | [Capture] | Capture specific bytes from a packet and store them in [filter dynamic metadata](#filter-dynamic-metadata). | | [Compress](./filters/compress.md) | Compress and decompress packets data. | -| [ConcatenateBytes](./filters/concatenate_bytes.md) | Add authentication tokens to packets. | -| [Debug](./filters/concatenate_bytes.md) | Logs every packet. | +| [Concatenate](./filters/concatenate.md) | Add authentication tokens to packets. | +| [Debug](./filters/debug.md) | Logs every packet. | | [Drop](./filters/drop.md) | Drop all packets | | [Firewall](./filters/firewall.md) | Allowing/blocking traffic by IP and port. | | [LoadBalancer](./filters/load_balancer.md) | Distributes downstream packets among upstream endpoints. | diff --git a/docs/src/services/proxy/filters/capture.md b/docs/src/services/proxy/filters/capture.md index a21a72ac90..19e989488b 100644 --- a/docs/src/services/proxy/filters/capture.md +++ b/docs/src/services/proxy/filters/capture.md @@ -5,7 +5,7 @@ The `Capture` filter's job is to find a series of bytes within a packet, and cap down the chain. This is often used as a way of retrieving authentication tokens from a packet, and used in combination with -[ConcatenateBytes](concatenate_bytes.md) and +[Concatenate](concatenate.md) and [TokenRouter](token_router.md) filter to provide common packet routing utilities. ## Capture strategies diff --git a/docs/src/services/proxy/filters/concatenate_bytes.md b/docs/src/services/proxy/filters/concatenate.md similarity index 59% rename from docs/src/services/proxy/filters/concatenate_bytes.md rename to docs/src/services/proxy/filters/concatenate.md index 76bc61eaeb..e036c6ef56 100644 --- a/docs/src/services/proxy/filters/concatenate_bytes.md +++ b/docs/src/services/proxy/filters/concatenate.md @@ -1,11 +1,11 @@ -# ConcatenateBytes +# Concatenate -The `ConcatenateBytes` filter's job is to add a byte packet to either the beginning or end of each UDP packet that passes +The `Concatenate` filter's job is to add a byte packet to either the beginning or end of each UDP packet that passes through. This is commonly used to provide an auth token to each packet, so they can be routed appropriately. ## Filter name ```text -quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes +quilkin.filters.concatenate.v1alpha1.Concatenate ``` ## Configuration Examples @@ -13,7 +13,7 @@ quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes # let yaml = " version: v1alpha1 filters: - - name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes + - name: quilkin.filters.concatenate.v1alpha1.Concatenate config: on_read: APPEND on_write: DO_NOTHING @@ -26,8 +26,8 @@ clusters: # assert_eq!(config.filters.load().len(), 1); ``` -## Configuration Options ([Rust Doc](../../../../api/quilkin/filters/concatenate_bytes/struct.Config.html)) +## Configuration Options ([Rust Doc](../../../../api/quilkin/filters/concatenate/struct.Config.html)) ```yaml -{{#include ../../../../../target/quilkin.filters.concatenate_bytes.v1alpha1.yaml}} +{{#include ../../../../../target/quilkin.filters.concatenate.v1alpha1.yaml}} ``` diff --git a/docs/src/services/proxy/filters/token_router.md b/docs/src/services/proxy/filters/token_router.md index ed56428eef..d92d26d9a8 100644 --- a/docs/src/services/proxy/filters/token_router.md +++ b/docs/src/services/proxy/filters/token_router.md @@ -99,7 +99,7 @@ clusters: # assert_eq!(config.filters.load().len(), 2); ``` -On the game client side the [ConcatenateBytes](concatenate_bytes.md) filter could also be used to add authentication +On the game client side the [Concatenate](concatenate.md) filter could also be used to add authentication tokens to outgoing packets. [filter-dynamic-metadata]: ../filters.md#filter-dynamic-metadata diff --git a/examples/agones-xonotic-relay/client-token.yaml b/examples/agones-xonotic-relay/client-token.yaml index 37942a6b3e..440eadb8c4 100644 --- a/examples/agones-xonotic-relay/client-token.yaml +++ b/examples/agones-xonotic-relay/client-token.yaml @@ -16,7 +16,7 @@ version: v1alpha1 filters: - - name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes + - name: quilkin.filters.concatenate.v1alpha1.Concatenate config: on_read: APPEND on_write: DO_NOTHING diff --git a/examples/agones-xonotic-xds/client-token.yaml b/examples/agones-xonotic-xds/client-token.yaml index 1b99fc536a..ee52927331 100644 --- a/examples/agones-xonotic-xds/client-token.yaml +++ b/examples/agones-xonotic-xds/client-token.yaml @@ -16,7 +16,7 @@ version: v1alpha1 filters: - - name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes + - name: quilkin.filters.concatenate.v1alpha1.Concatenate config: on_read: APPEND on_write: DO_NOTHING diff --git a/proto/quilkin/filters/concatenate_bytes/v1alpha1/concatenate_bytes.proto b/proto/quilkin/filters/concatenate/v1alpha1/concatenate.proto similarity index 91% rename from proto/quilkin/filters/concatenate_bytes/v1alpha1/concatenate_bytes.proto rename to proto/quilkin/filters/concatenate/v1alpha1/concatenate.proto index b2c43f446e..e71589d464 100644 --- a/proto/quilkin/filters/concatenate_bytes/v1alpha1/concatenate_bytes.proto +++ b/proto/quilkin/filters/concatenate/v1alpha1/concatenate.proto @@ -16,9 +16,9 @@ syntax = "proto3"; -package quilkin.filters.concatenate_bytes.v1alpha1; +package quilkin.filters.concatenate.v1alpha1; -message ConcatenateBytes { +message Concatenate { enum Strategy { DoNothing = 0; Append = 1; diff --git a/src/filters.rs b/src/filters.rs index ecc0928e1a..585c17b2ea 100644 --- a/src/filters.rs +++ b/src/filters.rs @@ -27,7 +27,7 @@ mod write; pub mod capture; pub mod compress; -pub mod concatenate_bytes; +pub mod concatenate; pub mod debug; pub mod drop; pub mod firewall; @@ -53,7 +53,7 @@ pub mod prelude { pub use self::{ capture::Capture, compress::Compress, - concatenate_bytes::ConcatenateBytes, + concatenate::Concatenate, debug::Debug, drop::Drop, error::{ConvertProtoConfigError, CreationError, FilterError}, diff --git a/src/filters/concatenate_bytes.rs b/src/filters/concatenate.rs similarity index 77% rename from src/filters/concatenate_bytes.rs rename to src/filters/concatenate.rs index 47d7fb003a..201d82b62d 100644 --- a/src/filters/concatenate_bytes.rs +++ b/src/filters/concatenate.rs @@ -14,28 +14,28 @@ * limitations under the License. */ -crate::include_proto!("quilkin.filters.concatenate_bytes.v1alpha1"); +crate::include_proto!("quilkin.filters.concatenate.v1alpha1"); mod config; use crate::filters::prelude::*; -use self::quilkin::filters::concatenate_bytes::v1alpha1 as proto; +use self::quilkin::filters::concatenate::v1alpha1 as proto; pub use config::{Config, Strategy}; -/// The `ConcatenateBytes` filter's job is to add a byte packet to either the +/// The `Concatenate` filter's job is to add a byte packet to either the /// beginning or end of each UDP packet that passes through. This is commonly /// used to provide an auth token to each packet, so they can be /// routed appropriately. -pub struct ConcatenateBytes { +pub struct Concatenate { on_read: Strategy, on_write: Strategy, bytes: Vec, } -impl ConcatenateBytes { +impl Concatenate { pub fn new(config: Config) -> Self { - ConcatenateBytes { + Concatenate { on_read: config.on_read, on_write: config.on_write, bytes: config.bytes, @@ -44,7 +44,7 @@ impl ConcatenateBytes { } #[async_trait::async_trait] -impl Filter for ConcatenateBytes { +impl Filter for Concatenate { async fn read(&self, ctx: &mut ReadContext) -> Result<(), FilterError> { match self.on_read { Strategy::Append => { @@ -74,12 +74,12 @@ impl Filter for ConcatenateBytes { } } -impl StaticFilter for ConcatenateBytes { - const NAME: &'static str = "quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes"; +impl StaticFilter for Concatenate { + const NAME: &'static str = "quilkin.filters.concatenate.v1alpha1.Concatenate"; type Configuration = Config; - type BinaryConfiguration = proto::ConcatenateBytes; + type BinaryConfiguration = proto::Concatenate; fn try_from_config(config: Option) -> Result { - Ok(ConcatenateBytes::new(Self::ensure_config_exists(config)?)) + Ok(Concatenate::new(Self::ensure_config_exists(config)?)) } } diff --git a/src/filters/concatenate_bytes/config.rs b/src/filters/concatenate/config.rs similarity index 76% rename from src/filters/concatenate_bytes/config.rs rename to src/filters/concatenate/config.rs index eb0e9dd426..326ccf42c9 100644 --- a/src/filters/concatenate_bytes/config.rs +++ b/src/filters/concatenate/config.rs @@ -31,7 +31,7 @@ pub enum Strategy { DoNothing, } -impl From for proto::concatenate_bytes::Strategy { +impl From for proto::concatenate::Strategy { fn from(strategy: Strategy) -> Self { match strategy { Strategy::Append => Self::Append, @@ -41,25 +41,25 @@ impl From for proto::concatenate_bytes::Strategy { } } -impl From for Strategy { - fn from(strategy: proto::concatenate_bytes::Strategy) -> Self { +impl From for Strategy { + fn from(strategy: proto::concatenate::Strategy) -> Self { match strategy { - proto::concatenate_bytes::Strategy::Append => Self::Append, - proto::concatenate_bytes::Strategy::Prepend => Self::Prepend, - proto::concatenate_bytes::Strategy::DoNothing => Self::DoNothing, + proto::concatenate::Strategy::Append => Self::Append, + proto::concatenate::Strategy::Prepend => Self::Prepend, + proto::concatenate::Strategy::DoNothing => Self::DoNothing, } } } -impl From for proto::concatenate_bytes::StrategyValue { +impl From for proto::concatenate::StrategyValue { fn from(strategy: Strategy) -> Self { Self { - value: proto::concatenate_bytes::Strategy::from(strategy) as i32, + value: proto::concatenate::Strategy::from(strategy) as i32, } } } -/// Config represents a `ConcatenateBytes` filter configuration. +/// Config represents a `Concatenate` filter configuration. #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, JsonSchema)] #[non_exhaustive] pub struct Config { @@ -77,7 +77,7 @@ pub struct Config { pub bytes: Vec, } -impl From for proto::ConcatenateBytes { +impl From for proto::Concatenate { fn from(config: Config) -> Self { Self { on_read: Some(config.on_read.into()), @@ -87,8 +87,8 @@ impl From for proto::ConcatenateBytes { } } -impl From for Config { - fn from(p: proto::ConcatenateBytes) -> Self { +impl From for Config { + fn from(p: proto::Concatenate) -> Self { let on_read = p .on_read .map(|p| p.value()) diff --git a/src/filters/set.rs b/src/filters/set.rs index 7b1af7ef35..b17e95ed36 100644 --- a/src/filters/set.rs +++ b/src/filters/set.rs @@ -29,7 +29,7 @@ pub type FilterMap = std::collections::HashMap<&'static str, Arc::default(), bytes: b1.as_bytes().to_vec(), }) .unwrap(), - ConcatenateBytes::as_filter_config(concatenate_bytes::Config { - on_read: concatenate_bytes::Strategy::Append, + Concatenate::as_filter_config(concatenate::Config { + on_read: concatenate::Strategy::Append, on_write: <_>::default(), bytes: b2.as_bytes().to_vec(), }) diff --git a/tests/concatenate_bytes.rs b/tests/concatenate.rs similarity index 93% rename from tests/concatenate_bytes.rs rename to tests/concatenate.rs index d10f0f1d3f..a74aca866b 100644 --- a/tests/concatenate_bytes.rs +++ b/tests/concatenate.rs @@ -21,12 +21,12 @@ use tokio::time::{timeout, Duration}; use quilkin::{ config::Filter, endpoint::Endpoint, - filters::{ConcatenateBytes, StaticFilter}, + filters::{Concatenate, StaticFilter}, test_utils::{AddressType, TestHelper}, }; #[tokio::test] -async fn concatenate_bytes() { +async fn concatenate() { let mut t = TestHelper::default(); let yaml = " on_read: APPEND @@ -45,7 +45,7 @@ bytes: YWJj #abc .modify(|clusters| clusters.insert_default([Endpoint::new(echo.clone())].into())); server_config.filters.store( quilkin::filters::FilterChain::try_from(vec![Filter { - name: ConcatenateBytes::factory().name().into(), + name: Concatenate::factory().name().into(), label: None, config: serde_yaml::from_str(yaml).unwrap(), }]) diff --git a/tests/filter_order.rs b/tests/filter_order.rs index 0267e49603..23e99a389d 100644 --- a/tests/filter_order.rs +++ b/tests/filter_order.rs @@ -21,7 +21,7 @@ use tokio::time::{timeout, Duration}; use quilkin::{ config::Filter, endpoint::Endpoint, - filters::{Compress, ConcatenateBytes, StaticFilter}, + filters::{Compress, Concatenate, StaticFilter}, test_utils::{AddressType, TestHelper}, }; @@ -65,12 +65,12 @@ on_write: DECOMPRESS server_config.filters.store( quilkin::filters::FilterChain::try_from(vec![ Filter { - name: ConcatenateBytes::factory().name().into(), + name: Concatenate::factory().name().into(), label: None, config: serde_yaml::from_str(yaml_concat_read).unwrap(), }, Filter { - name: ConcatenateBytes::factory().name().into(), + name: Concatenate::factory().name().into(), label: None, config: serde_yaml::from_str(yaml_concat_write).unwrap(), }, diff --git a/tests/match.rs b/tests/match.rs index ec354f728d..6462b9693c 100644 --- a/tests/match.rs +++ b/tests/match.rs @@ -40,18 +40,18 @@ suffix: on_read: metadataKey: quilkin.dev/capture fallthrough: - name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes + name: quilkin.filters.concatenate.v1alpha1.Concatenate config: on_read: APPEND bytes: ZGVm branches: - value: abc - name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes + name: quilkin.filters.concatenate.v1alpha1.Concatenate config: on_read: APPEND bytes: eHl6 # xyz - value: xyz - name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes + name: quilkin.filters.concatenate.v1alpha1.Concatenate config: on_read: APPEND bytes: YWJj # abc