Dagger
Search

argocd

rendering ArgoCD resources from OCI-hosted KCL modules.

Functions live in dedicated files:
- cli.go AddClusterCli (logs in with the argocd CLI and runs `cluster add`)
- cluster.go AddClusterK8s (applies a cluster Secret directly; no ArgoCD API call)
- project.go CreateAppProject (renders + optionally applies an AppProject via the shared KCL module)

Installation

dagger install github.com/stuttgart-things/dagger/argocd@v0.97.0

Entrypoint

Return Type
Argocd
Example
dagger -m github.com/stuttgart-things/dagger/argocd@e45d527b89d462ed2a4255aefaa312918045b817 call \
func (m *MyModule) Example() *dagger.Argocd  {
	return dag.
			Argocd()
}
@function
def example() -> dagger.Argocd:
	return (
		dag.argocd()
	)
@func()
example(): Argocd {
	return dag
		.argocd()
}

Types

Argocd 🔗

addClusterCli() 🔗

AddClusterCli registers a Kubernetes cluster in ArgoCD via argocd cluster add.

It builds a Wolfi-based container with the argocd CLI and kubectl, logs in to the ArgoCD server, and runs argocd cluster add <context> --name <clusterName>. The kubeconfig context is taken from its current-context (or –source-context when supplied); no context rename is performed.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
kubeConfigSecret !-Kubeconfig of the target cluster
argocdServerString !-ArgoCD server address (host[:port], no scheme)
usernameString !-ArgoCD username (not a secret)
passwordSecret !-ArgoCD password
clusterNameString !-Display name for the cluster in ArgoCD (--name on `argocd cluster add`)
baseImageString "cgr.dev/chainguard/wolfi-base:latest"No description provided
insecureBoolean trueNo description provided
serverCertFile -CA certificate (PEM) to verify the ArgoCD server. When provided, insecure is ignored.
serverCertsDirDirectory -Directory of CA certificates (*.crt / *.pem) concatenated into the trust bundle passed to `argocd login --server-crt`. When provided, insecure is ignored. Takes precedence over serverCert.
sourceContextString -Kubeconfig context to register. If empty, the kubeconfig's current-context is used.
plaintextBoolean falseUse plain HTTP (no TLS) to talk to the ArgoCD server.
cliPackageString "argo-cd-2.14"Wolfi apk package providing the argocd CLI. Pin to a major.minor that matches your ArgoCD server (e.g. argo-cd-2.14, argo-cd-3.3). The "argo-cd" meta-package tracks the latest major and can break against older servers.
Example
dagger -m github.com/stuttgart-things/dagger/argocd@e45d527b89d462ed2a4255aefaa312918045b817 call \
 add-cluster-cli --kube-config env:MYSECRET --argocd-server string --username string --password env:MYSECRET --cluster-name string
func (m *MyModule) Example(ctx context.Context, kubeConfig *dagger.Secret, argocdServer string, username string, password *dagger.Secret, clusterName string) string  {
	return dag.
			Argocd().
			AddClusterCli(ctx, kubeConfig, argocdServer, username, password, clusterName)
}
@function
async def example(kube_config: dagger.Secret, argocd_server: str, username: str, password: dagger.Secret, cluster_name: str) -> str:
	return await (
		dag.argocd()
		.add_cluster_cli(kube_config, argocd_server, username, password, cluster_name)
	)
@func()
async example(kubeConfig: Secret, argocdServer: string, username: string, password: Secret, clusterName: string): Promise<string> {
	return dag
		.argocd()
		.addClusterCli(kubeConfig, argocdServer, username, password, clusterName)
}

addClusterK8S() 🔗

AddClusterK8s registers a Kubernetes cluster in ArgoCD without calling the ArgoCD HTTP/gRPC API. It creates (or reuses) a ServiceAccount with cluster-admin permissions in the target cluster, mints a token via kubectl create token, extracts the cluster’s server URL and CA from the kubeconfig, and assembles the ArgoCD cluster Secret (labelled argocd.argoproj.io/secret-type=cluster).

The rendered Secret is always returned in the output Directory as <clusterName>.yaml. When applyToCluster is true the Secret is also applied to the ArgoCD-hosting cluster; when false (the default, matching create-app-project / create-application*) you get the file back without touching the ArgoCD cluster — handy for git-committing or inspecting before apply. Either way, the target cluster IS mutated (SAcreated, token minted) because the Secret can’t be built without a live token.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
kubeConfigSecret !-Kubeconfig of the target cluster to register (where the SA is created)
clusterNameString !-Display name for the cluster in ArgoCD (also the Secret name and output filename)
argocdKubeConfigSecret -Kubeconfig of the cluster where ArgoCD runs. Required when applyToCluster is true (and you want to apply somewhere other than the target cluster). Ignored when applyToCluster is false.
argocdNamespaceString "argocd"Namespace where ArgoCD is installed
serviceAccountNameString "argocd-manager"ServiceAccount name created/reused in the target cluster
serviceAccountNamespaceString "kube-system"Namespace for the ServiceAccount in the target cluster
sourceContextString -Kubeconfig context of the target cluster. Empty = current-context.
argocdContextString -Kubeconfig context of the ArgoCD cluster. Empty = current-context of argocdKubeConfig.
serverUrlString -Override the server URL written into the cluster Secret. Empty = server from kubeconfig.
tokenDurationString "8760h"Duration passed to `kubectl create token`. Subject to the cluster's max.
applyToClusterBoolean falseApply the generated cluster Secret to the ArgoCD cluster. When false (default), the Secret is only rendered and returned — inspect/commit it, apply later with your own tooling (or pipe it through SOPS first).
baseImageString "cgr.dev/chainguard/wolfi-base:latest"No description provided
Example
dagger -m github.com/stuttgart-things/dagger/argocd@e45d527b89d462ed2a4255aefaa312918045b817 call \
 add-cluster-k-8-s --kube-config env:MYSECRET --cluster-name string
func (m *MyModule) Example(kubeConfig *dagger.Secret, clusterName string) *dagger.Directory  {
	return dag.
			Argocd().
			AddClusterK8S(kubeConfig, clusterName)
}
@function
def example(kube_config: dagger.Secret, cluster_name: str) -> dagger.Directory:
	return (
		dag.argocd()
		.add_cluster_k8_s(kube_config, cluster_name)
	)
@func()
example(kubeConfig: Secret, clusterName: string): Directory {
	return dag
		.argocd()
		.addClusterK8S(kubeConfig, clusterName)
}

createAppProject() 🔗

CreateAppProject renders an ArgoCD AppProject manifest from the stuttgart-things/argocd-app-project KCL module (hosted as an OCI artifact) and optionally applies it to the ArgoCD-hosting cluster.

Every field of the AppProject can be overridden via the individual parameters below. Complex fields (destinations, whitelists, labels) take JSON strings that are passed straight to kcl run -D key=<json>.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
nameString -AppProject name (metadata.name and the output file basename). Can also be supplied via parametersFile; the CLI value wins.
parametersFileFile -YAML/JSON file with KCL parameters as key: value pairs. Every CLI flag below takes precedence over values in this file. Values may be scalars, JSON arrays, or JSON objects (yq/jq stringifies nested values before handing them to `kcl run -D`).
namespaceString -Namespace where ArgoCD is installed (KCL default: "argocd")
descriptionString -Free-form description written to spec.description
sourceReposString -Allowed source repo URLs, JSON array (e.g. '["https://github.com/org/repo"]')
destinationsString -Deployment destinations, JSON array of {server?,name?,namespace} (e.g. '[{"server":"https://10.0.0.1:6443","namespace":"*"}]')
clusterResourceWhitelistString -Cluster-scoped resource kinds allowed, JSON array of {group,kind}
namespaceResourceWhitelistString -Namespace-scoped resource kinds allowed, JSON array of {group,kind}
labelsString -metadata.labels as JSON object (e.g. '{"team":"platform"}')
annotationsString -metadata.annotations as JSON object
ociSourceString "oci://ghcr.io/stuttgart-things/argocd-app-project"OCI source of the KCL module; append ?tag=<version> to pin.
fileExtensionString "yaml"File extension for the rendered manifest
applyToClusterBoolean falseWhen true, apply the rendered manifest to the cluster via kubectl.
kubeConfigSecret -Kubeconfig of the ArgoCD-hosting cluster. Required when applyToCluster is true.
Example
dagger -m github.com/stuttgart-things/dagger/argocd@e45d527b89d462ed2a4255aefaa312918045b817 call \
 create-app-project
func (m *MyModule) Example() *dagger.Directory  {
	return dag.
			Argocd().
			CreateAppProject()
}
@function
def example() -> dagger.Directory:
	return (
		dag.argocd()
		.create_app_project()
	)
@func()
example(): Directory {
	return dag
		.argocd()
		.createAppProject()
}

createApplication() 🔗

CreateApplication renders an ArgoCD Application manifest from the stuttgart-things/argocd-application KCL module (hosted as an OCI artifact) and optionally applies it to the ArgoCD-hosting cluster.

See https://github.com/stuttgart-things/kcl/tree/main/kubernetes/argocd-application for the full parameter reference. Common scalar fields are exposed directly; complex nested fields (helm, kustomize, sources, syncPolicy, …) take JSON strings that pass straight through to kcl run -D key=<json>.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
nameString -metadata.name and output file basename. Can also be supplied via parametersFile; the CLI value wins.
parametersFileFile -YAML/JSON file with KCL parameters as key: value pairs. Every CLI flag below takes precedence over values in this file.
namespaceString -Namespace where ArgoCD is installed (KCL default: "argocd")
projectString -AppProject this Application belongs to (KCL default: "default")
repoUrlString -spec.source.repoURL (git URL or Helm repo URL)
pathString -spec.source.path (git dir; mutually exclusive with chart)
targetRevisionString -spec.source.targetRevision
chartString -spec.source.chart (Helm chart name; mutually exclusive with path)
destServerString -spec.destination.server
destNameString -spec.destination.name (mutually exclusive with destServer)
destNamespaceString -spec.destination.namespace
syncOptionsString -syncPolicy.syncOptions as JSON array (e.g. '["CreateNamespace=true"]')
helmString -Full spec.source.helm dict as JSON
kustomizeString -Full spec.source.kustomize dict as JSON
sourceString -Entire spec.source dict as JSON (overrides repoURL/path/chart/helm/etc.)
sourcesString -Multi-source spec.sources as JSON array (replaces source when set)
destinationString -Entire spec.destination dict as JSON (overrides destServer/destName/destNamespace)
syncPolicyString -Entire spec.syncPolicy dict as JSON
automatedString -spec.syncPolicy.automated as JSON
retryString -spec.syncPolicy.retry as JSON
infoString -spec.info as JSON array
labelsString -metadata.labels as JSON object
annotationsString -metadata.annotations as JSON object
finalizersString -metadata.finalizers as JSON array
revisionHistoryLimitString -spec.revisionHistoryLimit
ociSourceString "oci://ghcr.io/stuttgart-things/argocd-application"OCI source of the KCL module; append ?tag=<version> to pin
fileExtensionString "yaml"No description provided
applyToClusterBoolean falseApply the rendered manifest via kubectl
kubeConfigSecret -Kubeconfig of the ArgoCD-hosting cluster (required when applyToCluster is true)
Example
dagger -m github.com/stuttgart-things/dagger/argocd@e45d527b89d462ed2a4255aefaa312918045b817 call \
 create-application
func (m *MyModule) Example() *dagger.Directory  {
	return dag.
			Argocd().
			CreateApplication()
}
@function
def example() -> dagger.Directory:
	return (
		dag.argocd()
		.create_application()
	)
@func()
example(): Directory {
	return dag
		.argocd()
		.createApplication()
}

createApplicationSet() 🔗

CreateApplicationSet renders an ArgoCD ApplicationSet manifest from the stuttgart-things/argocd-application-set KCL module (hosted as an OCI artifact) and optionally applies it to the ArgoCD-hosting cluster.

See https://github.com/stuttgart-things/kcl/tree/main/kubernetes/argocd-application-set for the full parameter reference. The generators field is the main lever; every complex nested field takes a JSON string that passes straight through to kcl run -D key=<json>. Argo Go-template expressions like {{ .cluster.name }} survive the JSON parser untouched as long as they’re inside string values.

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
nameString -metadata.name and output file basename. Can also be supplied via parametersFile; the CLI value wins.
parametersFileFile -YAML/JSON file with KCL parameters as key: value pairs. Every CLI flag below takes precedence over values in this file.
namespaceString -Namespace where ArgoCD is installed (KCL default: "argocd")
goTemplateString -spec.goTemplate (pass "false" to disable Go templating)
goTemplateOptionsString -spec.goTemplateOptions as JSON array
generatorsString -spec.generators as JSON array. The module's default renders the `kro` example.
projectString -template.spec.project
templateNameString -template.metadata.name (usually contains Go-template expressions)
templateNamespaceString -template.metadata.namespace
templateLabelsString -template.metadata.labels as JSON object
templateAnnotationsString -template.metadata.annotations as JSON object
templateFinalizersString -template.metadata.finalizers as JSON array
templateMetadataString -Whole template.metadata dict as JSON (overrides templateName/templateLabels/…)
sourceString -template.spec.source dict as JSON (single-source apps)
sourcesString -template.spec.sources as JSON array (multi-source apps; replaces source)
destServerString -template.spec.destination.server
destNameString -template.spec.destination.name (mutually exclusive with destServer)
destNamespaceString -template.spec.destination.namespace
destinationString -Whole template.spec.destination dict as JSON
syncOptionsString -template.spec.syncPolicy.syncOptions as JSON array
automatedString -template.spec.syncPolicy.automated as JSON
retryString -template.spec.syncPolicy.retry as JSON
templateSyncPolicyString -Whole template.spec.syncPolicy dict as JSON
templateSpecString -Whole template.spec dict as JSON
templateString -Whole spec.template dict as JSON (overrides everything under template.*)
syncPolicyTopLevelString -spec.syncPolicy (appset-level, e.g. preserveResourcesOnDeletion) as JSON
strategyString -spec.strategy (RollingSync) as JSON
preservedFieldsString -spec.preservedFields as JSON
templatePatchString -spec.templatePatch (raw string)
labelsString -metadata.labels as JSON object
annotationsString -metadata.annotations as JSON object
finalizersString -metadata.finalizers as JSON array
ociSourceString "oci://ghcr.io/stuttgart-things/argocd-application-set"OCI source of the KCL module; append ?tag=<version> to pin
fileExtensionString "yaml"No description provided
applyToClusterBoolean falseApply the rendered manifest via kubectl
kubeConfigSecret -Kubeconfig of the ArgoCD-hosting cluster (required when applyToCluster is true)
Example
dagger -m github.com/stuttgart-things/dagger/argocd@e45d527b89d462ed2a4255aefaa312918045b817 call \
 create-application-set
func (m *MyModule) Example() *dagger.Directory  {
	return dag.
			Argocd().
			CreateApplicationSet()
}
@function
def example() -> dagger.Directory:
	return (
		dag.argocd()
		.create_application_set()
	)
@func()
example(): Directory {
	return dag
		.argocd()
		.createApplicationSet()
}