syncable_cli/analyzer/kubelint/context/
mod.rs1pub mod object;
7
8pub use object::{InvalidObject, K8sObject, Object, ObjectMetadata};
9
10pub trait LintContext: Send + Sync {
12 fn objects(&self) -> &[Object];
14
15 fn invalid_objects(&self) -> &[InvalidObject];
17}
18
19#[derive(Debug, Default)]
21pub struct LintContextImpl {
22 objects: Vec<Object>,
23 invalid_objects: Vec<InvalidObject>,
24}
25
26impl LintContextImpl {
27 pub fn new() -> Self {
29 Self::default()
30 }
31
32 pub fn add_object(&mut self, object: Object) {
34 self.objects.push(object);
35 }
36
37 pub fn add_invalid_object(&mut self, invalid: InvalidObject) {
39 self.invalid_objects.push(invalid);
40 }
41
42 pub fn objects_mut(&mut self) -> &mut Vec<Object> {
44 &mut self.objects
45 }
46}
47
48impl LintContext for LintContextImpl {
49 fn objects(&self) -> &[Object] {
50 &self.objects
51 }
52
53 fn invalid_objects(&self) -> &[InvalidObject] {
54 &self.invalid_objects
55 }
56}