Child pages
    • Pattern Configuration
    Skip to end of metadata
    Go to start of metadata

    It is sometimes useful to permit the end-user to modify certain characteristics of a pattern, such as whether to enable features that might be costly, or to change a set of default paths or package names. This is enabled with pattern configuration blocks. Pattern configuration is new in TPL 1.2.

    Changes in the pattern configuration block revision number may reset the pattern configuration changes to the default values

    If you install a Technology Knowledge Update (TKU) which contains an update to a pattern configuration block that requires its major revision number to be incremented, any end-user configuration changes to that pattern (made through the pattern configuration block) are lost and the default pattern values are restored.

    Configuration block definition

    configuration blocks are top-level elements. Like other elements, they have a name and a version number. Pattern modules can import configuration blocks from other modules, using the usual version numbering conventions.

    The form of a configuration block is:

    configuration name version
      """
      Description of configuration block to show in UI
      """
    
      "Description of first configuration item"
      config_name := config_value;
    
      ...
    end configuration;
    

    Configuration items are given a human-readable description to be shown in the user interface, an identifier to use in patterns, and a default value. The default value is the value used if the configuration item has not been changed by the user. It also determines the type of the configuration item — the user interface will only allow the user to change the setting to a value with the same type. The valid types for configuration items are text string, integer, boolean, list of strings, and list of integers.

    This example shows a number of configuration settings:

    configuration MyConfig 1.0
      """
      An example configuration block.
      """
    
      "A boolean flag"
      a_flag := true;
    
      "Command to run"
      command := "sudo rm -rf /";
    
      "Port for the service"
      port := 12345;
    
      "Paths to look in"
      paths := [ "/usr/bin", "/usr/local/bin" ];
    
    end configuration;
    

    Using configuration settings

    Configuration settings are used in patterns by giving the scoped name of the configuration block, followed by the configuration setting name:

    if MyConfig.a_flag then
      result := discovery.runCommand(host, MyConfig.command);
    end if
    

    Types of default empty lists

    The types of configurations items can usually be inferred from the type of the default value. However, if the default value of a configuration item is an empty list, the system cannot know whether it is a list of text strings or a list of integers. To tell the system the type of such a configuration item, an example of the type should be provided in parentheses after the empty list:

    "This is a list of strings that's empty by default"
    empty_string_list := [ ] ("");
    
    "This is a list of integers that's empty by default"
    empty_number_list := [ ] (0);
    
    • No labels