Skip to content

Conversation

blakepettersson
Copy link
Collaborator

@blakepettersson blakepettersson commented Apr 9, 2025

This has one caveat, which likely cannot be fixed until #615 is merged; we're limited to simple string maps for parameters, which is only a subset of what the plugin generator supports. In reality pretty much anything can go in as a parameter from the perspective of the plugin generator, but terraform-plugin-sdk needs an explicit type.

With terraform-plugin-framework we can use any as a type, then we can handle the marshaling/unmarshaling appropriately. I don't believe this will be a breaking change in the future since we will be widening the types parameters will accept at a later stage.

Fixes #620

@blakepettersson blakepettersson force-pushed the feature/add-support-for-appset-plugin-generators branch from a31700e to 5de458f Compare April 9, 2025 16:10
This has one caveat, which likely cannot be fixed until argoproj-labs#615 is merged;
we're limited to simple string maps for `parameters`, which is only a
subset of what the plugin generator supports. In reality pretty much
anything can go in as a parameter from the perspective of the plugin
generator, but `terraform-plugin-sdk` needs an explicit type.

With `terraform-plugin-framework` we can use any as a type, then we can
handle the marshaling/unmarshaling appropriately. I don't believe this
will be a breaking change in the future since we will be widening the
types `parameters` will accept at a later stage.

Fixes argoproj-labs#620.

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
@blakepettersson blakepettersson force-pushed the feature/add-support-for-appset-plugin-generators branch from 5de458f to 39a0f59 Compare April 9, 2025 16:18
Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
@khalilj-appsflyer
Copy link

Dear maintainers @oboukili @onematchfox @the-technat @mkilchhofer
Can you please review this PR as it fixes a blocker issue for us at AppsFlyer?
Appreciate you kind help.

Copy link
Collaborator

@the-technat the-technat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@the-technat
Copy link
Collaborator

@blakepettersson have you also done a manual test locally to see if the fields are set correctly?

@blakepettersson
Copy link
Collaborator Author

@the-technat yes, this TF

resource "argocd_application_set" "plugin" {
	metadata {
		name = "plugin"
	}
	spec {
		generator {
			plugin {
				config_map_ref = "plugin"
				input {
					parameters = {
						key1 = "value1"
					}
				}
				requeue_after_seconds = 30
			}
		}
		template {
			metadata {
				name = "{{cluster}}-guestbook"
			}
			spec {
				project = "default"
				source {
					repo_url        = "https://github.com/argoproj/argo-cd.git"
					target_revision = "HEAD"
					path            = "applicationset/examples/list-generator/guestbook/{{cluster}}"
				}
				destination {
					server    = "{{url}}"
					namespace = "guestbook"
				}
			}
		}
	}
}

Will create this appset

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: plugin
  namespace: argocd
spec:
  generators:
  - plugin:
      configMapRef:
        name: plugin
      input:
        parameters:
          key1: value1
      requeueAfterSeconds: 30
      template:
        metadata: {}
        spec:
          destination: {}
          project: ""
  template:
    metadata:
      name: '{{cluster}}-guestbook'
    spec:
      destination:
        namespace: guestbook
        server: '{{url}}'
      project: default
      revisionHistoryLimit: 10
      source:
        path: applicationset/examples/list-generator/guestbook/{{cluster}}
        repoURL: https://github.com/argoproj/argo-cd.git
        targetRevision: HEAD
  templatePatch: ""

@blakepettersson blakepettersson enabled auto-merge (squash) April 24, 2025 07:14
@blakepettersson blakepettersson merged commit 71bffe3 into argoproj-labs:main Apr 24, 2025
13 of 15 checks passed
blakepettersson added a commit to blakepettersson/terraform-provider-argocd that referenced this pull request May 5, 2025
argoproj-labs#624 added support for plugin generators, but the support for it was
never added to the nested generators.

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
blakepettersson added a commit that referenced this pull request May 5, 2025
* fix: add plugin generator to nested generator

#624 added support for plugin generators, but the support for it was
never added to the nested generators.

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>

* fix: add flatten step

This needs to go the other way as well. Added test which verifies this
works E2E.

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>

* chore: please linter

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>

* fix(test): make sure appset name is unique

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>

---------

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
VerhovnikU pushed a commit to VerhovnikU/terraform-provider-argocd that referenced this pull request May 5, 2025
* fix: add plugin generator to nested generator

argoproj-labs#624 added support for plugin generators, but the support for it was
never added to the nested generators.

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>

* fix: add flatten step

This needs to go the other way as well. Added test which verifies this
works E2E.

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>

* chore: please linter

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>

* fix(test): make sure appset name is unique

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>

---------

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
Signed-off-by: VerhovnikU <verhovnik.uros@gmail.com>
@blakepettersson blakepettersson deleted the feature/add-support-for-appset-plugin-generators branch May 28, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Application Set - Support for Plugin Generator
4 participants