Skip to content

Add githubAppClientID as an alternative to githubAppID - #2168

Open
Erik-Schuetze wants to merge 1 commit into
fluxcd:mainfrom
Erik-Schuetze:githubapp-client-id
Open

Erik-Schuetze wants to merge 1 commit into
fluxcd:mainfrom
Erik-Schuetze:githubapp-client-id

Conversation

@Erik-Schuetze

Copy link
Copy Markdown

Refs: fluxcd/pkg#1291
Depends on (merged): fluxcd/pkg#1296
Depends on (merged): fluxcd/flux2#6085

GitHub Apps can be identified either by their numeric AppID or by their ClientID, and GitHub recommends the ClientID in the official docs. As of fluxcd/pkg#1296 (auth/v0.58.0, runtime/v0.114.0), pkg/auth/githubapp accepts a ClientID as the JWT iss claim and pkg/runtime/secrets.GitHubAppDataFromSecret enforces exactly one of the two fields. This PR wires that into source-controller.

Changes

  • go.mod: bump pkg/auth v0.57.0 → v0.58.0 and pkg/runtime v0.112.0 → v0.114.0.
  • gitrepository_controller.go: extend the the default provider case to also trigger on githubAppClientID. (a clientID-only secret without provider: github produces the same misconfiguration warning as for appID)
  • gitrepository_controller_test.go: add a test case for the new branch
  • docs/spec/v1/gitrepositories.md: add githubAppClientID to the GitHub App secret YAML example alongside githubAppID, and document the exactly-one constraint (mirroring the installationOwner / installationID paragraph below it).

Behaviour

  • Existing githubAppID usage is unchanged.
  • Exactly one of githubAppID / githubAppClientID must be provided; enforced by pkg/runtime/secrets.GitHubAppDataFromSecret (same pattern as installationOwner / installationID).
  • No changes to the main auth flow — getAuthOpts delegates to pkg/runtime/secrets and pkg/auth/githubapp, which already handle both fields.

Tests

  • Added test case generic provider with github app client id in secret to TestGitRepositoryReconciler_getAuthOpts_provider.
  • go build ./internal/controller/, gofmt, and the relevant test function pass locally.

Bump pkg/auth to v0.58.0 and pkg/runtime to v0.114.0 for the new
KeyAppClientID constant and the updated GitHubAppDataFromSecret that
accepts either a numeric App ID or an alphanumeric Client ID.

Update the detection heuristic in the default provider case to trigger
on githubAppClientID as well, add a test case, and document the new
field in the GitRepository spec.

Assisted-by: claude-code/claude-sonnet-5
Signed-off-by: Erik Schuetze <erik.schuetze@sap.com>

@matheuscscp matheuscscp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@Erik-Schuetze We may need a PR in image-automation-controller as well, similar to what this PR is changing in gitrepository_controller.go 🙏

@matheuscscp

Copy link
Copy Markdown
Member

@Erik-Schuetze The CI failures are due to our ongoing work regarding events. We will merge a PR to fix it and later ask you to rebase this one 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants