(key, value string, directives []sshDirective)
| 1038 | } |
| 1039 | |
| 1040 | func rewriteSSHMultiValueDirective(key, value string, directives []sshDirective) error { |
| 1041 | block, err := loadSSHManagedBlockFromFile(sshPath) |
| 1042 | if err != nil { |
| 1043 | return err |
| 1044 | } |
| 1045 | targetFiles := make(map[string][]int) |
| 1046 | for _, item := range directives { |
| 1047 | if item.InMatch || !strings.EqualFold(item.Key, key) { |
| 1048 | continue |
| 1049 | } |
| 1050 | if item.File == sshPath && block.contains(item.Line) { |
| 1051 | continue |
| 1052 | } |
| 1053 | targetFiles[item.File] = append(targetFiles[item.File], item.Line) |
| 1054 | } |
| 1055 | for fileName, lines := range targetFiles { |
| 1056 | if err := commentSSHConfigLines(fileName, lines); err != nil { |
| 1057 | return err |
| 1058 | } |
| 1059 | } |
| 1060 | |
| 1061 | return rewriteSSHManagedDirectives(sshPath, key, buildSSHDirectiveLines(key, value)) |
| 1062 | } |
| 1063 | |
| 1064 | func buildSSHDirectiveLines(key, value string) []string { |
| 1065 | var directives []string |
no test coverage detected