Morpheus Custom Plugin Settings

By: Morpheus Data

The Morpheus platform supports extending the functionality of the platform with the development of custom plugins. This could be custom reports, tasks or instance UI tabs. The 5.4.1 release of the Morpheus platform introduced custom plugin settings to define a plugin’s settings at runtime. This feature is helpful for plugins that utilize credentials for interacting with the external systems or situations where a setting needs to be modified without the need to rebuild the plugin.

Plugin Settings

The Plugins section of the UI has been updated to include additional information as well as the ability to update the configuration of individual plugins from the UI.

Once a plugin has been installed the plugin settings can be updated by clicking on the pencil next to the plugin entry. The EDIT PLUGIN modal will open for the plugin with the settings defined by the plugin author if any have been defined.

DataDog custom plugin settings

Plugin Settings Code

The plugin settings are defined by adding the desired option types to the plugin. The code displayed below is an example of the API Key and the Environments option types from the example shown above.

Plugin Settings Definition

The declaration is added to the plugin entry point of the Morpheus plugin. The option type attributes can be found in the plugin API documentation.

this.settings << new OptionType(
name: 'API Key',
code: 'datadog-plugin-api-key',
fieldName: 'ddApiKey',
displayOrder: 0,
fieldLabel: 'API Key',
helpText: 'The DataDog API key',
required: true,
inputType: OptionType.InputType.PASSWORD
)

this.settings << new OptionType(
name: 'Visible Environments',
code: 'datadog-plugin-environments-field',
fieldName: 'environmentVisibilityField',
defaultValue: 'any',
displayOrder: 2,
fieldLabel: 'Environments',
fieldGroup: 'Visibility Settings',
helpText: 'List of the names of the Morpheus environments the tab is visible (i.e. - production,qa,dev)',
required: false,
inputType: OptionType.InputType.TEXT
)

Accessing Plugin Settings

The settings are available to the plugin providers as a JSON payload and accessed using the fieldName defined for the option type via dot notation.

// Retrieve plugin settings
def settings = morpheus.getSettings(plugin)
def settingsOutput = ""
settings.subscribe(
{ outData ->
settingsOutput = outData
},
{ error ->
println error.printStackTrace()
}
)

// Parse the plugin settings payload. The settings will be available as
// settingsJson.$optionTypeFieldName i.e. - settingsJson.ddApiKey to retrieve the DataDog API key setting
JsonSlurper slurper = new JsonSlurper()
def settingsJson = slurper.parseText(settingsOutput)

// The API Key setting can now be accessed via settingsJson.ddApiKey
// The Environment visibility setting can be accessed via settingsJson.environmentVisibilityField

Option Types

The plugin settings support option types similar to the inputs or option types used elsewhere within the platform. The following table details the currently supported plugin setting option types.

TypeDescription
CheckboxA checkbox field
Code EditorA multi-line code text box
NumberA number field with the ability increment and decrement the value using arrows on the side of the text box
PasswordA masked password field for sensitive data
RadioA radio button for multi-select toggling
SelectA drop-down select field that uses values specified in the plugin or via an API call
TextA single line string text field
Text AreaA multi-line string text box

Conclusion

The addition of custom plugin settings enables administrators to configure the runtime configuration of a plugin without needing to rebuild the plugin or hardcoding configuration data.

Try Morpheus Community Edition or Get a Demo
The Morpheus Community Edition lets you fully experience the Morpheus platform including nearly all features and capabilities! Register at Morpheus Hub and try it in your home lab or test environment today! Interested in learning more about Morpheus from one of our cloud transformation experts? Schedule a demo to walk through how Morpheus can help your organization here.

Related Resources

  • card listing image
    Oct 2024 | Webinar
    Tech Brief: Building a Morpheus Integration
  • card listing image
    Sep 2024 | Paper
    Morpheus Data Reference Architecture for 7.x
  • listing image
    Aug 2024 | Blog
    NEWS: Morpheus is joining HPE!
  • listing image
    Aug 2024 | Blog
    Cloud Field Day 20: A NeverEnding Story of Innovation
  • listing image
    Jul 2024 | Paper
    ISG Provider Lens – Hybrid Cloud Management
  • card listing image
    Jul 2024 | Webinar
    Tech Brief: Building a Database as a Service Solution w...
  • card listing image
    Jun 2024 | Webinar
    Cloud Field Day 20 – Introducing MVM: An Embedded...
  • card listing image
    Jun 2024 | Webinar
    Cloud Field Day 20 – Morpheus Platform Architectu...
  • card listing image
    Jun 2024 | Webinar
    Cloud Field Day 20 – Morpheus in 2024: The Critic...
  • card listing image
    Jun 2024 | Webinar
    Cloud Field Day 20 – Morpheus Tech Foundation: De...