Skip to content

Commit 53cc3fc

Browse files
committed
Create argocd-namespace before applying 'secrets' folder
1 parent d980504 commit 53cc3fc

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

src/argocd.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ pub struct ArgoCDOptions<'a> {
1010

1111
const CONFIG_PATH: &str = "argocd-config";
1212

13+
pub async fn create_namespace() -> Result<(), Box<dyn Error>> {
14+
15+
match run_command("kubectl create ns argocd", None).await {
16+
Ok(_) => (),
17+
Err(e) => {
18+
error!("❌ Failed to create namespace argocd");
19+
panic!("error: {}", String::from_utf8_lossy(&e.stderr))
20+
}
21+
}
22+
23+
debug!("🦑 Namespace argocd created successfully");
24+
Ok(())
25+
}
26+
1327
pub async fn install_argo_cd(options: ArgoCDOptions<'_>) -> Result<(), Box<dyn Error>> {
1428
info!(
1529
"🦑 Installing Argo CD Helm Chart version: '{}'",
@@ -37,15 +51,6 @@ pub async fn install_argo_cd(options: ArgoCDOptions<'_>) -> Result<(), Box<dyn E
3751
}
3852
};
3953

40-
// create namespace argocd
41-
match run_command("kubectl create ns argocd", None).await {
42-
Ok(_) => (),
43-
Err(e) => {
44-
error!("❌ Failed to create namespace argocd");
45-
panic!("error: {}", String::from_utf8_lossy(&e.stderr))
46-
}
47-
}
48-
4954
// add argo repo to helm
5055
match run_command(
5156
"helm repo add argo https://argoproj.github.io/argo-helm",

src/main.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
348348
ClusterTool::Minikube => minikube::create_cluster().await?,
349349
}
350350

351-
argocd::install_argo_cd(argocd::ArgoCDOptions {
352-
version: argocd_version,
353-
debug: opt.debug,
354-
})
355-
.await?;
351+
argocd::create_namespace().await?;
356352

357353
create_folder_if_not_exists(secrets_folder);
358354
match apply_folder(secrets_folder) {
@@ -364,6 +360,12 @@ async fn main() -> Result<(), Box<dyn Error>> {
364360
}
365361
}
366362

363+
argocd::install_argo_cd(argocd::ArgoCDOptions {
364+
version: argocd_version,
365+
debug: opt.debug,
366+
})
367+
.await?;
368+
367369
fs::write(apps_file(&Branch::Base), applications_to_string(base_apps))?;
368370
fs::write(
369371
apps_file(&Branch::Target),

0 commit comments

Comments
 (0)