config.go 4.0 KB

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