cargo fmt
This commit is contained in:
parent
af22741ade
commit
fd8dbd9ce7
@ -2,4 +2,4 @@
|
||||
|
||||
reorder_impl_items = true
|
||||
use_small_heuristics = "Max"
|
||||
imports_granularity = "Crate"
|
||||
imports_granularity = "Module"
|
||||
|
@ -1,12 +1,13 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use clap::{builder::PossibleValue, Arg, Command};
|
||||
use detee_cli::{
|
||||
general::cli_handler::{handle_account, handle_completion, handle_operators, handle_packagers},
|
||||
sgx::cli_handler::{handle_app, handle_app_nodes},
|
||||
snp::cli_handler::{handle_vm, handle_vm_nodes},
|
||||
*,
|
||||
use clap::builder::PossibleValue;
|
||||
use clap::{Arg, Command};
|
||||
use detee_cli::general::cli_handler::{
|
||||
handle_account, handle_completion, handle_operators, handle_packagers,
|
||||
};
|
||||
use detee_cli::sgx::cli_handler::{handle_app, handle_app_nodes};
|
||||
use detee_cli::snp::cli_handler::{handle_vm, handle_vm_nodes};
|
||||
use detee_cli::*;
|
||||
|
||||
const ABOUT: &str = r#"The DeTEE CLI allows you to manage and deploy applications and virtual machines.
|
||||
All software runs within Trusted Execution Environments on a distributed network.
|
||||
@ -54,15 +55,15 @@ fn main() {
|
||||
|
||||
fn clap_cmd() -> Command {
|
||||
let snp_locations = [
|
||||
PossibleValue::new("GB").help("London, England, GB"),
|
||||
PossibleValue::new("Canada").help("Montréal or Vancouver"),
|
||||
PossibleValue::new("Montreal").help("Montréal, Quebec, CA"),
|
||||
PossibleValue::new("Vancouver").help("Vancouver, British Columbia, CA"),
|
||||
PossibleValue::new("California").help("San Jose, California, US"),
|
||||
PossibleValue::new("US").help("San Jose, California, US"),
|
||||
PossibleValue::new("France").help("Paris, Île-de-France, FR"),
|
||||
PossibleValue::new("Any").help("List offers for any location."),
|
||||
];
|
||||
PossibleValue::new("GB").help("London, England, GB"),
|
||||
PossibleValue::new("Canada").help("Montréal or Vancouver"),
|
||||
PossibleValue::new("Montreal").help("Montréal, Quebec, CA"),
|
||||
PossibleValue::new("Vancouver").help("Vancouver, British Columbia, CA"),
|
||||
PossibleValue::new("California").help("San Jose, California, US"),
|
||||
PossibleValue::new("US").help("San Jose, California, US"),
|
||||
PossibleValue::new("France").help("Paris, Île-de-France, FR"),
|
||||
PossibleValue::new("Any").help("List offers for any location."),
|
||||
];
|
||||
Command::new("detee-cli")
|
||||
.version(build::CLAP_LONG_VERSION)
|
||||
.author("https://detee.ltd")
|
||||
|
@ -1,7 +1,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::constants::{BRAIN_STAGING, BRAIN_TESTING};
|
||||
use crate::{general, utils::block_on};
|
||||
use crate::general;
|
||||
use crate::utils::block_on;
|
||||
use ed25519_dalek::SigningKey;
|
||||
use log::{debug, info, warn};
|
||||
use openssl::bn::BigNum;
|
||||
@ -9,7 +10,9 @@ use openssl::hash::{Hasher, MessageDigest};
|
||||
use openssl::pkey::{PKey, Private};
|
||||
use openssl::rsa::Rsa;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{fs::File, io::Write, path::Path};
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Serialize, Default)]
|
||||
pub struct AccountData {
|
||||
|
@ -7,8 +7,8 @@ pub const HRATLS_APP_PORT: u32 = 34500;
|
||||
pub const MAX_REDIRECTS: u16 = 3;
|
||||
pub const STAGING_BRAIN_URLS: [&str; 3] = [
|
||||
"https://156.146.63.216:31337", // staging brain 1
|
||||
"https://156.146.63.216:31337", // staging brain 2
|
||||
"https://156.146.63.216:31337", // staging brain 3
|
||||
"https://156.146.63.216:31337", // staging brain 2
|
||||
"https://156.146.63.216:31337", // staging brain 3
|
||||
];
|
||||
|
||||
pub const TESTNET_BRAIN_URLS: [&str; 3] = [
|
||||
|
@ -1,10 +1,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use super::operators;
|
||||
use super::packagers;
|
||||
use super::{operators, packagers};
|
||||
use crate::{cli_print, config};
|
||||
use clap::ArgMatches;
|
||||
use clap::Command;
|
||||
use clap::{ArgMatches, Command};
|
||||
use clap_complete::{generate, Shell};
|
||||
use std::error::Error;
|
||||
use std::io;
|
||||
|
@ -380,4 +380,3 @@ const APP_SUBSTANTIVES: [&str; 70] = [
|
||||
"gecko",
|
||||
"zebra",
|
||||
];
|
||||
|
||||
|
@ -9,18 +9,16 @@ use crate::sgx::packaging::package_enclave;
|
||||
use crate::sgx::utils::{
|
||||
deploy_new_app_and_update_config, fetch_config, override_envs_and_args_launch_config,
|
||||
};
|
||||
use crate::sgx::AppDeleteResponse;
|
||||
use crate::sgx::{
|
||||
append_uuid_list, get_app_node, get_app_node_by_contract, get_one_contract, inspect_node,
|
||||
package_entry_from_name, print_nodes, write_uuid_list,
|
||||
package_entry_from_name, print_nodes, write_uuid_list, AppContract, AppDeleteResponse,
|
||||
AppDeployResponse,
|
||||
};
|
||||
use crate::sgx::{AppContract, AppDeployResponse};
|
||||
use crate::utils::block_on;
|
||||
use crate::{cli_print, SimpleOutput};
|
||||
use clap::ArgMatches;
|
||||
use detee_shared::app_proto::ListAppContractsReq;
|
||||
use detee_shared::sgx::types::brain::AppDeployConfig;
|
||||
use detee_shared::sgx::types::brain::Resource;
|
||||
use detee_shared::sgx::types::brain::{AppDeployConfig, Resource};
|
||||
|
||||
pub fn handle_app(app_matche: &ArgMatches) {
|
||||
match app_matche.subcommand() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use detee_shared::sgx::types::{brain::AppDeployConfig, dtpm::DtpmConfig};
|
||||
use detee_shared::sgx::types::brain::AppDeployConfig;
|
||||
use detee_shared::sgx::types::dtpm::DtpmConfig;
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum Error {
|
||||
|
@ -1,27 +1,21 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use detee_sgx::{prelude::*, HRaTlsConfigBuilder};
|
||||
use detee_shared::{
|
||||
common_proto::Empty,
|
||||
sgx::{pb::dtpm_proto::DtpmGetConfigRes, types::dtpm::FileEntry},
|
||||
};
|
||||
use detee_sgx::prelude::*;
|
||||
use detee_sgx::HRaTlsConfigBuilder;
|
||||
use detee_shared::common_proto::Empty;
|
||||
use detee_shared::sgx::pb::dtpm_proto::DtpmGetConfigRes;
|
||||
use detee_shared::sgx::types::dtpm::FileEntry;
|
||||
use hyper_rustls::HttpsConnectorBuilder;
|
||||
use rustls::ClientConfig;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use tokio::sync::mpsc;
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
use tonic::{
|
||||
codec::CompressionEncoding,
|
||||
transport::{Channel, Endpoint},
|
||||
};
|
||||
use tonic::codec::CompressionEncoding;
|
||||
use tonic::transport::{Channel, Endpoint};
|
||||
|
||||
use detee_shared::sgx::{
|
||||
pb::dtpm_proto::{
|
||||
dtpm_config_manager_client::DtpmConfigManagerClient, DtpmSetConfigReq,
|
||||
FileEntry as FileEntryPb,
|
||||
},
|
||||
types::dtpm::DtpmConfig,
|
||||
};
|
||||
use detee_shared::sgx::pb::dtpm_proto::dtpm_config_manager_client::DtpmConfigManagerClient;
|
||||
use detee_shared::sgx::pb::dtpm_proto::{DtpmSetConfigReq, FileEntry as FileEntryPb};
|
||||
use detee_shared::sgx::types::dtpm::DtpmConfig;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::sgx::utils::hratls_url_and_mr_enclave_from_app_id;
|
||||
|
@ -8,16 +8,14 @@ pub mod packaging;
|
||||
pub mod utils;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::constants::HRATLS_APP_PORT;
|
||||
use crate::snp;
|
||||
use crate::utils::shorten_string;
|
||||
use crate::{constants::HRATLS_APP_PORT, utils::block_on};
|
||||
use detee_shared::{
|
||||
app_proto::{
|
||||
AppContract as AppContractPB, AppNodeFilters, AppNodeListResp, AppResource,
|
||||
ListAppContractsReq, NewAppRes,
|
||||
},
|
||||
sgx::types::brain::Resource,
|
||||
use crate::utils::{block_on, shorten_string};
|
||||
use detee_shared::app_proto::{
|
||||
AppContract as AppContractPB, AppNodeFilters, AppNodeListResp, AppResource,
|
||||
ListAppContractsReq, NewAppRes,
|
||||
};
|
||||
use detee_shared::sgx::types::brain::Resource;
|
||||
use grpc_brain::get_one_app_node;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::LazyLock;
|
||||
@ -310,7 +308,8 @@ fn write_uuid_list(app_contracts: &[AppContract]) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
pub fn append_uuid_list(uuid: &str, app_name: &str) -> Result<(), Error> {
|
||||
use std::{fs::OpenOptions, io::prelude::*};
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::prelude::*;
|
||||
let mut file =
|
||||
OpenOptions::new().create(true).append(true).open(Config::app_uuid_list_path()?).unwrap();
|
||||
writeln!(file, "{uuid}\t{app_name}")?;
|
||||
|
@ -1,17 +1,13 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::constants::HRATLS_APP_PORT;
|
||||
use crate::sgx::get_one_contract;
|
||||
use crate::sgx::grpc_brain::new_app;
|
||||
use crate::sgx::grpc_dtpm::connect_app_dtpm_client;
|
||||
use crate::sgx::grpc_dtpm::set_config_pb;
|
||||
use crate::sgx::grpc_dtpm::upload_files_pb;
|
||||
use crate::sgx::package_entry_from_name;
|
||||
use crate::sgx::grpc_dtpm::{connect_app_dtpm_client, set_config_pb, upload_files_pb};
|
||||
use crate::sgx::{get_one_contract, package_entry_from_name};
|
||||
use detee_shared::app_proto::NewAppRes;
|
||||
use detee_shared::sgx::pb::dtpm_proto::DtpmSetConfigReq;
|
||||
use detee_shared::sgx::types::brain::AppDeployConfig;
|
||||
use detee_shared::sgx::types::dtpm::DtpmConfig;
|
||||
use detee_shared::sgx::types::dtpm::EnvironmentEntry;
|
||||
use detee_shared::sgx::types::dtpm::{DtpmConfig, EnvironmentEntry};
|
||||
use tokio_retry::strategy::FixedInterval;
|
||||
use tokio_retry::Retry;
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use super::{
|
||||
grpc::{self, proto},
|
||||
injector, Distro, Dtrfs, Error, VmSshArgs, DEFAULT_ARCHLINUX, DEFAULT_DTRFS,
|
||||
};
|
||||
use crate::{config::Config, utils::block_on};
|
||||
use super::grpc::{self, proto};
|
||||
use super::{injector, Distro, Dtrfs, Error, VmSshArgs, DEFAULT_ARCHLINUX, DEFAULT_DTRFS};
|
||||
use crate::config::Config;
|
||||
use crate::utils::block_on;
|
||||
use log::{debug, info};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -10,9 +10,10 @@ use crate::config::Config;
|
||||
use crate::utils::{self, sign_request};
|
||||
use lazy_static::lazy_static;
|
||||
use log::{debug, info, warn};
|
||||
use proto::brain_vm_cli_client::BrainVmCliClient;
|
||||
use proto::{
|
||||
brain_vm_cli_client::BrainVmCliClient, DeleteVmReq, ExtendVmReq, ListVmContractsReq, NewVmReq,
|
||||
NewVmResp, UpdateVmReq, UpdateVmResp, VmContract, VmNodeFilters, VmNodeListResp,
|
||||
DeleteVmReq, ExtendVmReq, ListVmContractsReq, NewVmReq, NewVmResp, UpdateVmReq, UpdateVmResp,
|
||||
VmContract, VmNodeFilters, VmNodeListResp,
|
||||
};
|
||||
use tokio_stream::StreamExt;
|
||||
use tonic::metadata::errors::InvalidMetadataValue;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::{config::Config, snp::grpc::proto};
|
||||
use crate::config::Config;
|
||||
use crate::snp::grpc::proto;
|
||||
use log::debug;
|
||||
use std::net::IpAddr;
|
||||
|
||||
|
@ -6,11 +6,9 @@ pub mod grpc;
|
||||
mod injector;
|
||||
pub mod update;
|
||||
|
||||
use crate::{
|
||||
config::{self, Config},
|
||||
snp,
|
||||
utils::{block_on, display_mib_or_gib, shorten_string},
|
||||
};
|
||||
use crate::config::{self, Config};
|
||||
use crate::snp;
|
||||
use crate::utils::{block_on, display_mib_or_gib, shorten_string};
|
||||
use grpc::proto;
|
||||
use lazy_static::lazy_static;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -352,7 +350,8 @@ fn write_uuid_list(contracts: &[VmContract]) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
pub fn append_uuid_list(uuid: &str, hostname: &str) -> Result<(), Error> {
|
||||
use std::{fs::OpenOptions, io::prelude::*};
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::prelude::*;
|
||||
let mut file =
|
||||
OpenOptions::new().create(true).append(true).open(Config::vm_uuid_list_path()?)?;
|
||||
writeln!(file, "{uuid}\t{hostname}")?;
|
||||
|
@ -1,9 +1,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use super::{
|
||||
grpc::{self, proto},
|
||||
injector, Dtrfs, Error,
|
||||
};
|
||||
use super::grpc::{self, proto};
|
||||
use super::{injector, Dtrfs, Error};
|
||||
use crate::config::Config;
|
||||
use crate::utils::block_on;
|
||||
use log::{debug, info};
|
||||
@ -34,7 +32,8 @@ impl Request {
|
||||
Some(Dtrfs::load_from_file(path)?)
|
||||
}
|
||||
};
|
||||
let req = Self { hostname, vcpus, memory_mib: memory_mb, disk_size_mib: disk_size_gb, dtrfs };
|
||||
let req =
|
||||
Self { hostname, vcpus, memory_mib: memory_mb, disk_size_mib: disk_size_gb, dtrfs };
|
||||
if req == Self::default() {
|
||||
log::info!("Skipping hardware upgrade (no arguments specified).");
|
||||
return Ok(());
|
||||
@ -70,12 +69,7 @@ impl Request {
|
||||
};
|
||||
let measurement = measurement_args.get_measurement()?;
|
||||
|
||||
injector::execute(
|
||||
measurement,
|
||||
args.dtrfs_api_endpoint,
|
||||
None,
|
||||
&updated_contract.hostname,
|
||||
)?;
|
||||
injector::execute(measurement, args.dtrfs_api_endpoint, None, &updated_contract.hostname)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::config::Config;
|
||||
use tonic::{
|
||||
metadata::{errors::InvalidMetadataValue, AsciiMetadataValue},
|
||||
Request,
|
||||
};
|
||||
use tonic::metadata::errors::InvalidMetadataValue;
|
||||
use tonic::metadata::AsciiMetadataValue;
|
||||
use tonic::Request;
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum Error {
|
||||
|
Loading…
Reference in New Issue
Block a user