syncable_cli/analyzer/kubelint/objectkinds/
mod.rs1use crate::analyzer::kubelint::types::ObjectKind;
6
7pub fn matches_kind(specifier: &str, kind: &ObjectKind) -> bool {
12 match specifier {
13 "DeploymentLike" => kind.is_deployment_like(),
14 "JobLike" => kind.is_job_like(),
15 "Any" => true,
16 _ => specifier == kind.as_str(),
17 }
18}
19
20pub fn expand_kind_specifier(specifier: &str) -> Vec<ObjectKind> {
22 match specifier {
23 "DeploymentLike" => vec![
24 ObjectKind::Deployment,
25 ObjectKind::StatefulSet,
26 ObjectKind::DaemonSet,
27 ObjectKind::ReplicaSet,
28 ObjectKind::Pod,
29 ObjectKind::Job,
30 ObjectKind::CronJob,
31 ObjectKind::DeploymentConfig,
32 ],
33 "JobLike" => vec![ObjectKind::Job, ObjectKind::CronJob],
34 "Any" => vec![
35 ObjectKind::Deployment,
36 ObjectKind::StatefulSet,
37 ObjectKind::DaemonSet,
38 ObjectKind::ReplicaSet,
39 ObjectKind::Pod,
40 ObjectKind::Job,
41 ObjectKind::CronJob,
42 ObjectKind::Service,
43 ObjectKind::Ingress,
44 ObjectKind::NetworkPolicy,
45 ObjectKind::Role,
46 ObjectKind::ClusterRole,
47 ObjectKind::RoleBinding,
48 ObjectKind::ClusterRoleBinding,
49 ObjectKind::ServiceAccount,
50 ObjectKind::HorizontalPodAutoscaler,
51 ObjectKind::PodDisruptionBudget,
52 ],
53 _ => ObjectKind::from_kind(specifier)
54 .map(|k| vec![k])
55 .unwrap_or_default(),
56 }
57}