copyFile copies a file from src to dst, preserving the executable permission.
(src, dst string)
| 402 | |
| 403 | // copyFile copies a file from src to dst, preserving the executable permission. |
| 404 | func copyFile(src, dst string) error { |
| 405 | in, err := os.Open(src) |
| 406 | if err != nil { |
| 407 | return err |
| 408 | } |
| 409 | defer in.Close() |
| 410 | |
| 411 | out, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o755) // #nosec G302 |
| 412 | if err != nil { |
| 413 | return err |
| 414 | } |
| 415 | defer out.Close() |
| 416 | |
| 417 | _, err = io.Copy(out, in) |
| 418 | return err |
| 419 | } |
| 420 | |
| 421 | // Tar and gzip a file. Used with trusted artifacts. |
| 422 | func tarGzipFile(source, target string) error { |
no test coverage detected