MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / rewriteSSHMultiValueDirective

Function rewriteSSHMultiValueDirective

agent/app/service/ssh.go:1040–1062  ·  view source on GitHub ↗
(key, value string, directives []sshDirective)

Source from the content-addressed store, hash-verified

1038}
1039
1040func 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
1064func buildSSHDirectiveLines(key, value string) []string {
1065 var directives []string

Callers 1

updateSSHDirectiveValueFunction · 0.85

Calls 5

commentSSHConfigLinesFunction · 0.85
buildSSHDirectiveLinesFunction · 0.85
containsMethod · 0.80

Tested by

no test coverage detected