From 1ad059c4372f26fbe2291093291bf81173a41205 Mon Sep 17 00:00:00 2001 From: Emmanuel Bosquet Date: Thu, 25 Jul 2024 11:11:45 +0200 Subject: [PATCH] bump prost and prost-build to 0.13.1 --- Cargo.lock | 16 ++++++++-------- bin/Cargo.toml | 2 +- command/Cargo.toml | 4 ++-- command/src/proto/mod.rs | 4 ++-- command/src/state.rs | 18 ++++++------------ 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b6eb20af7..6710c2705 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1269,9 +1269,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" dependencies = [ "bytes", "prost-derive", @@ -1279,9 +1279,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.12.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" +checksum = "5bb182580f71dd070f88d01ce3de9f4da5021db7115d2e1c3605a754153b77c1" dependencies = [ "bytes", "heck", @@ -1300,9 +1300,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" dependencies = [ "anyhow", "itertools", @@ -1313,9 +1313,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" dependencies = [ "prost", ] diff --git a/bin/Cargo.toml b/bin/Cargo.toml index 12994c285..8ef26bbc2 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -29,7 +29,7 @@ nom = "^7.1.3" paw = "^1.0.0" serde = { version = "^1.0.203", features = ["derive"] } serde_json = "^1.0.117" -prost = "^0.12.6" +prost = "^0.13.1" tempfile = "^3.10.1" termion = "^4.0.0" thiserror = "^1.0.61" diff --git a/command/Cargo.toml b/command/Cargo.toml index 4b6bff286..001500df4 100644 --- a/command/Cargo.toml +++ b/command/Cargo.toml @@ -36,7 +36,7 @@ memchr = "^2.7.2" mio = { version = "^1.0.0", features = ["os-poll", "net"] } nix = { version = "^0.29.0", features = ["socket", "uio"] } nom = "^7.1.3" -prost = "^0.12.6" +prost = "^0.13.1" rand = "^0.8.5" rusty_ulid = "^2.0.0" serde = { version = "^1.0.203", features = ["derive"] } @@ -58,4 +58,4 @@ logs-trace = [] travis-ci = { repository = "sozu-proxy/sozu" } [build-dependencies] -prost-build = { version = "^0.12.6" } +prost-build = { version = "^0.13.1" } diff --git a/command/src/proto/mod.rs b/command/src/proto/mod.rs index b512e7eb5..f433fae3e 100644 --- a/command/src/proto/mod.rs +++ b/command/src/proto/mod.rs @@ -4,7 +4,7 @@ use command::{ filtered_metrics::Inner, AggregatedMetrics, BackendMetrics, Bucket, FilteredHistogram, FilteredMetrics, }; -use prost::DecodeError; +use prost::UnknownEnumValue; /// Contains all types received by and sent from Sōzu pub mod command; @@ -23,7 +23,7 @@ pub enum DisplayError { #[error("Could not format the datetime to ISO 8601")] DateTime, #[error("unrecognized protobuf variant: {0}")] - DecodeError(DecodeError), + DecodeError(UnknownEnumValue), } // Simple helper to build ResponseContent from ContentType diff --git a/command/src/state.rs b/command/src/state.rs index 104eb1e09..bb40f4494 100644 --- a/command/src/state.rs +++ b/command/src/state.rs @@ -10,7 +10,7 @@ use std::{ net::SocketAddr, }; -use prost::{DecodeError, Message}; +use prost::{Message, UnknownEnumValue}; use crate::{ certificate::{calculate_fingerprint, CertificateError, Fingerprint}, @@ -44,8 +44,8 @@ pub enum StateError { NotFound { kind: ObjectKind, id: String }, #[error("{kind:?} '{id}' already exists")] Exists { kind: ObjectKind, id: String }, - #[error("Wrong request: {0}")] - WrongRequest(String), + #[error("Wrong field value: {0}")] + WrongFieldValue(UnknownEnumValue), #[error("Could not add certificate: {0}")] AddCertificate(CertificateError), #[error("Could not remove certificate: {0}")] @@ -60,12 +60,6 @@ pub enum StateError { FileError(std::io::Error), } -impl From for StateError { - fn from(decode_error: DecodeError) -> Self { - Self::WrongRequest(format!("Wrong field value: {decode_error}")) - } -} - /// The `ConfigState` represents the state of Sōzu's business, which is to forward traffic /// from frontends to backends. Hence, it contains all details about: /// @@ -223,7 +217,7 @@ impl ConfigState { } fn remove_listener(&mut self, remove: &RemoveListener) -> Result<(), StateError> { - match ListenerType::try_from(remove.proxy)? { + match ListenerType::try_from(remove.proxy).map_err(StateError::WrongFieldValue)? { ListenerType::Http => self.remove_http_listener(&remove.address.clone().into()), ListenerType::Https => self.remove_https_listener(&remove.address.clone().into()), ListenerType::Tcp => self.remove_tcp_listener(&remove.address.clone().into()), @@ -252,7 +246,7 @@ impl ConfigState { } fn activate_listener(&mut self, activate: &ActivateListener) -> Result<(), StateError> { - match ListenerType::try_from(activate.proxy)? { + match ListenerType::try_from(activate.proxy).map_err(StateError::WrongFieldValue)? { ListenerType::Http => self .http_listeners .get_mut(&activate.address.clone().into()) @@ -281,7 +275,7 @@ impl ConfigState { } fn deactivate_listener(&mut self, deactivate: &DeactivateListener) -> Result<(), StateError> { - match ListenerType::try_from(deactivate.proxy)? { + match ListenerType::try_from(deactivate.proxy).map_err(StateError::WrongFieldValue)? { ListenerType::Http => self .http_listeners .get_mut(&deactivate.address.clone().into())