Skip to content

Commit 45dee89

Browse files
committed
refactor(argocd): improve repository authentication handling
- use try() function to handle optional authentication fields - remove insecure_ignore_host_key when repo_auth_type is not ssh
1 parent fcf7c14 commit 45dee89

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

main.tf

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,17 @@ resource "argocd_repository" "app_repo" {
6969
project = argocd_project.app_project.metadata[0].name
7070

7171
# SSH Authentication
72-
ssh_private_key = local.repo_config.ssh_private_key
73-
insecure_ignore_host_key = var.repo_auth_type == "ssh" ? var.insecure_ignore_host_key : null
72+
ssh_private_key = try(local.repo_config.ssh_private_key, null)
7473

7574
# HTTPS/Token Authentication
76-
username = local.repo_config.username
77-
password = local.repo_config.password
75+
username = try(local.repo_config.username, null)
76+
password = try(local.repo_config.password, null)
7877

7978
# GitHub App Authentication
80-
githubapp_id = local.repo_config.githubapp_id
81-
githubapp_installation_id = local.repo_config.githubapp_installation_id
82-
githubapp_private_key = local.repo_config.githubapp_private_key
83-
githubapp_enterprise_base_url = local.repo_config.githubapp_enterprise_base_url
79+
githubapp_id = try(local.repo_config.githubapp_id, null)
80+
githubapp_installation_id = try(local.repo_config.githubapp_installation_id, null)
81+
githubapp_private_key = try(local.repo_config.githubapp_private_key, null)
82+
githubapp_enterprise_base_url = try(local.repo_config.githubapp_enterprise_base_url, null)
8483

8584
# Additional repository settings
8685
enable_lfs = var.enable_git_lfs

0 commit comments

Comments
 (0)