translateSource provides the name of the source of the option, depending on the supplied target ValueSource.
(target serpent.ValueSource, opt serpent.Option)
| 1823 | // translateSource provides the name of the source of the option, depending on the |
| 1824 | // supplied target ValueSource. |
| 1825 | func translateSource(target serpent.ValueSource, opt serpent.Option) string { |
| 1826 | switch target { |
| 1827 | case serpent.ValueSourceFlag: |
| 1828 | return fmt.Sprintf("`--%s`", opt.Flag) |
| 1829 | case serpent.ValueSourceEnv: |
| 1830 | return fmt.Sprintf("`%s`", opt.Env) |
| 1831 | case serpent.ValueSourceYAML: |
| 1832 | return fmt.Sprintf("`%s`", fullYamlName(opt)) |
| 1833 | default: |
| 1834 | return opt.Name |
| 1835 | } |
| 1836 | } |
| 1837 | |
| 1838 | func fullYamlName(opt serpent.Option) string { |
| 1839 | var full strings.Builder |
no test coverage detected