Skip to content

Commit

Permalink
Truncate the credential file to avoid the change of secret content me…
Browse files Browse the repository at this point in the history
…ssing it up

Truncate the credential file to avoid the change of secret content messing it up

Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
  • Loading branch information
ywk253100 committed Nov 8, 2023
1 parent 866fbb5 commit 55f1086
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelogs/unreleased/7071-ywk253100
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Truncate the credential file to avoid the change of secret content messing it up
2 changes: 1 addition & 1 deletion internal/credentials/file_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (n *namespacedFileStore) Path(selector *corev1api.SecretKeySelector) (strin

keyFilePath := filepath.Join(n.fsRoot, fmt.Sprintf("%s-%s", selector.Name, selector.Key))

file, err := n.fs.OpenFile(keyFilePath, os.O_RDWR|os.O_CREATE, 0644)
file, err := n.fs.OpenFile(keyFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
return "", errors.Wrap(err, "unable to open credentials file for writing")
}
Expand Down

0 comments on commit 55f1086

Please sign in to comment.