Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMalformedEntry = k8s.ErrUserTokenMalformed
var ErrNotFound = k8s.ErrUserTokenNotFound
Sentinel errors for UserTokenStore operations. These reference the canonical errors defined in the k8s package.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ListenHTTP string
GitHubAppID int64
GitHubPrivateKey string
GitHubWebhookSecret string
// Atlassian OAuth 2.0 client credentials (used for per-user token refresh)
JiraClientID string
JiraClientSecret string
JiraDefaultProject string
JiraDefaultIssueType string
// Kubernetes pod identity (from downward API)
PodName string // POD_NAME
PodNamespace string // POD_NAMESPACE
// Leader election config
LeaderEnabled bool // derived: true when PodName and PodNamespace are both set
LeaseDuration time.Duration // JIRA_BOT_LEASE_DURATION, default 15s
LeaseRenewDeadline time.Duration // JIRA_BOT_LEASE_RENEW_DEADLINE, default 10s
TokenLeaseName string // JIRA_BOT_TOKEN_LEASE_NAME
// Per-user token fields
GitHubAppClientID string // JIRA_BOT_GITHUB_APP_CLIENT_ID
GitHubAppClientSecret string // JIRA_BOT_GITHUB_APP_CLIENT_SECRET
UserTokenSecretName string // JIRA_BOT_USER_TOKEN_SECRET_NAME
UserAuthCallbackURL string // JIRA_BOT_USER_AUTH_CALLBACK_URL
RefreshCheckInterval time.Duration // JIRA_BOT_REFRESH_CHECK_INTERVAL, default 30s, clamped [10s, 300s]
// Atlassian Cloud ID for the target Jira site
CloudID string // JIRA_BOT_CLOUD_ID
// Auto-assign: whether to set the assignee field when creating issues
JiraDefaultAssign bool // JIRA_BOT_DEFAULT_ASSIGN, default false
// GitHub redirect base URL prepended to stored path for post-OAuth redirect
GitHubRedirectBaseURL string // JIRA_BOT_GITHUB_REDIRECT_BASE_URL, default "https://github.com"
// Redirect delay in seconds on the success page before auto-redirecting
RedirectDelaySec int // JIRA_BOT_GITHUB_REDIRECT_DELAY_SECONDS, default 3
}
func LoadConfig ¶
func LoadConfig() Config
type GitHubClientInterface ¶
type GitHubClientInterface interface {
ReactWithThumbsUp(ctx context.Context, installationID int64, issueComment *github.IssueComment) error
ReactWithConfused(ctx context.Context, installationID int64, issueComment *github.IssueComment) error
PostComment(ctx context.Context, installationID int64, issueComment *github.IssueComment, body string) error
UpdateIssueDescription(ctx context.Context, installationID int64, issueComment *github.IssueComment, body string) error
FetchComment(ctx context.Context, installationID int64, owner, repo string, commentID uint64) (*github.IssueComment, error)
EditComment(ctx context.Context, installationID int64, owner, repo string, commentID int64, body string) error
ListIssueComments(ctx context.Context, installationID int64, owner, repo string, issueNumber int) ([]*gogithub.IssueComment, error)
}
GitHubClientInterface defines the methods used by the executor and handlers to interact with GitHub. This enables dependency injection of mock implementations during testing.
type JiraClientInterface ¶
type JiraClientInterface interface {
CreateIssue(project, issueType, summary, description string, extraFields map[string]interface{}) (string, error)
}
JiraClientInterface defines the methods used by the executor to interact with Jira. This enables dependency injection of mock implementations during testing.
type JiraClientResolveResult ¶
type JiraClientResolveResult struct {
Client JiraClientInterface
AuthRequired bool
AuthLink string
ErrorMsg string
}
JiraClientResolveResult holds the outcome of resolving a per-user Jira client.
type JiraClientResolver ¶
type JiraClientResolver interface {
// Resolve looks up or constructs a per-user Jira client.
// Returns a result indicating either a ready client or an auth link to present.
Resolve(ctx context.Context, login string) JiraClientResolveResult
}
JiraClientResolver resolves the appropriate per-user Jira client at request time.
type RepoConfigLoaderInterface ¶
type RepoConfigLoaderInterface interface {
LoadRepoConfig(ctx context.Context, installationID int64, owner, repo string) (config.RepoConfig, error)
}
RepoConfigLoaderInterface defines the method for loading per-repository configuration.
type State ¶
type State struct {
Config
GitHubClient GitHubClientInterface
RepoConfigLoader RepoConfigLoaderInterface
UserTokenStore UserTokenStore // per-user token persistence
JiraClientResolver JiraClientResolver // resolves per-user Jira clients
}
type UserTokenEntry ¶
type UserTokenEntry = k8s.UserTokenEntry
UserTokenEntry is a type alias for k8s.UserTokenEntry to maintain a single canonical definition and avoid type mismatches at interface boundaries.
type UserTokenStore ¶
type UserTokenStore interface {
// Read returns a single token entry. Returns ErrNotFound if no entry exists.
// Returns ErrMalformedEntry if the stored JSON is invalid.
Read(ctx context.Context, login string) (UserTokenEntry, error)
// ReadAll returns all valid token entries, skipping malformed ones.
// Returns a map of login → entry.
ReadAll(ctx context.Context) (map[string]UserTokenEntry, error)
// Write creates or updates a token entry for the given login.
// Uses optimistic concurrency with up to 3 retries on conflict.
Write(ctx context.Context, login string, entry UserTokenEntry) error
// Delete removes a token entry for the given login.
Delete(ctx context.Context, login string) error
}
UserTokenStore defines the interface for per-user token persistence.