Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions contrib/pkg/utils/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utils
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -159,6 +160,10 @@ func ProjectToDir(obj client.Object, dir string, keys ...string) {
return
}
path := filepath.Join(dir, filename)
// Unlink if present, in case this is a recycled pod
if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) {
log.WithError(err).WithField("path", path).Fatal("Failed to remove existing file")
}
if err := os.WriteFile(path, bytes, 0400); err != nil {
log.WithError(err).WithField("path", path).Fatal("Failed to write file")
}
Expand Down