|
| 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 | + |
| 8 | +use crate::{time::Duration, versioned::versioned}; |
| 9 | + |
| 10 | +mod v1alpha1_impl; |
| 11 | + |
| 12 | +#[versioned(version(name = "v1alpha1"))] |
| 13 | +pub mod versioned { |
| 14 | + pub mod v1alpha1 { |
| 15 | + pub use v1alpha1_impl::{Error, GitSyncResources}; |
| 16 | + } |
| 17 | + |
| 18 | + #[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Eq, Serialize)] |
| 19 | + #[serde(rename_all = "camelCase")] |
| 20 | + pub struct GitSync { |
| 21 | + /// The git repository URL that will be cloned, for example: `https://github.com/stackabletech/airflow-operator`. |
| 22 | + pub repo: String, |
| 23 | + |
| 24 | + /// The branch to clone; defaults to `main`. |
| 25 | + /// |
| 26 | + /// Since git-sync v4.x.x this field is mapped to the flag `--ref`. |
| 27 | + #[serde(default = "GitSync::default_branch")] |
| 28 | + pub branch: String, |
| 29 | + |
| 30 | + /// The location of the DAG folder, relative to the synced repository root. |
| 31 | + /// |
| 32 | + /// It can optionally start with `/`, however, no trailing slash is recommended. |
| 33 | + /// An empty string (``) or slash (`/`) corresponds to the root folder in Git. |
| 34 | + #[serde(default = "GitSync::default_git_folder")] |
| 35 | + pub git_folder: PathBuf, |
| 36 | + |
| 37 | + /// The depth of syncing, i.e. the number of commits to clone; defaults to 1. |
| 38 | + #[serde(default = "GitSync::default_depth")] |
| 39 | + pub depth: u32, |
| 40 | + |
| 41 | + /// The synchronization interval, e.g. `20s` or `5m`; defaults to `20s`. |
| 42 | + /// |
| 43 | + /// Since git-sync v4.x.x this field is mapped to the flag `--period`. |
| 44 | + #[serde(default = "GitSync::default_wait")] |
| 45 | + pub wait: Duration, |
| 46 | + |
| 47 | + /// The name of the Secret used to access the repository if it is not public. |
| 48 | + /// This should include two fields: `user` and `password`. |
| 49 | + /// The `password` field can either be an actual password (not recommended) or a GitHub token, |
| 50 | + /// as described [here](https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual). |
| 51 | + pub credentials_secret: Option<String>, |
| 52 | + |
| 53 | + /// 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). |
| 54 | + /// Read the [git sync example](DOCS_BASE_URL_PLACEHOLDER/airflow/usage-guide/mounting-dags#_example). |
| 55 | + #[serde(default)] |
| 56 | + pub git_sync_conf: BTreeMap<String, String>, |
| 57 | + } |
| 58 | +} |
0 commit comments