envconfs.go 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. package env
  2. import (
  3. "time"
  4. )
  5. // ServerConf is the server configuration
  6. type ServerConf struct {
  7. Debug bool `env:"DEBUG,default=false"`
  8. ServerURL string `env:"SERVER_URL,default=http://localhost:8080"`
  9. // The instance name is used to set a name for integrations linked only by a project ID,
  10. // in order to differentiate between the same project ID on different instances. For example,
  11. // when writing a Github secret with `PORTER_TOKEN_<PROJECT_ID>`, setting this value will change
  12. // this to `PORTER_TOKEN_<INSTANCE_NAME>_<PROJECT_ID>`
  13. InstanceName string `env:"INSTANCE_NAME"`
  14. UsageTrackingEnabled bool `env:"USAGE_TRACKING_ENABLED,default=false"`
  15. Port int `env:"SERVER_PORT,default=8080"`
  16. StaticFilePath string `env:"STATIC_FILE_PATH,default=/porter/static"`
  17. CookieName string `env:"COOKIE_NAME,default=porter"`
  18. CookieSecrets []string `env:"COOKIE_SECRETS,default=random_hash_key_;random_block_key"`
  19. CookieInsecure bool `env:"COOKIE_INSECURE,default=false"`
  20. TokenGeneratorSecret string `env:"TOKEN_GENERATOR_SECRET,default=secret"`
  21. TimeoutRead time.Duration `env:"SERVER_TIMEOUT_READ,default=5s"`
  22. TimeoutWrite time.Duration `env:"SERVER_TIMEOUT_WRITE,default=60s"`
  23. TimeoutIdle time.Duration `env:"SERVER_TIMEOUT_IDLE,default=15s"`
  24. IsLocal bool `env:"IS_LOCAL,default=false"`
  25. IsTesting bool `env:"IS_TESTING,default=false"`
  26. AppRootDomain string `env:"APP_ROOT_DOMAIN,default=porter.run"`
  27. DefaultApplicationHelmRepoURL string `env:"HELM_APP_REPO_URL,default=https://charts.getporter.dev"`
  28. DefaultAddonHelmRepoURL string `env:"HELM_ADD_ON_REPO_URL,default=https://chart-addons.getporter.dev"`
  29. BasicLoginEnabled bool `env:"BASIC_LOGIN_ENABLED,default=true"`
  30. GithubClientID string `env:"GITHUB_CLIENT_ID"`
  31. GithubClientSecret string `env:"GITHUB_CLIENT_SECRET"`
  32. GithubLoginEnabled bool `env:"GITHUB_LOGIN_ENABLED,default=true"`
  33. GithubIncomingWebhookSecret string `env:"GITHUB_INCOMING_WEBHOOK_SECRET"`
  34. GithubAppClientID string `env:"GITHUB_APP_CLIENT_ID"`
  35. GithubAppClientSecret string `env:"GITHUB_APP_CLIENT_SECRET"`
  36. GithubAppName string `env:"GITHUB_APP_NAME"`
  37. GithubAppWebhookSecret string `env:"GITHUB_APP_WEBHOOK_SECRET"`
  38. GithubAppID string `env:"GITHUB_APP_ID"`
  39. GithubAppSecretPath string `env:"GITHUB_APP_SECRET_PATH"`
  40. // GithubAppSecretBase64 is a base64 encoded version of the GithubAppSecret. This can be used instead of GithubAppSecretPath to pass in a key, allowing for support in systems where mounting the secret is not possible.
  41. // If GithubAppSecretBase64 is set, it will check for a file at GithubAppSecretPath. If a file is found, the file will NOT be overwritten. If no file it found, then GithubAppSecretBase64 will be decoded and written to GithubAppSecretPath.
  42. GithubAppSecretBase64 string `env:"GITHUB_APP_SECRET_BASE64"`
  43. GithubAppSecret []byte
  44. GoogleClientID string `env:"GOOGLE_CLIENT_ID"`
  45. GoogleClientSecret string `env:"GOOGLE_CLIENT_SECRET"`
  46. GoogleRestrictedDomain string `env:"GOOGLE_RESTRICTED_DOMAIN"`
  47. // FeatureFlagClient controls which client to use (database or launch_darkly)
  48. FeatureFlagClient string `env:"FEATURE_FLAG_CLIENT,default=launch_darkly"`
  49. LaunchDarklySDKKey string `env:"LAUNCHDARKLY_SDK_KEY"`
  50. SendgridAPIKey string `env:"SENDGRID_API_KEY"`
  51. SendgridPWResetTemplateID string `env:"SENDGRID_PW_RESET_TEMPLATE_ID"`
  52. SendgridPWGHTemplateID string `env:"SENDGRID_PW_GH_TEMPLATE_ID"`
  53. SendgridVerifyEmailTemplateID string `env:"SENDGRID_VERIFY_EMAIL_TEMPLATE_ID"`
  54. SendgridProjectInviteTemplateID string `env:"SENDGRID_INVITE_TEMPLATE_ID"`
  55. SendgridIncidentAlertTemplateID string `env:"SENDGRID_INCIDENT_ALERT_TEMPLATE_ID"`
  56. SendgridIncidentResolvedTemplateID string `env:"SENDGRID_INCIDENT_RESOLVED_TEMPLATE_ID"`
  57. SendgridDeleteProjectTemplateID string `env:"SENDGRID_DELETE_PROJECT_TEMPLATE_ID"`
  58. SendgridSenderEmail string `env:"SENDGRID_SENDER_EMAIL"`
  59. StripeSecretKey string `env:"STRIPE_SECRET_KEY"`
  60. StripePublishableKey string `env:"STRIPE_PUBLISHABLE_KEY"`
  61. MetronomeAPIKey string `env:"METRONOME_API_KEY"`
  62. PorterCloudPlanID string `env:"PORTER_CLOUD_PLAN_ID"`
  63. SlackClientID string `env:"SLACK_CLIENT_ID"`
  64. SlackClientSecret string `env:"SLACK_CLIENT_SECRET"`
  65. BillingPrivateKey string `env:"BILLING_PRIVATE_KEY"`
  66. BillingPrivateServerURL string `env:"BILLING_PRIVATE_URL"`
  67. BillingPublicServerURL string `env:"BILLING_PUBLIC_URL"`
  68. WhitelistedUsers []uint `env:"WHITELISTED_USERS"`
  69. DOClientID string `env:"DO_CLIENT_ID"`
  70. DOClientSecret string `env:"DO_CLIENT_SECRET"`
  71. // Options for the provisioner service
  72. ProvisionerServerURL string `env:"PROVISIONER_SERVER_URL"`
  73. ProvisionerToken string `env:"PROVISIONER_TOKEN"`
  74. // ClusterControlPlane settings
  75. ClusterControlPlaneAddress string `env:"CLUSTER_CONTROL_PLANE_ADDRESS"`
  76. SegmentClientKey string `env:"SEGMENT_CLIENT_KEY"`
  77. // DnsProvider controls which provider to use for dns (powerdns or cloudflare)
  78. // Setting this to empty string will disable external dns
  79. DnsProvider string `env:"DNS_PROVIDER,default=powerdns"`
  80. // Cloudflare API Key
  81. CloudflareAPIToken string `env:"CLOUDFLARE_API_TOKEN"`
  82. // PowerDNS client API key and the host of the PowerDNS API server
  83. PowerDNSAPIServerURL string `env:"POWER_DNS_API_SERVER_URL"`
  84. PowerDNSAPIKey string `env:"POWER_DNS_API_KEY"`
  85. // Email for an admin user. On a self-hosted instance of Porter, the
  86. // admin user is the only user that can log in and register. After the admin
  87. // user has logged in, registration is turned off.
  88. AdminEmail string `env:"ADMIN_EMAIL"`
  89. AdminUserId string `env:"ADMIN_USER_ID"`
  90. SentryDSN string `env:"SENTRY_DSN"`
  91. SentryEnv string `env:"SENTRY_ENV,default=dev"`
  92. InitInCluster bool `env:"INIT_IN_CLUSTER,default=false"`
  93. WelcomeFormWebhook string `env:"WELCOME_FORM_WEBHOOK"`
  94. // Token for internal retool to authenticate to internal API endpoints
  95. RetoolToken string `env:"RETOOL_TOKEN"`
  96. // Enable pprof profiling endpoints
  97. PprofEnabled bool `env:"PPROF_ENABLED,default=false"`
  98. ProvisionerTest bool `env:"PROVISIONER_TEST,default=false"`
  99. // Disable filtering for project creation
  100. DisableAllowlist bool `env:"DISABLE_ALLOWLIST,default=true"`
  101. // Enable gitlab integration
  102. EnableGitlab bool `env:"ENABLE_GITLAB,default=false"`
  103. // DisableRegistrySecretsInjection is used to denote if Porter should not inject
  104. // imagePullSecrets into a kubernetes deployment (Porter application)
  105. DisablePullSecretsInjection bool `env:"DISABLE_PULL_SECRETS_INJECTION,default=false"`
  106. // EnableAutoPreviewBranchDeploy is used to enable preview branch deployments automatically
  107. // The default behaviour is to automatically create preview deployment against a deploy branch
  108. EnableAutoPreviewBranchDeploy bool `env:"ENABLE_AUTO_PREVIEW_BRANCH_DEPLOY,default=true"`
  109. // DisableTemporaryKubeconfig is used to denote if Porter should not
  110. // create a temporary kubeconfig file for a cluster. When set to true, the
  111. // /api/projects/{project_id}/clusters/{cluster_id}/kubeconfig will be disabled.
  112. DisableTemporaryKubeconfig bool `env:"DISABLE_TEMPORARY_KUBECONFIG,default=false"`
  113. // EnableCAPIProvisioner disables checks for ClusterControlPlaneClient and NATS, if set to true
  114. EnableCAPIProvisioner bool `env:"ENABLE_CAPI_PROVISIONER"`
  115. // EnableSandbox configures the API server to hit the endpoints designed for Porter's sandbox instance
  116. EnableSandbox bool `env:"ENABLE_SANDBOX"`
  117. // NATSUrl is the URL of the NATS cluster. This is required if ENABLE_CAPI_PROVISIONER is true
  118. NATSUrl string `env:"NATS_URL"`
  119. // TelemetryName is the name that will group this service during collection
  120. TelemetryName string `env:"TELEMETRY_NAME"`
  121. // TelemetryCollectorURL is the URL (host:port) for collecting spans
  122. TelemetryCollectorURL string `env:"TELEMETRY_COLLECTOR_URL,default=localhost:4317"`
  123. }
  124. // DBConf is the database configuration: if generated from environment variables,
  125. // it assumes the default docker-compose configuration is used
  126. type DBConf struct {
  127. // EncryptionKey is the key to use for sensitive values that are encrypted at rest
  128. EncryptionKey string `env:"ENCRYPTION_KEY,default=__random_strong_encryption_key__"`
  129. Host string `env:"DB_HOST,default=postgres"`
  130. Port int `env:"DB_PORT,default=5432"`
  131. Username string `env:"DB_USER,default=porter"`
  132. Password string `env:"DB_PASS,default=porter"`
  133. DbName string `env:"DB_NAME,default=porter"`
  134. ForceSSL bool `env:"DB_FORCE_SSL,default=false"`
  135. SQLLite bool `env:"SQL_LITE,default=false"`
  136. SQLLitePath string `env:"SQL_LITE_PATH,default=/porter/porter.db"`
  137. // VaultEnabled is used to denote if Porter should use Vault for secrets management. This was previously set by 'ee' build tags
  138. VaultEnabled bool `env:"VAULT_ENABLED,default=false"`
  139. VaultPrefix string `env:"VAULT_PREFIX,default=production"`
  140. VaultAPIKey string `env:"VAULT_API_KEY"`
  141. VaultServerURL string `env:"VAULT_SERVER_URL"`
  142. }
  143. // RedisConf is the redis config required for the provisioner container
  144. type RedisConf struct {
  145. // if redis should be used
  146. Enabled bool `env:"REDIS_ENABLED,default=true"`
  147. Host string `env:"REDIS_HOST,default=redis"`
  148. Port string `env:"REDIS_PORT,default=6379"`
  149. Username string `env:"REDIS_USER"`
  150. Password string `env:"REDIS_PASS"`
  151. DB int `env:"REDIS_DB,default=0"`
  152. }