Skip to content

Commit

Permalink
infisical feature flag (#4572)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianedwards authored Apr 23, 2024
1 parent 9949862 commit cb13428
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 19 deletions.
1 change: 1 addition & 0 deletions api/types/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 26 additions & 17 deletions dashboard/src/main/home/integrations/Integrations.tsx
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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>
Expand All @@ -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}
Expand Down Expand Up @@ -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={() => {}}
/>
Expand Down
3 changes: 2 additions & 1 deletion dashboard/src/shared/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -779,4 +780,4 @@ export type AppEventWebhook = {
app_event_type: string;
app_event_status: string;
payload_encryption_key: string;
}
};
2 changes: 2 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
5 changes: 5 additions & 0 deletions internal/models/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -102,6 +105,7 @@ var ProjectFeatureFlags = map[FeatureFlagLabel]bool{
CapiProvisionerEnabled: true,
BillingEnabled: false,
MetronomeEnabled: false,
InfisicalEnabled: false,
DBEnabled: false,
EFSEnabled: false,
EnableReprovision: false,
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit cb13428

Please sign in to comment.