config.go 3.1 KB

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