Skip to content

Commit 5d837cc

Browse files
feat(stackable-operator): Add git-sync support (#1024)
* Add git-sync support * Version the git_sync structure as v1alpha1 * Rephrase the comment for GitSync::git_folder * Add logging support to git-sync containers * Use the type Url for the git-sync repository URL * Extend the comment of the GitSync structure * Improve a comment in the GitSync structure Co-authored-by: Techassi <[email protected]> * Extend the comment of the GitSync structure * Reformat the code Co-authored-by: Techassi <[email protected]> * Improve the code style Co-authored-by: Techassi <[email protected]> * Improve the code style Co-authored-by: Techassi <[email protected]> * Improve the code style Co-authored-by: Techassi <[email protected]> * Improve the code style Co-authored-by: Techassi <[email protected]> * Add always the git-sync parameter one-time * Improve the code style Co-authored-by: Techassi <[email protected]> * Improve the code style * Disallow variants of the option `--git-config` * Extend a comment in the GitSync structure --------- Co-authored-by: Techassi <[email protected]>
1 parent 9a4c959 commit 5d837cc

File tree

5 files changed

+1101
-0
lines changed

5 files changed

+1101
-0
lines changed

crates/stackable-operator/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Add git-sync support ([#1024]).
10+
11+
[#1024]: https://github.com/stackabletech/operator-rs/pull/1024
12+
713
## [0.93.0] - 2025-05-19
814

915
### Changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//! GitSync structure for CRDs
2+
3+
use std::{collections::BTreeMap, path::PathBuf};
4+
5+
use schemars::{self, JsonSchema};
6+
use serde::{Deserialize, Serialize};
7+
use url::Url;
8+
9+
use crate::{time::Duration, versioned::versioned};
10+
11+
mod v1alpha1_impl;
12+
13+
#[versioned(version(name = "v1alpha1"))]
14+
pub mod versioned {
15+
pub mod v1alpha1 {
16+
pub use v1alpha1_impl::{Error, GitSyncResources};
17+
}
18+
19+
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Eq, Serialize)]
20+
#[serde(rename_all = "camelCase")]
21+
pub struct GitSync {
22+
/// The git repository URL that will be cloned, for example: `https://github.com/stackabletech/airflow-operator`.
23+
pub repo: Url,
24+
25+
/// The branch to clone; defaults to `main`.
26+
///
27+
/// Since git-sync v4.x.x this field is mapped to the flag `--ref`.
28+
#[serde(default = "GitSync::default_branch")]
29+
pub branch: String,
30+
31+
/// Location in the Git repository containing the resource; defaults to the root folder.
32+
///
33+
/// It can optionally start with `/`, however, no trailing slash is recommended.
34+
/// An empty string (``) or slash (`/`) corresponds to the root folder in Git.
35+
#[serde(default = "GitSync::default_git_folder")]
36+
pub git_folder: PathBuf,
37+
38+
/// The depth of syncing, i.e. the number of commits to clone; defaults to 1.
39+
#[serde(default = "GitSync::default_depth")]
40+
pub depth: u32,
41+
42+
/// The synchronization interval, e.g. `20s` or `5m`; defaults to `20s`.
43+
///
44+
/// Since git-sync v4.x.x this field is mapped to the flag `--period`.
45+
#[serde(default = "GitSync::default_wait")]
46+
pub wait: Duration,
47+
48+
/// The name of the Secret used to access the repository if it is not public.
49+
///
50+
/// The referenced Secret must include two fields: `user` and `password`.
51+
/// The `password` field can either be an actual password (not recommended) or a GitHub token,
52+
/// as described in the git-sync [documentation].
53+
///
54+
/// [documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
55+
pub credentials_secret: Option<String>,
56+
57+
/// A map of optional configuration settings that are listed in the git-sync [documentation].
58+
///
59+
/// Also read the git-sync [example] in our documentation. These settings are not verified.
60+
///
61+
/// [documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
62+
/// [example]: DOCS_BASE_URL_PLACEHOLDER/airflow/usage-guide/mounting-dags#_example
63+
#[serde(default)]
64+
pub git_sync_conf: BTreeMap<String, String>,
65+
}
66+
}

0 commit comments

Comments
 (0)