metadata.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package config
  2. import "github.com/porter-dev/porter/api/server/shared/config/env"
  3. type Metadata struct {
  4. Provisioning bool `json:"provisioner"`
  5. Github bool `json:"github"`
  6. BasicLogin bool `json:"basic_login"`
  7. GithubLogin bool `json:"github_login"`
  8. GoogleLogin bool `json:"google_login"`
  9. SlackNotifications bool `json:"slack_notifications"`
  10. Email bool `json:"email"`
  11. Analytics bool `json:"analytics"`
  12. }
  13. func MetadataFromConf(sc *env.ServerConf) *Metadata {
  14. return &Metadata{
  15. // TODO: case provisioning on env variables
  16. Provisioning: false,
  17. Github: hasGithubAppVars(sc),
  18. GithubLogin: sc.GithubClientID != "" && sc.GithubClientSecret != "" && sc.GithubLoginEnabled,
  19. BasicLogin: sc.BasicLoginEnabled,
  20. GoogleLogin: sc.GoogleClientID != "" && sc.GoogleClientSecret != "",
  21. SlackNotifications: sc.SlackClientID != "" && sc.SlackClientSecret != "",
  22. Email: sc.SendgridAPIKey != "",
  23. Analytics: sc.SegmentClientKey != "",
  24. }
  25. }
  26. func hasGithubAppVars(sc *env.ServerConf) bool {
  27. return sc.GithubAppClientID != "" &&
  28. sc.GithubAppClientSecret != "" &&
  29. sc.GithubAppName != "" &&
  30. sc.GithubAppWebhookSecret != "" &&
  31. sc.GithubAppSecretPath != "" &&
  32. sc.GithubAppID != ""
  33. }