Skip to content

Commit

Permalink
Add support for templatePatch (#499)
Browse files Browse the repository at this point in the history
* fix test

Signed-off-by: AvivGuiser <avivguiser@gmail.com>

* ran make generate

Signed-off-by: AvivGuiser <avivguiser@gmail.com>

* fix tests by guarding the templatePatch behined a feature

Signed-off-by: AvivGuiser <avivguiser@gmail.com>

* fix test in 2.9

Signed-off-by: AvivGuiser <avivguiser@gmail.com>

---------

Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Co-authored-by: Nathanael Liechti <technat@technat.ch>
  • Loading branch information
KyriosGN0 and the-technat authored Dec 6, 2024
1 parent f8a0cdd commit e634913
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 227 deletions.
4 changes: 2 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARGOCD_INSECURE?=true
ARGOCD_SERVER?=127.0.0.1:8080
ARGOCD_AUTH_USERNAME?=admin
ARGOCD_AUTH_PASSWORD?=acceptancetesting
ARGOCD_VERSION?=v2.9.3
ARGOCD_VERSION?=v2.11.9

export

Expand Down Expand Up @@ -39,4 +39,4 @@ testacc_prepare_env:
clean:
git clean -fXd -e \!vendor -e \!vendor/**/* -e \!.vscode

.PHONY: build install lint generate fmt test testacc testacc_clean_env testacc_prepare_env clean
.PHONY: build install lint generate fmt test testacc testacc_clean_env testacc_prepare_env clean
8 changes: 6 additions & 2 deletions argocd/resource_argocd_application_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func resourceArgoCDApplicationSetCreate(ctx context.Context, d *schema.ResourceD
return featureNotSupported(features.ApplicationSet)
}

objectMeta, spec, err := expandApplicationSet(d, si.IsFeatureSupported(features.MultipleApplicationSources), si.IsFeatureSupported(features.ApplicationSetIgnoreApplicationDifferences))
objectMeta, spec, err := expandApplicationSet(d, si.IsFeatureSupported(features.MultipleApplicationSources), si.IsFeatureSupported(features.ApplicationSetIgnoreApplicationDifferences), si.IsFeatureSupported(features.ApplicationSetTemplatePatch))
if err != nil {
return errorToDiagnostics("failed to expand application set", err)
}
Expand All @@ -58,6 +58,10 @@ func resourceArgoCDApplicationSetCreate(ctx context.Context, d *schema.ResourceD
return featureNotSupported(features.ApplicationSetApplicationsSyncPolicy)
}

if !si.IsFeatureSupported(features.ApplicationSetTemplatePatch) && spec.TemplatePatch != nil {
return featureNotSupported(features.ApplicationSetTemplatePatch)
}

as, err := si.ApplicationSetClient.Create(ctx, &applicationset.ApplicationSetCreateRequest{
Applicationset: &application.ApplicationSet{
ObjectMeta: objectMeta,
Expand Down Expand Up @@ -126,7 +130,7 @@ func resourceArgoCDApplicationSetUpdate(ctx context.Context, d *schema.ResourceD
return nil
}

objectMeta, spec, err := expandApplicationSet(d, si.IsFeatureSupported(features.MultipleApplicationSources), si.IsFeatureSupported(features.ApplicationSetIgnoreApplicationDifferences))
objectMeta, spec, err := expandApplicationSet(d, si.IsFeatureSupported(features.MultipleApplicationSources), si.IsFeatureSupported(features.ApplicationSetIgnoreApplicationDifferences), si.IsFeatureSupported(features.ApplicationSetTemplatePatch))
if err != nil {
return errorToDiagnostics(fmt.Sprintf("failed to expand application set %s", d.Id()), err)
}
Expand Down
Loading

0 comments on commit e634913

Please # to comment.