GitHub support for infra repo - #1176
Conversation
…ort multiple type of git clients.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @shekharc-in. Thanks for your PR. I'm waiting for a nephio-project member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/easycla |
Add GitHub provider support for infrastructure repositories
Summary
Nephio's
RepositoryandTokencontrollers are currently hard-wired to Gitea.This PR introduces a provider-agnostic git client abstraction and adds GitHub as
a second supported provider, so infrastructure repositories can be hosted on
GitHub as well as Gitea.
The provider is selected per-resource via a new
spec.providerfield on theRepositoryCRD, defaulting togitea.What changed
Provider abstraction
git.Clientinterface (controllers/pkg/git/client.go) covering theoperations the reconcilers need: user info, repo CRUD, and access-token
lifecycle.
git/typespackage holding provider-neutral request/response types(
Repository,User,AccessToken,CreateRepoOption, …), so reconcilercode no longer depends on the Gitea SDK types directly.
git.ProviderTypeenum:gitea,github,gitlab. GitLab is declaredbut not implemented — the registration sites are marked so it can be added
without further refactoring.
GitHub client
controllers/pkg/git/githubimplementinggit.Clienton top ofgoogle/go-github/v66.CreateAccessToken()for Porch to consume
personal_access_token,app_id,installation_id,private_key). Full setup instructions are incontrollers/pkg/git/github/README.md.Reconciler changes
map[git.ProviderType]git.Client, populated atstartup for whichever providers have credentials configured.
Repositoryreconciler resolves the provider fromcr.Spec.Provider.Tokenreconciler regenerates GitHub installation tokens on a 55-minuterequeue, since they expire after one hour. Gitea tokens keep their existing
create-once behaviour.
Package move
controllers/pkg/giteaclient→controllers/pkg/git/gitea, now implementingthe shared interface. Behaviour is unchanged.
mocks/external/gitclient, in line with theexisting
mocks/external/...layout.Backward compatibility
Existing Gitea deployments are unaffected.
spec.provideris optional andabsent values resolve to
gitea, preserving today's behaviour and secretlayout. No CRD field was removed or renamed.
Dependencies
Requires the companion API change adding
provider,urlandorgtoRepositorySpec:This PR cannot build or merge until that API change is released. See below.
Testing
githubclient_test.go) and the migratedGitea client.
RepositoryandTokenreconciler tests reworked against thegit.Clientmock, retaining existing coverage.
controllers/pkgsuite passes locally (15 packages);nephio-controller-managerbuilds clean.Before this can merge
Two items I'd like reviewer input on:
replacedirectives must be removed. Bothcontrollers/pkg/go.modandoperators/nephio-controller-manager/go.modcurrently carryreplace github.com/nephio-project/api => ../../../apiso the branch canbuild against the unreleased API change. These will fail CI and must be
dropped once a release of
nephio-project/apicontaining the new fields isavailable.
Pre-existing dependency conflict, surfaced by this work. Building against
the current
apimain pullsnokia/k8s-ipamforward tov0.0.4-0.20241009045647-de66a47ea16c(bumped in api's "Bump go version anddependencies"). That version removes
NephioInterfaceNameKeyandNephioNodeNameKey, whichhenderiw-nephio/networkstill references — andthat module appears unmaintained, with no release newer than
v0.0.0-20231206051529-4287dc43f8a6. This breakscontrollers/pkg/reconcilers/network, which is registered innephio-controller-manager.This is not introduced by this PR — any consumer picking up the newer API
module will hit it. A
replacepinningk8s-ipamback works as a localstopgap, but a proper fix (forking/replacing
henderiw-nephio/network, ordropping the dependency) is out of scope here. Guidance welcome.