(localFilePath string, remoteFilePath string, remoteUser string, remoteHost string)
| 10 | ) |
| 11 | |
| 12 | func transferConfigFileToRemote(localFilePath string, remoteFilePath string, remoteUser string, remoteHost string) error { |
| 13 | localFile, err := os.Open(localFilePath) |
| 14 | if err != nil { |
| 15 | return fmt.Errorf("failed to open local file: %s", err) |
| 16 | } |
| 17 | defer localFile.Close() |
| 18 | |
| 19 | cmd := exec.Command("scp", localFilePath, remoteUser+"@"+remoteHost+":"+remoteFilePath) |
| 20 | err = cmd.Run() |
| 21 | if err != nil { |
| 22 | return fmt.Errorf("file %s transferred to %s@%s:%s failed", localFilePath, remoteUser, remoteHost, remoteFilePath) |
| 23 | } |
| 24 | |
| 25 | log.Printf("file '%s' transferred to '%s@%s:%s' successfully.\n", localFilePath, remoteUser, remoteHost, remoteFilePath) |
| 26 | |
| 27 | return nil |
| 28 | } |
| 29 | |
| 30 | func transferDirectoryToRemote(localFilePath string, remoteFilePath string, remoteUser string, remoteHost string) error { |
| 31 | localFile, err := os.Open(localFilePath) |
no test coverage detected