Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRootPath ¶ added in v3.2.0
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)
// 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
// PersistAppHydratorStatus persists the application status for the source hydrator.
PersistAppHydratorStatus(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)
}
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 if the application needs hydration and if so, it updates the application's status to indicate that hydration is in progress. It then adds the hydration queue item to the queue for further processing.
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, hydrates their latest commit, and updates their 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.
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.