151 lines
5.3 KiB
Markdown
151 lines
5.3 KiB
Markdown
# Gitea Automatic Repository Creation - Implementation Summary
|
|
|
|
## Overview
|
|
|
|
This implementation adds automatic repository creation to the Gitea Helm chart configuration for the Bakery-IA project. When Gitea is installed or upgraded via Helm, it will automatically create a `bakery-ia` repository with the specified configuration.
|
|
|
|
## Changes Made
|
|
|
|
### 1. Updated Helm Values (`values.yaml`)
|
|
|
|
Added the `initialRepositories` configuration under the `gitea:` section:
|
|
|
|
```yaml
|
|
# Initial repositories to create automatically after Gitea installation
|
|
# These will be created with the admin user as owner
|
|
gitea:
|
|
initialRepositories:
|
|
- name: bakery-ia
|
|
description: "Main repository for Bakery IA project - Automatically created by Helm"
|
|
private: false
|
|
auto_init: true
|
|
default_branch: main
|
|
owner: "{{ .Values.gitea.admin.username }}"
|
|
# Enable issues, wiki, and other features
|
|
enable_issues: true
|
|
enable_wiki: true
|
|
enable_pull_requests: true
|
|
enable_projects: true
|
|
```
|
|
|
|
### 2. Created Setup Script (`setup-gitea-repository.sh`)
|
|
|
|
A comprehensive bash script that:
|
|
- Checks if Gitea is accessible
|
|
- Verifies if the repository exists (creates it if not)
|
|
- Configures the local Git repository
|
|
- Pushes the existing code to the new Gitea repository
|
|
|
|
### 3. Created Test Script (`test-repository-creation.sh`)
|
|
|
|
A test script that verifies:
|
|
- Gitea accessibility
|
|
- Repository existence
|
|
- Repository configuration (issues, wiki, pull requests)
|
|
- Provides detailed repository information
|
|
|
|
### 4. Created Documentation
|
|
|
|
- **README.md**: Complete guide on installation, usage, and troubleshooting
|
|
- **IMPLEMENTATION_SUMMARY.md**: This file, summarizing the implementation
|
|
|
|
## How It Works
|
|
|
|
### Automatic Repository Creation Flow
|
|
|
|
1. **Helm Installation**: When `helm install` or `helm upgrade` is executed with the updated values
|
|
2. **Gitea Initialization**: Gitea starts and creates the admin user
|
|
3. **Repository Creation**: Gitea processes the `initialRepositories` configuration and creates the specified repositories
|
|
4. **Completion**: The repository is ready for use immediately after Gitea is fully initialized
|
|
|
|
### Key Features
|
|
|
|
- **Automatic**: No manual intervention required after Helm installation
|
|
- **Idempotent**: Safe to run multiple times (won't duplicate repositories)
|
|
- **Configurable**: All repository settings are defined in Helm values
|
|
- **Integrated**: Uses native Gitea Helm chart features
|
|
|
|
## Usage
|
|
|
|
### Installation
|
|
|
|
```bash
|
|
# Install Gitea with automatic repository creation
|
|
helm install gitea gitea/gitea -n gitea \
|
|
-f infrastructure/cicd/gitea/values.yaml \
|
|
--set gitea.admin.password=your-secure-password
|
|
```
|
|
|
|
### Push Existing Code
|
|
|
|
```bash
|
|
export GITEA_ADMIN_PASSWORD="your-secure-password"
|
|
./infrastructure/cicd/gitea/setup-gitea-repository.sh
|
|
```
|
|
|
|
### Verify Repository
|
|
|
|
```bash
|
|
export GITEA_ADMIN_PASSWORD="your-secure-password"
|
|
./infrastructure/cicd/gitea/test-repository-creation.sh
|
|
```
|
|
|
|
## Repository Configuration
|
|
|
|
The automatically created repository includes:
|
|
|
|
| Feature | Enabled | Description |
|
|
|---------|---------|-------------|
|
|
| Name | bakery-ia | Main project repository |
|
|
| Description | Main repository for Bakery IA project | Clear identification |
|
|
| Visibility | Public | Accessible without authentication |
|
|
| Auto Init | Yes | Creates initial README.md |
|
|
| Default Branch | main | Standard branch naming |
|
|
| Issues | Yes | Bug and feature tracking |
|
|
| Wiki | Yes | Project documentation |
|
|
| Pull Requests | Yes | Code review workflow |
|
|
| Projects | Yes | Project management |
|
|
|
|
## CI/CD Integration
|
|
|
|
The repository is ready for immediate CI/CD integration:
|
|
|
|
- **Repository URL**: `https://gitea.bakery-ia.local/bakery-admin/bakery-ia.git`
|
|
- **Clone URL**: `https://gitea.bakery-ia.local/bakery-admin/bakery-ia.git`
|
|
- **SSH URL**: `git@gitea.bakery-ia.local:bakery-admin/bakery-ia.git`
|
|
|
|
## Benefits
|
|
|
|
1. **Automation**: Eliminates manual repository creation step
|
|
2. **Consistency**: Ensures all environments have the same repository structure
|
|
3. **Reliability**: Uses Helm's declarative configuration management
|
|
4. **Documentation**: Clear repository purpose and features
|
|
5. **CI/CD Ready**: Repository is immediately available for pipeline configuration
|
|
|
|
## Troubleshooting
|
|
|
|
### Repository Not Created
|
|
|
|
1. **Check Helm Values**: Ensure the `initialRepositories` section is correctly formatted
|
|
2. **Verify Gitea Logs**: `kubectl logs -n gitea -l app.kubernetes.io/name=gitea`
|
|
3. **Manual Creation**: Use the setup script to create the repository manually
|
|
|
|
### Authentication Issues
|
|
|
|
1. **Verify Password**: Ensure `GITEA_ADMIN_PASSWORD` is correct
|
|
2. **Check Accessibility**: Confirm Gitea service is running and accessible
|
|
3. **Network Configuration**: Verify ingress and DNS settings
|
|
|
|
## Future Enhancements
|
|
|
|
Potential improvements for future iterations:
|
|
|
|
1. **Multiple Repositories**: Add more repositories for different components
|
|
2. **Webhooks**: Automatically configure webhooks for CI/CD triggers
|
|
3. **Teams and Permissions**: Set up teams and access controls
|
|
4. **Template Repositories**: Create repository templates with standard files
|
|
5. **Backup Configuration**: Add automatic backup configuration
|
|
|
|
## Conclusion
|
|
|
|
This implementation provides a robust, automated solution for Gitea repository creation in the Bakery-IA project. It leverages Helm's native capabilities to ensure consistent, reliable repository setup across all environments. |