envconfs.go 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 must have the protocol set .i.e http or https
  7. ServerURL string `env:"SERVER_URL,default=http://localhost:8080"`
  8. // The instance name is used to set a name for integrations linked only by a project ID,
  9. // in order to differentiate between the same project ID on different instances. For example,
  10. // when writing a Github secret with `PORTER_TOKEN_<PROJECT_ID>`, setting this value will change
  11. // this to `PORTER_TOKEN_<INSTANCE_NAME>_<PROJECT_ID>`
  12. InstanceName string `env:"INSTANCE_NAME"`
  13. UsageTrackingEnabled bool `env:"USAGE_TRACKING_ENABLED,default=false"`
  14. Port int `env:"SERVER_PORT,default=8080"`
  15. StaticFilePath string `env:"STATIC_FILE_PATH,default=/porter/static"`
  16. CookieName string `env:"COOKIE_NAME,default=porter"`
  17. // CookieSecrets must be in the format "16-chars;16-chars"
  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=10s"`
  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.dev.getporter.dev"`
  28. DefaultAddonHelmRepoURL string `env:"HELM_ADD_ON_REPO_URL,default=https://chart-addons.dev.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. GithubAppSecret []byte
  41. GoogleClientID string `env:"GOOGLE_CLIENT_ID"`
  42. GoogleClientSecret string `env:"GOOGLE_CLIENT_SECRET"`
  43. GoogleRestrictedDomain string `env:"GOOGLE_RESTRICTED_DOMAIN"`
  44. SendgridAPIKey string `env:"SENDGRID_API_KEY"`
  45. SendgridPWResetTemplateID string `env:"SENDGRID_PW_RESET_TEMPLATE_ID"`
  46. SendgridPWGHTemplateID string `env:"SENDGRID_PW_GH_TEMPLATE_ID"`
  47. SendgridVerifyEmailTemplateID string `env:"SENDGRID_VERIFY_EMAIL_TEMPLATE_ID"`
  48. SendgridProjectInviteTemplateID string `env:"SENDGRID_INVITE_TEMPLATE_ID"`
  49. SendgridIncidentAlertTemplateID string `env:"SENDGRID_INCIDENT_ALERT_TEMPLATE_ID"`
  50. SendgridIncidentResolvedTemplateID string `env:"SENDGRID_INCIDENT_RESOLVED_TEMPLATE_ID"`
  51. SendgridSenderEmail string `env:"SENDGRID_SENDER_EMAIL"`
  52. SlackClientID string `env:"SLACK_CLIENT_ID"`
  53. SlackClientSecret string `env:"SLACK_CLIENT_SECRET"`
  54. BillingPrivateKey string `env:"BILLING_PRIVATE_KEY"`
  55. BillingPrivateServerURL string `env:"BILLING_PRIVATE_URL"`
  56. BillingPublicServerURL string `env:"BILLING_PUBLIC_URL"`
  57. WhitelistedUsers []uint `env:"WHITELISTED_USERS"`
  58. DOClientID string `env:"DO_CLIENT_ID"`
  59. DOClientSecret string `env:"DO_CLIENT_SECRET"`
  60. // Options for the provisioner service
  61. ProvisionerServerURL string `env:"PROVISIONER_SERVER_URL"`
  62. ProvisionerToken string `env:"PROVISIONER_TOKEN"`
  63. SegmentClientKey string `env:"SEGMENT_CLIENT_KEY"`
  64. // PowerDNS client API key and the host of the PowerDNS API server
  65. PowerDNSAPIServerURL string `env:"POWER_DNS_API_SERVER_URL"`
  66. PowerDNSAPIKey string `env:"POWER_DNS_API_KEY"`
  67. // Email for an admin user. On a self-hosted instance of Porter, the
  68. // admin user is the only user that can log in and register. After the admin
  69. // user has logged in, registration is turned off.
  70. AdminEmail string `env:"ADMIN_EMAIL"`
  71. SentryDSN string `env:"SENTRY_DSN"`
  72. SentryEnv string `env:"SENTRY_ENV,default=dev"`
  73. InitInCluster bool `env:"INIT_IN_CLUSTER,default=false"`
  74. WelcomeFormWebhook string `env:"WELCOME_FORM_WEBHOOK"`
  75. // Token for internal retool to authenticate to internal API endpoints
  76. RetoolToken string `env:"RETOOL_TOKEN"`
  77. // Enable pprof profiling endpoints
  78. PprofEnabled bool `env:"PPROF_ENABLED,default=false"`
  79. ProvisionerTest bool `env:"PROVISIONER_TEST,default=false"`
  80. // Disable filtering for project creation
  81. DisableAllowlist bool `env:"DISABLE_ALLOWLIST,default=true"`
  82. // Enable gitlab integration
  83. EnableGitlab bool `env:"ENABLE_GITLAB,default=false"`
  84. // DisableRegistrySecretsInjection is used to denote if Porter should not inject
  85. // imagePullSecrets into a kubernetes deployment (Porter application)
  86. DisablePullSecretsInjection bool `env:"DISABLE_PULL_SECRETS_INJECTION,default=false"`
  87. }
  88. // DBConf is the database configuration: if generated from environment variables,
  89. // it assumes the default docker-compose configuration is used
  90. type DBConf struct {
  91. // EncryptionKey is the key to use for sensitive values that are encrypted at rest
  92. EncryptionKey string `env:"ENCRYPTION_KEY,default=__random_strong_encryption_key__"`
  93. Host string `env:"DB_HOST,default=postgres"`
  94. Port int `env:"DB_PORT,default=5432"`
  95. Username string `env:"DB_USER,default=porter"`
  96. Password string `env:"DB_PASS,default=porter"`
  97. DbName string `env:"DB_NAME,default=porter"`
  98. ForceSSL bool `env:"DB_FORCE_SSL,default=false"`
  99. SQLLite bool `env:"SQL_LITE,default=false"`
  100. SQLLitePath string `env:"SQL_LITE_PATH,default=/porter/porter.db"`
  101. VaultPrefix string `env:"VAULT_PREFIX,default=production"`
  102. VaultAPIKey string `env:"VAULT_API_KEY"`
  103. VaultServerURL string `env:"VAULT_SERVER_URL"`
  104. }
  105. // RedisConf is the redis config required for the provisioner container
  106. type RedisConf struct {
  107. // if redis should be used
  108. Enabled bool `env:"REDIS_ENABLED,default=true"`
  109. Host string `env:"REDIS_HOST,default=redis"`
  110. Port string `env:"REDIS_PORT,default=6379"`
  111. Username string `env:"REDIS_USER"`
  112. Password string `env:"REDIS_PASS"`
  113. DB int `env:"REDIS_DB,default=0"`
  114. }