use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "lowercase", deny_unknown_fields)]
#[non_exhaustive]
pub enum ReleaseSource {
Github {
owner: String,
repo: String,
#[serde(default = "default_github_host")]
host: String,
},
Gitlab {
project: String,
#[serde(default = "default_gitlab_host")]
host: String,
},
Bitbucket {
workspace: String,
repo_slug: String,
#[serde(default = "default_bitbucket_host")]
host: String,
},
Gitea {
owner: String,
repo: String,
host: String,
},
Codeberg {
owner: String,
repo: String,
},
Direct {
url_template: String,
},
}
fn default_github_host() -> String {
"github.com".into()
}
fn default_gitlab_host() -> String {
"gitlab.com".into()
}
fn default_bitbucket_host() -> String {
"api.bitbucket.org/2.0".into()
}
#[derive(Debug, Clone, Serialize, Deserialize, bon::Builder)]
#[serde(deny_unknown_fields)]
#[builder(on(String, into))]
pub struct ToolMetadata {
pub name: String,
pub summary: String,
#[serde(default)]
#[builder(default)]
pub description: String,
#[serde(default)]
pub release_source: Option<ReleaseSource>,
#[serde(default, skip_serializing)]
pub release_credential: Option<rtb_credentials::CredentialRef>,
#[serde(default)]
#[builder(default)]
pub help: HelpChannel,
#[serde(skip)]
#[builder(default)]
pub update_public_keys: Vec<[u8; 32]>,
#[serde(skip)]
pub update_checksums_asset: Option<&'static str>,
#[serde(skip)]
pub update_asset_pattern: Option<&'static str>,
#[serde(skip)]
pub telemetry_notice: Option<&'static str>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "lowercase", deny_unknown_fields)]
#[non_exhaustive]
pub enum HelpChannel {
#[default]
None,
Slack {
team: String,
channel: String,
},
Teams {
team: String,
channel: String,
},
Url {
url: String,
},
}
impl HelpChannel {
#[must_use]
pub fn footer(&self) -> Option<String> {
match self {
Self::None => None,
Self::Slack { team, channel } => Some(format!("support: slack #{channel} (in {team})")),
Self::Teams { team, channel } => Some(format!("support: Teams → {team} / {channel}")),
Self::Url { url } => Some(format!("support: {url}")),
}
}
}