2
0

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