Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewOperator ¶
func NewOperator(cfg Config, log *logger.Logger, kubeClient client.Client, manager ctrl.Manager) (*operator, error)
NewOperator creates a new operator instance with the given configuration. This is the constructor following the New* pattern from Uber Go Guide. Returns a pointer because operator is a stateful service type. Returns an error if configuration is invalid or initialization fails.
Parameters:
- cfg: Operator configuration
- log: Logger instance for structured logging
- kubeClient: Kubernetes client for CRD operations
- manager: Controller-runtime manager for CRD controllers
Types ¶
type ClusterConfig ¶
type ClusterConfig struct {
// Name is the unique identifier for this cluster
Name string
// ArgoCDMode determines how to connect to ArgoCD: "internal" or "external"
// - internal: ArgoCD runs in the same cluster as the operator
// - external: ArgoCD runs in a separate cluster
ArgoCDMode string
// ArgoCDEndpoint is the ArgoCD API server URL (e.g., "https://argocd.example.com")
ArgoCDEndpoint string
// ArgoCDToken is the authentication token for ArgoCD API access
ArgoCDToken string
}
ClusterConfig contains per-cluster ArgoCD configuration. Each cluster represents a deployment target with its own ArgoCD instance.
type Config ¶
type Config struct {
// GitHub holds GitHub client configuration
GitHub GitHubConfig
// Clusters holds per-cluster ArgoCD configuration
Clusters []ClusterConfig
// WorkerPoolSize controls the number of concurrent workers for each pipeline
WorkerPoolSize int
// ReconcileInterval controls how often the operator reconciles state
ReconcileInterval time.Duration
// Webhook holds webhook server configuration
Webhook WebhookConfig
}
Config holds the operator configuration. This is a value type (small, immutable struct passed by value) following Uber Go Guide. All configuration should be loaded once at startup and remain immutable.
type GitHubConfig ¶
type GitHubConfig struct {
// Token is the GitHub personal access token for API authentication
Token string
// Org is the GitHub organization name
Org string
// Repos is the list of repository names to monitor
Repos []string
}
GitHubConfig contains GitHub client configuration. All fields are required for proper GitHub API access.
type Operator ¶
type Operator interface {
// Start initializes and starts the operator's pipelines and worker pools.
// It spawns goroutines for concurrent processing and returns immediately.
// The operator continues running until the context is cancelled or Shutdown is called.
// Returns an error if initialization fails.
Start(ctx context.Context) error
// Shutdown gracefully stops the operator and all its components.
// It waits for in-flight work to complete or the context to timeout.
// This ensures no work is lost during shutdown.
Shutdown(ctx context.Context) error
}
Operator defines the interface for the CD operator. This interface exists for testing and allows mocking the operator in tests. The interface follows the Single Responsibility Principle - only lifecycle management.
type WebhookConfig ¶
type WebhookConfig struct {
// Enabled controls whether the webhook server is enabled
Enabled bool
// Addr is the address to listen on (e.g., ":8080")
Addr string
// Secret is the GitHub webhook secret for HMAC validation
Secret string
// TLSCertFile is the path to the TLS certificate file (optional)
TLSCertFile string
// TLSKeyFile is the path to the TLS key file (optional)
TLSKeyFile string
// DiscoveryMode determines how PRs are discovered: webhook|polling|hybrid
// - webhook: only process webhook events (fastest, but requires reliable delivery)
// - polling: only use periodic polling (slower, but more reliable)
// - hybrid: webhook primary with polling as safety net (recommended)
DiscoveryMode string
}
WebhookConfig contains webhook server configuration.