Skip to content

Commit b9ea275

Browse files
committed
Added support for specifying argocd version
1 parent 2a80af3 commit b9ea275

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ FLAGS:
281281
-V, --version Prints version information
282282

283283
OPTIONS:
284+
--argocd-version <argocd-version> Argo CD version [env: ARGOCD_VERSION=] [default: stable]
284285
-b, --base-branch <base-branch> Base branch name [env: BASE_BRANCH=] [default: main]
285286
--base-branch-folder <folder> Base branch folder [env: BASE_BRANCH_FOLDER=] [default: base-branch]
286287
-i, --diff-ignore <diff-ignore> Ignore lines in diff. Example: use 'v[1,9]+.[1,9]+.[1,9]+' for ignoring changes caused by version changes following semver [env: DIFF_IGNORE=]

src/argocd.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ data:
2323
reposerver.parallelism.limit: "300"
2424
"#;
2525

26-
pub async fn install_argo_cd() -> Result<(), Box<dyn Error>> {
26+
pub async fn install_argo_cd(version: Option<&str>) -> Result<(), Box<dyn Error>> {
2727
info!("🦑 Installing Argo CD...");
2828

2929
match run_command("kubectl create ns argocd", None).await {
@@ -35,7 +35,11 @@ pub async fn install_argo_cd() -> Result<(), Box<dyn Error>> {
3535
}
3636

3737
// Install Argo CD
38-
match run_command("kubectl -n argocd apply -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml", None).await {
38+
let install_url = format!(
39+
"https://raw.githubusercontent.com/argoproj/argo-cd/{}/manifests/install.yaml",
40+
version.unwrap_or("stable")
41+
);
42+
match run_command(&format!("kubectl -n argocd apply -f {}", install_url), None).await {
3943
Ok(_) => (),
4044
Err(e) => {
4145
error!("❌ Failed to install Argo CD");

src/main.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ struct Opt {
4444
#[structopt(short = "i", long, env)]
4545
diff_ignore: Option<String>,
4646

47+
/// Argo CD version. Default: stable
48+
#[structopt(long, env)]
49+
argocd_version: Option<String>,
50+
4751
/// Base branch name
4852
#[structopt(short, long, default_value = "main", env)]
4953
base_branch: String,
@@ -137,6 +141,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
137141
let timeout = opt.timeout;
138142
let output_folder = opt.output_folder.as_str();
139143
let secrets_folder = opt.secrets_folder.as_str();
144+
let argocd_version = opt.argocd_version.as_deref();
140145

141146
// select local cluster tool
142147
let tool = match opt.local_cluster_tool {
@@ -172,6 +177,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
172177
if let Some(a) = diff_ignore.clone() {
173178
info!("✨ - diff-ignore: {}", a);
174179
}
180+
if let Some(a) = argocd_version {
181+
info!("✨ - argocd-version: {}", a);
182+
}
175183

176184
if !check_if_folder_exists(&base_branch_folder) {
177185
error!(
@@ -195,12 +203,12 @@ async fn main() -> Result<(), Box<dyn Error>> {
195203
ClusterTool::Kind => kind::create_cluster(&cluster_name).await?,
196204
ClusterTool::Minikube => minikube::create_cluster().await?,
197205
}
198-
argocd::install_argo_cd().await?;
206+
argocd::install_argo_cd(argocd_version).await?;
199207

200208
create_folder_if_not_exists(secrets_folder);
201209
match apply_folder(secrets_folder) {
202210
Ok(count) if count > 0 => info!("🤫 Applied {} secrets", count),
203-
Ok(_) => info!("🤷‍♂️ No secrets found in {}", secrets_folder),
211+
Ok(_) => info!("🤷 No secrets found in {}", secrets_folder),
204212
Err(e) => {
205213
error!("❌ Failed to apply secrets");
206214
panic!("error: {}", e)

0 commit comments

Comments
 (0)