mirror of
https://github.com/bytedream/docker4ssh.git
synced 2025-05-10 20:55:10 +02:00
Removed compiler warnings
This commit is contained in:
parent
73c24e457a
commit
90da7b4999
@ -1,7 +1,4 @@
|
|||||||
use std::fmt::{Debug, format};
|
use std::process::Command;
|
||||||
use std::net::TcpStream;
|
|
||||||
use std::os::unix::process::ExitStatusExt;
|
|
||||||
use std::process::{Command, ExitStatus};
|
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
@ -9,7 +6,7 @@ use structopt::clap::AppSettings;
|
|||||||
use crate::configure::cli::parser;
|
use crate::configure::cli::parser;
|
||||||
use crate::shared::api::api::API;
|
use crate::shared::api::api::API;
|
||||||
use crate::shared::api::request;
|
use crate::shared::api::request;
|
||||||
use crate::shared::api::request::{ConfigGetResponse, ConfigNetworkMode, ConfigPostRequest, ConfigRunLevel};
|
use crate::shared::api::request::{ConfigGetResponse, ConfigNetworkMode, ConfigRunLevel};
|
||||||
|
|
||||||
type Result<T> = std::result::Result<T, failure::Error>;
|
type Result<T> = std::result::Result<T, failure::Error>;
|
||||||
|
|
||||||
@ -24,9 +21,6 @@ trait Execute {
|
|||||||
settings = &[AppSettings::ArgRequiredElseHelp]
|
settings = &[AppSettings::ArgRequiredElseHelp]
|
||||||
)]
|
)]
|
||||||
struct Opts {
|
struct Opts {
|
||||||
#[structopt(short, long, global = true, help = "Verbose output")]
|
|
||||||
verbose: bool,
|
|
||||||
|
|
||||||
#[structopt(subcommand)]
|
#[structopt(subcommand)]
|
||||||
commands: Option<Root>
|
commands: Option<Root>
|
||||||
}
|
}
|
||||||
@ -259,7 +253,7 @@ enum Root {
|
|||||||
pub fn cli(route: String) {
|
pub fn cli(route: String) {
|
||||||
if let Some(subcommand) = Opts::from_args().commands {
|
if let Some(subcommand) = Opts::from_args().commands {
|
||||||
let mut result: Result<()> = Ok(());
|
let mut result: Result<()> = Ok(());
|
||||||
let mut api = API::new(route, String::new());
|
let mut api = API::new(route);
|
||||||
match subcommand {
|
match subcommand {
|
||||||
Root::Auth(auth) => {
|
Root::Auth(auth) => {
|
||||||
if let Some(subsubcommand) = auth.commands {
|
if let Some(subsubcommand) = auth.commands {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use std::f32::consts::E;
|
|
||||||
use std::fmt::format;
|
|
||||||
use crate::shared::api::request::{ConfigNetworkMode, ConfigRunLevel};
|
use crate::shared::api::request::{ConfigNetworkMode, ConfigRunLevel};
|
||||||
|
|
||||||
pub fn parse_network_mode(src: &str) -> Result<ConfigNetworkMode, String> {
|
pub fn parse_network_mode(src: &str) -> Result<ConfigNetworkMode, String> {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::net::TcpStream;
|
|
||||||
use std::os::unix::net::UnixStream;
|
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use log::{LevelFilter, trace, warn, info, error};
|
use log::{LevelFilter, error};
|
||||||
use docker4ssh::configure::cli;
|
use docker4ssh::configure::cli;
|
||||||
use docker4ssh::shared::logging::init_logger;
|
use docker4ssh::shared::logging::init_logger;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
init_logger(LevelFilter::Debug);
|
if init_logger(LevelFilter::Debug).is_err() {
|
||||||
|
println!("Failed to initialize logger");
|
||||||
|
}
|
||||||
|
|
||||||
match fs::read_to_string("/etc/docker4ssh") {
|
match fs::read_to_string("/etc/docker4ssh") {
|
||||||
Ok(route) => cli(route),
|
Ok(route) => cli(route),
|
||||||
|
@ -1,21 +1,18 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
use log::Level::Error;
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, failure::Error>;
|
pub type Result<T> = std::result::Result<T, failure::Error>;
|
||||||
|
|
||||||
pub struct API {
|
pub struct API {
|
||||||
route: String,
|
route: String,
|
||||||
host: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl API {
|
impl API {
|
||||||
pub const fn new(route: String, host: String) -> Self {
|
pub const fn new(route: String) -> Self {
|
||||||
API {
|
API {
|
||||||
route,
|
route,
|
||||||
host,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +83,7 @@ impl APIResult {
|
|||||||
let result: T = serde_json::from_str(&self.result_body).map_err(|e| {
|
let result: T = serde_json::from_str(&self.result_body).map_err(|e| {
|
||||||
// checks if the error has a body and if so, return it
|
// checks if the error has a body and if so, return it
|
||||||
if self.has_body() {
|
if self.has_body() {
|
||||||
let error: APIError = serde_json::from_str(&self.result_body).unwrap_or_else(|ee| {
|
let error: APIError = serde_json::from_str(&self.result_body).unwrap_or_else(|_| {
|
||||||
APIError{message: format!("could not deserialize response: {}", e.to_string())}
|
APIError{message: format!("could not deserialize response: {}", e.to_string())}
|
||||||
});
|
});
|
||||||
failure::format_err!("Failed to call '{}': {}", self.request_path, error.message)
|
failure::format_err!("Failed to call '{}': {}", self.request_path, error.message)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde::de::Unexpected::Str;
|
|
||||||
use serde_repr::{Deserialize_repr, Serialize_repr};
|
use serde_repr::{Deserialize_repr, Serialize_repr};
|
||||||
|
|
||||||
use crate::shared::api::api::{API, Method, Request, Result};
|
use crate::shared::api::api::{API, Method, Request, Result};
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use log::{info, Metadata, Record};
|
use log::{Metadata, Record};
|
||||||
|
|
||||||
pub struct Logger;
|
pub struct Logger;
|
||||||
|
|
||||||
impl log::Log for Logger {
|
impl log::Log for Logger {
|
||||||
fn enabled(&self, metadata: &Metadata) -> bool {
|
fn enabled(&self, _metadata: &Metadata) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,7 +13,5 @@ impl log::Log for Logger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&self) {
|
fn flush(&self) {}
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ pub mod logger;
|
|||||||
|
|
||||||
pub use logger::Logger;
|
pub use logger::Logger;
|
||||||
|
|
||||||
static LOGGER: Logger = Logger;
|
|
||||||
|
|
||||||
pub fn init_logger(level: LevelFilter) -> Result<(), SetLoggerError> {
|
pub fn init_logger(level: LevelFilter) -> Result<(), SetLoggerError> {
|
||||||
log::set_logger(&Logger).map(|()| log::set_max_level(level))
|
log::set_logger(&Logger).map(|()| log::set_max_level(level))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user