githubreconciler

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOrgTokenSource added in v0.7.5

func NewOrgTokenSource(ctx context.Context, identity, org string) oauth2.TokenSource

NewOrgTokenSource creates a new token source for org-scoped GitHub credentials

func NewRepoTokenSource added in v0.7.5

func NewRepoTokenSource(ctx context.Context, identity, org, repo string) oauth2.TokenSource

NewRepoTokenSource creates a new token source for repo-scoped GitHub credentials

Types

type ClientCache

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

ClientCache manages GitHub clients for multiple org/repo combinations.

func NewClientCache

func NewClientCache(tokenSourceFunc TokenSourceFunc) *ClientCache

NewClientCache creates a new client cache with the provided token source function.

func (*ClientCache) Clear

func (cc *ClientCache) Clear()

Clear removes all cached clients.

func (*ClientCache) Get

func (cc *ClientCache) Get(ctx context.Context, org, repo string) (*github.Client, error)

Get returns a GitHub client for the given org/repo, creating one if needed.

type Option

type Option func(*Reconciler)

Option configures a Reconciler.

func WithOrgScopedCredentials added in v0.7.0

func WithOrgScopedCredentials() Option

WithOrgScopedCredentials configures the reconciler to use org-scoped credentials instead of repo-scoped credentials. When enabled, the same GitHub client will be used for all repositories within an organization.

func WithReconciler

func WithReconciler(f ReconcilerFunc) Option

WithReconciler sets the reconciler function for all resource types.

func WithStateManager

func WithStateManager(sm *StateManager) Option

WithStateManager sets a custom state manager.

type Reconciler

type Reconciler struct {
	workqueue.UnimplementedWorkqueueServiceServer
	// contains filtered or unexported fields
}

Reconciler manages the reconciliation of GitHub resources.

func NewReconciler

func NewReconciler(cc *ClientCache, opts ...Option) *Reconciler

NewReconciler creates a new Reconciler with the given options.

func (*Reconciler) GetStateManager

func (r *Reconciler) GetStateManager() *StateManager

GetStateManager returns the state manager for accessing state operations.

func (*Reconciler) Process added in v0.6.196

Process implements the WorkqueueService.Process RPC.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, url string) error

Reconcile processes the given resource URL.

type ReconcilerFunc

type ReconcilerFunc func(ctx context.Context, res *Resource, gh *github.Client) error

ReconcilerFunc is the function signature for GitHub resource reconcilers. It receives the parsed resource information and appropriate GitHub client, and returns an error if reconciliation fails.

type Resource

type Resource struct {
	// Owner is the GitHub organization or user.
	Owner string

	// Repo is the repository name.
	Repo string

	// Number is the issue or pull request number.
	Number int

	// Type indicates whether this is an issue or pull request.
	Type ResourceType

	// URL is the original URL that was parsed.
	URL string
}

Resource represents a parsed GitHub resource (issue or pull request).

func ParseURL

func ParseURL(uri string) (*Resource, error)

ParseURL parses a GitHub issue or pull request URL and extracts the components.

Expected formats:

func (*Resource) String

func (r *Resource) String() string

String returns the string representation of the resource.

type ResourceType

type ResourceType string

ResourceType represents the type of GitHub resource.

const (
	// ResourceTypeIssue represents a GitHub issue.
	ResourceTypeIssue ResourceType = "issue"

	// ResourceTypePullRequest represents a GitHub pull request.
	ResourceTypePullRequest ResourceType = "pull_request"
)

type State

type State[T any] struct {
	// contains filtered or unexported fields
}

State wraps a typed state with resource information.

func NewState

func NewState[T any](identity string, client *github.Client, resource *Resource) *State[T]

NewState creates a new state instance for a specific resource.

func (*State[T]) Commit

func (s *State[T]) Commit(ctx context.Context, state *T, message string) error

Commit updates or creates the automation comment with new state and message.

func (*State[T]) Fetch

func (s *State[T]) Fetch(ctx context.Context) (*T, error)

Fetch retrieves the current state from the automation comment.

type StateManager

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

StateManager manages reconciler state stored in GitHub comments.

func NewStateManager

func NewStateManager(identity string) *StateManager

NewStateManager creates a new state manager with the given identity. The identity is used to identify comments created by this reconciler.

func (*StateManager) Identity

func (sm *StateManager) Identity() string

Identity returns the identity used by this state manager.

type TokenSourceFunc

type TokenSourceFunc func(ctx context.Context, org, repo string) (oauth2.TokenSource, error)

TokenSourceFunc is a function that creates an OAuth2 token source for a given org/repo.

Directories

Path Synopsis
Package statusmanager provides Kubernetes-style status management for GitHub reconcilers using GitHub Check Runs API.
Package statusmanager provides Kubernetes-style status management for GitHub reconcilers using GitHub Check Runs API.

Jump to

Keyboard shortcuts

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