Use feature flag manifests

Feature flag manifests in App Lifecycle Manager let you create and export flags in bulk using local JSON files that conform to the open-source OpenFeature flag manifest schema. You can push new definitions to the App Lifecycle Manager management plane or pull existing flags for OpenFeature code generation.

Prerequisites

Before you begin, ensure you have:

  1. A gcloud environment configured to manage App Lifecycle Manager resources.
  2. Completed the Deploy feature flags quickstart or the Deploy with the gcloud CLI quickstart.

Create flags from a manifest

The push command lets you create multiple flags at once by providing a local JSON manifest file.

  1. Create a file named my_flags.json with your flag definitions. This file serves as the local source of truth for your manifest.

    Example my_flags.json:

    {
      "flags": {
        "my-flag": {
          "defaultValue": "foo-bar",
          "description": "A description of the flag.",
          "flagType": "string"
        }
      }
    }
    
    1. Run the push command specifying your manifest file and the targeted UnitKind.
    gcloud beta app-lifecycle-manager flags push \
        --file="my_flags.json" \
        --location="global" \
        --unit-kind="UNIT_KIND_NAME"
    

Create a manifest from existing flag configurations

The pull command fetches existing flag configurations from the App Lifecycle Manager API and generates a local JSON manifest file. This lets you maintain a local record of your flags or prepare them for use with OpenFeature codegen tools.

  1. Run the pull command specifying your chosen output path.

     gcloud beta app-lifecycle-manager flags pull \
         --location="global" \
         --output-file="manifest.json" \
         --unit-kind="UNIT_KIND_NAME" \
         --overwrite-output-file
    
  2. If you are using type-safe flag accessors, run the OpenFeature CLI codegen utility against the new manifest.json to update your application's type-safe flag accessors. This ensures the manifests match the keys and types in the management plane.

What's next