Skip to content

Commit

Permalink
Ensured that helm version and managed fields managers are flattened. …
Browse files Browse the repository at this point in the history
…Added test cases for helm version and managed fields managers

Signed-off-by: Tony Owens <anthony.owens1987@gmail.com>
  • Loading branch information
tonedefdev committed Aug 8, 2024
1 parent f17b87e commit adadffb
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 6 deletions.
74 changes: 74 additions & 0 deletions argocd/resource_argocd_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ ingress:
"spec.0.source.0.helm.0.ignore_missing_value_files",
"true",
),
resource.TestCheckResourceAttr(
"argocd_application.helm",
"spec.0.source.0.helm.0.version",
"3",
),
),
},
{
Expand Down Expand Up @@ -261,6 +266,32 @@ func TestAccArgoCDApplication_IgnoreDifferences(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"wait", "cascade", "status"},
},
{
Config: testAccArgoCDApplicationIgnoreDiffManagedFieldsManagers(
acctest.RandomWithPrefix("test-acc")),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(
"argocd_application.ignore_differences_managed_fields_managers",
"metadata.0.uid",
),
resource.TestCheckResourceAttr(
"argocd_application.ignore_differences_managed_fields_managers",
"spec.0.ignore_difference.0.managed_field_managers.0",
"some-controller-owner",
),
resource.TestCheckResourceAttr(
"argocd_application.ignore_differences_managed_fields_managers",
"spec.0.ignore_difference.0.managed_field_managers.1",
"some-other-controller-owner",
),
),
},
{
ResourceName: "argocd_application.ignore_differences_managed_fields_managers",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"wait", "cascade", "status"},
},
},
})
}
Expand Down Expand Up @@ -1630,6 +1661,49 @@ resource "argocd_application" "ignore_differences_jqpe" {
`, name)
}

func testAccArgoCDApplicationIgnoreDiffManagedFieldsManagers(name string) string {
return fmt.Sprintf(`
resource "argocd_application" "ignore_differences_managed_fields_managers" {
metadata {
name = "%s"
namespace = "argocd"
labels = {
acceptance = "true"
}
}
spec {
source {
repo_url = "https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami"
chart = "redis"
target_revision = "16.9.11"
}
destination {
server = "https://kubernetes.default.svc"
namespace = "default"
}
ignore_difference {
group = "apps"
kind = "Deployment"
managed_fields_managers = ["some-controller-owner"]
}
ignore_difference {
group = "apps"
kind = "StatefulSet"
name = "someStatefulSet"
managed_fields_managers = [
"some-controller-owner",
"some-other-controller-owner",
]
}
}
}
`, name)
}

func testAccArgoCDApplication_OptionalDestinationNamespace(name string) string {
return fmt.Sprintf(`
resource "argocd_application" "no_namespace" {
Expand Down
14 changes: 8 additions & 6 deletions argocd/structure_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,13 @@ func flattenApplicationInfo(infos []application.Info) (result []map[string]strin
func flattenApplicationIgnoreDifferences(ids []application.ResourceIgnoreDifferences) (result []map[string]interface{}) {
for _, id := range ids {
result = append(result, map[string]interface{}{
"group": id.Group,
"kind": id.Kind,
"name": id.Name,
"namespace": id.Namespace,
"json_pointers": id.JSONPointers,
"jq_path_expressions": id.JQPathExpressions,
"group": id.Group,
"kind": id.Kind,
"name": id.Name,
"namespace": id.Namespace,
"json_pointers": id.JSONPointers,
"jq_path_expressions": id.JQPathExpressions,
"managed_fields_managers": id.ManagedFieldsManagers,
})
}

Expand Down Expand Up @@ -799,6 +800,7 @@ func flattenApplicationSourceHelm(as []*application.ApplicationSourceHelm) (resu
"values": a.Values,
"pass_credentials": a.PassCredentials,
"ignore_missing_value_files": a.IgnoreMissingValueFiles,
"version": a.Version,
})
}
}
Expand Down

0 comments on commit adadffb

Please sign in to comment.