init_ee.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //go:build ee
  2. // +build ee
  3. package loader
  4. import (
  5. eeBilling "github.com/porter-dev/porter/ee/billing"
  6. "github.com/porter-dev/porter/ee/integrations/vault"
  7. "github.com/porter-dev/porter/ee/models"
  8. "github.com/porter-dev/porter/internal/billing"
  9. )
  10. func init() {
  11. sharedInit()
  12. InstanceDB.AutoMigrate(
  13. &models.ProjectBilling{},
  14. &models.UserBilling{},
  15. )
  16. var key [32]byte
  17. for i, b := range []byte(InstanceEnvConf.DBConf.EncryptionKey) {
  18. key[i] = b
  19. }
  20. if InstanceEnvConf.ServerConf.IronPlansAPIKey != "" && InstanceEnvConf.ServerConf.IronPlansServerURL != "" {
  21. serverURL := InstanceEnvConf.ServerConf.IronPlansServerURL
  22. apiKey := InstanceEnvConf.ServerConf.IronPlansAPIKey
  23. var err error
  24. InstanceBillingManager, err = eeBilling.NewClient(serverURL, apiKey)
  25. if err != nil {
  26. panic(err)
  27. }
  28. } else {
  29. InstanceBillingManager = &billing.NoopBillingManager{}
  30. }
  31. if InstanceEnvConf.DBConf.VaultAPIKey != "" && InstanceEnvConf.DBConf.VaultServerURL != "" && InstanceEnvConf.DBConf.VaultPrefix != "" {
  32. InstanceCredentialBackend = vault.NewClient(
  33. InstanceEnvConf.DBConf.VaultServerURL,
  34. InstanceEnvConf.DBConf.VaultAPIKey,
  35. InstanceEnvConf.DBConf.VaultPrefix,
  36. )
  37. }
  38. }