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

Commit 796ca2f

Browse files
authored
Fixup onefuzz-task dependencies
1 parent f9f26b9 commit 796ca2f

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

src/agent/onefuzz-task/src/check_for_update.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::process::Stdio;
22

3-
use anyhow::Result;
3+
use anyhow::{bail, Result};
4+
use onefuzz_telemetry::info;
45
use serde_json::Value;
56

67
pub fn run(onefuzz_built_version: &str) -> Result<()> {

src/agent/onefuzz-task/src/main.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
#[macro_use]
5-
extern crate anyhow;
6-
#[macro_use]
7-
extern crate clap;
8-
#[macro_use]
9-
extern crate onefuzz_telemetry;
10-
extern crate onefuzz;
11-
124
use anyhow::Result;
13-
use clap::{ArgMatches, Command};
5+
use clap::{crate_version, ArgMatches, Command};
146

157
use std::io::{stdout, Write};
168

179
mod check_for_update;
18-
mod local;
1910
mod managed;
20-
mod tasks;
2111

2212
const LICENSE_CMD: &str = "licenses";
2313
const LOCAL_CMD: &str = "local";
@@ -37,7 +27,7 @@ fn main() -> Result<()> {
3727
let app = Command::new("onefuzz-task")
3828
.version(built_version)
3929
.subcommand(managed::cmd::args(MANAGED_CMD))
40-
.subcommand(local::cmd::args(LOCAL_CMD))
30+
.subcommand(onefuzz_task_lib::local::cmd::args(LOCAL_CMD))
4131
.subcommand(Command::new(LICENSE_CMD).about("display third-party licenses"))
4232
.subcommand(
4333
Command::new(CHECK_FOR_UPDATE)
@@ -62,7 +52,7 @@ async fn run(args: ArgMatches) -> Result<()> {
6252

6353
match args.subcommand() {
6454
Some((LICENSE_CMD, _)) => licenses(),
65-
Some((LOCAL_CMD, sub)) => local::cmd::run(sub.to_owned()).await,
55+
Some((LOCAL_CMD, sub)) => onefuzz_task_lib::local::cmd::run(sub.to_owned()).await,
6656
Some((MANAGED_CMD, sub)) => managed::cmd::run(sub).await,
6757
Some((CHECK_FOR_UPDATE, _)) => check_for_update::run(ONEFUZZ_BUILT_VERSION),
6858
_ => anyhow::bail!("No command provided. Run with 'help' to see available commands."),

src/agent/onefuzz-task/src/managed/cmd.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
// Licensed under the MIT License.
33
use std::path::PathBuf;
44

5-
use anyhow::Result;
6-
use clap::{Arg, Command};
5+
use anyhow::{bail, Result};
6+
use clap::{Arg, Command, value_parser};
77
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
88

99
use flexi_logger::{Duplicate, FileSpec, Logger, WriteMode};
1010
use onefuzz::ipc::IpcMessageKind;
11+
use onefuzz_telemetry::{error, info, warn};
1112
use std::time::Duration;
1213
use tokio::task;
1314

14-
use crate::tasks::config::{CommonConfig, Config};
15+
use onefuzz_task_lib::tasks::config::{CommonConfig, Config};
1516

1617
const OOM_CHECK_INTERVAL: Duration = Duration::from_secs(5);
1718

@@ -56,7 +57,7 @@ pub async fn run(args: &clap::ArgMatches) -> Result<()> {
5657
IpcSender<IpcMessageKind>,
5758
IpcReceiver<IpcMessageKind>,
5859
) = ipc::channel()?;
59-
info!("Conecting...");
60+
info!("Connecting...");
6061
let oneshot_sender = IpcSender::connect(config.common().from_agent_to_task_endpoint.clone())?;
6162
info!("Sending sender to agent");
6263
oneshot_sender.send(agent_sender)?;
@@ -104,7 +105,7 @@ pub async fn run(args: &clap::ArgMatches) -> Result<()> {
104105
// Ignore this task if it returns due to a querying error.
105106
Ok(oom) = check_oom => {
106107
// Convert the OOM notification to an error, so we can log it below.
107-
let err = format_err!("out of memory: {} bytes available, {} required", oom.available_bytes, oom.min_bytes);
108+
let err = anyhow::format_err!("out of memory: {} bytes available, {} required", oom.available_bytes, oom.min_bytes);
108109
Err(err)
109110
},
110111

0 commit comments

Comments
 (0)