mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-10 06:38:22 +00:00
Fix formatting issues
This commit is contained in:
committed by
Christoph Herzog
parent
011e494e29
commit
52b04d5806
@@ -11,9 +11,9 @@ use url::Url;
|
|||||||
use crate::{
|
use crate::{
|
||||||
types::{
|
types::{
|
||||||
self, CreateNamespaceVars, DeployApp, DeployAppConnection, DeployAppVersion,
|
self, CreateNamespaceVars, DeployApp, DeployAppConnection, DeployAppVersion,
|
||||||
DeployAppVersionConnection, GetCurrentUserWithAppsVars, GetDeployAppAndVersion,
|
DeployAppVersionConnection, DnsDomain, GetCurrentUserWithAppsVars, GetDeployAppAndVersion,
|
||||||
GetDeployAppVersionsVars, GetNamespaceAppsVars, Log, LogStream, PackageVersionConnection,
|
GetDeployAppVersionsVars, GetNamespaceAppsVars, Log, LogStream, PackageVersionConnection,
|
||||||
PublishDeployAppVars, UpsertDomainFromZoneFileVars, DnsDomain,
|
PublishDeployAppVars, UpsertDomainFromZoneFileVars,
|
||||||
},
|
},
|
||||||
GraphQLApiFailure, WasmerClient,
|
GraphQLApiFailure, WasmerClient,
|
||||||
};
|
};
|
||||||
@@ -850,7 +850,6 @@ pub async fn get_domain_zone_file(
|
|||||||
Ok(opt)
|
Ok(opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Retrieve a domain by its name, along with all it's records.
|
/// Retrieve a domain by its name, along with all it's records.
|
||||||
pub async fn get_domain_with_records(
|
pub async fn get_domain_with_records(
|
||||||
client: &WasmerClient,
|
client: &WasmerClient,
|
||||||
@@ -892,7 +891,6 @@ pub async fn get_all_domains(
|
|||||||
.map(|x| x.get_all_domains)
|
.map(|x| x.get_all_domains)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Retrieve a domain by its name.
|
/// Retrieve a domain by its name.
|
||||||
///
|
///
|
||||||
/// Specify with_records to also retrieve all records for the domain.
|
/// Specify with_records to also retrieve all records for the domain.
|
||||||
|
|||||||
@@ -1225,7 +1225,6 @@ mod queries {
|
|||||||
pub zone_file: String,
|
pub zone_file: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(cynic::QueryFragment, Debug, Clone, Serialize)]
|
#[derive(cynic::QueryFragment, Debug, Clone, Serialize)]
|
||||||
#[cynic(graphql_type = "DNSDomain")]
|
#[cynic(graphql_type = "DNSDomain")]
|
||||||
pub struct DnsDomainWithRecords {
|
pub struct DnsDomainWithRecords {
|
||||||
@@ -1235,7 +1234,6 @@ mod queries {
|
|||||||
pub records: Option<Vec<Option<DnsRecord>>>,
|
pub records: Option<Vec<Option<DnsRecord>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(cynic::Scalar, Debug, Clone)]
|
#[derive(cynic::Scalar, Debug, Clone)]
|
||||||
pub struct BigInt(pub u64);
|
pub struct BigInt(pub u64);
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ impl AsyncCliCommand for CmdDomainGet {
|
|||||||
|
|
||||||
async fn run_async(self) -> Result<(), anyhow::Error> {
|
async fn run_async(self) -> Result<(), anyhow::Error> {
|
||||||
let client = self.api.client()?;
|
let client = self.api.client()?;
|
||||||
if let Some(domain) = wasmer_api::query::get_domain_with_records(&client, self.name).await? {
|
if let Some(domain) = wasmer_api::query::get_domain_with_records(&client, self.name).await?
|
||||||
|
{
|
||||||
println!("{}", self.fmt.format.render(&domain));
|
println!("{}", self.fmt.format.render(&domain));
|
||||||
} else {
|
} else {
|
||||||
println!("Domain not found");
|
println!("Domain not found");
|
||||||
|
|||||||
@@ -23,13 +23,23 @@ impl AsyncCliCommand for CmdDomainList {
|
|||||||
|
|
||||||
async fn run_async(self) -> Result<(), anyhow::Error> {
|
async fn run_async(self) -> Result<(), anyhow::Error> {
|
||||||
let client = self.api.client()?;
|
let client = self.api.client()?;
|
||||||
let domains_connection = wasmer_api::query::get_all_domains(&client, GetAllDomainsVariables {
|
let domains_connection = wasmer_api::query::get_all_domains(
|
||||||
first: None, after: None, namespace: self.namespace,
|
&client,
|
||||||
}).await?;
|
GetAllDomainsVariables {
|
||||||
|
first: None,
|
||||||
|
after: None,
|
||||||
|
namespace: self.namespace,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
let domains = domains_connection
|
let domains = domains_connection
|
||||||
.edges
|
.edges
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|edge| edge.expect("domain not found").node.expect("domain not found"))
|
.map(|edge| {
|
||||||
|
edge.expect("domain not found")
|
||||||
|
.node
|
||||||
|
.expect("domain not found")
|
||||||
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
println!("{}", self.fmt.format.render(&domains));
|
println!("{}", self.fmt.format.render(&domains));
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
pub mod list;
|
|
||||||
pub mod get;
|
pub mod get;
|
||||||
|
pub mod list;
|
||||||
pub mod zonefile;
|
pub mod zonefile;
|
||||||
|
|
||||||
use crate::commands::AsyncCliCommand;
|
use crate::commands::AsyncCliCommand;
|
||||||
|
|
||||||
|
|
||||||
/// Manage DNS records
|
/// Manage DNS records
|
||||||
#[derive(clap::Subcommand, Debug)]
|
#[derive(clap::Subcommand, Debug)]
|
||||||
pub enum CmdDomain {
|
pub enum CmdDomain {
|
||||||
@@ -19,7 +18,6 @@ pub enum CmdDomain {
|
|||||||
|
|
||||||
/// Sync local zone file with remotex
|
/// Sync local zone file with remotex
|
||||||
SyncZoneFile(self::zonefile::CmdZoneFileSync),
|
SyncZoneFile(self::zonefile::CmdZoneFileSync),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
|
|||||||
@@ -30,34 +30,37 @@ pub struct CmdZoneFileSync {
|
|||||||
zone_file_path: String,
|
zone_file_path: String,
|
||||||
|
|
||||||
/// Do not delete records that are not present in the zone file
|
/// Do not delete records that are not present in the zone file
|
||||||
#[clap(short='n', long="no-delete-missing-records", required = false, default_value = "false")]
|
#[clap(
|
||||||
|
short = 'n',
|
||||||
|
long = "no-delete-missing-records",
|
||||||
|
required = false,
|
||||||
|
default_value = "false"
|
||||||
|
)]
|
||||||
no_delete_missing_records: bool,
|
no_delete_missing_records: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl AsyncCliCommand for CmdZoneFileGet {
|
impl AsyncCliCommand for CmdZoneFileGet {
|
||||||
type Output = ();
|
type Output = ();
|
||||||
|
|
||||||
async fn run_async(self) -> Result<(), anyhow::Error> {
|
async fn run_async(self) -> Result<(), anyhow::Error> {
|
||||||
let client = self.api.client()?;
|
let client = self.api.client()?;
|
||||||
if let Some(domain) = wasmer_api::query::get_domain_zone_file(&client, self.domain_name).await? {
|
if let Some(domain) =
|
||||||
|
wasmer_api::query::get_domain_zone_file(&client, self.domain_name).await?
|
||||||
|
{
|
||||||
let zone_file_contents = domain.zone_file;
|
let zone_file_contents = domain.zone_file;
|
||||||
if let Some(zone_file_path) = self.zone_file_path {
|
if let Some(zone_file_path) = self.zone_file_path {
|
||||||
std::fs::write(zone_file_path, zone_file_contents).expect("Unable to write file");
|
std::fs::write(zone_file_path, zone_file_contents).expect("Unable to write file");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
println!("{}", zone_file_contents);
|
println!("{}", zone_file_contents);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
println!("Domain not found");
|
println!("Domain not found");
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl AsyncCliCommand for CmdZoneFileSync {
|
impl AsyncCliCommand for CmdZoneFileSync {
|
||||||
type Output = ();
|
type Output = ();
|
||||||
@@ -65,7 +68,12 @@ impl AsyncCliCommand for CmdZoneFileSync {
|
|||||||
async fn run_async(self) -> Result<(), anyhow::Error> {
|
async fn run_async(self) -> Result<(), anyhow::Error> {
|
||||||
let data = std::fs::read(&self.zone_file_path).expect("Unable to read file");
|
let data = std::fs::read(&self.zone_file_path).expect("Unable to read file");
|
||||||
let zone_file_contents = String::from_utf8(data).expect("Not a valid UTF-8 sequence");
|
let zone_file_contents = String::from_utf8(data).expect("Not a valid UTF-8 sequence");
|
||||||
let domain = wasmer_api::query::upsert_domain_from_zone_file(&self.api.client()?, zone_file_contents, !self.no_delete_missing_records,).await?;
|
let domain = wasmer_api::query::upsert_domain_from_zone_file(
|
||||||
|
&self.api.client()?,
|
||||||
|
zone_file_contents,
|
||||||
|
!self.no_delete_missing_records,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
println!("Successfully synced domain: {}", domain.name);
|
println!("Successfully synced domain: {}", domain.name);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ mod create_exe;
|
|||||||
#[cfg(feature = "static-artifact-create")]
|
#[cfg(feature = "static-artifact-create")]
|
||||||
mod create_obj;
|
mod create_obj;
|
||||||
pub(crate) mod deploy;
|
pub(crate) mod deploy;
|
||||||
|
pub(crate) mod domain;
|
||||||
#[cfg(feature = "static-artifact-create")]
|
#[cfg(feature = "static-artifact-create")]
|
||||||
mod gen_c_header;
|
mod gen_c_header;
|
||||||
mod init;
|
mod init;
|
||||||
@@ -22,7 +23,6 @@ mod inspect;
|
|||||||
mod journal;
|
mod journal;
|
||||||
mod login;
|
mod login;
|
||||||
pub(crate) mod namespace;
|
pub(crate) mod namespace;
|
||||||
pub(crate) mod domain;
|
|
||||||
mod package;
|
mod package;
|
||||||
mod publish;
|
mod publish;
|
||||||
mod run;
|
mod run;
|
||||||
|
|||||||
@@ -108,7 +108,6 @@ pub struct ItemTableFormatOpts {
|
|||||||
pub format: crate::utils::render::ItemFormat,
|
pub format: crate::utils::render::ItemFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Formatting options for a list of items.
|
/// Formatting options for a list of items.
|
||||||
#[derive(clap::Parser, Debug)]
|
#[derive(clap::Parser, Debug)]
|
||||||
pub struct ListFormatOpts {
|
pub struct ListFormatOpts {
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
use comfy_table::Table;
|
use comfy_table::Table;
|
||||||
use wasmer_api::types::{DeployApp, DeployAppVersion, Namespace, DnsDomain, DnsDomainWithRecords};
|
use wasmer_api::types::{DeployApp, DeployAppVersion, DnsDomain, DnsDomainWithRecords, Namespace};
|
||||||
|
|
||||||
use crate::utils::render::CliRender;
|
use crate::utils::render::CliRender;
|
||||||
|
|
||||||
impl CliRender for DnsDomain {
|
impl CliRender for DnsDomain {
|
||||||
fn render_item_table(&self) -> String {
|
fn render_item_table(&self) -> String {
|
||||||
let mut table = Table::new();
|
let mut table = Table::new();
|
||||||
table.add_rows([
|
table.add_rows([vec!["Domain".to_string(), self.name.clone()]]);
|
||||||
vec!["Domain".to_string(), self.name.clone()],
|
|
||||||
]);
|
|
||||||
table.to_string()
|
table.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,14 +23,14 @@ impl CliRender for DnsDomain {
|
|||||||
);
|
);
|
||||||
table.to_string()
|
table.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CliRender for DnsDomainWithRecords {
|
impl CliRender for DnsDomainWithRecords {
|
||||||
fn render_item_table(&self) -> String {
|
fn render_item_table(&self) -> String {
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
let mut table = Table::new();
|
let mut table = Table::new();
|
||||||
table.load_preset(comfy_table::presets::UTF8_FULL_CONDENSED)
|
table
|
||||||
|
.load_preset(comfy_table::presets::UTF8_FULL_CONDENSED)
|
||||||
.set_header(vec![
|
.set_header(vec![
|
||||||
"Type".to_string(),
|
"Type".to_string(),
|
||||||
"Name".to_string(),
|
"Name".to_string(),
|
||||||
@@ -41,16 +39,17 @@ impl CliRender for DnsDomainWithRecords {
|
|||||||
]);
|
]);
|
||||||
let mut rows: Vec<Vec<String>> = vec![];
|
let mut rows: Vec<Vec<String>> = vec![];
|
||||||
if let Some(ref records) = self.records {
|
if let Some(ref records) = self.records {
|
||||||
for record in records {
|
records.iter().flatten().for_each(|record| {
|
||||||
if let Some(ref record) = record {
|
|
||||||
rows.push(vec![
|
rows.push(vec![
|
||||||
record.record_type().to_string(),
|
record.record_type().to_string(),
|
||||||
record.name().expect("Expected record name").to_string(),
|
record.name().expect("Expected record name").to_string(),
|
||||||
record.ttl().expect("expected a TTL value for record").to_string(),
|
record
|
||||||
|
.ttl()
|
||||||
|
.expect("expected a TTL value for record")
|
||||||
|
.to_string(),
|
||||||
record.text().to_string(),
|
record.text().to_string(),
|
||||||
]);
|
]);
|
||||||
}
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
table.add_rows(rows);
|
table.add_rows(rows);
|
||||||
@@ -64,14 +63,9 @@ impl CliRender for DnsDomainWithRecords {
|
|||||||
}
|
}
|
||||||
let mut table = Table::new();
|
let mut table = Table::new();
|
||||||
table.set_header(vec!["Domain".to_string()]);
|
table.set_header(vec!["Domain".to_string()]);
|
||||||
table.add_rows(
|
table.add_rows(items.iter().map(|ns| vec![ns.name.clone()]));
|
||||||
items
|
|
||||||
.iter()
|
|
||||||
.map(|ns| vec![ns.name.clone()]),
|
|
||||||
);
|
|
||||||
table.to_string()
|
table.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CliRender for Namespace {
|
impl CliRender for Namespace {
|
||||||
|
|||||||
Reference in New Issue
Block a user