PatchDefinition implements the ConfigPatch.PatchDefinition interface.
(d model.ConfigDefinition, _ string)
| 86 | |
| 87 | // PatchDefinition implements the ConfigPatch.PatchDefinition interface. |
| 88 | func (c *ConfigPatchAll) PatchDefinition(d model.ConfigDefinition, _ string) model.ConfigDefinition { |
| 89 | if d.Definition.DisplayName == "" || d.Definition.DisplayName == d.Definition.Name { |
| 90 | computedDisplayName := c.configNameToDisplayName(d.Definition.Name) |
| 91 | d.SetDisplayName(computedDisplayName) |
| 92 | } |
| 93 | |
| 94 | if d.Definition.Name == "errors.tolerance" { |
| 95 | d.SetDisplayName("Error tolerance"). |
| 96 | SetComponentType(model.ComponentRadioGroup). |
| 97 | AddRecommendedValueWithMetadata("none", "NONE"). |
| 98 | AddRecommendedValueWithMetadata("all", "ALL") |
| 99 | } |
| 100 | |
| 101 | d.SetDocumentation(strings.TrimRight(d.Definition.Documentation, ".")) |
| 102 | |
| 103 | for i := range d.Value.Errors { |
| 104 | d.Value.Errors[i] = strings.TrimRight(d.Value.Errors[i], ".") |
| 105 | } |
| 106 | |
| 107 | d.SetDocumentation(strings.TrimRight(d.Definition.Documentation, ".")) |
| 108 | |
| 109 | for i := range d.Value.Errors { |
| 110 | d.Value.Errors[i] = strings.TrimRight(d.Value.Errors[i], ".") |
| 111 | } |
| 112 | |
| 113 | return d |
| 114 | } |
| 115 | |
| 116 | // ConfigNameToDisplayName computes a display name by title casing the input key |
| 117 | // and replacing known abbreviations with the correctly formatted abbreviation. |