1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
use std::str::FromStr;
use bodhi::*;
use structopt::StructOpt;
#[derive(Debug)]
pub enum Format {
JSON,
Plain,
}
impl TryFrom<&str> for Format {
type Error = String;
fn try_from(value: &str) -> Result<Format, String> {
match value.to_lowercase().as_str() {
"json" => Ok(Format::JSON),
"plain" => Ok(Format::Plain),
_ => Err(format!("Not a recognised value for format: {}", &value)),
}
}
}
impl FromStr for Format {
type Err = String;
fn from_str(s: &str) -> Result<Format, String> {
TryFrom::try_from(s)
}
}
/// bodhi-cli expects a configuration file at ~/.config/fedora.toml, with at
/// least the following contents:
///
/// """
/// [FAS]
/// username = "USERNAME"
/// """
///
/// This username is used for logging in with bodhi for authenticated requests,
/// and for determining which updates, overrides, and comments the user has
/// created themselves.
#[derive(Debug, StructOpt)]
#[structopt(setting = structopt::clap::AppSettings::DisableHelpSubcommand)]
#[structopt(verbatim_doc_comment)]
pub struct BaseCommand {
/// Use the fedora staging instance of bodhi
#[structopt(long)]
pub staging: bool,
/// Manually specify bodhi server URL
#[structopt(long, requires("login_url"), conflicts_with("staging"))]
pub bodhi_url: Option<String>,
/// Manually specify OpenID endpoint URL
#[structopt(long, requires("bodhi_url"), conflicts_with("staging"))]
pub login_url: Option<String>,
/// Don't store password in session keyring
#[structopt(long, short = "n")]
pub no_store_password: bool,
/// Ignore password stored in session keyring
#[structopt(long, short = "k")]
pub ignore_keyring: bool,
/// Make output more verbose
#[structopt(long, short = "v")]
pub verbose: bool,
#[structopt(subcommand)]
pub subcommand: BodhiCommand,
}
#[allow(clippy::large_enum_variant)]
#[derive(Debug, StructOpt)]
pub enum BodhiCommand {
/// Comment on an update
Comment {
/// ID of the update to comment on
#[structopt(long)]
update: String,
/// Publicly visible comment text
#[structopt(long)]
text: String,
/// Karma submitted with this comment (-1/0/+1)
#[structopt(long)]
karma: Option<Karma>,
},
/// Query bodhi for information about a compose
ComposeInfo {
/// release string
release: FedoraRelease,
/// request string ("stable" or "testing")
request: ComposeRequest,
/// Output format (plain, JSON)
#[structopt(long)]
format: Option<Format>,
},
/// Query bodhi for running composes
ComposeList {
/// Output format (plain, JSON)
#[structopt(long)]
format: Option<Format>,
},
/// Create a new buildroot override
CreateOverride {
/// NVR of the override
nvr: String,
/// duration (in days) it should be active
#[structopt(long)]
duration: u32,
/// publicly visible notes
#[structopt(long)]
notes: String,
},
/// Create buildroot overrides from an update
CreateUpdateOverride {
/// alias of the update (i.e. "FEDORA-2022-XXXXXXXXXX")
alias: String,
/// duration (in days) it should be active
#[structopt(long)]
duration: u32,
/// publicly visible notes
#[structopt(long)]
notes: String,
},
/// Create a new update
CreateUpdate {
/// Push to stable based on karma
#[structopt(long)]
autokarma: Option<bool>,
/// Push to stable based on time
#[structopt(long)]
autotime: Option<bool>,
/// Bugs fixed by this update
#[structopt(long)]
bugs: Option<Vec<u32>>,
/// Builds that are part of this update
#[structopt(long, conflicts_with = "from_tag")]
builds: Option<Vec<String>>,
/// Close bugs when pushed to stable
#[structopt(long)]
close_bugs: Option<bool>,
/// Override displayed update name
#[structopt(long)]
display_name: Option<String>,
/// Koji tag to create this update from
#[structopt(long, conflicts_with = "builds")]
from_tag: Option<String>,
/// Publicly visible update notes
#[structopt(long)]
notes: String,
/// Require bug feedback for karma to count
#[structopt(long)]
require_bugs: Option<bool>,
/// Require test case feedback for karma to count
#[structopt(long)]
require_testcases: Option<bool>,
/// List of required gating tests
#[structopt(long)]
requirements: Option<Vec<String>>,
/// Update severity
#[structopt(long)]
severity: Option<UpdateSeverity>,
/// Days until it can be pushed to stable
#[structopt(long)]
stable_days: Option<u32>,
/// Karma until it can be pushed to stable
#[structopt(long)]
stable_karma: Option<i32>,
/// Logout / reboot suggestion
#[structopt(long)]
suggestion: Option<UpdateSuggestion>,
/// Karma until it will be unpushed
#[structopt(long)]
unstable_karma: Option<i32>,
/// Type of the update
#[structopt(long, name = "type")]
update_type: Option<UpdateType>,
},
/// Edit an existing buildroot override
EditOverride {
/// NVR of the override
nvr: String,
/// duration it will still be active
#[structopt(long)]
duration: u32,
/// publicly visible notes
#[structopt(long)]
notes: String,
},
/// Edit an existing update
EditUpdate {
/// Alias of the edited update
alias: String,
/// Add bugs to this update
#[structopt(long)]
add_bugs: Option<Vec<u32>>,
/// Add builds to this update
#[structopt(long)]
add_builds: Option<Vec<String>>,
/// Push to stable based on karma
#[structopt(long)]
autokarma: Option<bool>,
/// Push to stable based on time
#[structopt(long)]
autotime: Option<bool>,
/// Close bugs when pushed to stable
#[structopt(long)]
close_bugs: Option<bool>,
/// Override displayed update name
#[structopt(long)]
display_name: Option<String>,
/// Publicly visible update notes
#[structopt(long)]
notes: Option<String>,
/// Remove bugs from this update
#[structopt(long)]
remove_bugs: Option<Vec<u32>>,
/// Remove builds from this update
#[structopt(long)]
remove_builds: Option<Vec<String>>,
/// List of required gating tests
#[structopt(long)]
requirements: Option<Vec<String>>,
/// Update severity
#[structopt(long)]
severity: Option<UpdateSeverity>,
/// Days until it can be pushed to stable
#[structopt(long)]
stable_days: Option<u32>,
/// Karma until it can be pushed to stable
#[structopt(long)]
stable_karma: Option<i32>,
/// Logout / reboot suggestion
#[structopt(long)]
suggestion: Option<UpdateSuggestion>,
/// Karma until it will be unpushed
#[structopt(long)]
unstable_karma: Option<i32>,
/// Type of the update
#[structopt(long, name = "type")]
update_type: Option<UpdateType>,
},
/// Expire an existing buildroot override
ExpireOverride {
/// NVR of the override
nvr: String,
},
/// Query bodhi for buildroot overrides
QueryOverrides {
/// Query for this build / these builds
#[structopt(long)]
builds: Option<Vec<String>>,
/// Query for expired overrides
#[structopt(long)]
expired: Option<bool>,
/// Output format (plain, JSON)
#[structopt(long)]
format: Option<Format>,
/// Query for this release / these releases
#[structopt(long)]
releases: Option<Vec<FedoraRelease>>,
/// Query for overrides submitted by these users
#[structopt(long)]
users: Option<Vec<String>>,
/// Force long-running queries
#[structopt(long, short)]
force: bool,
},
/// Query bodhi for updates
QueryUpdates {
/// update with this alias
#[structopt(long)]
alias: Option<String>,
/// updates associated with these bugs
#[structopt(long)]
bugs: Option<Vec<u32>>,
/// updates associated with these builds
#[structopt(long)]
builds: Option<Vec<String>>,
/// updates for critpath packages
#[structopt(long)]
critpath: Option<bool>,
/// RPM / module / flatpak updates
#[structopt(long)]
content_type: Option<ContentType>,
/// Output format (plain, JSON)
#[structopt(long)]
format: Option<Format>,
/// locked updates
#[structopt(long)]
locked: Option<bool>,
/// updates modified before this date
#[structopt(long)]
modified_before: Option<BodhiDate>,
/// updates modified after this date
#[structopt(long)]
modified_since: Option<BodhiDate>,
/// updates for these packages
#[structopt(long)]
packages: Option<Vec<String>>,
/// pushed updates
#[structopt(long)]
pushed: Option<bool>,
/// updates pushed before this date
#[structopt(long)]
pushed_before: Option<BodhiDate>,
/// updates pushed after this date
#[structopt(long)]
pushed_since: Option<BodhiDate>,
/// updates for these releases
#[structopt(long)]
releases: Option<Vec<FedoraRelease>>,
/// updates with this status request
#[structopt(long)]
request: Option<UpdateRequest>,
/// updates with this severity
#[structopt(long)]
severity: Option<UpdateSeverity>,
/// updates with this status
#[structopt(long)]
status: Option<UpdateStatus>,
/// updates submitted before this date
#[structopt(long)]
submitted_before: Option<BodhiDate>,
/// updates submitted after this date
#[structopt(long)]
submitted_since: Option<BodhiDate>,
/// updates with logout / reboot suggestion
#[structopt(long)]
suggestion: Option<UpdateSuggestion>,
/// updates with this type
#[structopt(name = "type", long)]
update_type: Option<UpdateType>,
/// updates submitted by this user
#[structopt(long)]
users: Option<Vec<String>>,
/// Force long-running queries
#[structopt(long, short)]
force: bool,
},
/// Query bodhi for information about a release
ReleaseInfo {
/// ID of the release
release: String,
/// Output format (plain, JSON)
#[structopt(long)]
format: Option<Format>,
},
/// Query bodhi for active releases
ReleaseList {
/// Output format (plain, JSON)
#[structopt(long)]
format: Option<Format>,
},
/// Submit an update status request
UpdateRequest {
/// ID of the update
alias: String,
/// (obsolete, revoke, stable, testing, unpush)
request: UpdateRequest,
},
/// Waive an update's test results
WaiveTests {
/// ID of the update
alias: String,
/// comment submitted with the waiver
comment: String,
/// test results to be waived (default: empty / all)
#[structopt(long)]
tests: Option<Vec<String>>,
},
}
impl BaseCommand {
pub fn authenticated(&self) -> bool {
use BodhiCommand::*;
match self.subcommand {
Comment { .. } => true,
ComposeInfo { .. } => false,
ComposeList { .. } => false,
CreateOverride { .. } => true,
CreateUpdateOverride { .. } => true,
CreateUpdate { .. } => true,
EditOverride { .. } => true,
EditUpdate { .. } => true,
ExpireOverride { .. } => true,
QueryOverrides { .. } => false,
QueryUpdates { .. } => false,
ReleaseInfo { .. } => false,
ReleaseList { .. } => false,
UpdateRequest { .. } => true,
WaiveTests { .. } => true,
}
}
}