config.go 2.6 KB

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