Skip to content

feat(stackable-operator): Add git-sync support #1024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

- Add git-sync support ([#1024]).

### Changed

- BREAKING: Version common CRD structs and enums ([#968]).
Expand All @@ -17,6 +21,7 @@ All notable changes to this project will be documented in this file.
- Re-export versioned CRD-specific error types ([#1025]).

[#968]: https://github.com/stackabletech/operator-rs/pull/968
[#1024]: https://github.com/stackabletech/operator-rs/pull/1024
[#1025]: https://github.com/stackabletech/operator-rs/pull/1025

## [0.92.0] - 2025-04-14
Expand Down
58 changes: 58 additions & 0 deletions crates/stackable-operator/src/crd/git_sync/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//! GitSync structure for CRDs

use std::{collections::BTreeMap, path::PathBuf};

use schemars::{self, JsonSchema};
use serde::{Deserialize, Serialize};

use crate::{time::Duration, versioned::versioned};

mod v1alpha1_impl;

#[versioned(version(name = "v1alpha1"))]
pub mod versioned {
pub mod v1alpha1 {
pub use v1alpha1_impl::{Error, GitSyncResources};
}

#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GitSync {
/// The git repository URL that will be cloned, for example: `https://github.com/stackabletech/airflow-operator`.
pub repo: String,

/// The branch to clone; defaults to `main`.
///
/// Since git-sync v4.x.x this field is mapped to the flag `--ref`.
#[serde(default = "GitSync::default_branch")]
pub branch: String,

/// The location of the DAG folder, relative to the synced repository root.
///
/// It can optionally start with `/`, however, no trailing slash is recommended.
/// An empty string (``) or slash (`/`) corresponds to the root folder in Git.
#[serde(default = "GitSync::default_git_folder")]
pub git_folder: PathBuf,

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

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

/// The name of the Secret used to access the repository if it is not public.
/// This should include two fields: `user` and `password`.
/// The `password` field can either be an actual password (not recommended) or a GitHub token,
/// as described [here](https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual).
pub credentials_secret: Option<String>,

/// A map of optional configuration settings that are listed in the [git-sync documentation](https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual).
/// Read the [git sync example](DOCS_BASE_URL_PLACEHOLDER/airflow/usage-guide/mounting-dags#_example).
#[serde(default)]
pub git_sync_conf: BTreeMap<String, String>,
}
}
Loading