Skip to content

Commit

Permalink
Make file permission more explict
Browse files Browse the repository at this point in the history
Replace os.Create by os.OpenFile for more granular permissions and flags.
Also, adding defer function to close the file once done as per review
comment.

Signed-off-by: Tam Mach <[email protected]>
  • Loading branch information
sayboras committed Jan 4, 2022
1 parent 041cdc1 commit cb34a69
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/k8s/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ func (c *Client) CopyFromPod(ctx context.Context, namespace, pod, container stri
ReadFunc: readFromPod(ctx, c, namespace, pod, container, srcFile),
})

outFile, err := os.Create(destFile)
outFile, err := os.OpenFile(destFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return err
}
defer outFile.Close()

if _, err = io.Copy(outFile, pipe); err != nil {
return err
Expand Down

0 comments on commit cb34a69

Please sign in to comment.