Skip to content

Commit d84d091

Browse files
feat(argocd_application_set): Add support for pathParamPrefix (#336)
* feat(argocd_application_set): Add support for pathParamPrefix * Update docs * fix test * add path_param_prefix to flatten function * fix attribute name in test * fix: no need to check for existence of string * tests: use matrix generator when testing new parameter * build(deps): align test versions with latest releases of ArgoCD * docs: add note regarding use of attribute with matrix generator Also keep attributes in alphabetic order * revert: docs: add note regarding use of attribute with matrix generator This reverts commit f859377. --------- Co-authored-by: Brian Fox <[email protected]>
1 parent 5aad18e commit d84d091

File tree

5 files changed

+112
-6
lines changed

5 files changed

+112
-6
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
strategy:
4949
fail-fast: false
5050
matrix:
51-
argocd_version: ["v2.5.18", "v2.6.9", "v2.7.4"]
51+
argocd_version: ["v2.6.15", "v2.7.14", "v2.8.3"]
5252
steps:
5353
- name: Check out code
5454
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

argocd/resource_argocd_application_set_test.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,40 @@ func TestAccArgoCDApplicationSet_matrix(t *testing.T) {
222222
})
223223
}
224224

225+
func TestAccArgoCDApplicationSet_matrixGitPathParamPrefix(t *testing.T) {
226+
resource.ParallelTest(t, resource.TestCase{
227+
PreCheck: func() { testAccPreCheck(t); testAccPreCheckFeatureSupported(t, features.ApplicationSet) },
228+
ProviderFactories: testAccProviders,
229+
Steps: []resource.TestStep{
230+
{
231+
Config: testAccArgoCDApplicationSet_matrixGitPathParamPrefix(),
232+
Check: resource.ComposeTestCheckFunc(
233+
resource.TestCheckResourceAttrSet(
234+
"argocd_application_set.matrix_git_path_param_prefix",
235+
"metadata.0.uid",
236+
),
237+
resource.TestCheckResourceAttr(
238+
"argocd_application_set.matrix_git_path_param_prefix",
239+
"spec.0.generator.0.matrix.0.generator.0.git.0.path_param_prefix",
240+
"foo",
241+
),
242+
resource.TestCheckResourceAttr(
243+
"argocd_application_set.matrix_git_path_param_prefix",
244+
"spec.0.generator.0.matrix.0.generator.1.git.0.path_param_prefix",
245+
"bar",
246+
),
247+
),
248+
},
249+
{
250+
ResourceName: "argocd_application_set.matrix_git_path_param_prefix",
251+
ImportState: true,
252+
ImportStateVerify: true,
253+
ImportStateVerifyIgnore: []string{"metadata.0.resource_version"},
254+
},
255+
},
256+
})
257+
}
258+
225259
func TestAccArgoCDApplicationSet_matrixNested(t *testing.T) {
226260
resource.ParallelTest(t, resource.TestCase{
227261
PreCheck: func() { testAccPreCheck(t); testAccPreCheckFeatureSupported(t, features.ApplicationSet) },
@@ -1170,6 +1204,64 @@ resource "argocd_application_set" "matrix" {
11701204
}`
11711205
}
11721206

1207+
func testAccArgoCDApplicationSet_matrixGitPathParamPrefix() string {
1208+
return `
1209+
resource "argocd_application_set" "matrix_git_path_param_prefix" {
1210+
metadata {
1211+
name = "matrix-git-path-param-prefix"
1212+
}
1213+
1214+
spec {
1215+
generator {
1216+
matrix {
1217+
generator {
1218+
git {
1219+
repo_url = "https://github.com/argoproj/argo-cd.git"
1220+
revision = "HEAD"
1221+
path_param_prefix = "foo"
1222+
1223+
file {
1224+
path = "applicationset/examples/git-generator-files-discovery/cluster-config/**/config.json"
1225+
}
1226+
}
1227+
}
1228+
1229+
generator {
1230+
git {
1231+
repo_url = "https://github.com/argoproj/argo-cd.git"
1232+
revision = "HEAD"
1233+
path_param_prefix = "bar"
1234+
1235+
file {
1236+
path = "applicationset/examples/git-generator-files-discovery/cluster-config/**/config.json"
1237+
}
1238+
}
1239+
}
1240+
}
1241+
}
1242+
1243+
template {
1244+
metadata {
1245+
name = "matrix-git-path-param-prefix"
1246+
}
1247+
1248+
spec {
1249+
source {
1250+
repo_url = "https://github.com/argoproj/argo-cd.git"
1251+
target_revision = "HEAD"
1252+
path = "applicationset/examples/git-generator-files-discovery/apps/guestbook"
1253+
}
1254+
1255+
destination {
1256+
server = "{{cluster.address}}"
1257+
namespace = "guestbook"
1258+
}
1259+
}
1260+
}
1261+
}
1262+
}`
1263+
}
1264+
11731265
func testAccArgoCDApplicationSet_matrixNested() string {
11741266
return `
11751267
resource "argocd_application_set" "matrix_nested" {

argocd/schema_application_set.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ func applicationSetGitGeneratorSchemaV0() *schema.Schema {
286286
Description: "Revision of the source repository to use.",
287287
Optional: true,
288288
},
289+
"path_param_prefix": {
290+
Type: schema.TypeString,
291+
Description: "Prefix for all path-related parameter names.",
292+
Optional: true,
293+
},
289294
"template": {
290295
Type: schema.TypeList,
291296
Description: "Generator template. Used to override the values of the spec-level template.",

argocd/structure_application_set.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ func expandApplicationSetGitGenerator(gg interface{}, featureMultipleApplication
166166

167167
asg := &application.ApplicationSetGenerator{
168168
Git: &application.GitGenerator{
169-
RepoURL: g["repo_url"].(string),
170-
Revision: g["revision"].(string),
169+
PathParamPrefix: g["path_param_prefix"].(string),
170+
RepoURL: g["repo_url"].(string),
171+
Revision: g["revision"].(string),
171172
},
172173
}
173174

@@ -963,9 +964,10 @@ func flattenApplicationSetClusterDecisionResourceGenerator(c *application.DuckTy
963964

964965
func flattenApplicationSetGitGenerator(gg *application.GitGenerator) []map[string]interface{} {
965966
g := map[string]interface{}{
966-
"repo_url": gg.RepoURL,
967-
"revision": gg.Revision,
968-
"template": flattenApplicationSetTemplate(gg.Template),
967+
"repo_url": gg.RepoURL,
968+
"revision": gg.Revision,
969+
"path_param_prefix": gg.PathParamPrefix,
970+
"template": flattenApplicationSetTemplate(gg.Template),
969971
}
970972

971973
if len(gg.Directories) > 0 {

docs/resources/application_set.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,7 @@ Optional:
11681168

11691169
- `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))
11701170
- `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))
1171+
- `path_param_prefix` (String) Prefix for all path-related parameter names.
11711172
- `revision` (String) Revision of the source repository to use.
11721173
- `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))
11731174

@@ -2258,6 +2259,7 @@ Optional:
22582259

22592260
- `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))
22602261
- `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))
2262+
- `path_param_prefix` (String) Prefix for all path-related parameter names.
22612263
- `revision` (String) Revision of the source repository to use.
22622264
- `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))
22632265

@@ -3346,6 +3348,7 @@ Optional:
33463348

33473349
- `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))
33483350
- `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))
3351+
- `path_param_prefix` (String) Prefix for all path-related parameter names.
33493352
- `revision` (String) Revision of the source repository to use.
33503353
- `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))
33513354

@@ -5477,6 +5480,7 @@ Optional:
54775480

54785481
- `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))
54795482
- `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))
5483+
- `path_param_prefix` (String) Prefix for all path-related parameter names.
54805484
- `revision` (String) Revision of the source repository to use.
54815485
- `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))
54825486

@@ -8652,6 +8656,7 @@ Optional:
86528656

86538657
- `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))
86548658
- `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))
8659+
- `path_param_prefix` (String) Prefix for all path-related parameter names.
86558660
- `revision` (String) Revision of the source repository to use.
86568661
- `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))
86578662

@@ -9740,6 +9745,7 @@ Optional:
97409745

97419746
- `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))
97429747
- `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))
9748+
- `path_param_prefix` (String) Prefix for all path-related parameter names.
97439749
- `revision` (String) Revision of the source repository to use.
97449750
- `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))
97459751

@@ -11871,6 +11877,7 @@ Optional:
1187111877

1187211878
- `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))
1187311879
- `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))
11880+
- `path_param_prefix` (String) Prefix for all path-related parameter names.
1187411881
- `revision` (String) Revision of the source repository to use.
1187511882
- `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))
1187611883

0 commit comments

Comments
 (0)