{
  "name": "argocd-sync",
  "title": "Sync an Argo CD application",
  "category": "Kubernetes",
  "tags": [
    "kubernetes",
    "python"
  ],
  "version": "1.0.0",
  "date": "2026-10-18",
  "notes": "Initial release.",
  "latest": true,
  "installable": true,
  "url": "https://catalog.dagweave.com/api/v1/items/argocd-sync/1.0.0.json",
  "templateUrl": "https://catalog.dagweave.com/api/v1/items/argocd-sync/1.0.0/template.yaml",
  "entrypoint": "sync",
  "parameters": [
    {
      "name": "app",
      "title": "App",
      "description": "Name of the Argo CD application.",
      "type": "string",
      "required": true,
      "example": "checkout-api"
    },
    {
      "name": "server-url",
      "title": "Server url",
      "description": "Address of the Argo CD server, with https://.",
      "type": "string",
      "required": true,
      "example": "https://argocd.example.com"
    },
    {
      "name": "insecure",
      "title": "Insecure",
      "description": "Set to \"true\" to skip TLS certificate checks, for a server with a self-signed certificate.",
      "type": "string",
      "required": false,
      "default": "false",
      "enum": [
        "true",
        "false"
      ]
    },
    {
      "name": "prune",
      "title": "Prune",
      "description": "Set to \"true\" to delete resources that are no longer in Git.",
      "type": "string",
      "required": false,
      "default": "false",
      "enum": [
        "true",
        "false"
      ]
    },
    {
      "name": "revision",
      "title": "Revision",
      "description": "Git revision to sync to. Leave blank to use the revision the application tracks.",
      "type": "string",
      "required": false,
      "default": ""
    },
    {
      "name": "timeout",
      "title": "Timeout",
      "description": "Seconds to wait for the sync, counted again from the same start for health.",
      "type": "string",
      "required": false,
      "default": "300"
    },
    {
      "name": "token-secret-key",
      "title": "Token secret key",
      "description": "Key in that Secret that holds the token.",
      "type": "string",
      "required": false,
      "default": "token"
    },
    {
      "name": "token-secret-name",
      "title": "Token secret name",
      "description": "Name of the Kubernetes Secret that holds an Argo CD API token.",
      "type": "string",
      "required": false,
      "default": "argocd-auth"
    },
    {
      "name": "wait-for-health",
      "title": "Wait for health",
      "description": "Set to \"true\" to wait for the application to report Healthy after the sync.",
      "type": "string",
      "required": false,
      "default": "true",
      "enum": [
        "true",
        "false"
      ]
    }
  ],
  "images": [
    {
      "ref": "cgr.dev/chainguard/python@sha256:8a5780972067cfba4592b10e786a889807ed876c1100f89410fd0ed4e398992c",
      "repository": "cgr.dev/chainguard/python",
      "tag": "latest-dev",
      "digest": "sha256:8a5780972067cfba4592b10e786a889807ed876c1100f89410fd0ed4e398992c"
    }
  ],
  "install": {
    "kubectl": "kubectl apply -n argo -f https://catalog.dagweave.com/api/v1/items/argocd-sync/1.0.0/template.yaml",
    "argo": "argo template create -n argo https://catalog.dagweave.com/api/v1/items/argocd-sync/1.0.0/template.yaml"
  },
  "template": "apiVersion: argoproj.io/v1alpha1\nkind: WorkflowTemplate\nmetadata:\n  name: argocd-sync\n  labels:\n    dagweave.io/catalog-item: argocd-sync\n  annotations:\n    dagweave.io/catalog-version: \"1.0.0\"\n    dagweave.io/catalog-category: \"Kubernetes\"\nspec:\n  entrypoint: sync\n  templates:\n    - name: sync\n      inputs:\n        parameters:\n          - name: app\n          - name: server-url\n          - name: revision\n            default: \"\"\n          - name: prune\n            default: \"false\"\n          - name: wait-for-health\n            default: \"true\"\n          - name: timeout\n            default: \"300\"\n          - name: insecure\n            default: \"false\"\n          - name: token-secret-name\n            default: \"argocd-auth\"\n          - name: token-secret-key\n            default: \"token\"\n      retryStrategy:\n        limit: \"2\"\n        retryPolicy: OnError\n        backoff:\n          duration: 10s\n          factor: \"2\"\n          maxDuration: 2m\n      container:\n        # cgr.dev/chainguard/python:latest-dev\n        image: cgr.dev/chainguard/python@sha256:8a5780972067cfba4592b10e786a889807ed876c1100f89410fd0ed4e398992c\n        command: [sh, -c]\n        args:\n          - |\n            set -eu\n            python - \u003c\u003c'PY'\n            import json, os, ssl, sys, time, urllib.error, urllib.request\n\n            env = os.environ\n            base = env[\"SERVER_URL\"].rstrip(\"/\") + \"/api/v1/applications/\" + env[\"APP\"]\n            ctx = ssl._create_unverified_context() if env[\"INSECURE\"] == \"true\" else None\n            deadline = time.time() + int(env[\"TIMEOUT\"])\n\n\n            def call(method, url, body=None):\n                req = urllib.request.Request(\n                    url, method=method, data=None if body is None else json.dumps(body).encode(),\n                    headers={\"Content-Type\": \"application/json\", \"Authorization\": \"Bearer \" + env[\"ARGOCD_AUTH_TOKEN\"]})\n                try:\n                    with urllib.request.urlopen(req, timeout=30, context=ctx) as resp:\n                        return json.load(resp)\n                except urllib.error.HTTPError as err:\n                    sys.exit(\"argocd answered %s: %s\" % (err.code, err.read().decode()))\n\n\n            body = {\"prune\": env[\"PRUNE\"] == \"true\"}\n            if env[\"REVISION\"]:\n                body[\"revision\"] = env[\"REVISION\"]\n            call(\"POST\", base + \"/sync\", body)\n            print(\"sync requested for\", env[\"APP\"])\n\n            while True:\n                app = call(\"GET\", base)\n                op = app.get(\"status\", {}).get(\"operationState\", {})\n                if not app.get(\"operation\") and op.get(\"phase\") in (\"Succeeded\", \"Failed\", \"Error\"):\n                    break\n                if time.time() \u003e deadline:\n                    sys.exit(\"timed out waiting for the sync to finish\")\n                time.sleep(3)\n            print(\"sync\", op[\"phase\"], \"-\", op.get(\"message\", \"\"))\n            if op[\"phase\"] != \"Succeeded\":\n                sys.exit(1)\n\n            if env[\"WAIT_FOR_HEALTH\"] == \"true\":\n                while True:\n                    health = call(\"GET\", base).get(\"status\", {}).get(\"health\", {}).get(\"status\")\n                    if health == \"Healthy\":\n                        break\n                    if time.time() \u003e deadline:\n                        sys.exit(\"timed out waiting for Healthy, last saw \" + str(health))\n                    time.sleep(3)\n                print(\"application is Healthy\")\n            PY\n        env:\n          - name: APP\n            value: \"{{inputs.parameters.app}}\"\n          - name: SERVER_URL\n            value: \"{{inputs.parameters.server-url}}\"\n          - name: REVISION\n            value: \"{{inputs.parameters.revision}}\"\n          - name: PRUNE\n            value: \"{{inputs.parameters.prune}}\"\n          - name: WAIT_FOR_HEALTH\n            value: \"{{inputs.parameters.wait-for-health}}\"\n          - name: TIMEOUT\n            value: \"{{inputs.parameters.timeout}}\"\n          - name: INSECURE\n            value: \"{{inputs.parameters.insecure}}\"\n          - name: ARGOCD_AUTH_TOKEN\n            valueFrom:\n              secretKeyRef:\n                name: \"{{inputs.parameters.token-secret-name}}\"\n                key: \"{{inputs.parameters.token-secret-key}}\"\n        resources:\n          requests:\n            cpu: 50m\n            memory: 64Mi\n          limits:\n            memory: 256Mi\n",
  "templateSha256": "b1f8391f3bada8bb38b6cf7c305ba40a5de36d91644d2da406e4d686bc739c79",
  "source": "https://github.com/dagweave/catalog/tree/67458f74dbbf913b03177f3cefc69424be85eb1d/catalog/argocd-sync",
  "catalogSha": "67458f74dbbf913b03177f3cefc69424be85eb1d"
}
