Skip to content

Commit

Permalink
Removal of Proxy Mode (#168)
Browse files Browse the repository at this point in the history
* Removal of Proxy Mode

Removes all references to Proxy Mode, from documentation and
implementation as well.

Closed #163

* Increase submodules depth.
  • Loading branch information
markmandel authored Jan 14, 2021
1 parent 827164f commit 7dbe759
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 65 deletions.
8 changes: 4 additions & 4 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ steps:
args:
- '-c'
- |
git clone --depth 800 https://github.com/envoyproxy/data-plane-api.git proto/data-plane-api
git clone --depth 1000 https://github.com/envoyproxy/data-plane-api.git proto/data-plane-api
git -C proto/data-plane-api checkout b84d3bea45b59abc3fd21fba26140a379461fc67
git clone --depth 800 https://github.com/cncf/udpa.git proto/udpa
git clone --depth 1000 https://github.com/cncf/udpa.git proto/udpa
git -C proto/udpa checkout efcf912fb35470672231c7b7bef620f3d17f655a
git clone --depth 800 https://github.com/envoyproxy/protoc-gen-validate.git proto/protoc-gen-validate
git clone --depth 1000 https://github.com/envoyproxy/protoc-gen-validate.git proto/protoc-gen-validate
git -C proto/protoc-gen-validate checkout e84d38a1a4c27d4662779c31a06528cdbc6b4b4f
git clone --depth 800 https://github.com/googleapis/googleapis.git proto/googleapis
git clone --depth 1000 https://github.com/googleapis/googleapis.git proto/googleapis
git -C proto/googleapis checkout 2db5725bf898b544a0cf951e1694d3b0fce5eda3
id: fetch-git-submodules
# clippy tends to rely on cached results from other cargo sub-commands so
Expand Down
8 changes: 0 additions & 8 deletions docs/proxy-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ properties:
description: |
The listening port for the proxy.
default: 7000
mode:
type: string
description: |
The mode in which the proxy should run.
enum:
- SERVER
- CLIENT
default: SERVER
admin:
type: object
description: |
Expand Down
1 change: 0 additions & 1 deletion examples/control-plane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

version: v1alpha1
proxy:
mode: SERVER # Run the proxy in server mode.
id: my-proxy # An identifier for the proxy instance.
port: 7001 # the port to receive traffic to locally
dynamic: # Provide configuration of endpoints using an XDS management server
Expand Down
1 change: 0 additions & 1 deletion examples/proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

version: v1alpha1
proxy:
mode: SERVER # Run the proxy in server mode.
id: my-proxy # An identifier for the proxy instance.
port: 7001 # the port to receive traffic to locally
static: # Provide static configuration of endpoints
Expand Down
9 changes: 1 addition & 8 deletions src/config/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
*/

use super::{Config, Filter};
use crate::config::{EndPoint, Proxy, ProxyMode, Source, Version};
use crate::config::{EndPoint, Proxy, Source, Version};

/// Builder for a [`Config`]
#[derive(Debug)]
pub struct Builder {
pub mode: ProxyMode,
pub port: u16,
pub source: Source,
}
Expand All @@ -29,7 +28,6 @@ impl Builder {
/// Returns a [`Builder`] with empty values.
pub fn empty() -> Self {
Builder {
mode: ProxyMode::Server,
port: 0,
source: Source::Static {
filters: vec![],
Expand All @@ -38,10 +36,6 @@ impl Builder {
}
}

pub fn with_mode(self, mode: ProxyMode) -> Self {
Builder { mode, ..self }
}

pub fn with_port(self, port: u16) -> Self {
Builder { port, ..self }
}
Expand All @@ -55,7 +49,6 @@ impl Builder {
Config {
version: Version::V1Alpha1,
proxy: Proxy {
mode: self.mode,
id: "test".into(),
port: self.port,
},
Expand Down
30 changes: 1 addition & 29 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,8 @@ pub enum Version {
V1Alpha1,
}

#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub enum ProxyMode {
#[serde(rename = "CLIENT")]
Client,
#[serde(rename = "SERVER")]
Server,
}

impl Default for ProxyMode {
fn default() -> Self {
ProxyMode::Server
}
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Proxy {
#[serde(default)]
pub mode: ProxyMode,
#[serde(default = "default_proxy_id")]
pub id: String,
#[serde(default = "default_proxy_port")]
Expand All @@ -81,7 +65,6 @@ fn default_proxy_port() -> u16 {
impl Default for Proxy {
fn default() -> Self {
Proxy {
mode: Default::default(),
id: default_proxy_id(),
port: default_proxy_port(),
}
Expand Down Expand Up @@ -278,9 +261,7 @@ impl Source {
mod tests {
use serde_yaml::Value;

use crate::config::{
Builder, Config, EndPoint, ManagementServer, ProxyMode, Source, ValidationError,
};
use crate::config::{Builder, Config, EndPoint, ManagementServer, Source, ValidationError};
use std::collections::HashMap;

fn parse_config(yaml: &str) -> Config {
Expand Down Expand Up @@ -348,7 +329,6 @@ static:
";
let config = parse_config(yaml);

assert_eq!(config.proxy.mode, ProxyMode::Server);
assert_eq!(config.proxy.port, 7000);
assert_eq!(config.proxy.id.len(), 36);
}
Expand All @@ -358,7 +338,6 @@ static:
let yaml = "
version: v1alpha1
proxy:
mode: CLIENT
id: client-proxy
port: 7000 # the port to receive traffic to locally
static:
Expand Down Expand Up @@ -400,7 +379,6 @@ static:
let yaml = "
version: v1alpha1
proxy:
mode: CLIENT
id: server-proxy
port: 7000
static:
Expand All @@ -409,7 +387,6 @@ static:
";
let config = parse_config(yaml);

assert_eq!(config.proxy.mode, ProxyMode::Client);
assert_eq!(config.proxy.port, 7000);
assert_eq!(config.proxy.id.as_str(), "server-proxy");
}
Expand All @@ -418,16 +395,13 @@ static:
fn parse_client() {
let yaml = "
version: v1alpha1
proxy:
mode: CLIENT
static:
endpoints:
- name: ep-1
address: 127.0.0.1:25999
";
let config = parse_config(yaml);

assert_eq!(config.proxy.mode, ProxyMode::Client);
assert_static_endpoints(
&config.source,
vec![EndPoint::new("127.0.0.1:25999".parse().unwrap())],
Expand All @@ -439,8 +413,6 @@ static:
let yaml = "
---
version: v1alpha1
proxy:
mode: SERVER
static:
endpoints:
- address: 127.0.0.1:26000
Expand Down
4 changes: 1 addition & 3 deletions src/extensions/filter_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ mod tests {
use std::str::from_utf8;

use crate::config;
use crate::config::{Builder, Endpoints, ProxyMode, UpstreamEndpoints};
use crate::config::{Builder, Endpoints, UpstreamEndpoints};
use crate::extensions::filters::DebugFactory;
use crate::extensions::{default_registry, FilterFactory};
use crate::test_utils::{ep, logger, TestFilter};
Expand All @@ -133,7 +133,6 @@ mod tests {

// everything is fine
let config = Builder::empty()
.with_mode(ProxyMode::Client)
.with_static(
vec![config::Filter {
name: provider.name(),
Expand All @@ -150,7 +149,6 @@ mod tests {

// uh oh, something went wrong
let config = Builder::empty()
.with_mode(ProxyMode::Client)
.with_static(
vec![config::Filter {
name: "this is so wrong".to_string(),
Expand Down
5 changes: 1 addition & 4 deletions src/proxy/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ mod tests {
use tokio::time::{Duration, Instant};

use crate::config;
use crate::config::{Builder as ConfigBuilder, EndPoint, ProxyMode};
use crate::config::{Builder as ConfigBuilder, EndPoint};
use crate::extensions::FilterRegistry;
use crate::proxy::sessions::{Packet, SESSION_TIMEOUT_SECONDS};
use crate::proxy::Builder;
Expand All @@ -413,7 +413,6 @@ mod tests {

let local_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 12358);
let config = ConfigBuilder::empty()
.with_mode(ProxyMode::Server)
.with_port(local_addr.port())
.with_static(
vec![],
Expand All @@ -440,7 +439,6 @@ mod tests {

let local_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 12357);
let config = ConfigBuilder::empty()
.with_mode(ProxyMode::Client)
.with_port(local_addr.port())
.with_static(vec![], vec![EndPoint::new(endpoint.addr)])
.build();
Expand All @@ -465,7 +463,6 @@ mod tests {
let mut endpoint = t.open_socket_and_recv_single_packet().await;
let local_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 12367);
let config = ConfigBuilder::empty()
.with_mode(ProxyMode::Client)
.with_port(local_addr.port())
.with_static(
vec![config::Filter {
Expand Down
12 changes: 5 additions & 7 deletions src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use tokio::net::UdpSocket;
use tokio::sync::{mpsc, oneshot, watch};

use crate::cluster::Endpoint;
use crate::config::{Builder as ConfigBuilder, Config, EndPoint, Endpoints, ProxyMode};
use crate::config::{Builder as ConfigBuilder, Config, EndPoint, Endpoints};
use crate::extensions::{
default_registry, CreateFilterArgs, DownstreamContext, DownstreamResponse, Error, Filter,
FilterFactory, FilterRegistry, UpstreamContext, UpstreamResponse,
Expand Down Expand Up @@ -355,12 +355,10 @@ where
}

pub fn config_with_dummy_endpoint() -> ConfigBuilder {
ConfigBuilder::empty()
.with_mode(ProxyMode::Server)
.with_static(
vec![],
vec![EndPoint::new("127.0.0.1:8080".parse().unwrap())],
)
ConfigBuilder::empty().with_static(
vec![],
vec![EndPoint::new("127.0.0.1:8080".parse().unwrap())],
)
}
/// Creates a dummy endpoint with `id` as a suffix.
pub fn ep(id: u8) -> EndPoint {
Expand Down

0 comments on commit 7dbe759

Please sign in to comment.