diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 61ab4d1a..983c9cf7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,7 +48,7 @@ jobs: strategy: fail-fast: false matrix: - argocd_version: ["v2.5.18", "v2.6.9", "v2.7.4"] + argocd_version: ["v2.6.15", "v2.7.14", "v2.8.3"] steps: - name: Check out code uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 diff --git a/argocd/resource_argocd_application_set_test.go b/argocd/resource_argocd_application_set_test.go index 05fa3e8b..e1c46742 100644 --- a/argocd/resource_argocd_application_set_test.go +++ b/argocd/resource_argocd_application_set_test.go @@ -222,6 +222,40 @@ func TestAccArgoCDApplicationSet_matrix(t *testing.T) { }) } +func TestAccArgoCDApplicationSet_matrixGitPathParamPrefix(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t); testAccPreCheckFeatureSupported(t, features.ApplicationSet) }, + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccArgoCDApplicationSet_matrixGitPathParamPrefix(), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet( + "argocd_application_set.matrix_git_path_param_prefix", + "metadata.0.uid", + ), + resource.TestCheckResourceAttr( + "argocd_application_set.matrix_git_path_param_prefix", + "spec.0.generator.0.matrix.0.generator.0.git.0.path_param_prefix", + "foo", + ), + resource.TestCheckResourceAttr( + "argocd_application_set.matrix_git_path_param_prefix", + "spec.0.generator.0.matrix.0.generator.1.git.0.path_param_prefix", + "bar", + ), + ), + }, + { + ResourceName: "argocd_application_set.matrix_git_path_param_prefix", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"metadata.0.resource_version"}, + }, + }, + }) +} + func TestAccArgoCDApplicationSet_matrixNested(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t); testAccPreCheckFeatureSupported(t, features.ApplicationSet) }, @@ -1170,6 +1204,64 @@ resource "argocd_application_set" "matrix" { }` } +func testAccArgoCDApplicationSet_matrixGitPathParamPrefix() string { + return ` +resource "argocd_application_set" "matrix_git_path_param_prefix" { + metadata { + name = "matrix-git-path-param-prefix" + } + + spec { + generator { + matrix { + generator { + git { + repo_url = "https://github.com/argoproj/argo-cd.git" + revision = "HEAD" + path_param_prefix = "foo" + + file { + path = "applicationset/examples/git-generator-files-discovery/cluster-config/**/config.json" + } + } + } + + generator { + git { + repo_url = "https://github.com/argoproj/argo-cd.git" + revision = "HEAD" + path_param_prefix = "bar" + + file { + path = "applicationset/examples/git-generator-files-discovery/cluster-config/**/config.json" + } + } + } + } + } + + template { + metadata { + name = "matrix-git-path-param-prefix" + } + + spec { + source { + repo_url = "https://github.com/argoproj/argo-cd.git" + target_revision = "HEAD" + path = "applicationset/examples/git-generator-files-discovery/apps/guestbook" + } + + destination { + server = "{{cluster.address}}" + namespace = "guestbook" + } + } + } + } +}` +} + func testAccArgoCDApplicationSet_matrixNested() string { return ` resource "argocd_application_set" "matrix_nested" { diff --git a/argocd/schema_application_set.go b/argocd/schema_application_set.go index ffe9a787..b336cfa7 100644 --- a/argocd/schema_application_set.go +++ b/argocd/schema_application_set.go @@ -286,6 +286,11 @@ func applicationSetGitGeneratorSchemaV0() *schema.Schema { Description: "Revision of the source repository to use.", Optional: true, }, + "path_param_prefix": { + Type: schema.TypeString, + Description: "Prefix for all path-related parameter names.", + Optional: true, + }, "template": { Type: schema.TypeList, Description: "Generator template. Used to override the values of the spec-level template.", diff --git a/argocd/structure_application_set.go b/argocd/structure_application_set.go index 928f311d..779956ba 100644 --- a/argocd/structure_application_set.go +++ b/argocd/structure_application_set.go @@ -166,8 +166,9 @@ func expandApplicationSetGitGenerator(gg interface{}, featureMultipleApplication asg := &application.ApplicationSetGenerator{ Git: &application.GitGenerator{ - RepoURL: g["repo_url"].(string), - Revision: g["revision"].(string), + PathParamPrefix: g["path_param_prefix"].(string), + RepoURL: g["repo_url"].(string), + Revision: g["revision"].(string), }, } @@ -963,9 +964,10 @@ func flattenApplicationSetClusterDecisionResourceGenerator(c *application.DuckTy func flattenApplicationSetGitGenerator(gg *application.GitGenerator) []map[string]interface{} { g := map[string]interface{}{ - "repo_url": gg.RepoURL, - "revision": gg.Revision, - "template": flattenApplicationSetTemplate(gg.Template), + "repo_url": gg.RepoURL, + "revision": gg.Revision, + "path_param_prefix": gg.PathParamPrefix, + "template": flattenApplicationSetTemplate(gg.Template), } if len(gg.Directories) > 0 { diff --git a/docs/resources/application_set.md b/docs/resources/application_set.md index b8956699..7d02ad40 100644 --- a/docs/resources/application_set.md +++ b/docs/resources/application_set.md @@ -1168,6 +1168,7 @@ Optional: - `directory` (Block List) List of directories in the source repository to use when template the Application.. (see [below for nested schema](#nestedblock--spec--generator--git--directory)) - `file` (Block List) List of files in the source repository to use when template the Application. (see [below for nested schema](#nestedblock--spec--generator--git--file)) +- `path_param_prefix` (String) Prefix for all path-related parameter names. - `revision` (String) Revision of the source repository to use. - `template` (Block List, Max: 1) Generator template. Used to override the values of the spec-level template. (see [below for nested schema](#nestedblock--spec--generator--git--template)) @@ -2258,6 +2259,7 @@ Optional: - `directory` (Block List) List of directories in the source repository to use when template the Application.. (see [below for nested schema](#nestedblock--spec--generator--matrix--generator--git--directory)) - `file` (Block List) List of files in the source repository to use when template the Application. (see [below for nested schema](#nestedblock--spec--generator--matrix--generator--git--file)) +- `path_param_prefix` (String) Prefix for all path-related parameter names. - `revision` (String) Revision of the source repository to use. - `template` (Block List, Max: 1) Generator template. Used to override the values of the spec-level template. (see [below for nested schema](#nestedblock--spec--generator--matrix--generator--git--template)) @@ -3346,6 +3348,7 @@ Optional: - `directory` (Block List) List of directories in the source repository to use when template the Application.. (see [below for nested schema](#nestedblock--spec--generator--matrix--generator--matrix--generator--git--directory)) - `file` (Block List) List of files in the source repository to use when template the Application. (see [below for nested schema](#nestedblock--spec--generator--matrix--generator--matrix--generator--git--file)) +- `path_param_prefix` (String) Prefix for all path-related parameter names. - `revision` (String) Revision of the source repository to use. - `template` (Block List, Max: 1) Generator template. Used to override the values of the spec-level template. (see [below for nested schema](#nestedblock--spec--generator--matrix--generator--matrix--generator--git--template)) @@ -5477,6 +5480,7 @@ Optional: - `directory` (Block List) List of directories in the source repository to use when template the Application.. (see [below for nested schema](#nestedblock--spec--generator--matrix--generator--merge--generator--git--directory)) - `file` (Block List) List of files in the source repository to use when template the Application. (see [below for nested schema](#nestedblock--spec--generator--matrix--generator--merge--generator--git--file)) +- `path_param_prefix` (String) Prefix for all path-related parameter names. - `revision` (String) Revision of the source repository to use. - `template` (Block List, Max: 1) Generator template. Used to override the values of the spec-level template. (see [below for nested schema](#nestedblock--spec--generator--matrix--generator--merge--generator--git--template)) @@ -8652,6 +8656,7 @@ Optional: - `directory` (Block List) List of directories in the source repository to use when template the Application.. (see [below for nested schema](#nestedblock--spec--generator--merge--generator--git--directory)) - `file` (Block List) List of files in the source repository to use when template the Application. (see [below for nested schema](#nestedblock--spec--generator--merge--generator--git--file)) +- `path_param_prefix` (String) Prefix for all path-related parameter names. - `revision` (String) Revision of the source repository to use. - `template` (Block List, Max: 1) Generator template. Used to override the values of the spec-level template. (see [below for nested schema](#nestedblock--spec--generator--merge--generator--git--template)) @@ -9740,6 +9745,7 @@ Optional: - `directory` (Block List) List of directories in the source repository to use when template the Application.. (see [below for nested schema](#nestedblock--spec--generator--merge--generator--matrix--generator--git--directory)) - `file` (Block List) List of files in the source repository to use when template the Application. (see [below for nested schema](#nestedblock--spec--generator--merge--generator--matrix--generator--git--file)) +- `path_param_prefix` (String) Prefix for all path-related parameter names. - `revision` (String) Revision of the source repository to use. - `template` (Block List, Max: 1) Generator template. Used to override the values of the spec-level template. (see [below for nested schema](#nestedblock--spec--generator--merge--generator--matrix--generator--git--template)) @@ -11871,6 +11877,7 @@ Optional: - `directory` (Block List) List of directories in the source repository to use when template the Application.. (see [below for nested schema](#nestedblock--spec--generator--merge--generator--merge--generator--git--directory)) - `file` (Block List) List of files in the source repository to use when template the Application. (see [below for nested schema](#nestedblock--spec--generator--merge--generator--merge--generator--git--file)) +- `path_param_prefix` (String) Prefix for all path-related parameter names. - `revision` (String) Revision of the source repository to use. - `template` (Block List, Max: 1) Generator template. Used to override the values of the spec-level template. (see [below for nested schema](#nestedblock--spec--generator--merge--generator--merge--generator--git--template))