argoproj-labs / terraform-provider-argocd

Terraform provider for Argo CD
Mozilla Public License 2.0
429 stars 89 forks source link

Feature request: Improved diffs #390

Open cpboyd opened 6 months ago

cpboyd commented 6 months ago

Description

Currently, it seems like any time certain blocks are added/removed (e.g. destination {} on argocd_project) then it lists all blocks as being removed and re-added.

With ArgoCD projects that have several destinations specified, this makes it very difficult to track what the actual changes are:

          - destination {
              - namespace = "api" -> null
              - server    = "https://server-1" -> null
            }
          - destination {
              - namespace = "api" -> null
              - server    = "https://server-2" -> null
            }
          - destination {
              - namespace = "api" -> null
              - server    = "https://server-3" -> null
            }
          - destination {
              - namespace = "api" -> null
              - server    = "https://server-4" -> null
            }
          - destination {
              - namespace = "argo-*" -> null
              - server    = "https://server-1" -> null
            }
          - destination {
              - namespace = "argo-*" -> null
              - server    = "https://server-2" -> null
            }
          - destination {
              - namespace = "argo-*" -> null
              - server    = "https://server-3" -> null
            }
          - destination {
              - namespace = "argo-*" -> null
              - server    = "https://server-4" -> null
            }
          - destination {
              - namespace = "pub" -> null
              - server    = "https://server-1" -> null
            }
          - destination {
              - namespace = "pub" -> null
              - server    = "https://server-2" -> null
            }
          - destination {
              - namespace = "pub" -> null
              - server    = "https://server-3" -> null
            }
          - destination {
              - namespace = "pub" -> null
              - server    = "https://server-4" -> null
            }
          - destination {
              - namespace = "sec" -> null
              - server    = "https://server-2" -> null
            }
          - destination {
              - namespace = "sec" -> null
              - server    = "https://server-3" -> null
            }
          - destination {
              - namespace = "sec" -> null
              - server    = "https://server-4" -> null
            }
          - destination {
              - namespace = "test" -> null
              - server    = "https://server-1" -> null
            }
          - destination {
              - namespace = "test" -> null
              - server    = "https://server-2" -> null
            }
          - destination {
              - namespace = "test" -> null
              - server    = "https://server-3" -> null
            }
          - destination {
              - namespace = "test" -> null
              - server    = "https://server-4" -> null
            }
          - destination {
              - namespace = "test" -> null
              - server    = "https://kubernetes.default.svc" -> null
            }
          - destination {
              - namespace = "ui" -> null
              - server    = "https://server-1" -> null
            }
          - destination {
              - namespace = "ui" -> null
              - server    = "https://server-2" -> null
            }
          - destination {
              - namespace = "ui" -> null
              - server    = "https://server-3" -> null
            }
          - destination {
              - namespace = "ui" -> null
              - server    = "https://server-4" -> null
            }
          - destination {
              - namespace = "sec" -> null
              - server    = "https://server-1" -> null
            }
          + destination {
              + namespace = "map"
              + server    = "https://server-1"
            }
          + destination {
              + namespace = "map"
              + server    = "https://server-2"
            }
          + destination {
              + namespace = "map"
              + server    = "https://server-3"
            }
          + destination {
              + namespace = "map"
              + server    = "https://server-4"
            }
          + destination {
              + namespace = "api"
              + server    = "https://server-1"
            }
          + destination {
              + namespace = "api"
              + server    = "https://server-2"
            }
          + destination {
              + namespace = "api"
              + server    = "https://server-3"
            }
          + destination {
              + namespace = "api"
              + server    = "https://server-4"
            }
          + destination {
              + namespace = "argo-*"
              + server    = "https://server-1"
            }
          + destination {
              + namespace = "argo-*"
              + server    = "https://server-2"
            }
          + destination {
              + namespace = "argo-*"
              + server    = "https://server-3"
            }
          + destination {
              + namespace = "argo-*"
              + server    = "https://server-4"
            }
          + destination {
              + namespace = "pub"
              + server    = "https://server-1"
            }
          + destination {
              + namespace = "pub"
              + server    = "https://server-2"
            }
          + destination {
              + namespace = "pub"
              + server    = "https://server-3"
            }
          + destination {
              + namespace = "pub"
              + server    = "https://server-4"
            }
          + destination {
              + namespace = "sec"
              + server    = "https://server-1"
            }
          + destination {
              + namespace = "sec"
              + server    = "https://server-2"
            }
          + destination {
              + namespace = "sec"
              + server    = "https://server-3"
            }
          + destination {
              + namespace = "sec"
              + server    = "https://server-4"
            }
          + destination {
              + namespace = "test"
              + server    = "https://server-1"
            }
          + destination {
              + namespace = "test"
              + server    = "https://server-2"
            }
          + destination {
              + namespace = "test"
              + server    = "https://server-3"
            }
          + destination {
              + namespace = "test"
              + server    = "https://server-4"
            }
          + destination {
              + namespace = "test"
              + server    = "https://kubernetes.default.svc"
            }
          + destination {
              + namespace = "ui"
              + server    = "https://server-1"
            }
          + destination {
              + namespace = "ui"
              + server    = "https://server-2"
            }
          + destination {
              + namespace = "ui"
              + server    = "https://server-3"
            }
          + destination {
              + namespace = "ui"
              + server    = "https://server-4"
            }

Potential Terraform Configuration

I know that other modules have changed from list to map for easier diffs. I'm not sure if maybe using blocks (instead of a map or some other structure) for this is causing the issue here.

Maybe there's also something with how the provider is rendering the pending changes that could be adjusted, like putting the new stuff last (since in this specific example, the only addition is the namespace = "map")

References

https://github.com/hashicorp/terraform/issues/21901

Community Note

github-actions[bot] commented 1 month ago

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.