Skip to content

Commit

Permalink
Create argocd-namespace before applying 'secrets' folder
Browse files Browse the repository at this point in the history
  • Loading branch information
dag-andersen committed Oct 26, 2024
1 parent d980504 commit 53cc3fc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
23 changes: 14 additions & 9 deletions src/argocd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ pub struct ArgoCDOptions<'a> {

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

pub async fn create_namespace() -> Result<(), Box<dyn Error>> {

match run_command("kubectl create ns argocd", None).await {
Ok(_) => (),
Err(e) => {
error!("❌ Failed to create namespace argocd");
panic!("error: {}", String::from_utf8_lossy(&e.stderr))
}
}

debug!("🦑 Namespace argocd created successfully");
Ok(())
}

pub async fn install_argo_cd(options: ArgoCDOptions<'_>) -> Result<(), Box<dyn Error>> {
info!(
"🦑 Installing Argo CD Helm Chart version: '{}'",
Expand Down Expand Up @@ -37,15 +51,6 @@ pub async fn install_argo_cd(options: ArgoCDOptions<'_>) -> Result<(), Box<dyn E
}
};

// create namespace argocd
match run_command("kubectl create ns argocd", None).await {
Ok(_) => (),
Err(e) => {
error!("❌ Failed to create namespace argocd");
panic!("error: {}", String::from_utf8_lossy(&e.stderr))
}
}

// add argo repo to helm
match run_command(
"helm repo add argo https://argoproj.github.io/argo-helm",
Expand Down
12 changes: 7 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
ClusterTool::Minikube => minikube::create_cluster().await?,
}

argocd::install_argo_cd(argocd::ArgoCDOptions {
version: argocd_version,
debug: opt.debug,
})
.await?;
argocd::create_namespace().await?;

create_folder_if_not_exists(secrets_folder);
match apply_folder(secrets_folder) {
Expand All @@ -364,6 +360,12 @@ async fn main() -> Result<(), Box<dyn Error>> {
}
}

argocd::install_argo_cd(argocd::ArgoCDOptions {
version: argocd_version,
debug: opt.debug,
})
.await?;

fs::write(apps_file(&Branch::Base), applications_to_string(base_apps))?;
fs::write(
apps_file(&Branch::Target),
Expand Down

0 comments on commit 53cc3fc

Please sign in to comment.