Bladeren bron

infisical feature flag (#4572)

ianedwards 2 jaren geleden
bovenliggende
commit
cb13428c4e

+ 1 - 0
api/types/project.go

@@ -40,6 +40,7 @@ type Project struct {
 	CapiProvisionerEnabled          bool    `json:"capi_provisioner_enabled"`
 	BillingEnabled                  bool    `json:"billing_enabled"`
 	MetronomeEnabled                bool    `json:"metronome_enabled"`
+	InfisicalEnabled                bool    `json:"infisical_enabled"`
 	DBEnabled                       bool    `json:"db_enabled"`
 	EFSEnabled                      bool    `json:"efs_enabled"`
 	EnableReprovision               bool    `json:"enable_reprovision"`

+ 1 - 1
dashboard/src/main/home/integrations/IntegrationCategories.tsx

@@ -176,7 +176,7 @@ const IntegrationCategories: React.FC<Props> = (props) => {
         <SlackIntegrationList slackData={slackData} />
       ) : props.category === "doppler" ? (
         <DopplerIntegrationList />
-      ) : props.category === "infisical" ? (
+      ) : props.category === "infisical" && currentProject?.infisical_enabled ? (
         <InfisicalIntegrationList />
       ) : (
         <IntegrationList

+ 26 - 17
dashboard/src/main/home/integrations/Integrations.tsx

@@ -1,18 +1,24 @@
 import React, { useContext, useMemo } from "react";
-import { Route, RouteComponentProps, Switch, withRouter } from "react-router";
+import {
+  Route,
+  Switch,
+  withRouter,
+  type RouteComponentProps,
+} from "react-router";
+import styled from "styled-components";
+
+import Spacer from "components/porter/Spacer";
+import TitleSection from "components/TitleSection";
 
 import { integrationList } from "shared/common";
-import styled from "styled-components";
+import { Context } from "shared/Context";
 import { pushFiltered } from "shared/routing";
 import integrationGrad from "assets/integration-grad.svg";
 
+import DashboardHeader from "../cluster-dashboard/DashboardHeader";
 import CreateIntegrationForm from "./create-integration/CreateIntegrationForm";
 import IntegrationCategories from "./IntegrationCategories";
 import IntegrationList from "./IntegrationList";
-import TitleSection from "components/TitleSection";
-import { Context } from "shared/Context";
-import Spacer from "components/porter/Spacer";
-import DashboardHeader from "../cluster-dashboard/DashboardHeader";
 
 type PropsType = RouteComponentProps;
 
@@ -21,11 +27,15 @@ const Integrations: React.FC<PropsType> = (props) => {
 
   const IntegrationCategoryStrings = useMemo(() => {
     if (!enableGitlab) {
-      return ["slack", "doppler", "infisical"];
+      return currentProject?.infisical_enabled
+        ? ["slack", "doppler", "infisical"]
+        : ["slack", "doppler"];
     }
 
-    return ["slack", "doppler", "infisical", "gitlab"];
-  }, [enableGitlab]);
+    return currentProject?.infisical_enabled
+      ? ["slack", "doppler", "infisical", "gitlab"]
+      : ["slack", "doppler", "gitlab"];
+  }, [enableGitlab, currentProject]);
 
   return (
     <StyledIntegrations>
@@ -37,16 +47,15 @@ const Integrations: React.FC<PropsType> = (props) => {
             if (!IntegrationCategoryStrings.includes(category)) {
               pushFiltered(props, "/integrations", ["project_id"]);
             }
-            let icon =
-              integrationList[integration] && integrationList[integration].icon;
+            const icon = integrationList[integration]?.icon;
             return (
               <Flex>
                 <TitleSection
-                  handleNavBack={() =>
+                  handleNavBack={() => {
                     pushFiltered(props, `/integrations/${category}`, [
                       "project_id",
-                    ])
-                  }
+                    ]);
+                  }}
                   icon={icon}
                 >
                   {integrationList[integration].label}
@@ -86,9 +95,9 @@ const Integrations: React.FC<PropsType> = (props) => {
             <IntegrationList
               currentCategory={""}
               integrations={IntegrationCategoryStrings}
-              setCurrent={(x) =>
-                pushFiltered(props, `/integrations/${x}`, ["project_id"])
-              }
+              setCurrent={(x) => {
+                pushFiltered(props, `/integrations/${x}`, ["project_id"]);
+              }}
               isCategory={true}
               updateIntegrationList={() => {}}
             />

+ 2 - 1
dashboard/src/shared/types.tsx

@@ -317,6 +317,7 @@ export type ProjectType = {
   beta_features_enabled: boolean;
   billing_enabled: boolean;
   metronome_enabled: boolean;
+  infisical_enabled: boolean;
   capi_provisioner_enabled: boolean;
   db_enabled: boolean;
   efs_enabled: boolean;
@@ -779,4 +780,4 @@ export type AppEventWebhook = {
   app_event_type: string;
   app_event_status: string;
   payload_encryption_key: string;
-}
+};

+ 2 - 0
go.work.sum

@@ -857,6 +857,8 @@ github.com/porter-dev/api-contracts v0.2.78 h1:Iyp1DL33mPxJZQSjH8W/ylv5Ch8i30eJJ
 github.com/porter-dev/api-contracts v0.2.78/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
 github.com/porter-dev/api-contracts v0.2.93/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
 github.com/porter-dev/api-contracts v0.2.110/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
+github.com/porter-dev/api-contracts v0.2.150 h1:4BMuDuRboUg5aeuQOTy+/MWK+zFmKQ6Vdgek3/1nKOk=
+github.com/porter-dev/api-contracts v0.2.150/go.mod h1:VV5BzXd02ZdbWIPLVP+PX3GKawJSGQnxorVT2sUZALU=
 github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
 github.com/pquerna/cachecontrol v0.1.0 h1:yJMy84ti9h/+OEWa752kBTKv4XC30OtVVHYv/8cTqKc=
 github.com/pquerna/cachecontrol v0.1.0/go.mod h1:NrUG3Z7Rdu85UNR3vm7SOsl1nFIeSiQnrHV5K9mBcUI=

+ 5 - 0
internal/models/project.go

@@ -32,6 +32,9 @@ const (
 	// MetronomeEnabled enables all Metronome business logic
 	MetronomeEnabled FeatureFlagLabel = "metronome_enabled"
 
+	// InfisicalEnabled enables the Infisical secrets operator integration
+	InfisicalEnabled FeatureFlagLabel = "infisical_enabled"
+
 	// DBEnabled enables the "Databases" tab
 	DBEnabled FeatureFlagLabel = "db_enabled"
 
@@ -102,6 +105,7 @@ var ProjectFeatureFlags = map[FeatureFlagLabel]bool{
 	CapiProvisionerEnabled:          true,
 	BillingEnabled:                  false,
 	MetronomeEnabled:                false,
+	InfisicalEnabled:                false,
 	DBEnabled:                       false,
 	EFSEnabled:                      false,
 	EnableReprovision:               false,
@@ -308,6 +312,7 @@ func (p *Project) ToProjectType(launchDarklyClient *features.Client) types.Proje
 		CapiProvisionerEnabled:          p.GetFeatureFlag(CapiProvisionerEnabled, launchDarklyClient),
 		BillingEnabled:                  p.GetFeatureFlag(BillingEnabled, launchDarklyClient),
 		MetronomeEnabled:                p.GetFeatureFlag(MetronomeEnabled, launchDarklyClient),
+		InfisicalEnabled:                p.GetFeatureFlag(InfisicalEnabled, launchDarklyClient),
 		DBEnabled:                       p.GetFeatureFlag(DBEnabled, launchDarklyClient),
 		EFSEnabled:                      p.GetFeatureFlag(EFSEnabled, launchDarklyClient),
 		EnableReprovision:               p.GetFeatureFlag(EnableReprovision, launchDarklyClient),