cargo_dist/config/v1/hosts/
github.rs1use super::*;
4
5#[derive(Debug, Default, Clone, Serialize, Deserialize)]
7#[serde(rename_all = "kebab-case")]
8pub struct GithubHostLayer {
9 #[serde(flatten)]
11 pub common: CommonHostLayer,
12
13 #[serde(skip_serializing_if = "Option::is_none")]
22 pub create: Option<bool>,
23
24 #[serde(skip_serializing_if = "Option::is_none")]
28 pub repo: Option<GithubRepoPair>,
29
30 #[serde(skip_serializing_if = "Option::is_none")]
33 pub submodule_path: Option<Utf8PathBuf>,
34
35 #[serde(skip_serializing_if = "Option::is_none")]
37 pub during: Option<GithubReleasePhase>,
38
39 #[serde(skip_serializing_if = "Option::is_none")]
41 pub attestations: Option<bool>,
42
43 #[serde(skip_serializing_if = "Option::is_none")]
45 pub attestations_filters: Option<GithubAttestationsFilters>,
46
47 #[serde(skip_serializing_if = "Option::is_none")]
49 pub attestations_phase: Option<GithubAttestationsPhase>,
50}
51#[derive(Debug, Default, Clone)]
53pub struct GithubHostConfig {
54 pub common: CommonHostConfig,
56 pub create: bool,
58 pub repo: Option<GithubRepoPair>,
60 pub submodule_path: Option<Utf8PathBuf>,
63 pub during: GithubReleasePhase,
65 pub attestations: bool,
67 pub attestations_filters: GithubAttestationsFilters,
69 pub attestations_phase: GithubAttestationsPhase,
71}
72
73impl GithubHostConfig {
74 pub fn defaults_for_workspace(_workspaces: &WorkspaceGraph, common: &CommonHostConfig) -> Self {
76 Self {
77 common: common.clone(),
78 create: true,
79 repo: None,
80 submodule_path: None,
81 during: GithubReleasePhase::default(),
82 attestations: false,
83 attestations_filters: GithubAttestationsFilters::default(),
84 attestations_phase: GithubAttestationsPhase::default(),
85 }
86 }
87}
88
89impl ApplyLayer for GithubHostConfig {
90 type Layer = GithubHostLayer;
91 fn apply_layer(
92 &mut self,
93 Self::Layer {
94 common,
95 create,
96 repo,
97 submodule_path,
98 during,
99 attestations,
100 attestations_filters,
101 attestations_phase,
102 }: Self::Layer,
103 ) {
104 self.common.apply_layer(common);
105 self.create.apply_val(create);
106 self.repo.apply_opt(repo);
107 self.submodule_path.apply_opt(submodule_path);
108 self.during.apply_val(during);
109 self.attestations.apply_val(attestations);
110 self.attestations_filters.apply_val(attestations_filters);
111 self.attestations_phase.apply_val(attestations_phase);
112 }
113}
114impl ApplyLayer for GithubHostLayer {
115 type Layer = GithubHostLayer;
116 fn apply_layer(
117 &mut self,
118 Self::Layer {
119 common,
120 create,
121 repo,
122 submodule_path,
123 during,
124 attestations,
125 attestations_filters,
126 attestations_phase,
127 }: Self::Layer,
128 ) {
129 self.common.apply_layer(common);
130 self.create.apply_opt(create);
131 self.repo.apply_opt(repo);
132 self.submodule_path.apply_opt(submodule_path);
133 self.during.apply_opt(during);
134 self.attestations.apply_opt(attestations);
135 self.attestations_filters.apply_opt(attestations_filters);
136 self.attestations_phase.apply_opt(attestations_phase);
137 }
138}
139
140impl std::ops::Deref for GithubHostConfig {
141 type Target = CommonHostConfig;
142 fn deref(&self) -> &Self::Target {
143 &self.common
144 }
145}