init_ee.go 997 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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/models"
  7. "github.com/porter-dev/porter/internal/billing"
  8. )
  9. func init() {
  10. sharedInit()
  11. InstanceDB.AutoMigrate(
  12. &models.ProjectBilling{},
  13. &models.UserBilling{},
  14. )
  15. var key [32]byte
  16. for i, b := range []byte(InstanceEnvConf.DBConf.EncryptionKey) {
  17. key[i] = b
  18. }
  19. if InstanceEnvConf.ServerConf.BillingPrivateServerURL != "" && InstanceEnvConf.ServerConf.BillingPrivateKey != "" && InstanceEnvConf.ServerConf.BillingPublicServerURL != "" {
  20. serverURL := InstanceEnvConf.ServerConf.BillingPrivateServerURL
  21. publicServerURL := InstanceEnvConf.ServerConf.BillingPublicServerURL
  22. apiKey := InstanceEnvConf.ServerConf.BillingPrivateKey
  23. var err error
  24. InstanceBillingManager, err = eeBilling.NewClient(serverURL, publicServerURL, apiKey)
  25. if err != nil {
  26. panic(err)
  27. }
  28. } else {
  29. InstanceBillingManager = &billing.NoopBillingManager{}
  30. }
  31. }