-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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, | ||||||||||||||||||||||||||||
Comment on lines
+21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: Is there any particular reason why this field is named note: Additionally, the type of this field should be |
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
/// 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, | ||||||||||||||||||||||||||||
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: This is a perfect case for a future |
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
/// Location in the Git repository containing the resource. | ||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||
/// 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, | ||||||||||||||||||||||||||||
Comment on lines
+30
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: All other fields document the default value. This one should then also do that. |
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
/// 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, | ||||||||||||||||||||||||||||
Comment on lines
+43
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: Another candidate for version |
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
/// 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>, | ||||||||||||||||||||||||||||
Comment on lines
+47
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Add newline between first line and the rest of the comment. Also some slight rewording.
Suggested change
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
/// 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>, | ||||||||||||||||||||||||||||
Comment on lines
+53
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Rename the field and slightly re-format the doc comment.
Suggested change
|
||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Nice job versioning this right from the start!