Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request: {}
merge_group:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"

jobs:

rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hecrj/setup-rust-action@v2
with:
components: rustfmt
- run: cargo fmt --all --check

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hecrj/setup-rust-action@v2
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --workspace --all-features --all-targets

build_and_test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
toolchain: [stable, beta, nightly]
steps:
- uses: actions/checkout@v4
- uses: hecrj/setup-rust-action@v2
- uses: taiki-e/install-action@protoc
- uses: Swatinem/rust-cache@v2
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo build --verbose
- run: cargo test --doc --all-features --verbose
18 changes: 9 additions & 9 deletions envoy-proto-collect/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use glob::glob;
use std::{
fs::{self, File},
io::{self, Write},
path::PathBuf,
path::{Path, PathBuf},
process,
};

Expand All @@ -29,24 +29,23 @@ fn apache_v2(year: u32, owner: &str) -> String {
}

fn collect_protos(
out_dir: &PathBuf,
out_dir: &Path,
repo: &str,
glob_patterns: Vec<&str>,
add_license: Option<&String>,
) {
let repo = PathBuf::from(std::env!("CARGO_MANIFEST_DIR"))
.join("submodules")
.join(repo);
let manifest_dir = std::env!("CARGO_MANIFEST_DIR");
let repo_dir = Path::new(manifest_dir).join("submodules").join(repo);

if !repo.is_dir() {
if !repo_dir.is_dir() {
eprintln!("Error: submodule repo {:?} not found.", repo);
process::exit(1);
}

let mut source_protos: Vec<PathBuf> = Vec::new();

for pattern in glob_patterns {
let mut matches: Vec<PathBuf> = glob(repo.join(pattern).to_str().unwrap())
let mut matches: Vec<PathBuf> = glob(repo_dir.join(pattern).to_str().unwrap())
.unwrap()
.filter_map(Result::ok)
.collect();
Expand All @@ -59,7 +58,7 @@ fn collect_protos(

let target_name = out_dir.join(
proto
.strip_prefix(repo.parent().expect("repo has parent"))
.strip_prefix(repo_dir.parent().expect("repo has parent"))
.expect("base is a prefix of proto"),
);

Expand All @@ -84,7 +83,8 @@ fn collect_protos(
}

fn main() {
let out_dir = PathBuf::from(std::env!("CARGO_MANIFEST_DIR"))
let manifest_dir = std::env!("CARGO_MANIFEST_DIR");
let out_dir = Path::new(manifest_dir)
.parent()
.expect("envoy-proto-collect is inside a workspace")
.join("envoy-types")
Expand Down
21 changes: 12 additions & 9 deletions envoy-types/src/ext_authz/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,17 @@ pub mod v3 {
}

fn with_status(status: tonic::Status) -> Self {
let mut check_response = CheckResponse::default();
check_response.status = Some(rpc::Status {
let status = Some(rpc::Status {
code: status.code().into(),
message: status.message().into(),
// `tonic::Status`'s details are not considered
details: Vec::new(),
});
check_response

CheckResponse {
status,
..Default::default()
}
}

fn set_status(&mut self, status: tonic::Status) -> &mut Self {
Expand Down Expand Up @@ -336,9 +339,9 @@ pub mod v3 {
}
}

impl Into<OkHttpResponse> for OkHttpResponseBuilder {
fn into(self) -> OkHttpResponse {
self.build()
impl From<OkHttpResponseBuilder> for OkHttpResponse {
fn from(val: OkHttpResponseBuilder) -> Self {
val.build()
}
}

Expand Down Expand Up @@ -437,9 +440,9 @@ pub mod v3 {
}
}

impl Into<DeniedHttpResponse> for DeniedHttpResponseBuilder {
fn into(self) -> DeniedHttpResponse {
self.build()
impl From<DeniedHttpResponseBuilder> for DeniedHttpResponse {
fn from(val: DeniedHttpResponseBuilder) -> Self {
val.build()
}
}

Expand Down
2 changes: 2 additions & 0 deletions envoy-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ using a [previous version of `envoy-types`].
#![warn(missing_debug_implementations, rust_2018_idioms)]
#![allow(missing_docs, rustdoc::invalid_html_tags, rustdoc::bare_urls)]

#[rustfmt::skip]
#[allow(clippy::all)]
mod generated;

/// Compiled protobuf types
Expand Down
6 changes: 4 additions & 2 deletions examples/src/ext_authz/authorization_server_basic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::env;
use tonic::{transport::Server, Request, Response, Status};

use envoy_types::ext_authz::v3::pb::{
Expand Down Expand Up @@ -34,8 +35,9 @@ impl Authorization for MyServer {

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = format!("0.0.0.0:50051").parse().unwrap();
let server = MyServer::default();
let server_port = env::var("SERVER_PORT").unwrap_or("50051".into());
let addr = format!("0.0.0.0:{server_port}").parse().unwrap();
let server = MyServer;

println!("AuthorizationServer listening on {addr}");

Expand Down
2 changes: 1 addition & 1 deletion examples/src/ext_authz/authorization_server_full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Authorization for MyServer {
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server_port = env::var("SERVER_PORT").unwrap_or("50051".into());
let addr = format!("0.0.0.0:{server_port}").parse().unwrap();
let server = MyServer::default();
let server = MyServer;

println!("AuthorizationServer listening on {}", addr);

Expand Down
2 changes: 1 addition & 1 deletion examples/src/ext_authz/authorization_server_pb_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl Authorization for MyServer {
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server_port = env::var("SERVER_PORT").unwrap_or("50051".into());
let addr = format!("0.0.0.0:{server_port}").parse().unwrap();
let server = MyServer::default();
let server = MyServer;

println!("AuthorizationServer listening on {}", addr);

Expand Down
Loading