2
0

config.go 3.9 KB

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