forked from github-starred/komodo
v1.12 Custom Git Providers / Docker Registries (#8)
* update deps * remove patch when 0 for deployments using specific build version * implement custom git provider and image registry support * common providers api * toml array alias * username alias account * get fe to build * http or https * fix frontend build * improve registry / provider config * frontend build * rework deployment / builds image registry * frontend builds * update build config fe * configure builder additional accounts / secrets * guard against managing non-github repo webhooks * fmt * md size dashboard * lowercase organization in image name * update config docs * update example env * provider configuration * distribute migrator * fix casing mismatch * docs
This commit is contained in:
@@ -67,17 +67,19 @@ pub async fn pull(
|
||||
logs
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(github_token))]
|
||||
#[tracing::instrument(level = "debug", skip(access_token))]
|
||||
pub async fn clone<T>(
|
||||
clone_args: T,
|
||||
repo_dir: &Path,
|
||||
github_token: Option<String>,
|
||||
access_token: Option<String>,
|
||||
) -> anyhow::Result<Vec<Log>>
|
||||
where
|
||||
T: Into<CloneArgs> + std::fmt::Debug,
|
||||
{
|
||||
let CloneArgs {
|
||||
name,
|
||||
provider,
|
||||
https,
|
||||
repo,
|
||||
branch,
|
||||
commit,
|
||||
@@ -87,7 +89,11 @@ where
|
||||
..
|
||||
} = clone_args.into();
|
||||
|
||||
let repo = repo.as_ref().context("build has no repo attached")?;
|
||||
let provider = provider
|
||||
.as_ref()
|
||||
.context("resource has no provider attached")?;
|
||||
let repo =
|
||||
repo.as_ref().context("resource has no repo attached")?;
|
||||
let name = to_monitor_name(&name);
|
||||
|
||||
let repo_dir = match destination {
|
||||
@@ -96,12 +102,19 @@ where
|
||||
None => repo_dir.join(name),
|
||||
};
|
||||
|
||||
let mut logs =
|
||||
clone_inner(repo, &repo_dir, &branch, &commit, github_token)
|
||||
.await;
|
||||
let mut logs = clone_inner(
|
||||
provider,
|
||||
https,
|
||||
repo,
|
||||
&branch,
|
||||
&commit,
|
||||
&repo_dir,
|
||||
access_token,
|
||||
)
|
||||
.await;
|
||||
|
||||
if !all_logs_success(&logs) {
|
||||
tracing::warn!("repo at {repo_dir:?} failed to clone");
|
||||
tracing::warn!("failed to clone repo at {repo_dir:?}");
|
||||
return Ok(logs);
|
||||
}
|
||||
|
||||
@@ -158,10 +171,12 @@ where
|
||||
skip(destination, access_token)
|
||||
)]
|
||||
async fn clone_inner(
|
||||
provider: &str,
|
||||
https: bool,
|
||||
repo: &str,
|
||||
destination: &Path,
|
||||
branch: &Option<String>,
|
||||
commit: &Option<String>,
|
||||
destination: &Path,
|
||||
access_token: Option<String>,
|
||||
) -> Vec<Log> {
|
||||
let _ = std::fs::remove_dir_all(destination);
|
||||
@@ -173,8 +188,9 @@ async fn clone_inner(
|
||||
Some(branch) => format!(" -b {branch}"),
|
||||
None => String::new(),
|
||||
};
|
||||
let protocol = if https { "https" } else { "http" };
|
||||
let repo_url =
|
||||
format!("https://{access_token_at}github.com/{repo}.git");
|
||||
format!("{protocol}://{access_token_at}{provider}/{repo}.git");
|
||||
let command =
|
||||
format!("git clone {repo_url} {}{branch}", destination.display());
|
||||
let start_ts = monitor_timestamp();
|
||||
|
||||
Reference in New Issue
Block a user