hydrator

package
v3.5.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRootPath added in v3.2.0

func IsRootPath(path string) bool

IsRootPath returns whether the path references a root path

Types

type Dependencies

type Dependencies interface {

	// GetProcessableAppProj returns the AppProject for the given application. It should only return projects that are
	// processable by the controller, meaning that the project is not deleted and the application is in a namespace
	// permitted by the project.
	GetProcessableAppProj(app *appv1.Application) (*appv1.AppProject, error)

	// GetProcessableApps returns a list of applications that are processable by the controller.
	GetProcessableApps() (*appv1.ApplicationList, error)

	// EvaluateAppRevisionsChanges checks if any source revisions have changes without generating manifests.
	// The returned string is the resolved revision for the given source.
	EvaluateAppRevisionsChanges(ctx context.Context, app *appv1.Application, source appv1.ApplicationSource, revision string, project *appv1.AppProject, noRevisionCache bool) (bool, string, error)

	// GetRepoObjs returns the repository objects for the given application, source, and revision. It calls the repo-
	// server and gets the manifests (objects).
	GetRepoObjs(ctx context.Context, app *appv1.Application, source appv1.ApplicationSource, revision string, project *appv1.AppProject) ([]*unstructured.Unstructured, *apiclient.ManifestResponse, error)

	// GetWriteCredentials returns the repository credentials for the given repository URL and project. These are to be
	// sent to the commit server to write the hydrated manifests.
	GetWriteCredentials(ctx context.Context, repoURL string, project string) (*appv1.Repository, error)

	// RequestAppRefresh requests a refresh of the application with the given name and namespace. This is used to
	// trigger a refresh after the application has been hydrated and a new commit has been pushed.
	RequestAppRefresh(appName string, appNamespace string) error

	// PersistHydrationStatus persists the application status for the source hydrator.
	PersistHydrationStatus(orig *appv1.Application, newStatus *appv1.SourceHydratorStatus)

	// AddHydrationQueueItem adds a hydration queue item to the queue. This is used to trigger the hydration process for
	// a group of applications which are hydrating to the same repo and target branch.
	AddHydrationQueueItem(key types.HydrationQueueKey)

	// GetHydratorCommitMessageTemplate gets the configured template for rendering commit messages.
	GetHydratorCommitMessageTemplate() (string, error)

	// GetHydratorReadmeMessageTemplate gets the configured template for rendering README messages.
	GetHydratorReadmeMessageTemplate() (string, error)

	// GetCommitAuthorName gets the configured commit author name from argocd-cm ConfigMap.
	GetCommitAuthorName() (string, error)

	// GetCommitAuthorEmail gets the configured commit author email from argocd-cm ConfigMap.
	GetCommitAuthorEmail() (string, error)
}

Dependencies is the interface for the dependencies of the Hydrator. It serves two purposes: 1) it prevents the hydrator from having direct access to the app controller, and 2) it allows for easy mocking of dependencies in tests. If you add something here, be sure that it is something the app controller needs to provide to the hydrator.

type Hydrator

type Hydrator struct {
	// contains filtered or unexported fields
}

Hydrator is the main struct that implements the hydration logic. It uses the Dependencies interface to access the app controller's functionality without directly depending on it.

func NewHydrator

func NewHydrator(dependencies Dependencies, statusRefreshTimeout time.Duration, commitClientset commitclient.Clientset, repoClientset apiclient.Clientset, repoGetter RepoGetter) *Hydrator

NewHydrator creates a new Hydrator instance with the given dependencies, status refresh timeout, commit clientset, repo clientset, and repo getter. The refresh timeout determines how often the hydrator checks if an application needs to be hydrated.

func (*Hydrator) ProcessAppHydrateQueueItem

func (h *Hydrator) ProcessAppHydrateQueueItem(origApp *appv1.Application)

ProcessAppHydrateQueueItem processes an application hydrate queue item. It checks whether the application needs hydration and, if so, enqueues the deduped hydration key.

The per-app status update that marks the application as Hydrating is deliberately NOT done here. It is performed by ProcessHydrationQueueItem, which gathers every application sharing the hydration key and updates them together. Because the hydration workqueue dedups by key and never hands the same key to two workers concurrently, ProcessHydrationQueueItem holds exclusive ownership of the entire app group when it runs — there is no possibility of a worker observing a partial view of the group, so the status update is safe under parallel hydration workers (https://github.com/argoproj/argo-cd/issues/27926).

It's likely that multiple applications will trigger hydration at the same time. The hydration queue key is meant to dedupe these requests.

func (*Hydrator) ProcessHydrationQueueItem

func (h *Hydrator) ProcessHydrationQueueItem(hydrationKey types.HydrationQueueKey)

ProcessHydrationQueueItem processes a hydration queue item. It retrieves the relevant applications for the given hydration key, marks every app in the group as Hydrating, generates and commits their manifests, and updates each app's status accordingly. If the hydration fails, it marks the operation as failed and logs the error. If successful, it updates the operation to indicate that hydration was successful and requests a refresh of the applications to pick up the new hydrated commit.

The hydration workqueue is a rate-limiting queue keyed by hydration key, which guarantees the same key is never handed to two workers at once. So at the start of this function we hold exclusive ownership over the entire app group sharing this key. That ownership is what makes the per-app status updates safe even when multiple hydration workers are running in parallel (https://github.com/argoproj/argo-cd/issues/27926): there is no possibility of a worker observing a partial view of the group, so we can mark every app Hydrating up front and keep their statuses in lockstep with the single commit produced by hydrate().

type RepoGetter added in v3.1.0

type RepoGetter interface {
	// GetRepository returns a repository by its URL and project name.
	GetRepository(ctx context.Context, repoURL, project string) (*appv1.Repository, error)
}

RepoGetter is an interface that defines methods for getting repository objects. It's a subset of the DB interface to avoid granting access to things we don't need.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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