config.go 3.8 KB

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