config.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package config
  2. import (
  3. "github.com/gorilla/sessions"
  4. "github.com/porter-dev/api-contracts/generated/go/porter/v1/porterv1connect"
  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/api/server/shared/websocket"
  8. "github.com/porter-dev/porter/internal/analytics"
  9. "github.com/porter-dev/porter/internal/auth/token"
  10. "github.com/porter-dev/porter/internal/billing"
  11. "github.com/porter-dev/porter/internal/helm/urlcache"
  12. "github.com/porter-dev/porter/internal/integrations/powerdns"
  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. "github.com/porter-dev/porter/internal/repository/credentials"
  17. "github.com/porter-dev/porter/pkg/logger"
  18. "github.com/porter-dev/porter/provisioner/client"
  19. "golang.org/x/oauth2"
  20. "gorm.io/gorm"
  21. )
  22. type Config struct {
  23. // Logger for logging
  24. Logger *logger.Logger
  25. // Repo implements a query repository
  26. Repo repository.Repository
  27. // Metadata is a description object for the server metadata, used
  28. // to determine which endpoints to register
  29. Metadata *Metadata
  30. // Alerter sends messages to alert aggregators (like Sentry) if the
  31. // error is fatal
  32. Alerter alerter.Alerter
  33. // Store implements a session store for session-based cookies
  34. Store sessions.Store
  35. // ServerConf is the set of configuration variables for the Porter server
  36. ServerConf *env.ServerConf
  37. // DBConf is the set of configuration variables for the DB
  38. DBConf *env.DBConf
  39. // RedisConf is the set of configuration variables for the redis instance
  40. RedisConf *env.RedisConf
  41. // TokenConf contains the config for generating and validating JWT tokens
  42. TokenConf *token.TokenGeneratorConf
  43. // UserNotifier is an object that notifies users of transactions (pw reset, email
  44. // verification, etc)
  45. UserNotifier notifier.UserNotifier
  46. // DOConf is the configuration for a DigitalOcean OAuth client
  47. DOConf *oauth2.Config
  48. // GithubConf is the configuration for a Github OAuth client
  49. GithubConf *oauth2.Config
  50. // GithubAppConf is the configuration for a Github App OAuth client
  51. GithubAppConf *oauth.GithubAppConf
  52. // GoogleConf is the configuration for a Google OAuth client
  53. GoogleConf *oauth2.Config
  54. // SlackConf is the configuration for a Slack OAuth client
  55. SlackConf *oauth2.Config
  56. // WSUpgrader upgrades HTTP connections to websocket connections
  57. WSUpgrader *websocket.Upgrader
  58. // URLCache contains a cache of chart names to chart repos
  59. URLCache *urlcache.ChartURLCache
  60. // ProvisionerClient is an authenticated client for the provisioner service
  61. ProvisionerClient *client.Client
  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. // BillingManager manages billing for Porter instances with billing enabled
  67. BillingManager billing.BillingManager
  68. // WhitelistedUsers do not count toward usage limits
  69. WhitelistedUsers map[uint]uint
  70. // PowerDNSClient is a client for PowerDNS, if the Porter instance supports vanity URLs
  71. PowerDNSClient *powerdns.Client
  72. // ClusterControlPlaneClient is a client for ClusterControlPlane
  73. ClusterControlPlaneClient porterv1connect.ClusterControlPlaneServiceClient
  74. // CredentialBackend is the backend for credential storage, if external cred storage (like Vault)
  75. // is used
  76. CredentialBackend credentials.CredentialStorage
  77. }
  78. type ConfigLoader interface {
  79. LoadConfig() (*Config, error)
  80. }