mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 12:03:33 +00:00
remove indentations from corrosion config
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package corrosion
|
package corrosion
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
@@ -43,14 +44,16 @@ type AdminConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) Write(path, owner string) error {
|
func (c *Config) Write(path, owner string) error {
|
||||||
data, err := toml.Marshal(c)
|
var data bytes.Buffer
|
||||||
if err != nil {
|
encoder := toml.NewEncoder(&data)
|
||||||
return fmt.Errorf("marshal config: %w", err)
|
encoder.Indent = "" // Disable indentation.
|
||||||
|
if err := encoder.Encode(c); err != nil {
|
||||||
|
return fmt.Errorf("encode config: %w", err)
|
||||||
}
|
}
|
||||||
|
if err := os.WriteFile(path, data.Bytes(), 0600); err != nil {
|
||||||
if err := os.WriteFile(path, data, 0600); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if owner != "" {
|
if owner != "" {
|
||||||
usr, err := user.Lookup(owner)
|
usr, err := user.Lookup(owner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user