|
109 | 109 | //!
|
110 | 110 | use crate::error;
|
111 | 111 | use crate::error::OperatorResult;
|
112 |
| -#[allow(deprecated)] |
113 |
| -use crate::CustomResourceExt; |
114 |
| -use clap::{App, AppSettings, Arg, ArgMatches, Args}; |
| 112 | +use clap::Args; |
115 | 113 | use product_config::ProductConfigManager;
|
116 | 114 | use std::{
|
117 | 115 | ffi::OsStr,
|
@@ -251,119 +249,6 @@ fn resolve_path<'a>(
|
251 | 249 | })
|
252 | 250 | }
|
253 | 251 |
|
254 |
| -const PRODUCT_CONFIG_ARG: &str = "product-config"; |
255 |
| - |
256 |
| -/// Generates a clap [`Arg`] that can be used to accept the location of a product configuration file. |
257 |
| -/// |
258 |
| -/// Meant to be handled by [`handle_productconfig_arg`]. |
259 |
| -/// |
260 |
| -/// See the module level documentation for a complete example. |
261 |
| -#[deprecated(note = "use ProductConfigPath (or Command) instead")] |
262 |
| -pub fn generate_productconfig_arg() -> Arg<'static> { |
263 |
| - Arg::new(PRODUCT_CONFIG_ARG) |
264 |
| - .short('p') |
265 |
| - .long(PRODUCT_CONFIG_ARG) |
266 |
| - .value_name("FILE") |
267 |
| - .help("Provides the path to a product-config file") |
268 |
| - .takes_value(true) |
269 |
| -} |
270 |
| - |
271 |
| -/// Handles the `product-config` CLI option. |
272 |
| -/// |
273 |
| -/// See the module level documentation for a complete example. |
274 |
| -/// |
275 |
| -/// # Arguments |
276 |
| -/// |
277 |
| -/// * `default_locations`: These locations will be checked for the existence of a config file if the user doesn't provide one |
278 |
| -#[deprecated(note = "use ProductConfigPath (or Command) instead")] |
279 |
| -pub fn handle_productconfig_arg( |
280 |
| - matches: &ArgMatches, |
281 |
| - default_locations: Vec<&str>, |
282 |
| -) -> OperatorResult<String> { |
283 |
| - Ok(resolve_path( |
284 |
| - matches.value_of(PRODUCT_CONFIG_ARG).map(str::as_ref), |
285 |
| - &default_locations, |
286 |
| - )? |
287 |
| - .to_str() |
288 |
| - // ArgMatches::value_of and `str` both already validate UTF-8, so this should never be possible |
289 |
| - .expect("product-config path must be UTF-8") |
290 |
| - .to_owned()) |
291 |
| -} |
292 |
| - |
293 |
| -/// This will generate a clap subcommand ([`App`]) that can be used for operations on CRDs. |
294 |
| -/// |
295 |
| -/// Currently two arguments are supported: |
296 |
| -/// * `print`: This will print the schema to stdout |
297 |
| -/// * `save`: This will save the schema to a file |
298 |
| -/// |
299 |
| -/// The resulting subcommand can be handled by the [`self::handle_crd_subcommand`] method. |
300 |
| -/// |
301 |
| -/// See the module level documentation for a complete example. |
302 |
| -/// |
303 |
| -/// # Arguments |
304 |
| -/// |
305 |
| -/// * `name`: Name of the CRD |
306 |
| -/// |
307 |
| -/// returns: App |
308 |
| -#[deprecated(note = "use Command instead")] |
309 |
| -#[allow(deprecated)] |
310 |
| -pub fn generate_crd_subcommand<T>() -> App<'static> |
311 |
| -where |
312 |
| - T: CustomResourceExt, |
313 |
| -{ |
314 |
| - let kind = T::api_resource().kind; |
315 |
| - |
316 |
| - App::new(&kind.to_lowercase()) |
317 |
| - .setting(AppSettings::ArgRequiredElseHelp) |
318 |
| - .arg( |
319 |
| - Arg::with_name("print") |
320 |
| - .short('p') |
321 |
| - .long("print") |
322 |
| - .help("Will print the CRD schema in YAML format to stdout"), |
323 |
| - ) |
324 |
| - .arg( |
325 |
| - Arg::with_name("save") |
326 |
| - .short('s') |
327 |
| - .long("save") |
328 |
| - .takes_value(true) |
329 |
| - .value_name("FILE") |
330 |
| - .conflicts_with("print") |
331 |
| - .help("Will write the CRD schema in YAML format to the specified location"), |
332 |
| - ) |
333 |
| -} |
334 |
| - |
335 |
| -/// This will handle a subcommand generated by the [`self::generate_crd_subcommand`] method. |
336 |
| -/// |
337 |
| -/// The CRD and the name of the subcommand will be identified by the `kind` of the generic parameter `T` being passed in. |
338 |
| -/// |
339 |
| -/// See the module level documentation for a complete example. |
340 |
| -/// |
341 |
| -/// # Arguments |
342 |
| -/// |
343 |
| -/// * `matches`: The [`ArgMatches`] object which _might_ contain a match for our current CRD. |
344 |
| -/// |
345 |
| -/// returns: A boolean wrapped in a result indicating whether the this method did handle the argument. |
346 |
| -/// If it returns `Ok(true)` the program should abort. |
347 |
| -#[deprecated(note = "use Command instead")] |
348 |
| -#[allow(deprecated)] |
349 |
| -pub fn handle_crd_subcommand<T>(matches: &ArgMatches) -> OperatorResult<bool> |
350 |
| -where |
351 |
| - T: CustomResourceExt, |
352 |
| -{ |
353 |
| - if let Some(crd_match) = matches.subcommand_matches(T::api_resource().kind.to_lowercase()) { |
354 |
| - if crd_match.is_present("print") { |
355 |
| - T::print_yaml_schema()?; |
356 |
| - return Ok(true); |
357 |
| - } |
358 |
| - if let Some(value) = crd_match.value_of("save") { |
359 |
| - T::write_yaml_schema(value)?; |
360 |
| - return Ok(true); |
361 |
| - } |
362 |
| - } |
363 |
| - |
364 |
| - Ok(false) |
365 |
| -} |
366 |
| - |
367 | 252 | #[cfg(test)]
|
368 | 253 | mod tests {
|
369 | 254 | use super::*;
|
|
0 commit comments