Skip to content

Commit 2bdbf5c

Browse files
authored
Prevent permanent diff on argocd_repository with inherited credentials (#296)
* fix: prevent permanent diff on repository with inherited credentials * build: bump test versions to latest patch(es)
1 parent f54c0dc commit 2bdbf5c

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
strategy:
4949
fail-fast: false
5050
matrix:
51-
argocd_version: ["v2.5.0", "v2.5.17", "v2.6.0", "v2.6.8", "v2.7.3"]
51+
argocd_version: ["v2.5.18", "v2.6.9", "v2.7.4"]
5252
steps:
5353
- name: Check out code
5454
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

argocd/structure_repository.go

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,30 @@ func flattenRepository(repository *application.Repository, d *schema.ResourceDat
9696
"insecure": repository.Insecure,
9797
"name": repository.Name,
9898
"project": repository.Project,
99-
// TODO: in case of repositoryCredentials existence, will perma-diff
100-
//"username": repository.Username,
101-
// TODO: ArgoCD API does not return sensitive data!
102-
//"password": repository.Password,
103-
//"ssh_private_key": repository.SSHPrivateKey,
104-
//"tls_client_cert_key": repository.TLSClientCertKey,
105-
"tls_client_cert_data": repository.TLSClientCertData,
106-
"type": repository.Type,
107-
"githubapp_enterprise_base_url": repository.GitHubAppEnterpriseBaseURL,
108-
}
99+
"type": repository.Type,
109100

110-
if repository.GithubAppId > 0 {
111-
r["githubapp_id"] = convertInt64ToString(repository.GithubAppId)
101+
// ArgoCD API does not return sensitive data so we can't track the state of these attributes.
102+
// "password": repository.Password,
103+
// "ssh_private_key": repository.SSHPrivateKey,
104+
// "tls_client_cert_key": repository.TLSClientCertKey,
105+
// "githubapp_private_key": repository.GithubAppPrivateKey,
112106
}
113107

114-
if repository.GithubAppInstallationId > 0 {
115-
r["githubapp_installation_id"] = convertInt64ToString(repository.GithubAppInstallationId)
108+
if !repository.InheritedCreds {
109+
// To prevent perma-diff in case of existence of repository credentials
110+
// existence, we only track the state of these values when the
111+
// repository is not inheriting credentials
112+
r["githubapp_enterprise_base_url"] = repository.GitHubAppEnterpriseBaseURL
113+
r["tls_client_cert_data"] = repository.TLSClientCertData
114+
r["username"] = repository.Username
115+
116+
if repository.GithubAppId > 0 {
117+
r["githubapp_id"] = convertInt64ToString(repository.GithubAppId)
118+
}
119+
120+
if repository.GithubAppInstallationId > 0 {
121+
r["githubapp_installation_id"] = convertInt64ToString(repository.GithubAppInstallationId)
122+
}
116123
}
117124

118125
for k, v := range r {

0 commit comments

Comments
 (0)