Merge pull request #15556 from drodil/app_feature_flags

feat: allow specifying app level feature flags
This commit is contained in:
Ben Lambert
2023-01-10 14:30:47 +01:00
committed by GitHub
11 changed files with 67 additions and 8 deletions
+21 -4
View File
@@ -1,16 +1,18 @@
---
id: feature-flags
title: Feature Flags
description: Details the process of defining setting and reading a plugin feature flag.
description: Details the process of defining setting and reading a feature flag.
---
Backstage offers the ability to define feature flags inside a plugin. This allows you to restrict parts of your plugin to those individual users who have toggled the feature flag to on.
Backstage offers the ability to define feature flags inside a plugin or during application creation. This allows you to restrict parts of your plugin to those individual users who have toggled the feature flag to on.
This page describes the process of defining setting and reading a plugin feature flag. If you are looking for using feature flags with software templates that can be found under [Writing Templates](https://backstage.io/docs/features/software-templates/writing-templates#remove-sections-or-fields-based-on-feature-flags).
This page describes the process of defining setting and reading a feature flag. If you are looking for using feature flags with software templates that can be found under [Writing Templates](https://backstage.io/docs/features/software-templates/writing-templates#remove-sections-or-fields-based-on-feature-flags).
## Defining a Feature Flag
Before using a feature flag we must first define it. This is done when we create the plugin by passing the name of the feature flag into the `featureFlags` array.
### In a plugin
Defining feature flag in a plugin is done by passing the name of the feature flag into the `featureFlags` array:
```ts
/* src/plugin.ts */
@@ -26,6 +28,21 @@ export const examplePlugin = createPlugin({
});
```
### In the application
Defining feature flag in the application is done by adding feature flags in`featureFlags` array in
`createApp()` function call:
```ts
const app = createApp({
// ...
featureFlags: [
{ name: 'tech-radar', description: 'Enables the tech radar plugin' },
],
// ...
});
```
## Enabling Feature Flags
Feature flags are defaulted to off and can be updated by individual users in the backstage interface.