feat: add support for multiple GitHub apps#22
Draft
tstollin wants to merge 2 commits into
Draft
Conversation
092d2ba to
c693269
Compare
7f57fcb to
f594a87
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for multiple GitHub Apps across organizations, so each CR can reference its own credentials secret. Also improves the CI workflow to fix a race condition with force-push triggered runs.
Multiple GitHub Apps
Previously the operator used a single, globally-configured credentials secret for all organizations. This PR makes credential resolution per-organization.
New:
spec.githubAppConfig(recommended)Deprecated:
spec.githubAppInstallationIdThe existing field is still supported for backward compatibility. When set alone it falls back to the default secret configured via
--app-credentials-secret-name. If both fields are set,githubAppConfigtakes precedence.Implementation details
GitHubAppConfigCRD type withinstallationIdandcredentialsSecretNamefieldsSecretProviderFuncnow accepts asecretName stringparameter — credentials are fetched lazily on first use and cached per secret nameCachingGitHubClientFactorycaches clients per organization and rate-limit state per GitHub App ID (so installations of the same App share a quota bucket)Organization.ResolveGitHubAppConfig(legacySecretName)resolves the effective config, hiding the deprecated fallback from callersgithubAppConfigorgithubAppInstallationIdis setSecret rotation
The in-memory client cache is not invalidated on Secret updates. A pod restart is required to pick up rotated credentials. Stakater Reloader is recommended for automated rotation workflows.
CI workflow improvements
ci.yml/pr.yml:commitlintandhelm-chart-remindermoved to a dedicatedpr.ymlthat only triggers onpull_requestevents. This eliminates the double-run race where a force-push fires bothpushandpull_request: synchronize, causing the PR-only jobs to be marked as skipped by the push run before the PR run completes.*.gofiles to prevent the workflow file itself from self-matching.Breaking changes
OrganizationSpec.GitHubAppInstallationIdint64to optional*int64. Existing CRs continue to work.SecretProviderFuncfunc(ctx) (*Secret, error)→func(ctx, secretName string) (*Secret, error)GitHubClientManagerinterfaceGetGitHubClientAndCheckRateLimitnow takesv1alpha1.GitHubAppConfiginstead ofint64