Skip to content

Commit

Permalink
test: add unit test for extractor
Browse files Browse the repository at this point in the history
Signed-off-by: iGxnon <[email protected]>
  • Loading branch information
iGxnon committed Sep 6, 2023
1 parent e87b040 commit d2da805
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 70 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions operator-k8s/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ event-listener = "2.5.3"

[dev-dependencies]
garde = { version = "0.11.2", default-features = false, features = ["derive", "pattern"] }
serde_yaml = "0.9.25"
2 changes: 2 additions & 0 deletions operator-k8s/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ pub(crate) const ANNOTATION_INHERIT_LABELS_PREFIX: &str =
pub(crate) const LABEL_CLUSTER_NAME: &str = "xlinecluster/name";
/// The label attach to subresources, indicate the component type of this subresource
pub(crate) const LABEL_CLUSTER_COMPONENT: &str = "xlinecluster/component";
/// Indicate the version of operator that creates this subresource
pub(crate) const LABEL_OPERATOR_VERSION: &str = "xlinecluster/operator-version";
9 changes: 9 additions & 0 deletions operator-k8s/src/crd/v1alpha1/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ pub(crate) enum StorageSpec {
},
}

impl StorageSpec {
pub(crate) fn as_pvc(&self) -> Option<&PersistentVolumeClaim> {
match *self {
Self::Pvc { ref pvc } => Some(pvc),
Self::S3 { .. } => None,
}
}
}

/// Xline cluster backup S3 specification
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[cfg_attr(test, derive(Validate))]
Expand Down
3 changes: 1 addition & 2 deletions operator-k8s/src/crd/v1alpha1/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(unused)] // TODO: remove when this CRD is used

pub(crate) use cluster::Cluster;
pub(crate) use cluster::StorageSpec;
pub(crate) use cluster::{BackupSpec, Cluster, ClusterSpec, StorageSpec};

mod cluster;
Loading

0 comments on commit d2da805

Please sign in to comment.