### Setup Documentation Development Environment Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/CONTRIBUTING.md Create a virtual environment and install MkDocs for local documentation development. ```bash python3 -m venv venv source venv/bin/activate pip3 install mkdocs-material ``` -------------------------------- ### Install Argo CD with Helm Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/how-it-works.md Installs Argo CD using the official Helm chart. Specify a version with `--argocd-chart-version` if needed. ```bash helm install my-argo-cd argo/argo-cd --version x.x.x ``` -------------------------------- ### Install Runner Scale Set Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/reusing-clusters/self-hosted-gh-runner.md Installs the runner scale set using Helm, applying the previously defined configuration file. ```bash # Add the runner scale set Helm repository helm repo add arc-runners https://actions-runner-controller.github.io/arc helm repo update # Install the runner scale set helm install arc-runner-set arc-runners/gha-runner-scale-set \ --version 0.12.1 \ --namespace arc-runners \ --create-namespace \ -f arc-runner-set.yaml ``` -------------------------------- ### Install Action Runner Controller (ARC) Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/reusing-clusters/self-hosted-gh-runner.md Installs the ARC controller using Helm. Ensure you have added the ARC Helm repository. ```bash # Add the ARC Helm repository helm repo add arc-systems https://actions-runner-controller.github.io/arc helm repo update # Install the controller helm install arc arc-systems/gha-runner-scale-set-controller \ --version 0.12.1 \ --namespace arc-systems \ --create-namespace ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/CONTRIBUTING.md Clone the project repository and download Go module dependencies to set up the local development environment. ```bash git clone https://github.com/dag-andersen/argocd-diff-preview.git cd argocd-diff-preview ``` ```bash go mod download ``` -------------------------------- ### Install Argo CD using Helm CLI Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/reusing-clusters/lockdown-mode.md Install Argo CD using the Helm CLI with the specified values file. Ensure the namespace is created and correctly set. ```bash helm repo add argo https://argoproj.github.io/argo-helm helm install argo-cd argo/argo-cd \ --create-namespace \ --namespace argocd-diff-preview \ -f values.yaml ``` -------------------------------- ### Install Argo CD with Helm Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/reusing-clusters/connecting.md Install Argo CD using Helm. Ensure you specify the correct version and namespace. ```bash kind create cluster helm repo add argo https://argoproj.github.io/argo-helm helm install argo-cd argo/argo-cd --version 8.0.3 --create-namespace --namespace argocd-diff-preview ``` -------------------------------- ### Example Diff Output Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/demo.md This is an example of the output generated by the Argo CD Diff Preview tool, showing the status of various components during the process. ```text ✨ Running with: ✨ - local-cluster-tool: Kind ✨ - base-branch: main ✨ - target-branch: helm-example-3 ✨ - secrets-folder: ./secrets ✨ - output-folder: ./output ✨ - repo: dag-andersen/argocd-diff-preview ✨ - timeout: 180 seconds 🚀 Creating cluster... 🚀 Cluster created successfully 🦑 Installing Argo CD Helm Chart version: 'latest' 🦑 Installing Argo CD Helm Chart 🦑 Waiting for Argo CD to start... 🦑 Argo CD is now available 🦑 Logging in to Argo CD through CLI... 🦑 Argo CD installed successfully 🤷 No secrets found in ./secrets 🤖 Fetching all files in dir: base-branch 🤖 Patching applications for branch: main 🤖 Patching 4 Argo CD Application[Sets] for branch: main 🤖 Fetching all files in dir: target-branch 🤖 Patching applications for branch: helm-example-3 🤖 Patching 4 Argo CD Application[Sets] for branch: helm-example-3 🌚 Getting resources from base ⏳ Waiting for 4 out of 4 applications to become 'OutOfSync'. Retrying in 5 seconds. Timeout in 180 seconds... 🌚 Got all resources from 4 applications for base 🧼 Removing applications 🧼 Removed applications successfully 🌚 Getting resources from target ⏳ Waiting for 3 out of 4 applications to become 'OutOfSync'. Retrying in 5 seconds. Timeout in 180 seconds... 🌚 Got all resources from 4 applications for target 💥 Deleting cluster... 🔮 Generating diff between main and helm-example-3 🙏 Please check the ./output/diff.md file for differences 🎉 Done in 99 seconds ``` -------------------------------- ### Install Argo CD from OCI Helm Chart Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/getting-started/custom-argo-cd-installation.md Install Argo CD using an OCI Helm chart by specifying the chart URL and version. This method is an alternative to using classic HTTP Helm repositories. ```bash argocd-diff-preview \ --argocd-chart-url=oci://ghcr.io/argoproj/argo-helm/argo-cd \ --argocd-chart-version=8.6.1 \ --repo=/ \ --target-branch= ``` -------------------------------- ### Example Diff Output for Child App Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/app-of-apps.md This example shows how the diff output for a child application includes a breadcrumb indicating its parent in a two-level app-of-apps hierarchy. ```text
child-app-1 (parent: my-root-app)
#### ConfigMap: default/some-config ... ``` -------------------------------- ### Run Argo CD Diff Preview with Binary Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/getting-started/installation.md Execute the diff preview tool using the installed binary. Specify the repository, base branch, and target branch as command-line arguments. ```bash argocd-diff-preview \ --repo / \ --base-branch \ --target-branch ``` -------------------------------- ### Deployment Diff Example Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-5/target-1/output.md Shows the changes in a Kubernetes Deployment resource, including name and service account modifications, when a watch pattern is applied. ```diff apiVersion: apps/v1 kind: Deployment metadata: labels: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: experiment namespace: default spec: replicas: 5 selector: matchLabels: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/name: myApp template: metadata: labels: @@ skipped 15 lines (21 -> 35) @@ - containerPort: 80 name: http protocol: TCP readinessProbe: httpGet: path: / port: http resources: {} securityContext: {} securityContext: {} - serviceAccountName: super-app-name + serviceAccountName: experiment ``` -------------------------------- ### Download and Install Binary on macOS Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/getting-started/installation.md Download the pre-compiled binary for macOS from the releases page, extract it, and move it to a directory in your system's PATH. ```bash curl -LJO https://github.com/dag-andersen/argocd-diff-preview/releases/download/v0.2.11/argocd-diff-preview-Darwin-x86_64.tar.gz tar -xvf argocd-diff-preview-Darwin-x86_64.tar.gz sudo mv argocd-diff-preview /usr/local/bin argocd-diff-preview --help ``` -------------------------------- ### Service Diff Example Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-5/target-1/output.md Illustrates the differences in a Kubernetes Service resource, focusing on name changes, as a result of applying a watch pattern. ```diff apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: experiment namespace: default spec: ports: - name: http port: 80 protocol: TCP targetPort: http selector: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/name: myApp ``` -------------------------------- ### Repo Server Connection Error Example Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/troubleshooting.md Illustrates typical error messages seen when the repo-server pod crashes or becomes unavailable during rendering. ```text Port forward failed error="lost connection to pod" ⚠️ Transient gRPC Unavailable error from repo server; will retry error="rpc error: code = Unavailable desc = error reading from server: EOF" (app: my-app) (attempt: 1) ... ❌ Failed to render application via repo server: error="... repo server unavailable after 5 attempts: rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing: dial tcp [::1]:8083: connect: connection refused\"" ``` -------------------------------- ### Diff for watch-pattern-valid-regex-example Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-7/target/output.md Shows the differences in Kubernetes resources for the watch-pattern-valid-regex-example. This includes changes to Deployment, Service, and ServiceAccount names, similar to the manifest generation example. ```diff apiVersion: apps/v1 kind: Deployment metadata: labels: app.kubernetes.io/instance: watch-pattern-valid-regex-example app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: super-duper-app-name namespace: default spec: replicas: 5 selector: matchLabels: app.kubernetes.io/instance: watch-pattern-valid-regex-example app.kubernetes.io/name: myApp template: metadata: labels: @@ skipped 15 lines (21 -> 35) @@ - containerPort: 80 name: http protocol: TCP readinessProbe: httpGet: path: / port: http resources: {} securityContext: {} securityContext: {} - serviceAccountName: super-app-name + serviceAccountName: super-duper-app-name ``` ```diff apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/instance: watch-pattern-valid-regex-example app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: super-duper-app-name namespace: default spec: ports: - name: http port: 80 protocol: TCP targetPort: http selector: app.kubernetes.io/instance: watch-pattern-valid-regex-example app.kubernetes.io/name: myApp ``` ```diff apiVersion: v1 automountServiceAccountToken: true kind: ServiceAccount metadata: labels: app.kubernetes.io/instance: watch-pattern-valid-regex-example app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: super-duper-app-name namespace: default ``` -------------------------------- ### Build and Run from Source with Cargo Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/getting-started/installation.md Clone the repository, navigate to the directory, and run the tool using Cargo. This method requires Rust and Cargo to be installed. ```bash git clone https://github.com/dag-andersen/argocd-diff-preview cd argocd-diff-preview cargo run -- --help ``` -------------------------------- ### Repo Server Restart Log Example Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/troubleshooting.md A log line indicating that the repo-server container has restarted, which can lead to rendering failures. ```text ⚠️ Container 'argocd-repo-server' in pod 'argocd-repo-server-xxx' has restarted (restarts: 0 -> 1). This may cause rendering failures or timeouts. ``` -------------------------------- ### Service Diff Example Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-5/target-1/output.html Illustrates changes within a Kubernetes Service resource, focusing on metadata and spec details like ports and selector. This is useful for monitoring network configurations. ```yaml apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: experiment namespace: default spec: ports: - name: http port: 80 protocol: TCP targetPort: http selector: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/name: myApp ``` -------------------------------- ### Deployment Diff Example Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-5/target-1/output.html Shows changes in a Kubernetes Deployment resource, including metadata labels and spec fields like serviceAccountName. Use this to track modifications to your application's deployment configuration. ```yaml apiVersion: apps/v1 kind: Deployment metadata: labels: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: experiment namespace: default spec: replicas: 5 selector: matchLabels: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/name: myApp template: metadata: labels: @@ skipped 15 lines (21 -> 35) @@ - containerPort: 80 name: http protocol: TCP readinessProbe: httpGet: path: / port: http resources: {} securityContext: {} securityContext: {} - serviceAccountName: super-app-name + serviceAccountName: experiment ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/CONTRIBUTING.md Build and serve the project's documentation locally using MkDocs. The documentation will be available in your default browser. ```bash make mkdocs ``` -------------------------------- ### Build Tool with Go Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/CONTRIBUTING.md Compile the project using Go to create a binary executable in the bin/ directory. ```bash make go-build ``` -------------------------------- ### Stale Cache Error Example Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/troubleshooting.md An example of an error message indicating a stale cache issue when trying to resolve a git revision. ```text unable to resolve git revision : unable to resolve 'refs/pull/833/merge' to a commit SHA ``` -------------------------------- ### Run All Integration Tests with Go Binary Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/README.md Builds the Go binary and executes all integration tests using the default render method. Run from the repository root. ```bash make run-integration-tests-go ``` -------------------------------- ### Build Go Binary and Docker Image Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/AGENTS.md Use these commands to build the Go binary or Docker image for the tool. Specify the target branch when running with Go or Docker. ```bash make go-build # Build Go binary to bin/argocd-diff-preview ``` ```bash make docker-build # Build Docker image ``` ```bash make run-with-go target_branch= # Run with Go ``` ```bash make run-with-docker target_branch= # Run with Docker ``` -------------------------------- ### Build Tool with Docker Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/CONTRIBUTING.md Create a Docker image for the project. ```bash make docker-build ``` -------------------------------- ### Run a Single Integration Test Case (Go) with Specific Render Method Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/README.md Executes a specific integration test case using the Go binary and forces a particular render method, such as `server-api`. Assumes the binary has been built. Navigate to the `integration-test` directory first. ```bash cd integration-test TEST_CASE="branch-1/target-1" go test -v -timeout 10m -run TestSingleCase -render-method=server-api ./... ``` -------------------------------- ### Install Namespace-Scoped Argo CD with Helm Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/reusing-clusters/lockdown-mode.md Configure Helm values to install Argo CD with namespace-scoped permissions by setting `createClusterRoles: false`. This ensures Argo CD only has access within its specified namespace. ```yaml nameOverride: argocd-diff-preview namespaceOverride: "argocd-diff-preview" createClusterRoles: false # The important part! crds: install: false # Only install CRDs if you don't have them already installed notifications: enabled: false dex: enabled: false applicationSet: replicas: 0 controller: roleRules: - apiGroups: - "*" resources: - "*" verbs: - get - list - watch - apiGroups: - argoproj.io resources: - applications - applications/status verbs: - get - list - watch - update - patch ``` -------------------------------- ### Run a Single Integration Test Case (Go) Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/README.md Executes a specific integration test case using the Go binary. Assumes the binary has been built. Navigate to the `integration-test` directory first. Reuses an existing cluster if available. ```bash cd integration-test TEST_CASE="branch-1/target-1" go test -v -timeout 10m -run TestSingleCase ./... ``` -------------------------------- ### Ignore Annotation Example: ServiceAccount Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-13/target-1/output.md This Kubernetes ServiceAccount manifest is part of an example demonstrating how to use annotations to ignore specific resources in Argo CD diff previews. It defines a service account for the application. ```yaml +apiVersion: v1 +automountServiceAccountToken: true +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/instance: ignore-annotation-example + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: myApp + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: myApp-0.1.0 + name: super-app-name + namespace: default ``` -------------------------------- ### Clone and Run Argo CD Diff Preview Locally Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/README.md Follow these three commands to clone the repository, set up branches, and run the tool locally using Docker. Ensure Docker is running before execution. The output will be saved to ./output/diff.md. ```bash git clone https://github.com/dag-andersen/argocd-diff-preview base-branch --depth 1 -q git clone https://github.com/dag-andersen/argocd-diff-preview target-branch --depth 1 -q -b helm-example-3 docker run \ --network host \ -v /var/run/docker.sock:/var/run/docker.sock \ -v $(pwd)/output:/output \ -v $(pwd)/base-branch:/base-branch \ -v $(pwd)/target-branch:/target-branch \ -e TARGET_BRANCH=helm-example-3 \ -e REPO=dag-andersen/argocd-diff-preview \ dagandersen/argocd-diff-preview:v0.2.11 ``` ```bash cat ./output/diff.md ``` -------------------------------- ### Ignore Annotation Example: Service Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-13/target-1/output.md This Kubernetes Service manifest is part of an example demonstrating how to use annotations to ignore specific resources in Argo CD diff previews. It defines a ClusterIP service for the application. ```yaml +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/instance: ignore-annotation-example + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: myApp + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: myApp-0.1.0 + name: super-app-name + namespace: default +spec: + ports: + - name: http + port: 80 + protocol: TCP + targetPort: http + selector: + app.kubernetes.io/instance: ignore-annotation-example + app.kubernetes.io/name: myApp + type: ClusterIP ``` -------------------------------- ### Dockerfile for argocd-diff-preview Runner Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/reusing-clusters/openshift.md This Dockerfile sets up a Red Hat UBI minimal image with necessary tools like curl, git, tar, and unzip. It installs the argocd CLI (optional), argocd-diff-preview CLI, kubectl, and oc CLI, preparing the environment for CI tasks. ```dockerfile FROM registry.access.redhat.com/ubi10-minimal:latest RUN microdnf install -y curl git tar unzip && \ rm -rf /var/cache/yum/* # argocd CLI (optional) # only needed if using --render-method=cli RUN curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 && \ install -m 555 argocd-linux-amd64 /usr/local/bin/argocd && \ rm argocd-linux-amd64 && \ argocd version || true # argocd-diff-preview CLI RUN curl -LJO https://github.com/dag-andersen/argocd-diff-preview/releases/download/v0.2.11/argocd-diff-preview-Linux-x86_64.tar.gz && \ tar -xvf argocd-diff-preview-Linux-x86_64.tar.gz && \ mv argocd-diff-preview /usr/local/bin && \ argocd-diff-preview --version # kubectl CLI # dependency of argocd-diff-preview, utilized by go k8s-client RUN curl -LO https://dl.k8s.io/release/v1.34.0/bin/linux/amd64/kubectl && \ install -m 555 kubectl /usr/local/bin/kubectl && \ rm -f kubectl # oc CLI # utilized by runner to login to openshift with the argocd-diff-preview-access service account # e.g. oc login --server "$OPENSHIFT_SERVER" -token="$ARGOCD_DIFF_PREVIEW_OPENSHIFT_SA_TOKEN" RUN curl -L -o /tmp/oc.tar.gz https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz && \ tar -xzvf /tmp/oc.tar.gz -C /usr/local/bin oc && \ chmod +x /usr/local/bin/oc && \ rm -f /tmp/oc.tar.gz ``` -------------------------------- ### Run Integration Tests with Go Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/CONTRIBUTING.md Execute all integration tests using a Go binary. This verifies the tool's behavior in a Kubernetes environment. ```bash make run-integration-tests-go ``` -------------------------------- ### Ignore Annotation Example: Deployment Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-13/target-1/output.md This Kubernetes Deployment manifest is part of an example demonstrating how to use annotations to ignore specific resources in Argo CD diff previews. It shows a typical Nginx deployment configuration. ```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/instance: ignore-annotation-example + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: myApp + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: myApp-0.1.0 + name: super-app-name + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: ignore-annotation-example + app.kubernetes.io/name: myApp + template: + metadata: + labels: + app.kubernetes.io/instance: ignore-annotation-example + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: myApp + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: myApp-0.1.0 + spec: + containers: + - image: nginx:1.16.0 + imagePullPolicy: IfNotPresent + livenessProbe: + httpGet: + path: / + port: http + name: myApp + ports: + - containerPort: 80 + name: http + protocol: TCP + readinessProbe: + httpGet: + path: / + port: http + resources: {} + securityContext: {} + securityContext: {} + serviceAccountName: super-app-name ``` -------------------------------- ### Modified Container Port in Deployment Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-1/target-2/output.html This snippet illustrates a modification in a Deployment manifest, specifically a change in the container port. Lines starting with '-' show the old value, and lines starting with '+' show the new value. ```yaml - - containerPort: 8080 + - containerPort: 80 ``` -------------------------------- ### Install ArgoCD Lovely Plugin via Helm Values (Binary) Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/getting-started/custom-argo-cd-installation.md Configure the Argo CD Helm chart to include the ArgoCD Lovely plugin by defining extra containers in `values.yaml`. This method is for binary installations where Helm values are written to a specific config directory. ```yaml jobs: build: ... steps: ... - name: Set Argo CD Custom Values run: | mkdir -p argocd-config cat > argocd-config/values.yaml << "EOF" repoServer: extraContainers: # ArgoCD Lovely plugin - https://github.com/crumbhole/argocd-lovely-plugin - name: lovely-plugin image: ghcr.io/crumbhole/lovely:1.1.1 securityContext: runAsNonRoot: true runAsUser: 999 volumeMounts: # Import the repo-server's plugin binary - mountPath: /var/run/argocd name: var-files - mountPath: /home/argocd/cmp-server/plugins name: plugins - mountPath: /tmp name: lovely-tmp volumes: - emptyDir: {} name: lovely-tmp EOF - name: Generate Diff run: | argocd-diff-preview \ --repo / \ --base-branch \ --target-branch ``` -------------------------------- ### Service Diff Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-5/target-2/output.md Illustrates the differences in a Kubernetes Service manifest. This example shows changes to the service name. ```diff apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: experiment namespace: default spec: ports: - name: http port: 80 protocol: TCP targetPort: http selector: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/name: myApp ``` -------------------------------- ### ServiceAccount Diff Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-5/target-2/output.md Displays the differences in a Kubernetes ServiceAccount manifest. This example shows a change in the service account name. ```diff apiVersion: v1 automountServiceAccountToken: true kind: ServiceAccount metadata: labels: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: experiment namespace: default ``` -------------------------------- ### Build Go Binary for Integration Tests Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/README.md Builds the Go binary required for running individual integration tests. This command should be executed from the repository root. ```bash make go-build ``` -------------------------------- ### Kubernetes Service Diff (watch-pattern) Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-7/target/output.html Highlights modifications in a Kubernetes Service manifest for the watch-pattern example, focusing on name changes. ```yaml apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/instance: watch-pattern-valid-regex-example app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: super-duper-app-name namespace: default spec: ports: - name: http port: 80 protocol: TCP targetPort: http selector: app.kubernetes.io/instance: watch-pattern-valid-regex-example app.kubernetes.io/name: myApp ``` -------------------------------- ### Add Environment to ConfigMap Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-17/target-1/output.html Illustrates adding a new key-value pair to a ConfigMap. This example adds an 'environment' field to the data. ```yaml apiVersion: v1 kind: ConfigMap metadata: name: level-2a-config namespace: default data: app: level-2a - color: green + color: yellow + environment: production ``` -------------------------------- ### Run argocd-diff-preview with Multi-Repo Setup Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/docs/multi-repo.md This command demonstrates how to run the argocd-diff-preview Docker container for multi-repository scenarios. Ensure the `-e REPO` variable matches the repository containing the PR and `-e TARGET_BRANCH` is set to the PR branch. The volumes map local directories to the container for base and target branches, as well as output. ```bash docker run \ --network=host \ -v /var/run/docker.sock:/var/run/docker.sock \ -v $(pwd)/main:/base-branch \ -v $(pwd)/pull-request:/target-branch \ -v $(pwd)/output:/output \ -e REPO=/ \ -e TARGET_BRANCH= \ dagandersen/argocd-diff-preview:v0.2.11 ``` -------------------------------- ### Argo CD Diff Preview YAML Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-16/target/output.md Example of a diff preview in YAML format, indicating modified resources and their changes. ```yaml Modified (1): ± my-app (+1|-1) ``` -------------------------------- ### Run a Single Integration Test Case (Go) with New Cluster Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/README.md Executes a specific integration test case using the Go binary and forces the creation of a new Kubernetes cluster. Assumes the binary has been built. Navigate to the `integration-test` directory first. ```bash cd integration-test TEST_CASE="branch-1/target-1" go test -v -timeout 10m -run TestSingleCase -create-cluster ./... ``` -------------------------------- ### Deployment Diff Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-5/target-2/output.md Shows the differences in a Kubernetes Deployment manifest. This example highlights changes in the deployment name and service account name. ```diff apiVersion: apps/v1 kind: Deployment metadata: labels: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: experiment namespace: default spec: replicas: 5 selector: matchLabels: app.kubernetes.io/instance: my-app-watch-pattern-valid-regex app.kubernetes.io/name: myApp template: metadata: labels: @@ skipped 15 lines (21 -> 35) @@ - containerPort: 80 name: http protocol: TCP readinessProbe: httpGet: path: / port: http resources: {} securityContext: {} securityContext: {} - serviceAccountName: super-app-name + serviceAccountName: experiment ``` -------------------------------- ### Run Single Integration Test Case (Go) Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/CONTRIBUTING.md Execute a specific integration test case using a Go binary. Useful for debugging. Reuses an existing cluster if available. ```bash cd integration-test && TEST_CASE="branch-1/target-1" go test -v -timeout 10m -run TestSingleCase ./... ``` -------------------------------- ### Argo CD ApplicationSet Manifest Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-17/target-2/output.html Example of an Argo CD ApplicationSet manifest. Use this to dynamically generate Argo CD Applications. ```yaml apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: level-1c-appset namespace: argocd spec: generators: - list: elements: - env: prod - env: staging template: metadata: name: level-1c-{{env}}-app namespace: argocd spec: destination: name: in-cluster namespace: default project: default source: ``` -------------------------------- ### Run a Single Integration Test Case (Docker) Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/README.md Executes a specific integration test case using Docker. Assumes the Go binary has been built. Navigate to the `integration-test` directory first. ```bash cd integration-test TEST_CASE="branch-1/target-1" go test -v -timeout 10m -run TestSingleCase -docker ./... ``` -------------------------------- ### Modified Deployment in multi-source-app Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-1/target-2/output.md This diff highlights a modification in the 'backend' Deployment within the 'multi-source-app' example. The change involves the container port. ```diff app: backend template: metadata: labels: app: backend spec: containers: - image: my-org/backend:1.0.0 name: backend ports: - - containerPort: 8080 + - containerPort: 80 ``` -------------------------------- ### Diff for valid-manifest-generate-paths-example Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-7/target/output.md Shows the differences in Kubernetes resources for the valid-manifest-generate-paths-example. This includes changes to Deployment, Service, and ServiceAccount names. ```diff apiVersion: apps/v1 kind: Deployment metadata: labels: app.kubernetes.io/instance: valid-manifest-generate-paths-example app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: super-duper-app-name namespace: default spec: replicas: 5 selector: matchLabels: app.kubernetes.io/instance: valid-manifest-generate-paths-example app.kubernetes.io/name: myApp template: metadata: labels: @@ skipped 15 lines (21 -> 35) @@ - containerPort: 80 name: http protocol: TCP readinessProbe: httpGet: path: / port: http resources: {} securityContext: {} securityContext: {} - serviceAccountName: super-app-name + serviceAccountName: super-duper-app-name ``` ```diff apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/instance: valid-manifest-generate-paths-example app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: super-duper-app-name namespace: default spec: ports: - name: http port: 80 protocol: TCP targetPort: http selector: app.kubernetes.io/instance: valid-manifest-generate-paths-example app.kubernetes.io/name: myApp ``` ```diff apiVersion: v1 automountServiceAccountToken: true kind: ServiceAccount metadata: labels: app.kubernetes.io/instance: valid-manifest-generate-paths-example app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: super-duper-app-name namespace: default ``` -------------------------------- ### Kubernetes Deployment Diff (watch-pattern) Source: https://github.com/dag-andersen/argocd-diff-preview/blob/main/integration-test/branch-7/target/output.html Shows changes in a Kubernetes Deployment manifest for the watch-pattern example, including name and service account updates. ```yaml apiVersion: apps/v1 kind: Deployment metadata: labels: app.kubernetes.io/instance: watch-pattern-valid-regex-example app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: myApp app.kubernetes.io/version: 1.16.0 helm.sh/chart: myApp-0.1.0 - name: super-app-name + name: super-duper-app-name namespace: default spec: replicas: 5 selector: matchLabels: app.kubernetes.io/instance: watch-pattern-valid-regex-example app.kubernetes.io/name: myApp template: metadata: labels: @@ skipped 15 lines (21 -> 35) @@ - containerPort: 80 name: http protocol: TCP readinessProbe: httpGet: path: / port: http resources: {} securityContext: {} securityContext: {} - serviceAccountName: super-app-name + serviceAccountName: super-duper-app-name ```