Application source paths should not default to `"."` when explicitly `null` or absent.
samhine opened this issue · 2 comments
Terraform Version, ArgoCD Provider Version and ArgoCD Version
Terraform version: v1.9.2
ArgoCD provider version: 6.1.1
ArgoCD version: 6.10.0
Affected Resource(s)
- argocd_application
Terraform Configuration Files
resource "argocd_application" "sample-application" {
cascade = true
wait = false
metadata {
name = "sample-application"
namespace = "argocd"
}
spec {
project = "root"
revision_history_limit = 10
destination {
namespace = "sample-application"
server = "https://kubernetes.default.svc"
}
source {
path = null
ref = "values"
repo_url = "https://github.com/org/values-repo.git"
target_revision = "main"
}
source {
path = "deploy"
repo_url = "https://github.com/org/chart-repo.git"
target_revision = "main"
helm {
value_files = [
"$values/projects/project/clusters/cluster/application-values/sample-application/values.yaml",
]
}
}
}
}
Steps to Reproduce
terraform plan
orterraform apply
Plan output:
# argocd_application.sample-application will be created
+ resource "argocd_application" "sample-application" {
+ cascade = true
+ id = (known after apply)
+ status = (known after apply)
+ wait = false
+ metadata {
+ generation = (known after apply)
+ name = "sample-application"
+ namespace = "argocd"
+ resource_version = (known after apply)
+ uid = (known after apply)
}
+ spec {
+ project = "root"
+ revision_history_limit = 10
+ destination {
name = null
+ namespace = "sample-application"
+ server = "https://kubernetes.default.svc"
}
+ source {
+ path = "." <------ This should not be the case!!
+ ref = "values"
+ repo_url = "https://github.com/org/values-repo.git"
+ target_revision = "main"
}
+ source {
+ path = "deploy"
+ repo_url = "https://github.com/org/chart-repo.git"
+ target_revision = "main"
+ helm {
+ value_files = [
+ "$values/projects/project/clusters/cluster/application-values/sample-application/values.yaml",
]
}
}
}
}
Expected Behavior
Terraform should not attempt to add a path
to the source where it is absent, or explicitly null
.
Otherwise, ArgoCD will attempt to deploy any YAML resources found at the source repository. This behaviour is documented in ArgoCD's documentation - https://argo-cd.readthedocs.io/en/stable/user-guide/multiple_sources/#helm-value-files-from-external-git-repository.
If the path field is set in the $values source, Argo CD will attempt to generate resources from the git repository at that URL. If the path field is not set, Argo CD will use the repository solely as a source of value files.
Currently - since path
defaults to "."
, this provider always instantiates applications which attempt to deploy any resources at this path (in my case, I have a Backstage definition file which uses the CRD format, which ArgoCD attempts to deploy).
Actual Behavior
The path
index should be absent within the application source
block. I can edit my applications once deployed to remove this - and everything works as expected.
I believe this is due to the default currently set within the application schema here.
Workaround
It's possible to simply specify a path that does not contain a YAML resource, since this is a non-op. For example, setting path to .git
means that ArgoCD does not find any YAML resources and continues as normal, however this is not ideal for a few obvious reasons.
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
First I thought you're doing something unsupported:
But when I read the docs it seems that this is a new feature of Argo CD called "multi source app".
And indeed this change resp. feature was not reflected into the terraform provider:
terraform-provider-argocd/argocd/schema_application.go
Lines 1285 to 1291 in 582b426