feature_flag.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package models
  2. import (
  3. "fmt"
  4. "github.com/launchdarkly/go-sdk-common/v3/ldcontext"
  5. "github.com/porter-dev/porter/internal/features"
  6. )
  7. func getAPITokensEnabled(context ldcontext.Context, client *features.Client) bool {
  8. defaultValue := false
  9. value, _ := client.BoolVariation("api_tokens_enabled", context, defaultValue)
  10. return value
  11. }
  12. func getAzureEnabled(context ldcontext.Context, client *features.Client) bool {
  13. defaultValue := false
  14. value, _ := client.BoolVariation("azure_enabled", context, defaultValue)
  15. return value
  16. }
  17. func getCapiProvisionerEnabled(context ldcontext.Context, client *features.Client) bool {
  18. defaultValue := true
  19. value, _ := client.BoolVariation("capi_provisioner_enabled", context, defaultValue)
  20. return value
  21. }
  22. func getEnableReprovision(context ldcontext.Context, client *features.Client) bool {
  23. defaultValue := false
  24. value, _ := client.BoolVariation("enable_reprovision", context, defaultValue)
  25. return value
  26. }
  27. func getFullAddOns(context ldcontext.Context, client *features.Client) bool {
  28. defaultValue := false
  29. value, _ := client.BoolVariation("full_add_ons", context, defaultValue)
  30. return value
  31. }
  32. func getHelmValuesEnabled(context ldcontext.Context, client *features.Client) bool {
  33. defaultValue := false
  34. value, _ := client.BoolVariation("helm_values_enabled", context, defaultValue)
  35. return value
  36. }
  37. func getManagedInfraEnabled(context ldcontext.Context, client *features.Client) bool {
  38. defaultValue := false
  39. value, _ := client.BoolVariation("managed_infra_enabled", context, defaultValue)
  40. return value
  41. }
  42. func getMultiCluster(context ldcontext.Context, client *features.Client) bool {
  43. defaultValue := false
  44. value, _ := client.BoolVariation("multi_cluster", context, defaultValue)
  45. return value
  46. }
  47. func getPreviewEnvsEnabled(context ldcontext.Context, client *features.Client) bool {
  48. defaultValue := false
  49. value, _ := client.BoolVariation("preview_envs_enabled", context, defaultValue)
  50. return value
  51. }
  52. func getRdsDatabasesEnabled(context ldcontext.Context, client *features.Client) bool {
  53. defaultValue := false
  54. value, _ := client.BoolVariation("rds_databases_enabled", context, defaultValue)
  55. return value
  56. }
  57. func getSimplifiedViewEnabled(context ldcontext.Context, client *features.Client) bool {
  58. defaultValue := true
  59. value, _ := client.BoolVariation("simplified_view_enabled", context, defaultValue)
  60. return value
  61. }
  62. func getStacksEnabled(context ldcontext.Context, client *features.Client) bool {
  63. defaultValue := false
  64. value, _ := client.BoolVariation("stacks_enabled", context, defaultValue)
  65. return value
  66. }
  67. func getValidateApplyV2(context ldcontext.Context, client *features.Client) bool {
  68. defaultValue := false
  69. value, _ := client.BoolVariation("validate_apply_v2", context, defaultValue)
  70. return value
  71. }
  72. func getProjectContext(projectID uint, projectName string) ldcontext.Context {
  73. projectIdentifier := fmt.Sprintf("project-%d", projectID)
  74. launchDarklyName := fmt.Sprintf("%s: %s", projectIdentifier, projectName)
  75. return ldcontext.NewBuilder(projectIdentifier).
  76. Kind("project").
  77. Name(launchDarklyName).
  78. SetInt("project_id", int(projectID)).
  79. Build()
  80. }