package ceph import ( "bytes" "io" "net/netip" "github.com/gofrs/uuid/v5" "gopkg.in/gcfg.v1" ) // Config represents a ceph.conf file type Config struct { Global GlobalConfig } // 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 Monitors []string MonitorsAddr []netip.Addr } type intermediateConfig struct { Global intermediateGlobalConfig } func (p intermediateConfig) Export() (*Config, error) { var out Config var err error // [global] out.Global, err = p.Global.Export() if err != nil { return nil, err } return &out, nil } type intermediateGlobalConfig struct { FSID uuid.UUID MonInitialMembers string MonHost string ClusterNetwork string } func (intermediateGlobalConfig) Export() (GlobalConfig, error) { var out GlobalConfig var err error return out, err } func NewConfigFromReader(r io.Reader) (*Config, error) { var temp intermediateConfig if err := gcfg.ReadInto(&temp, r); err != nil { return nil, err } return temp.Export() }