|
| 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