argocdrenderer

package
v0.2.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package argocdrenderer provides functionality for rendering ArgoCD Application resources to Kubernetes manifests by calling the ArgoCD API.

Index

Constants

View Source
const (

	// ArgoCDTrackingIDAnnotation is the annotation ArgoCD adds to track resources.
	ArgoCDTrackingIDAnnotation = "argocd.argoproj.io/tracking-id"
	// ArgoCDRefreshAnnotation triggers ArgoCD to re-fetch sources from git.
	ArgoCDRefreshAnnotation = "argocd.argoproj.io/refresh"
	// ArgoCDHydrateAnnotation triggers ArgoCD to re-hydrate rendered manifests.
	ArgoCDHydrateAnnotation = "argocd.argoproj.io/hydrate"
)

Variables

This section is empty.

Functions

func DisableAutoSync

func DisableAutoSync(app *unstructured.Unstructured)

DisableAutoSync removes spec.syncPolicy.automated to prevent ArgoCD from deploying. If spec.syncPolicy is then empty, it is removed as well.

func HasAutoSync

func HasAutoSync(app *unstructured.Unstructured) bool

HasAutoSync checks whether an ArgoCD Application has autosync enabled.

Per ArgoCD docs, autosync is enabled when:

  • spec.syncPolicy.automated is present (even if empty: `automated: {}`)
  • AND spec.syncPolicy.automated.enabled is NOT explicitly set to false

Setting enabled to null or omitting it is treated as enabled. Setting enabled to false disables autosync even if prune/selfHeal/allowEmpty are set.

func ParseApplication

func ParseApplication(data []byte) (*unstructured.Unstructured, error)

ParseApplication parses YAML bytes into an unstructured Application and validates it.

func PatchRefreshAnnotations

func PatchRefreshAnnotations(ctx context.Context, k8sClient client.Client, appName, appNamespace string) error

PatchRefreshAnnotations patches the refresh and hydrate annotations on an existing Application resource in the cluster to trigger ArgoCD to re-fetch and re-render.

func SetRefreshAnnotations

func SetRefreshAnnotations(app *unstructured.Unstructured)

SetRefreshAnnotations adds refresh and hydrate annotations to an Application to trigger ArgoCD to re-fetch sources from git and re-render manifests.

Types

type ArgoCDRendererWorker

type ArgoCDRendererWorker struct {
	KubernetesBridgeWorker kubernetes.KubernetesBridgeWorker
}

ArgoCDRendererWorker renders ArgoCD Application resources to Kubernetes manifests by creating the Application in the cluster and calling the ArgoCD API to get the rendered manifests.

When IsAuthoritative=true, Apply and Destroy of the Application resource are delegated to KubernetesBridgeWorker (SSA). WatchForApply then renders manifests via the ArgoCD API and returns them as LiveState.

When IsAuthoritative=false (default), the Application must already exist in the cluster. The bridge only reads rendered manifests without modifying the Application.

func NewArgoCDRendererWorker

func NewArgoCDRendererWorker() *ArgoCDRendererWorker

func (*ArgoCDRendererWorker) Apply

func (*ArgoCDRendererWorker) Destroy

func (*ArgoCDRendererWorker) Finalize

func (*ArgoCDRendererWorker) ID

func (*ArgoCDRendererWorker) Import

func (*ArgoCDRendererWorker) Info

func (*ArgoCDRendererWorker) Refresh

func (*ArgoCDRendererWorker) WatchForApply

func (w *ArgoCDRendererWorker) WatchForApply(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

func (*ArgoCDRendererWorker) WatchForDestroy

func (w *ArgoCDRendererWorker) WatchForDestroy(wctx api.BridgeWorkerContext, payload api.BridgeWorkerPayload) error

type Config

type Config struct {
	// ServerAddress is the ArgoCD server address (e.g. "argocd-server.argocd.svc.cluster.local").
	ServerAddress string

	// AuthToken is the Bearer token for ArgoCD API authentication.
	AuthToken string

	// Insecure skips TLS verification when true.
	Insecure bool
}

Config holds the configuration for connecting to an ArgoCD server.

type DestinationSettings added in v0.1.43

type DestinationSettings struct {
	// Namespace is spec.destination.namespace from the source Application.
	// When non-empty, the renderer sets metadata.namespace on every
	// namespaced resource in the rendered output that does not already
	// have one.
	Namespace string

	// CreateNamespace is true when the source Application's syncOptions
	// (either spec.syncPolicy.syncOptions or operation.sync.syncOptions)
	// contains "CreateNamespace=true". When true and Namespace is
	// non-empty, the renderer prepends a Namespace document to the
	// rendered output.
	CreateNamespace bool
}

DestinationSettings captures the destination-related fields the renderer bakes into the rendered output so the manifests stored in ConfigHub are self-contained: downstream apply paths do not need to re-derive a destination namespace at apply time, and the deployment bridge does not need a DestinationNamespace option.

func ExtractDestinationSettings added in v0.1.43

func ExtractDestinationSettings(app *unstructured.Unstructured) DestinationSettings

ExtractDestinationSettings reads namespace-related settings from an ArgoCD Application. The renderer uses these to bake namespace information into the rendered output. Returns a zero value when the Application has neither a destination namespace nor a CreateNamespace sync option (the renderer then leaves the manifests untouched).

type ManifestResponse

type ManifestResponse struct {
	Manifests  []string `json:"manifests"`
	Namespace  string   `json:"namespace"`
	Revision   string   `json:"revision"`
	SourceType string   `json:"sourceType"`
}

ManifestResponse represents the response from the ArgoCD manifests API endpoint.

type RenderResult

type RenderResult struct {
	// Manifests is the rendered YAML documents as a byte slice (multi-doc, --- separated).
	Manifests []byte

	// Revision is the source revision used.
	Revision string

	// SourceType is the ArgoCD source type (e.g. "Helm", "Kustomize", "Directory").
	SourceType string
}

RenderResult contains the rendered manifests from ArgoCD.

func RenderArgoCD

func RenderArgoCD(ctx context.Context, appYAML []byte, k8sClient client.Client, config Config) (*RenderResult, error)

RenderArgoCD renders an ArgoCD Application to Kubernetes manifests. It creates/updates the Application in the cluster (with auto-sync disabled), then calls the ArgoCD API to get the rendered manifests.

The Application's destination settings (spec.destination.namespace and the CreateNamespace sync option) are baked into the rendered output so the stored configuration is self-contained.

func RenderExistingArgoCD

func RenderExistingArgoCD(ctx context.Context, k8sClient client.Client, app *unstructured.Unstructured, config Config) (*RenderResult, error)

RenderExistingArgoCD renders manifests for an ArgoCD Application that already exists in the cluster. Unlike RenderArgoCD, it does not create or update the Application. The caller passes the in-cluster Application so destination settings can be extracted from its spec.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址