Search in sources :

Example 1 with YamlFormatter

use of org.rundeck.toolbelt.format.yaml.snakeyaml.YamlFormatter in project rundeck-cli by rundeck.

the class Main method configYamlFormat.

private static void configYamlFormat(final ToolBelt belt, final RdClientConfig config) {
    DumperOptions dumperOptions = new DumperOptions();
    dumperOptions.setDefaultFlowStyle("BLOCK".equalsIgnoreCase(config.getString("RD_YAML_FLOW", "BLOCK")) ? DumperOptions.FlowStyle.BLOCK : DumperOptions.FlowStyle.FLOW);
    dumperOptions.setPrettyFlow(config.getBool("RD_YAML_PRETTY", true));
    Representer representer = new Representer();
    representer.addClassTag(JobItem.class, Tag.MAP);
    representer.addClassTag(ScheduledJobItem.class, Tag.MAP);
    representer.addClassTag(DateInfo.class, Tag.MAP);
    representer.addClassTag(Execution.class, Tag.MAP);
    belt.formatter(new YamlFormatter(DataOutputAsFormatable, new Yaml(representer, dumperOptions)));
    belt.channels().infoEnabled(false);
    belt.channels().warningEnabled(false);
    belt.channels().errorEnabled(false);
}
Also used : Representer(org.yaml.snakeyaml.representer.Representer) YamlFormatter(org.rundeck.toolbelt.format.yaml.snakeyaml.YamlFormatter) DumperOptions(org.yaml.snakeyaml.DumperOptions) Yaml(org.yaml.snakeyaml.Yaml)

Aggregations

YamlFormatter (org.rundeck.toolbelt.format.yaml.snakeyaml.YamlFormatter)1 DumperOptions (org.yaml.snakeyaml.DumperOptions)1 Yaml (org.yaml.snakeyaml.Yaml)1 Representer (org.yaml.snakeyaml.representer.Representer)1