config.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package config
  2. import (
  3. "github.com/gorilla/sessions"
  4. "github.com/porter-dev/porter/api/server/shared/apierrors/alerter"
  5. "github.com/porter-dev/porter/api/server/shared/config/env"
  6. "github.com/porter-dev/porter/api/server/shared/websocket"
  7. "github.com/porter-dev/porter/internal/analytics"
  8. "github.com/porter-dev/porter/internal/auth/token"
  9. "github.com/porter-dev/porter/internal/billing"
  10. "github.com/porter-dev/porter/internal/helm/urlcache"
  11. "github.com/porter-dev/porter/internal/kubernetes"
  12. "github.com/porter-dev/porter/internal/logger"
  13. "github.com/porter-dev/porter/internal/notifier"
  14. "github.com/porter-dev/porter/internal/oauth"
  15. "github.com/porter-dev/porter/internal/repository"
  16. "golang.org/x/oauth2"
  17. "gorm.io/gorm"
  18. )
  19. type Config struct {
  20. // Logger for logging
  21. Logger *logger.Logger
  22. // Repo implements a query repository
  23. Repo repository.Repository
  24. // Metadata is a description object for the server metadata, used
  25. // to determine which endpoints to register
  26. Metadata *Metadata
  27. // Alerter sends messages to alert aggregators (like Sentry) if the
  28. // error is fatal
  29. Alerter alerter.Alerter
  30. // Store implements a session store for session-based cookies
  31. Store sessions.Store
  32. // ServerConf is the set of configuration variables for the Porter server
  33. ServerConf *env.ServerConf
  34. // DBConf is the set of configuration variables for the DB
  35. DBConf *env.DBConf
  36. // RedisConf is the set of configuration variables for the redis instance
  37. RedisConf *env.RedisConf
  38. // TokenConf contains the config for generating and validating JWT tokens
  39. TokenConf *token.TokenGeneratorConf
  40. // UserNotifier is an object that notifies users of transactions (pw reset, email
  41. // verification, etc)
  42. UserNotifier notifier.UserNotifier
  43. // DOConf is the configuration for a DigitalOcean OAuth client
  44. DOConf *oauth2.Config
  45. // GithubConf is the configuration for a Github OAuth client
  46. GithubConf *oauth2.Config
  47. // GithubAppConf is the configuration for a Github App OAuth client
  48. GithubAppConf *oauth.GithubAppConf
  49. // GoogleConf is the configuration for a Google OAuth client
  50. GoogleConf *oauth2.Config
  51. // SlackConf is the configuration for a Slack OAuth client
  52. SlackConf *oauth2.Config
  53. // WSUpgrader upgrades HTTP connections to websocket connections
  54. WSUpgrader *websocket.Upgrader
  55. // URLCache contains a cache of chart names to chart repos
  56. URLCache *urlcache.ChartURLCache
  57. // ProvisionerAgent is the kubernetes client responsible for creating new provisioner
  58. // jobs
  59. ProvisionerAgent *kubernetes.Agent
  60. // IngressAgent is the kubernetes client responsible for creating new ingress
  61. // resources
  62. IngressAgent *kubernetes.Agent
  63. // DB is the gorm DB instance
  64. DB *gorm.DB
  65. // AnalyticsClient if Segment analytics reporting is enabled on the API instance
  66. AnalyticsClient analytics.AnalyticsSegmentClient
  67. // BillingManager manages billing for Porter instances with billing enabled
  68. BillingManager billing.BillingManager
  69. }
  70. type ConfigLoader interface {
  71. LoadConfig() (*Config, error)
  72. }