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.
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.
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
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.
Type | Description |
Checkbox | A checkbox field |
Code Editor | A multi-line code text box |
Number | A number field with the ability increment and decrement the value using arrows on the side of the text box |
Password | A masked password field for sensitive data |
Radio | A radio button for multi-select toggling |
Select | A drop-down select field that uses values specified in the plugin or via an API call |
Text | A single line string text field |
Text Area | A multi-line string text box |
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.