config.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/notifier"
  13. "github.com/porter-dev/porter/internal/oauth"
  14. "github.com/porter-dev/porter/internal/repository"
  15. "github.com/porter-dev/porter/internal/repository/credentials"
  16. "github.com/porter-dev/porter/pkg/logger"
  17. "github.com/porter-dev/porter/provisioner/client"
  18. "golang.org/x/oauth2"
  19. "gorm.io/gorm"
  20. )
  21. type Config struct {
  22. // Logger for logging
  23. Logger *logger.Logger
  24. // Repo implements a query repository
  25. Repo repository.Repository
  26. // Metadata is a description object for the server metadata, used
  27. // to determine which endpoints to register
  28. Metadata *Metadata
  29. // Alerter sends messages to alert aggregators (like Sentry) if the
  30. // error is fatal
  31. Alerter alerter.Alerter
  32. // Store implements a session store for session-based cookies
  33. Store sessions.Store
  34. // ServerConf is the set of configuration variables for the Porter server
  35. ServerConf *env.ServerConf
  36. // DBConf is the set of configuration variables for the DB
  37. DBConf *env.DBConf
  38. // RedisConf is the set of configuration variables for the redis instance
  39. RedisConf *env.RedisConf
  40. // TokenConf contains the config for generating and validating JWT tokens
  41. TokenConf *token.TokenGeneratorConf
  42. // UserNotifier is an object that notifies users of transactions (pw reset, email
  43. // verification, etc)
  44. UserNotifier notifier.UserNotifier
  45. // DOConf is the configuration for a DigitalOcean OAuth client
  46. DOConf *oauth2.Config
  47. // GithubConf is the configuration for a Github OAuth client
  48. GithubConf *oauth2.Config
  49. // GithubAppConf is the configuration for a Github App OAuth client
  50. GithubAppConf *oauth.GithubAppConf
  51. // GoogleConf is the configuration for a Google OAuth client
  52. GoogleConf *oauth2.Config
  53. // SlackConf is the configuration for a Slack OAuth client
  54. SlackConf *oauth2.Config
  55. // WSUpgrader upgrades HTTP connections to websocket connections
  56. WSUpgrader *websocket.Upgrader
  57. // URLCache contains a cache of chart names to chart repos
  58. URLCache *urlcache.ChartURLCache
  59. // ProvisionerClient is an authenticated client for the provisioner service
  60. ProvisionerClient *client.Client
  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. // CredentialBackend is the backend for credential storage, if external cred storage (like Vault)
  72. // is used
  73. CredentialBackend credentials.CredentialStorage
  74. }
  75. type ConfigLoader interface {
  76. LoadConfig() (*Config, error)
  77. }