Create custom recipe action for Key module

Created on 19 December 2024, 4 months ago

Problem/Motivation

I am developing the AI module and we are heavily using your great module to store api keys and other secrets. Our module is going into Drupal CMS as an optional recipe you can apply after installation. Meaning that your module will be there as well.

There is now a way of using input variables Make it possible for recipes to prompt for input values Fixed in D11. This works well in terminal and will soon be available when applying a recipe in the GUI as well.

On top of that there are custom action plugins for recipes, meaning that the Key module could add a custom action plugin for recipes that will take care of:

  1. Creating the key entity from an input value if its set.
  2. Linking the key to a specific configuration key.

Proposed resolution

Create a custom plugin action that can take a value an connect it to a config on a specific config key.

Example of integration

One example for setting up the OpenAI API Key during installation or application of recipes would for instance be (in this example the plugin is called setKeyEntityIfValueExists:

input:
  api_key:
    data_type: string
    description: The OpenAI API Key if you want to use OpenAI.
    prompt:
      method: ask
      arguments:
        question: 'Please provide your OpenAI API Key:'
    default:
      source: value
      value: ''
config:
  actions:
    ai_provider_openai.settings: # The configuration file you want to add it to
      setKeyEntityIfValueExists: # The new action
        key_config_key: api_key # The config key that should take the keys entity id on the configuration (in this case ai_provider_openai.settings).
        value: ${api_key} # The value to check if its set.
        id: openai_key # The key entity id.
        label: 'OpenAI Key' #Other configurations for the key entity.
        key_type: authentication
        key_provider: config
        key_provider_settings:
          key_value: ${api_key}
        key_input: text_field
Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany marcus_johansson

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024