preview_factory.go 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. package services
  2. import (
  3. "git.linuxforward.com/byop/byop-engine/clients"
  4. "git.linuxforward.com/byop/byop-engine/cloud"
  5. "git.linuxforward.com/byop/byop-engine/config"
  6. "git.linuxforward.com/byop/byop-engine/dbstore"
  7. "github.com/sirupsen/logrus"
  8. )
  9. // NewPreviewService creates the appropriate preview service based on configuration
  10. // This is a factory function that replaces the manager pattern
  11. func NewPreviewService(store *dbstore.SQLiteStore, ovhProvider cloud.Provider, cfg *config.Config, registryClient clients.RegistryClient, registryURL, registryUser, registryPass string) PreviewService {
  12. entry := logrus.WithField("service", "PreviewServiceFactory")
  13. // Determine which service to use based on configuration
  14. useLocal := cfg.LocalPreview
  15. // In debug/development mode, we could force local preview
  16. if cfg.Debug {
  17. entry.Info("Debug mode enabled - forcing local preview service")
  18. useLocal = true
  19. }
  20. if useLocal {
  21. entry.Warn("Using local preview service - this is for development/testing only, not recommended for production")
  22. return NewLocalPreviewService(store, cfg, registryClient, registryURL, registryUser, registryPass)
  23. }
  24. entry.Info("Using remote VPS preview service for production deployment")
  25. return NewRemotePreviewService(store, ovhProvider, cfg, registryClient, registryURL, registryUser, registryPass)
  26. }