config.go 4.1 KB

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