config.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/helm/urlcache"
  10. "github.com/porter-dev/porter/internal/integrations/bind"
  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. // DB is the gorm DB instance
  61. DB *gorm.DB
  62. // AnalyticsClient if Segment analytics reporting is enabled on the API instance
  63. AnalyticsClient analytics.AnalyticsSegmentClient
  64. // BindClient is a client for Bind DNS, if the Porter instance supports vanity URLs
  65. BindClient *bind.Client
  66. }
  67. type ConfigLoader interface {
  68. LoadConfig() (*Config, error)
  69. }