use super::*;
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct GithubHostLayer {
#[serde(flatten)]
pub common: CommonHostLayer,
#[serde(skip_serializing_if = "Option::is_none")]
pub create: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub repo: Option<GithubRepoPair>,
#[serde(skip_serializing_if = "Option::is_none")]
pub submodule_path: Option<Utf8PathBuf>,
#[serde(skip_serializing_if = "Option::is_none")]
pub during: Option<GithubReleasePhase>,
#[serde(skip_serializing_if = "Option::is_none")]
pub attestations: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub attestations_filters: Option<GithubAttestationsFilters>,
#[serde(skip_serializing_if = "Option::is_none")]
pub attestations_phase: Option<GithubAttestationsPhase>,
}
#[derive(Debug, Default, Clone)]
pub struct GithubHostConfig {
pub common: CommonHostConfig,
pub create: bool,
pub repo: Option<GithubRepoPair>,
pub submodule_path: Option<Utf8PathBuf>,
pub during: GithubReleasePhase,
pub attestations: bool,
pub attestations_filters: GithubAttestationsFilters,
pub attestations_phase: GithubAttestationsPhase,
}
impl GithubHostConfig {
pub fn defaults_for_workspace(_workspaces: &WorkspaceGraph, common: &CommonHostConfig) -> Self {
Self {
common: common.clone(),
create: true,
repo: None,
submodule_path: None,
during: GithubReleasePhase::default(),
attestations: false,
attestations_filters: GithubAttestationsFilters::default(),
attestations_phase: GithubAttestationsPhase::default(),
}
}
}
impl ApplyLayer for GithubHostConfig {
type Layer = GithubHostLayer;
fn apply_layer(
&mut self,
Self::Layer {
common,
create,
repo,
submodule_path,
during,
attestations,
attestations_filters,
attestations_phase,
}: Self::Layer,
) {
self.common.apply_layer(common);
self.create.apply_val(create);
self.repo.apply_opt(repo);
self.submodule_path.apply_opt(submodule_path);
self.during.apply_val(during);
self.attestations.apply_val(attestations);
self.attestations_filters.apply_val(attestations_filters);
self.attestations_phase.apply_val(attestations_phase);
}
}
impl ApplyLayer for GithubHostLayer {
type Layer = GithubHostLayer;
fn apply_layer(
&mut self,
Self::Layer {
common,
create,
repo,
submodule_path,
during,
attestations,
attestations_filters,
attestations_phase,
}: Self::Layer,
) {
self.common.apply_layer(common);
self.create.apply_opt(create);
self.repo.apply_opt(repo);
self.submodule_path.apply_opt(submodule_path);
self.during.apply_opt(during);
self.attestations.apply_opt(attestations);
self.attestations_filters.apply_opt(attestations_filters);
self.attestations_phase.apply_opt(attestations_phase);
}
}
impl std::ops::Deref for GithubHostConfig {
type Target = CommonHostConfig;
fn deref(&self) -> &Self::Target {
&self.common
}
}