Skip to content

Commit

Permalink
Update to Rust 1.63.0 (googleforgames#568)
Browse files Browse the repository at this point in the history
* Update to Rust 1.63.0

* Fix silencing warnings from tonic codegen

* Format
  • Loading branch information
XAMPPRocky authored Aug 22, 2022
1 parent b9cd1f6 commit 578af87
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 31 deletions.
1 change: 1 addition & 0 deletions examples/quilkin-filter-example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

#[allow(warnings, clippy::all)]
// ANCHOR: include_proto
mod proto {
tonic::include_proto!("greet");
Expand Down
4 changes: 3 additions & 1 deletion macros/src/include.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ impl ToTokens for IncludeProto {

let module = id.split('.').rev().fold::<Vec<_>, _>(items, |acc, module| {
let module = syn::Ident::new(module, Span::mixed_site());
let result: syn::ItemMod = syn::parse_quote!(pub(crate) mod #module { #(#acc)* });
let result: syn::ItemMod = syn::parse_quote! {
#[allow(warnings, clippy::all)] pub(crate) mod #module { #(#acc)* }
};

vec![syn::Item::Mod(result)]
});
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.

[toolchain]
channel = "1.61.0"
channel = "1.63.0"
components = ["rustfmt", "clippy"]
10 changes: 5 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl PartialEq for Config {
}
}

#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq)]
#[derive(Clone, Debug, Deserialize, Eq, Serialize, JsonSchema, PartialEq)]
pub enum Version {
#[serde(rename = "v1alpha1")]
V1Alpha1,
Expand All @@ -218,7 +218,7 @@ impl Default for Version {
}
}

#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
#[derive(Clone, Debug, Deserialize, Eq, Serialize, JsonSchema, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct Proxy {
#[serde(default = "default_proxy_id")]
Expand Down Expand Up @@ -250,7 +250,7 @@ impl Default for Proxy {
}
}

#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
#[derive(Clone, Debug, Deserialize, Eq, Serialize, JsonSchema, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct Admin {
pub address: SocketAddr,
Expand All @@ -264,14 +264,14 @@ impl Default for Admin {
}
}

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[derive(Clone, Debug, Deserialize, Eq, Serialize, PartialEq, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct ManagementServer {
pub address: String,
}

/// Filter is the configuration for a single filter
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, JsonSchema)]
#[derive(Clone, Debug, Deserialize, Eq, Serialize, PartialEq, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Filter {
pub name: String,
Expand Down
2 changes: 1 addition & 1 deletion src/config/config_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl<'de> serde::Deserialize<'de> for ConfigType {
}
}

impl<'de> serde::Serialize for ConfigType {
impl serde::Serialize for ConfigType {
fn serialize<S>(&self, ser: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand Down
2 changes: 1 addition & 1 deletion src/config/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#[derive(Debug, PartialEq, thiserror::Error)]
#[derive(Debug, Eq, PartialEq, thiserror::Error)]
#[error("{field} has invalid value{clarification}{examples}",
clarification = clarification
.as_ref()
Expand Down
4 changes: 2 additions & 2 deletions src/filters/capture/affix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn is_valid_size(contents: &[u8], size: u32, metrics: &Metrics) -> bool {
}

/// Capture from the start of the packet.
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, schemars::JsonSchema)]
#[derive(Debug, Eq, PartialEq, serde::Deserialize, schemars::JsonSchema, serde::Serialize)]
pub struct Prefix {
/// Whether captured bytes are removed from the original packet.
#[serde(default)]
Expand All @@ -40,7 +40,7 @@ impl super::CaptureStrategy for Prefix {
}

/// Capture from the end of the packet.
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, schemars::JsonSchema)]
#[derive(Debug, Eq, PartialEq, serde::Serialize, schemars::JsonSchema, serde::Deserialize)]
pub struct Suffix {
/// Whether captured bytes are removed from the original packet.
pub size: u32,
Expand Down
6 changes: 3 additions & 3 deletions src/filters/compress/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use super::quilkin::filters::compress::v1alpha1::{
use crate::{filters::ConvertProtoConfigError, map_proto_enum};

/// The library to use when compressing.
#[derive(Clone, Copy, Deserialize, Debug, PartialEq, Serialize, JsonSchema)]
#[derive(Clone, Copy, Deserialize, Debug, Eq, PartialEq, Serialize, JsonSchema)]
#[non_exhaustive]
pub enum Mode {
// we only support one mode for now, but adding in the config option to
Expand Down Expand Up @@ -67,7 +67,7 @@ impl From<Mode> for ModeValue {
}

/// Whether to do nothing, compress or decompress the packet.
#[derive(Clone, Copy, Deserialize, Debug, PartialEq, Serialize, JsonSchema)]
#[derive(Clone, Copy, Deserialize, Debug, Eq, PartialEq, Serialize, JsonSchema)]
pub enum Action {
#[serde(rename = "DO_NOTHING")]
DoNothing,
Expand Down Expand Up @@ -101,7 +101,7 @@ impl From<Action> for ActionValue {
}
}

#[derive(Clone, Copy, Default, Deserialize, Debug, PartialEq, Serialize, JsonSchema)]
#[derive(Clone, Copy, Default, Deserialize, Debug, Eq, PartialEq, Serialize, JsonSchema)]
#[non_exhaustive]
pub struct Config {
#[serde(default)]
Expand Down
4 changes: 2 additions & 2 deletions src/filters/concatenate_bytes/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use super::proto;

base64_serde_type!(Base64Standard, base64::STANDARD);

#[derive(Serialize, Deserialize, Debug, PartialEq, JsonSchema)]
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, JsonSchema)]
pub enum Strategy {
#[serde(rename = "APPEND")]
Append,
Expand Down Expand Up @@ -61,7 +61,7 @@ impl From<Strategy> for proto::concatenate_bytes::StrategyValue {
}

/// Config represents a `ConcatenateBytes` filter configuration.
#[derive(Serialize, Deserialize, Debug, PartialEq, JsonSchema)]
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, JsonSchema)]
#[non_exhaustive]
pub struct Config {
/// Whether or not to `append` or `prepend` or `do nothing` on Filter `Read`
Expand Down
4 changes: 2 additions & 2 deletions src/filters/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::filters::{Filter, FilterFactory};

/// An error that occurred when attempting to create a [`Filter`] from
/// a [`FilterFactory`].
#[derive(Debug, PartialEq, thiserror::Error)]
#[derive(Debug, Eq, PartialEq, thiserror::Error)]
pub enum Error {
#[error("filter `{}` not found", .0)]
NotFound(String),
Expand Down Expand Up @@ -85,7 +85,7 @@ impl From<ConvertProtoConfigError> for Error {

/// An error representing failure to convert a filter's protobuf configuration
/// to its static representation.
#[derive(Debug, PartialEq, thiserror::Error)]
#[derive(Debug, Eq, PartialEq, thiserror::Error)]
#[error(
"{}failed to convert protobuf config: {}",
self.field.as_ref().map(|f| format!("Field `{f}`")).unwrap_or_default(),
Expand Down
8 changes: 4 additions & 4 deletions src/filters/firewall/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ use super::proto;

/// Represents how a Firewall filter is configured for read and write
/// operations.
#[derive(Clone, Deserialize, Debug, PartialEq, Serialize, JsonSchema)]
#[derive(Clone, Deserialize, Debug, Eq, PartialEq, Serialize, JsonSchema)]
#[non_exhaustive]
pub struct Config {
pub on_read: Vec<Rule>,
pub on_write: Vec<Rule>,
}

/// Whether or not a matching [Rule] should Allow or Deny access
#[derive(Clone, Deserialize, Debug, PartialEq, Serialize, JsonSchema)]
#[derive(Clone, Deserialize, Debug, Eq, PartialEq, Serialize, JsonSchema)]
pub enum Action {
/// Matching rules will allow packets through.
#[serde(rename = "ALLOW")]
Expand All @@ -55,7 +55,7 @@ impl From<Action> for proto::firewall::Action {
}

/// Combination of CIDR range, port range and action to take.
#[derive(Clone, Deserialize, Debug, PartialEq, Serialize, JsonSchema)]
#[derive(Clone, Deserialize, Debug, Eq, PartialEq, Serialize, JsonSchema)]
pub struct Rule {
pub action: Action,
/// ipv4 or ipv6 CIDR address.
Expand Down Expand Up @@ -116,7 +116,7 @@ pub enum PortRangeError {
}

/// Range of matching ports that are configured against a [Rule].
#[derive(Clone, Debug, PartialEq, JsonSchema)]
#[derive(Clone, Debug, Eq, PartialEq, JsonSchema)]
pub struct PortRange(Range<u16>);

impl PortRange {
Expand Down
2 changes: 1 addition & 1 deletion src/filters/load_balancer/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use super::proto;
use crate::{filters::ConvertProtoConfigError, map_proto_enum};

/// The configuration for [`load_balancer`][super].
#[derive(Serialize, Deserialize, Debug, PartialEq, JsonSchema)]
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, JsonSchema)]
#[non_exhaustive]
pub struct Config {
#[serde(default)]
Expand Down
2 changes: 1 addition & 1 deletion src/filters/local_rate_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl StaticFilter for LocalRateLimit {
}

/// Config represents a [self]'s configuration.
#[derive(Serialize, Deserialize, Debug, PartialEq, schemars::JsonSchema)]
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, schemars::JsonSchema)]
pub struct Config {
/// The maximum number of packets allowed to be forwarded by the rate
/// limiter in a given duration.
Expand Down
8 changes: 4 additions & 4 deletions src/filters/match/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
};

/// Configuration for [`Match`][super::Match].
#[derive(Debug, Deserialize, Serialize, PartialEq, schemars::JsonSchema)]
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, schemars::JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Config {
/// Configuration for [`Filter::read`][crate::filters::Filter::read].
Expand Down Expand Up @@ -67,7 +67,7 @@ impl TryFrom<proto::Match> for Config {
}

/// Configuration for a specific direction.
#[derive(Debug, Deserialize, Serialize, PartialEq, schemars::JsonSchema)]
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, schemars::JsonSchema)]
pub struct DirectionalConfig {
/// The key for the metadata to compare against.
#[serde(rename = "metadataKey")]
Expand Down Expand Up @@ -119,7 +119,7 @@ impl TryFrom<proto::r#match::Config> for DirectionalConfig {

/// A specific match branch. The filter is run when `value` matches the value
/// defined in `metadata_key`.
#[derive(Debug, Deserialize, Serialize, PartialEq, schemars::JsonSchema)]
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, schemars::JsonSchema)]
pub struct Branch {
/// The value to compare against the dynamic metadata.
pub value: crate::metadata::Value,
Expand Down Expand Up @@ -158,7 +158,7 @@ impl TryFrom<proto::r#match::Branch> for Branch {
}

/// The behaviour when the none of branches match. Defaults to dropping packets.
#[derive(Debug, PartialEq, Serialize, Deserialize, schemars::JsonSchema)]
#[derive(Debug, Eq, PartialEq, Serialize, Deserialize, schemars::JsonSchema)]
#[serde(transparent)]
pub struct Fallthrough(pub Filter);

Expand Down
2 changes: 1 addition & 1 deletion src/filters/token_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Filter for TokenRouter {
}
}

#[derive(Serialize, Deserialize, Debug, PartialEq, schemars::JsonSchema)]
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, schemars::JsonSchema)]
#[serde(default)]
pub struct Config {
/// the key to use when retrieving the token from the Filter's dynamic metadata
Expand Down
4 changes: 2 additions & 2 deletions src/xds/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ impl ControlPlane {
};

tracing::trace!(%id, %resource_type, "new request");
metrics::DISCOVERY_REQUESTS.with_label_values(&[&*id, resource_type.type_url()]).inc();
metrics::DISCOVERY_REQUESTS.with_label_values(&[id, resource_type.type_url()]).inc();

if let Some(error) = &new_message.error_detail {
metrics::NACKS.with_label_values(&[&*id, resource_type.type_url()]).inc();
metrics::NACKS.with_label_values(&[id, resource_type.type_url()]).inc();
tracing::error!(%id, %resource_type, nonce = %new_message.response_nonce, ?error, "NACK");
// Currently just resend previous discovery response.
} else if uuid::Uuid::parse_str(&new_message.response_nonce).is_ok() {
Expand Down

0 comments on commit 578af87

Please sign in to comment.