use serde::{Deserialize, Serialize};
use typeshare::typeshare;
pub mod core;
pub mod periphery;
#[typeshare]
#[derive(
Debug,
Clone,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
Serialize,
Deserialize,
)]
pub struct GitProvider {
#[serde(default = "default_git_provider")]
pub domain: String,
#[serde(default = "default_git_https")]
pub https: bool,
#[serde(alias = "account")]
pub accounts: Vec<ProviderAccount>,
}
fn default_git_provider() -> String {
String::from("github.com")
}
fn default_git_https() -> bool {
true
}
#[typeshare]
#[derive(
Debug,
Clone,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
Serialize,
Deserialize,
)]
pub struct DockerRegistry {
#[serde(default = "default_docker_provider")]
pub domain: String,
#[serde(default, alias = "account")]
pub accounts: Vec<ProviderAccount>,
#[serde(default, alias = "organization")]
pub organizations: Vec<String>,
}
fn default_docker_provider() -> String {
String::from("docker.io")
}
#[typeshare]
#[derive(
Debug,
Clone,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
Serialize,
Deserialize,
)]
pub struct ProviderAccount {
#[serde(alias = "account")]
pub username: String,
#[serde(default, skip_serializing)]
pub token: String,
}
fn empty_or_redacted(src: &str) -> String {
if src.is_empty() {
String::new()
} else {
String::from("##############")
}
}