config.go 4.4 KB

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