Thank you for considering contributing to lightstack! This document provides guidelines for contributing to the project.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Testing
- Submitting Changes
- Code Style
- Documentation
This project follows a standard code of conduct:
- Be respectful and inclusive
- Focus on constructive feedback
- Prioritize the project's goals and users
- Help others learn and grow
Required:
- Go 1.26 or higher
- PostgreSQL 18 or higher
- Git
Optional (for real mode testing):
- libvirt + KVM (Linux only)
- Ceph cluster (for RBD storage)
- AWS S3 / MinIO / Ceph RGW (for S3 storage)
# Fork the repository on GitHub, then:
git clone https://github.com/YOUR_USERNAME/lightstack.git
cd lightstack
git remote add upstream https://github.com/cobaltcore-dev/lightstack.git# Install Go dependencies
make install-deps
# Install development tools
make install-tools# Using Docker
docker run -d --name lightstack-postgres \
-e POSTGRES_DB=lightstack \
-e POSTGRES_USER=lightstack \
-e POSTGRES_PASSWORD=secret \
-p 5432:5432 postgres:18.3
# Or use your local PostgreSQL instancemake migrate-up# Build
make build
# Run
./bin/lightstack --config config/lightstack.yaml
# Or run with hot reload
make dev# Test authentication
export OS_AUTH_URL=http://localhost:35357/v3
export OS_USERNAME=admin
export OS_PASSWORD=secret
export OS_PROJECT_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_DOMAIN_NAME=default
openstack token issueUse descriptive branch names:
feature/add-floating-ips- New featuresfix/volume-attachment-bug- Bug fixesrefactor/storage-backend- Code refactoringdocs/api-reference- Documentation updates
Follow conventional commits format:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixrefactor: Code refactoringdocs: Documentation changestest: Adding or updating testschore: Maintenance tasks
Examples:
feat(glance): add S3 backend support for image storage
fix(nova): correct power_state in server detail response
refactor(cinder): simplify volume attachment logic
docs(readme): update installation instructions
lightstack/
├── cmd/lightstack/ # Main binary entry point
├── internal/ # Internal packages (not importable)
│ ├── keystone/ # Keystone service implementation
│ ├── nova/ # Nova service implementation
│ ├── neutron/ # Neutron service implementation
│ ├── cinder/ # Cinder service implementation
│ ├── glance/ # Glance service implementation
│ ├── database/ # Database models and migrations
│ ├── middleware/ # HTTP middleware
│ └── common/ # Shared utilities
├── pkg/ # Public packages (importable)
│ ├── hypervisor/ # libvirt abstraction
│ ├── networking/ # netlink abstraction
│ └── storage/ # Storage backends
├── migrations/ # SQL migrations
├── config/ # Configuration files
├── docs/ # Documentation
└── test/ # Integration tests
# Run all unit tests
make test
# Run tests for specific package
go test ./internal/keystone/...
# Run with coverage
go test -cover ./...# Run full integration test suite
./test/quick_test.sh
# Run Horizon compatibility tests
./test/horizon_compat_test.sh# Test authentication
openstack token issue
# Test compute
openstack server create --flavor m1.small --image cirros --network private test-vm
openstack server list
openstack server delete test-vm
# Test networking
openstack network create test-network
openstack subnet create --network test-network --subnet-range 192.168.1.0/24 test-subnet
openstack network delete test-network
# Test storage
openstack volume create --size 10 test-volume
openstack volume list
openstack volume delete test-volume
# Test images
openstack image create --file cirros.img --disk-format qcow2 test-image
openstack image list
openstack image delete test-image-
Update your fork:
git fetch upstream git rebase upstream/main
-
Run tests:
make test ./test/quick_test.sh -
Format code:
make fmt make lint
-
Push changes:
git push origin feature/your-feature-name
-
Create Pull Request:
- Go to GitHub and create a PR from your fork
- Fill out the PR template
- Link any related issues
- Tests pass (
make testand./test/quick_test.sh) - Code is formatted (
make fmt) - Linter passes (
make lint) - Documentation is updated
- Commit messages follow conventional format
- PR description is clear and complete
- Related issues are linked
Lightstack follows standard Go conventions:
-
Naming:
- Use
camelCasefor local variables - Use
PascalCasefor exported functions/types - Use descriptive names (
imageStorenotis)
- Use
-
Error Handling:
// Good if err != nil { return fmt.Errorf("failed to create volume: %w", err) } // Bad if err != nil { return err }
-
Context:
- Always pass
context.Contextas first parameter - Use
ctxas the variable name - Respect context cancellation
- Always pass
-
Comments:
- Public functions must have doc comments
- Comments should explain "why", not "what"
- Use complete sentences
-
Imports:
- Standard library first
- Third-party packages second
- Internal packages last
Example:
package glance
import (
"context"
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"github.com/cobaltcore-dev/lightstack/internal/database"
"github.com/cobaltcore-dev/lightstack/pkg/storage"
)
// CreateImage creates a new image in the image service.
// It returns the image ID and any error encountered.
func (svc *Service) CreateImage(ctx context.Context, req CreateImageRequest) (string, error) {
if err := validateImageRequest(req); err != nil {
return "", fmt.Errorf("invalid image request: %w", err)
}
imageID := uuid.New().String()
// ... implementation
return imageID, nil
}Follow OpenStack API conventions:
// Success (200/201)
c.JSON(http.StatusOK, gin.H{
"resource": gin.H{
"id": resourceID,
"name": name,
// ... fields
},
})
// List (200)
c.JSON(http.StatusOK, gin.H{
"resources": []gin.H{
// ... items
},
})
// Error (4xx/5xx)
c.JSON(http.StatusBadRequest, gin.H{
"error": gin.H{
"message": "Invalid request",
"code": 400,
"title": "Bad Request",
},
})- All exported functions must have doc comments
- Use examples for complex functions
- Document error conditions
When adding features, update:
README.md- If it affects quick startdocs/STORAGE_MODES.md- If it adds storage optionsdocs/REAL_LIBVIRT_MODE.md- If it affects VM lifecycledocs/MVP_V1_COMPLETE.md- If it completes a major feature
// CreateVolume creates a new block storage volume.
//
// The volume is created using the configured storage backend
// (local, RBD, or S3). If the backend is unavailable, it returns
// an error immediately (fail-fast).
//
// Parameters:
// - ctx: Request context (respects cancellation)
// - size: Volume size in GB (1-1000)
// - name: Optional volume name
//
// Returns:
// - volumeID: UUID of the created volume
// - error: Any error encountered
//
// Example:
// volumeID, err := svc.CreateVolume(ctx, 10, "my-volume")
// if err != nil {
// log.Fatalf("Failed to create volume: %v", err)
// }
func (svc *Service) CreateVolume(ctx context.Context, size int, name string) (string, error) {
// ... implementation
}-
Multi-node Networking
- VXLAN overlay networks
- Cross-node VM communication
- Distributed DHCP
-
Floating IPs
- External network access
- NAT configuration
- IP allocation/deallocation
-
Router L3 Forwarding
- Inter-network routing
- Static routes
- Default gateway configuration
-
eBPF Security Groups
- Replace iptables with eBPF
- Kernel-space filtering
- Performance improvement
-
Live Migration
- VM migration between hosts
- Storage migration
- Downtime minimization
-
High Availability
- Multi-node control plane
- Leader election
- Failover handling
-
Heat Orchestration
- Template parsing
- Stack creation
- Resource dependencies
-
Placement API
- Resource scheduling
- Affinity/anti-affinity
- Resource providers
- GitHub Issues: https://github.com/cobaltcore-dev/lightstack/issues
- Documentation:
docs/directory - Code Examples:
test/directory
By contributing to lightstack, you agree that your contributions will be licensed under the Apache License 2.0.
Thank you for contributing to lightstack!