Skip to content

Integrate Gitea Repo and Team Management into cr8tor-operator#51

Open
sauravscode wants to merge 13 commits into
mainfrom
feature/ss-cr8tor-gitea-int
Open

Integrate Gitea Repo and Team Management into cr8tor-operator#51
sauravscode wants to merge 13 commits into
mainfrom
feature/ss-cr8tor-gitea-int

Conversation

@sauravscode

Copy link
Copy Markdown
  • Adds async Gitea organisation, team, and repository provisioning for projects and groups.
  • Handles Gitea user-team membership based on group membership.
  • Adds robust error handling and feature flag for Gitea integration.
  • Updates operator deployment and Helm chart to support Gitea configuration via secrets and environment variables.
  • Refactors operator handlers to support async Gitea operations.
  • Ensures all Gitea API calls are modular, secure, and up-to-date with the latest Gitea API.
  • CRD management and project/group logic refactored for extensibility.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the cr8tor operator with Gitea provisioning capabilities (org/team/repo + user/team membership syncing), introduces a new “project-sync” plugin/handler for generating CRDs from published project data, and updates Helm/chart configuration to support these integrations.

Changes:

  • Add async Gitea client/manager and integrate Gitea org/team/repo provisioning + membership updates into identity/project handlers.
  • Introduce project_sync plugin and a ConfigMap-triggered handler to generate/apply User/Group/Project CRDs.
  • Update Helm values/deployment wiring and relax project network policy to allow Gitea and external egress.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/cr8tor/services/network_policy_manager.py Allows ingress/egress to gitea namespace and adds egress to world.
src/cr8tor/services/gitea/client.py New async HTTP client for Gitea API access via env-configured URL/token.
src/cr8tor/services/gitea/manager.py New async helpers for ensuring/deleting orgs, teams, repos, and team membership.
src/cr8tor/services/gitea/init.py Exposes Gitea integration functions via package exports.
src/cr8tor/plugins/registry.py Registers new builtin plugin module cr8tor.plugins.project_sync.
src/cr8tor/plugins/project_sync.py New plugin that generates/applies CRDs based on published project data.
src/cr8tor/handlers/project_sync_handler.py New kopf handler to trigger project sync from labeled ConfigMaps.
src/cr8tor/handlers/identity_handler.py Refactors handlers to async and adds Gitea provisioning/membership logic.
src/cr8tor/handlers/init.py Ensures new handler module is imported/available.
charts/cr8tor-operator/values.yaml Adds services ConfigMap name and Gitea enablement/secret configuration.
charts/cr8tor-operator/templates/deployment.yaml Wires services ConfigMap + Gitea env vars and adds initContainer wait logic.
charts/cr8tor-operator/templates/configmap.yaml Updates VDI pod template to reference a renamed init-scripts ConfigMap.
Comments suppressed due to low confidence (1)

src/cr8tor/handlers/identity_handler.py:81

  • get_user_projects() uses api.list_namespaced_custom_object(...) but api is no longer defined in this function (the CustomObjectsApi() instantiation was removed). This will raise a NameError and break notebook PVC provisioning and any downstream logic that depends on project resolution. Reintroduce a local api = kubernetes.client.CustomObjectsApi() (or otherwise pass/reuse a defined client) before calling api.list_namespaced_custom_object.
    try:
        all_groups = api.list_namespaced_custom_object(
            group="identity.karectl.io",
            version="v1alpha1",
            namespace=IDENTITY_NAMESPACE,
            plural="groups",
        )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cr8tor/handlers/identity_handler.py
Comment thread charts/cr8tor-operator/templates/configmap.yaml Outdated
Comment thread src/cr8tor/services/network_policy_manager.py
Comment on lines +58 to +83
async def get(self, path):
""" Make GET requests.
"""
async with httpx.AsyncClient(verify=self.verify_tls, timeout=30.0) as client:
url = f"{self.base_url}{path}"
logger.debug(f"GET {url}")
response = await client.get(url, headers=self._get_headers())
response.raise_for_status()
return response.json()

async def post(self, path, data):
""" Make POST request
"""
async with httpx.AsyncClient(verify=self.verify_tls, timeout=30.0) as client:
url = f"{self.base_url}{path}"
logger.debug(f"POST {url}")
response = await client.post(url, headers=self._get_headers(), json=data)
response.raise_for_status()
return response.json() if response.content else {}

async def put(self, path, data=None):
""" Make PUT request.
"""
async with httpx.AsyncClient(verify=self.verify_tls, timeout=30.0) as client:
url = f"{self.base_url}{path}"
logger.debug(f"PUT {url}")
Comment thread src/cr8tor/services/gitea/client.py Outdated
Comment thread src/cr8tor/services/gitea/manager.py Outdated
Comment thread src/cr8tor/plugins/project_sync.py Outdated
Comment thread src/cr8tor/plugins/project_sync.py Outdated
Comment thread src/cr8tor/handlers/identity_handler.py
Comment thread src/cr8tor/handlers/identity_handler.py
Comment thread src/cr8tor/handlers/identity_handler.py
Comment thread src/cr8tor/handlers/identity_handler.py Outdated
Comment thread src/cr8tor/services/gitea/manager.py
Comment thread charts/cr8tor-operator/templates/deployment.yaml
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.

3 participants