envconfs.go 8.7 KB

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