pkg/ceph: [WIP]

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-08-28 15:44:45 +01:00
parent f4e69f9953
commit d47ad6de12
7 changed files with 148 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
package ceph
import (
"bytes"
"io"
"net/netip"
"github.com/gofrs/uuid/v5"
"asciigoat.org/ini"
)
// Config represents a ceph.conf file
type Config struct {
Global GlobalConfig `ini:"global"`
}
// WriteTo writes a Wireguard [Config] onto the provided [io.Writer]
func (*Config) WriteTo(w io.Writer) (int64, error) {
var buf bytes.Buffer
return buf.WriteTo(w)
}
// GlobalConfig represents the [global] section of a ceph.conf file
type GlobalConfig struct {
FSID uuid.UUID `ini:"fsid"`
Monitors []string `ini:"mon_host,comma"`
MonitorsAddr []netip.Addr `ini:"mon_initial_members,comma"`
ClusterNetwork netip.Prefix `ini:"cluster_network"`
}
// NewConfigFromReader parses the ceph.conf file
func NewConfigFromReader(r io.Reader) (*Config, error) {
var out Config
dec := ini.NewDecoder(r)
if err := dec.Decode(&out); err != nil {
return nil, err
}
return &out, nil
}