Core infrastructure: - Uber fx dependency injection - Chi router with middleware stack - SQLite database with embedded migrations - Embedded templates and static assets - Structured logging with slog Features implemented: - Authentication (login, logout, session management, argon2id hashing) - App management (create, edit, delete, list) - Deployment pipeline (clone, build, deploy, health check) - Webhook processing for Gitea - Notifications (ntfy, Slack) - Environment variables, labels, volumes per app - SSH key generation for deploy keys Server startup: - Server.Run() starts HTTP server on configured port - Server.Shutdown() for graceful shutdown - SetupRoutes() wires all handlers with chi router
63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
// Package globals provides build-time variables and application-wide constants.
|
|
package globals
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
// Package-level variables set from main via ldflags.
|
|
// These are intentionally global to allow build-time injection using -ldflags.
|
|
//
|
|
//nolint:gochecknoglobals // Required for ldflags injection at build time
|
|
var (
|
|
mu sync.RWMutex
|
|
appname string
|
|
version string
|
|
buildarch string
|
|
)
|
|
|
|
// Globals holds build-time variables for dependency injection.
|
|
type Globals struct {
|
|
Appname string
|
|
Version string
|
|
Buildarch string
|
|
}
|
|
|
|
// New creates a new Globals instance from package-level variables.
|
|
func New(_ fx.Lifecycle) (*Globals, error) {
|
|
mu.RLock()
|
|
defer mu.RUnlock()
|
|
|
|
return &Globals{
|
|
Appname: appname,
|
|
Version: version,
|
|
Buildarch: buildarch,
|
|
}, nil
|
|
}
|
|
|
|
// SetAppname sets the application name (used for testing and main initialization).
|
|
func SetAppname(name string) {
|
|
mu.Lock()
|
|
defer mu.Unlock()
|
|
|
|
appname = name
|
|
}
|
|
|
|
// SetVersion sets the version (used for testing and main initialization).
|
|
func SetVersion(ver string) {
|
|
mu.Lock()
|
|
defer mu.Unlock()
|
|
|
|
version = ver
|
|
}
|
|
|
|
// SetBuildarch sets the build architecture (used for testing and main init).
|
|
func SetBuildarch(arch string) {
|
|
mu.Lock()
|
|
defer mu.Unlock()
|
|
|
|
buildarch = arch
|
|
}
|