Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source.directory not diffing correctly #341

Open
sidewinder12s opened this issue Oct 18, 2023 · 3 comments
Open

source.directory not diffing correctly #341

sidewinder12s opened this issue Oct 18, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@sidewinder12s
Copy link

Terraform Version, ArgoCD Provider Version and ArgoCD Version

Terraform v1.3.6
on linux_amd64
+ provider registry.terraform.io/oboukili/argocd v6.0.3

argocd: 2.7.14

Affected Resource(s)

argocd_application

Terraform Configuration Files

resource "argocd_application" "extras" {
  cascade = false
  wait    = false

  metadata {
    name      = "${local.account_name}-${module.eks.cluster_name}-extras"
    namespace = "argocd"
  }

  spec {
    project                = "${var.argocd_project}-extended"
    revision_history_limit = 0
    destination {
      server    = module.eks.cluster_endpoint
      namespace = "default"
    }

    source {
      repo_url        = "https://github.com/my-repo.git"
      path            = "mypath/"
      target_revision = "master"
      directory {
        include = "*.yaml"
      }
    }
    sync_policy {
      automated {
        prune     = false
        self_heal = false
      }
      sync_options = [
        "ApplyOutOfSyncOnly=true"
      ]
    }
  }
}

Steps to Reproduce

Take a standard directory based argocd application without the directory param set in the terraform HCL or in the app manifest, add directory and includes

Expected Behavior

The provider should have added to the source block:

directory:
  include: '*.yaml'

Actual Behavior

No diff reported

References

By default ArgoCD will infer directory if you just provide a source path in a repo, though we recently hit a bug with configuration mangement plugin resolution that can be avoided if you explicitly put directory, helm, kustomize in the app manifest to avoid the plugin resolution.

argoproj/argo-cd#15763

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
@sidewinder12s sidewinder12s added the bug Something isn't working label Oct 18, 2023
@the-technat
Copy link
Collaborator

Just tried to reproduce the bug with v6.1.1 and it's still possible to reproduce it.

I used the following snippet:

terraform {
  required_providers {
    argocd = {
      source = "oboukili/argocd"
    }
  }
}

provider "argocd" {
  server_addr = "localhost:8080"
  username    = "admin"
  password    = "acceptancetesting"
  insecure    = true
}

resource "argocd_application" "extras" {
  cascade = false
  wait    = false

  metadata {
    name      = "test-341"
    namespace = "argocd"
  }

  spec {
    project                = "default"
    revision_history_limit = 0
    destination {
      server    = "https://kubernetes.default.svc"
      namespace = "default"
    }

    source {
      repo_url        = "https://github.com/argoproj/argocd-example-apps.git"
      path            = "guestbook/"
      target_revision = "master"
      directory {
        include = "*.yaml"
      }
    }
  }
}

As far as I can see the problem is that https://github.com/oboukili/terraform-provider-argocd/blob/master/argocd/schema_application.go#L165-L171 suppresses a diff when recurse or jsonnet fields aren't populated. Looking back at #254 I think since the implementation of include and exclude this check is obsolete now or has to be extended to check for the presece of include/exclude as well.

I did a simple test by chaning the diff function (see here) and that would fix the issue and properly configure the include key. But still when rerunning Terraform the plan now shows a diff for spec.source.directory.include where I'm not quite sure where this comes from...

Copy link

github-actions bot commented Oct 3, 2024

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.

@github-actions github-actions bot added the Stale label Oct 3, 2024
@sidewinder12s
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants