1use indexmap::{IndexMap, IndexSet};
8use serde::Deserialize;
9
10#[derive(Deserialize, Debug)]
12#[serde(rename_all = "kebab-case")]
13pub struct Dependabot {
14 pub version: u64,
16 #[serde(default)]
17 pub enable_beta_ecosystems: bool,
18 #[serde(default)]
19 pub registries: IndexMap<String, Registry>,
20 pub updates: Vec<Update>,
21}
22
23#[derive(Deserialize, Debug)]
25#[serde(rename_all = "kebab-case", tag = "type")]
26pub enum Registry {
27 ComposerRepository {
28 url: String,
29 username: Option<String>,
30 password: Option<String>,
31 },
32 DockerRegistry {
33 url: String,
34 username: Option<String>,
35 password: Option<String>,
36 #[serde(default)]
37 replaces_base: bool,
38 },
39 Git {
40 url: String,
41 username: Option<String>,
42 password: Option<String>,
43 },
44 HexOrganization {
45 organization: String,
46 key: Option<String>,
47 },
48 HexRepository {
49 repo: Option<String>,
50 url: String,
51 auth_key: Option<String>,
52 public_key_fingerprint: Option<String>,
53 },
54 MavenRepository {
55 url: String,
56 username: Option<String>,
57 password: Option<String>,
58 },
59 NpmRegistry {
60 url: String,
61 username: Option<String>,
62 password: Option<String>,
63 #[serde(default)]
64 replaces_base: bool,
65 },
66 NugetFeed {
67 url: String,
68 username: Option<String>,
69 password: Option<String>,
70 },
71 PythonIndex {
72 url: String,
73 username: Option<String>,
74 password: Option<String>,
75 #[serde(default)]
76 replaces_base: bool,
77 },
78 RubygemsServer {
79 url: String,
80 username: Option<String>,
81 password: Option<String>,
82 #[serde(default)]
83 replaces_base: bool,
84 },
85 TerraformRegistry {
86 url: String,
87 token: Option<String>,
88 },
89}
90
91#[derive(Deserialize, Debug)]
93#[serde(rename_all = "kebab-case")]
94pub struct Cooldown {
95 pub default_days: Option<u64>,
96 pub semver_major_days: Option<u64>,
97 pub semver_minor_days: Option<u64>,
98 pub semver_patch_days: Option<u64>,
99 #[serde(default)]
100 pub include: Vec<String>,
101 #[serde(default)]
102 pub exclude: Vec<String>,
103}
104
105#[derive(Deserialize, Debug, PartialEq)]
107#[serde(rename_all = "kebab-case")]
108pub enum Directories {
109 Directory(String),
110 Directories(Vec<String>),
111}
112
113#[derive(Deserialize, Debug)]
115#[serde(rename_all = "kebab-case")]
116pub struct Update {
117 #[serde(default)]
118 pub allow: Vec<Allow>,
119 #[serde(default)]
120 pub assignees: IndexSet<String>,
121 pub commit_message: Option<CommitMessage>,
122 pub cooldown: Option<Cooldown>,
123 #[serde(flatten)]
124 pub directories: Directories,
125 #[serde(default)]
126 pub groups: IndexMap<String, Group>,
127 #[serde(default)]
128 pub ignore: Vec<Ignore>,
129 #[serde(default)]
130 pub insecure_external_code_execution: AllowDeny,
131 #[serde(default = "default_labels")]
135 pub labels: IndexSet<String>,
136 pub milestone: Option<u64>,
137 #[serde(default = "default_open_pull_requests_limit")]
142 pub open_pull_requests_limit: u64,
143 pub package_ecosystem: PackageEcosystem,
144 #[serde(default)]
146 pub rebase_strategy: RebaseStrategy,
147 #[serde(default, deserialize_with = "crate::common::scalar_or_vector")]
148 pub registries: Vec<String>,
149 #[serde(default)]
150 pub reviewers: IndexSet<String>,
151 pub schedule: Schedule,
152 pub target_branch: Option<String>,
153 #[serde(default)]
154 pub vendor: bool,
155 pub versioning_strategy: Option<VersioningStrategy>,
156}
157
158#[inline]
159fn default_labels() -> IndexSet<String> {
160 IndexSet::from(["dependencies".to_string()])
161}
162
163#[inline]
164fn default_open_pull_requests_limit() -> u64 {
165 5
167}
168
169#[derive(Deserialize, Debug)]
171#[serde(rename_all = "kebab-case")]
172pub struct Allow {
173 pub dependency_name: Option<String>,
174 pub dependency_type: Option<DependencyType>,
175}
176
177#[derive(Deserialize, Debug)]
179#[serde(rename_all = "kebab-case")]
180pub enum DependencyType {
181 Direct,
182 Indirect,
183 All,
184 Production,
185 Development,
186}
187
188#[derive(Deserialize, Debug)]
190#[serde(rename_all = "kebab-case")]
191pub struct CommitMessage {
192 pub prefix: Option<String>,
193 pub prefix_development: Option<String>,
194 pub include: Option<String>,
196}
197
198#[derive(Deserialize, Debug)]
200#[serde(rename_all = "kebab-case")]
201pub struct Group {
202 pub dependency_type: Option<DependencyType>,
205 #[serde(default)]
206 pub patterns: IndexSet<String>,
207 #[serde(default)]
208 pub exclude_patterns: IndexSet<String>,
209 #[serde(default)]
210 pub update_types: IndexSet<UpdateType>,
211}
212
213#[derive(Deserialize, Debug, Hash, Eq, PartialEq)]
215#[serde(rename_all = "kebab-case")]
216pub enum UpdateType {
217 Major,
218 Minor,
219 Patch,
220}
221
222#[derive(Deserialize, Debug)]
224#[serde(rename_all = "kebab-case")]
225pub struct Ignore {
226 pub dependency_name: Option<String>,
227 #[serde(default)]
230 pub update_types: IndexSet<String>,
231 #[serde(default)]
232 pub versions: IndexSet<String>,
233}
234
235#[derive(Deserialize, Debug, Default)]
237#[serde(rename_all = "kebab-case")]
238pub enum AllowDeny {
239 Allow,
240 #[default]
241 Deny,
242}
243
244#[derive(Deserialize, Debug, PartialEq)]
246#[serde(rename_all = "kebab-case")]
247pub enum PackageEcosystem {
248 Bundler,
249 Cargo,
250 Composer,
251 Docker,
252 Elm,
253 Gitsubmodule,
254 GithubActions,
255 Gomod,
256 Gradle,
257 Maven,
258 Mix,
259 Npm,
260 Nuget,
261 Pip,
262 Pub,
263 Swift,
264 Terraform,
265}
266
267#[derive(Deserialize, Debug, Default, PartialEq)]
269#[serde(rename_all = "kebab-case")]
270pub enum RebaseStrategy {
271 #[default]
272 Auto,
273 Disabled,
274}
275
276#[derive(Deserialize, Debug)]
278#[serde(rename_all = "kebab-case")]
279pub struct Schedule {
280 pub interval: Interval,
281 pub day: Option<Day>,
282 pub time: Option<String>,
283 pub timezone: Option<String>,
284}
285
286#[derive(Deserialize, Debug, PartialEq)]
288#[serde(rename_all = "kebab-case")]
289pub enum Interval {
290 Daily,
291 Weekly,
292 Monthly,
293}
294
295#[derive(Deserialize, Debug, PartialEq)]
297#[serde(rename_all = "kebab-case")]
298pub enum Day {
299 Monday,
300 Tuesday,
301 Wednesday,
302 Thursday,
303 Friday,
304 Saturday,
305 Sunday,
306}
307
308#[derive(Deserialize, Debug, PartialEq)]
310#[serde(rename_all = "kebab-case")]
311pub enum VersioningStrategy {
312 Auto,
313 Increase,
314 IncreaseIfNecessary,
315 LockfileOnly,
316 Widen,
317}