fix cleanup temp dir path
Signed-off-by: Mikhail Scherba <mikhail.scherba@flant.com>
This commit is contained in:
parent
a2f67e2ba6
commit
cbaf6fb69b
1 changed files with 4 additions and 3 deletions
|
@ -71,6 +71,8 @@ const (
|
|||
emptyUID = "-1"
|
||||
)
|
||||
|
||||
var tmpDir = os.TempDir() + "/nginx"
|
||||
|
||||
// NewNGINXController creates a new NGINX Ingress controller.
|
||||
func NewNGINXController(config *Configuration, mc metric.Collector) *NGINXController {
|
||||
eventBroadcaster := record.NewBroadcaster()
|
||||
|
@ -635,7 +637,6 @@ func (n *NGINXController) testTemplate(cfg []byte) error {
|
|||
if len(cfg) == 0 {
|
||||
return fmt.Errorf("invalid NGINX configuration (empty)")
|
||||
}
|
||||
tmpDir := os.TempDir() + "/nginx"
|
||||
tmpfile, err := os.CreateTemp(tmpDir, tempNginxPattern)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -1037,11 +1038,11 @@ func createOpentelemetryCfg(cfg *ngx_config.Configuration) error {
|
|||
func cleanTempNginxCfg() error {
|
||||
var files []string
|
||||
|
||||
err := filepath.Walk(os.TempDir(), func(path string, info os.FileInfo, err error) error {
|
||||
err := filepath.Walk(tmpDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info.IsDir() && os.TempDir() != path {
|
||||
if info.IsDir() && tmpDir != path {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue