Skip to content

Commit 020906f

Browse files
bors[bot]nightkr
andauthored
Merge #320
320: Burn deprecated stuff r=teozkr a=teozkr ## Description Fixes #316 ## Review Checklist - [ ] Code contains useful comments - [ ] (Integration-)Test cases added (or not applicable) - [ ] Documentation added (or not applicable) - [ ] Changelog updated (or not applicable) Co-authored-by: Teo Klestrup Röijezon <[email protected]>
2 parents 5fcf51b + 2a4d39a commit 020906f

25 files changed

+16
-5619
lines changed

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ All notable changes to this project will be documented in this file.
99

1010
### Removed
1111
- Chrono's time 0.1 compatibility ([#310]).
12+
- Deprecated pre-rework utilities ([#320]).
1213

1314
[#310]: https://github.com/stackabletech/operator-rs/pull/310
1415
[#319]: https://github.com/stackabletech/operator-rs/pull/319
16+
[#320]: https://github.com/stackabletech/operator-rs/pull/320
1517

1618
## [0.10.0] - 2022-02-04
1719

Diff for: src/cli.rs

+1-116
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@
109109
//!
110110
use crate::error;
111111
use crate::error::OperatorResult;
112-
#[allow(deprecated)]
113-
use crate::CustomResourceExt;
114-
use clap::{App, AppSettings, Arg, ArgMatches, Args};
112+
use clap::Args;
115113
use product_config::ProductConfigManager;
116114
use std::{
117115
ffi::OsStr,
@@ -251,119 +249,6 @@ fn resolve_path<'a>(
251249
})
252250
}
253251

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-
367252
#[cfg(test)]
368253
mod tests {
369254
use super::*;

Diff for: src/client.rs

+3-25
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use crate::error::{Error, OperatorResult};
2-
#[allow(deprecated)]
3-
use crate::finalizer;
42
use crate::label_selector;
5-
use crate::pod_utils;
63

74
use backoff::backoff::Backoff;
85
use backoff::ExponentialBackoff;
@@ -341,37 +338,18 @@ impl Client {
341338

342339
/// This deletes a resource _if it is not deleted already_.
343340
///
344-
/// It checks whether the resource is already deleted by looking at the `deletion_timestamp`
345-
/// of the resource using the [`finalizer::has_deletion_stamp`] method.
346-
/// If that is the case it'll return a `Ok(None)`.
347-
///
348341
/// In case the object is actually deleted or marked for deletion there are two possible
349342
/// return types.
350343
/// Which of the two are returned depends on the API being called.
351344
/// Take a look at the Kubernetes API reference.
352345
/// Some `delete` endpoints return the object and others return a `Status` object.
353-
#[allow(deprecated)]
354-
pub async fn delete<T>(&self, resource: &T) -> OperatorResult<Option<Either<T, Status>>>
346+
pub async fn delete<T>(&self, resource: &T) -> OperatorResult<Either<T, Status>>
355347
where
356348
T: Clone + Debug + DeserializeOwned + Resource,
357349
<T as Resource>::DynamicType: Default,
358350
{
359-
if finalizer::has_deletion_stamp(resource) {
360-
trace!(
361-
"Resource ([{}]) already has `deletion_timestamp`, not deleting",
362-
pod_utils::get_log_name(resource)
363-
);
364-
Ok(None)
365-
} else {
366-
trace!(
367-
"Resource ([{}]) does not have a `deletion_timestamp`, deleting now",
368-
pod_utils::get_log_name(resource)
369-
);
370-
let api: Api<T> = self.get_api(resource.namespace().as_deref());
371-
Ok(Some(
372-
api.delete(&resource.name(), &self.delete_params).await?,
373-
))
374-
}
351+
let api: Api<T> = self.get_api(resource.namespace().as_deref());
352+
Ok(api.delete(&resource.name(), &self.delete_params).await?)
375353
}
376354

377355
/// This deletes a resource _if it is not deleted already_ and waits until the deletion is

0 commit comments

Comments
 (0)