Skip to content

Commit 354c9e6

Browse files
committed
move default functions to non-versioned functions
1 parent 91c98d3 commit 354c9e6

2 files changed

Lines changed: 20 additions & 23 deletions

File tree

crates/stackable-operator/src/crd/git_sync/mod.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ pub mod versioned {
3030
/// The branch to clone; defaults to `main`.
3131
///
3232
/// Since git-sync v4.x.x this field is mapped to the flag `--ref`.
33-
#[serde(default = "v1alpha2::GitSync::default_branch")]
33+
#[serde(default = "default_branch")]
3434
pub branch: String,
3535

3636
/// Location in the Git repository containing the resource; defaults to the root folder.
3737
///
3838
/// It can optionally start with `/`, however, no trailing slash is recommended.
3939
/// An empty string (``) or slash (`/`) corresponds to the root folder in Git.
40-
#[serde(default = "v1alpha2::GitSync::default_git_folder")]
40+
#[serde(default = "default_git_folder")]
4141
pub git_folder: PathBuf,
4242

4343
/// The depth of syncing, i.e. the number of commits to clone; defaults to 1.
44-
#[serde(default = "v1alpha2::GitSync::default_depth")]
44+
#[serde(default = "default_depth")]
4545
pub depth: u32,
4646

4747
/// The synchronization interval, e.g. `20s` or `5m`; defaults to `20s`.
4848
///
4949
/// Since git-sync v4.x.x this field is mapped to the flag `--period`.
50-
#[serde(default = "v1alpha2::GitSync::default_wait")]
50+
#[serde(default = "default_wait")]
5151
pub wait: Duration,
5252

5353
/// A map of optional configuration settings that are listed in the git-sync [documentation].
@@ -91,6 +91,22 @@ pub mod versioned {
9191
}
9292
}
9393

94+
pub(crate) fn default_branch() -> String {
95+
"main".to_string()
96+
}
97+
98+
pub(crate) fn default_git_folder() -> PathBuf {
99+
PathBuf::from("/")
100+
}
101+
102+
pub(crate) fn default_depth() -> u32 {
103+
1
104+
}
105+
106+
pub(crate) fn default_wait() -> Duration {
107+
Duration::from_secs(20)
108+
}
109+
94110
pub fn credentials_to_secret(input: Option<Credentials>) -> Option<String> {
95111
if let Some(Credentials::BasicAuthSecretName(credentials_secret)) = input {
96112
Some(credentials_secret)

crates/stackable-operator/src/crd/git_sync/v1alpha2_impl.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use k8s_openapi::api::core::v1::{
44
Container, EmptyDirVolumeSource, EnvVar, EnvVarSource, SecretKeySelector, Volume, VolumeMount,
55
};
66
use snafu::{ResultExt, Snafu};
7-
use stackable_shared::time::Duration;
87
use strum::{EnumDiscriminants, IntoStaticStr};
98

109
use crate::{
@@ -46,24 +45,6 @@ pub enum Error {
4645
},
4746
}
4847

49-
impl GitSync {
50-
pub(crate) fn default_branch() -> String {
51-
"main".to_string()
52-
}
53-
54-
pub(crate) fn default_git_folder() -> PathBuf {
55-
PathBuf::from("/")
56-
}
57-
58-
pub(crate) fn default_depth() -> u32 {
59-
1
60-
}
61-
62-
pub(crate) fn default_wait() -> Duration {
63-
Duration::from_secs(20)
64-
}
65-
}
66-
6748
/// Kubernetes resources generated from `GitSync` specifications which should be added to the Pod.
6849
#[derive(Default)]
6950
pub struct GitSyncResources {

0 commit comments

Comments
 (0)