Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Bump clap in proxy to 4.0 #2855

Merged
merged 3 commits into from
Feb 19, 2023
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
64 changes: 24 additions & 40 deletions src/proxy-manager/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions src/proxy-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@ license = "MIT"

[dependencies]
anyhow = "1.0"
clap = "2.34"
clap = { version = "4", features = ["cargo", "string"] }
env_logger = "0.9"
futures = "0.3"
reqwest = { version = "0.11", features = ["json", "stream", "native-tls-vendored"], default-features = false }
reqwest = { version = "0.11", features = [
"json",
"stream",
"native-tls-vendored",
], default-features = false }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
storage-queue = { path = "../agent/storage-queue" }
thiserror = "1.0"
tokio = { version = "1.24", features = ["macros", "rt-multi-thread", "fs", "process"] }
tokio = { version = "1.24", features = [
"macros",
"rt-multi-thread",
"fs",
"process",
] }
url = { version = "2.3", features = ["serde"] }
reqwest-retry = { path = "../agent/reqwest-retry"}
reqwest-retry = { path = "../agent/reqwest-retry" }
onefuzz-telemetry = { path = "../agent/onefuzz-telemetry" }
uuid = "0.8"
log = "0.4"
7 changes: 2 additions & 5 deletions src/proxy-manager/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

use crate::proxy;
use anyhow::Result;
use anyhow::{bail, Result};
use onefuzz_telemetry::{
set_appinsights_clients, EventData, InstanceTelemetryKey, MicrosoftTelemetryKey, Role,
info, set_appinsights_clients, EventData, InstanceTelemetryKey, MicrosoftTelemetryKey, Role,
};
use reqwest_retry::SendRetry;
use serde::{Deserialize, Serialize};
Expand All @@ -16,9 +16,6 @@ use uuid::Uuid;

#[derive(Error, Debug)]
pub enum ProxyError {
#[error("missing argument {0}")]
MissingArg(String),

#[error("missing etag header")]
EtagError,

Expand Down
31 changes: 10 additions & 21 deletions src/proxy-manager/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#[macro_use]
extern crate onefuzz_telemetry;
#[macro_use]
extern crate anyhow;
#[macro_use]
extern crate clap;

mod config;
mod proxy;

use anyhow::Result;
use clap::{App, Arg, SubCommand};
use config::{Config, ProxyError::MissingArg};
use clap::{Arg, Command};
use config::Config;
use onefuzz_telemetry::{error, info};
use std::{
io::{stdout, Write},
time::Instant,
Expand Down Expand Up @@ -53,23 +47,18 @@ async fn run(proxy_config: Config) -> Result<()> {
fn main() -> Result<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();

let license_cmd = SubCommand::with_name("licenses").about("display third-party licenses");
let license_cmd = Command::new("licenses").about("display third-party licenses");

let version = format!(
"{} onefuzz:{} git:{}",
crate_version!(),
clap::crate_version!(),
env!("ONEFUZZ_VERSION"),
env!("GIT_VERSION")
);

let app = App::new("onefuzz-proxy")
.version(version.as_str())
.arg(
Arg::with_name("config")
.long("config")
.short("c")
.takes_value(true),
)
let app = Command::new("onefuzz-proxy")
.version(version)
.arg(Arg::new("config").long("config").short('c').required(true))
.subcommand(license_cmd);
let matches = app.get_matches();

Expand All @@ -79,8 +68,8 @@ fn main() -> Result<()> {
}

let config_path = matches
.value_of("config")
.ok_or_else(|| MissingArg("--config".to_string()))?
.get_one::<String>("config")
.expect("was required")
.parse()?;

let rt = Runtime::new()?;
Expand Down
1 change: 1 addition & 0 deletions src/proxy-manager/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::config::ConfigData;
use anyhow::Result;
use onefuzz_telemetry::{error, info};
use std::{collections::HashMap, path::Path};
use tokio::process::Command;

Expand Down