Skip to content

Extensibility through Event Hooks #1449

@grovesy

Description

@grovesy

Summary

Organizational deployments of Git Proxy often need to run organization-specific integrations before and after Git Proxy actions are performed, such as clone, pull, and push.

Examples include:

  • integration with internal request or approval systems
  • fine-grained entitlement system integrations
  • chat or notification integrations
  • organization-specific scanners or processing hooks

Proposal

Introduce a simple, lightweight, and well-abstracted event system that external integrations can hook into.

These interfaces should be abstracted from Git Proxy internals and should expose only the logical operations Git Proxy is performing. This would allow organizations to extend behavior without coupling directly to internal workflow or chain implementation details.

Example

A simple example of an email handler:

proxy
  .registerEventHandler()
  .onPull()
  .onCompleted(myEmailHandler);

async function myEmailHandler(repo: RepositoryContext, user: UserContext): Promise<void> {
  // Check whether this is the user's first pull of the repository
  if (await isFirstPull(repo, user)) {
    const emailBody = `
Welcome to Git Proxy.

Here is everything you need to get started before submitting your first push request...
`;

    await email.send(user.emailAddress, "Getting started with Git Proxy", emailBody);
  }
}

Proposed API

interface IProxyEventRegistry {
  onPull(): IActionEventHandler;
  onClone(): IActionEventHandler;
  onPush(): IActionEventHandler;
}
interface IActionEventHandler {
  onStarted(handler: ActionEventCallback): IActionEventHandler;
  onCompleted(handler: ActionEventCallback): IActionEventHandler;
  onError(handler: ActionErrorEventCallback): IActionEventHandler;
  onPermissionDenied(handler: ActionEventCallback): IActionEventHandler;
}
type ActionEventCallback = (
  repo: RepositoryContext,
  user: UserContext
) => void | Promise<void>;

type ActionErrorEventCallback = (
  repo: RepositoryContext,
  user: UserContext,
  error: Error
) => void | Promise<void>;

Notes

While the existing chain could theoretically be modified to insert additional actions, that approach is cumbersome and invasive because it requires integrations to hook directly into the core execution flow of Git Proxy.

That would make future workflow refactoring significantly harder, since external users would then become dependent on internal chain handler interfaces and execution semantics.

A dedicated event model would provide a cleaner extension point, with lower coupling and a clearer contract for organizational integrations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions