github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/clients/pkg/promtail/positions/write_positions_unix.go (about)

     1  //go:build !windows
     2  // +build !windows
     3  
     4  package positions
     5  
     6  import (
     7  	"os"
     8  	"path/filepath"
     9  
    10  	renameio "github.com/google/renameio/v2"
    11  	yaml "gopkg.in/yaml.v2"
    12  )
    13  
    14  func writePositionFile(filename string, positions map[string]string) error {
    15  	buf, err := yaml.Marshal(File{
    16  		Positions: positions,
    17  	})
    18  	if err != nil {
    19  		return err
    20  	}
    21  
    22  	target := filepath.Clean(filename)
    23  
    24  	return renameio.WriteFile(target, buf, os.FileMode(positionFileMode))
    25  }