From 1ec3376be51fe612667e13bcf36d35b8061338cc Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Thu, 26 Sep 2024 18:06:45 +1000 Subject: [PATCH] remove indentations from corrosion config --- internal/machine/corrosion/config.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/machine/corrosion/config.go b/internal/machine/corrosion/config.go index 66d86090..0fe07908 100644 --- a/internal/machine/corrosion/config.go +++ b/internal/machine/corrosion/config.go @@ -1,6 +1,7 @@ package corrosion import ( + "bytes" "fmt" "github.com/BurntSushi/toml" "net/netip" @@ -43,14 +44,16 @@ type AdminConfig struct { } func (c *Config) Write(path, owner string) error { - data, err := toml.Marshal(c) - if err != nil { - return fmt.Errorf("marshal config: %w", err) + var data bytes.Buffer + encoder := toml.NewEncoder(&data) + encoder.Indent = "" // Disable indentation. + if err := encoder.Encode(c); err != nil { + return fmt.Errorf("encode config: %w", err) } - - if err := os.WriteFile(path, data, 0600); err != nil { + if err := os.WriteFile(path, data.Bytes(), 0600); err != nil { return err } + if owner != "" { usr, err := user.Lookup(owner) if err != nil {