e65c96ee33
Signed-off-by: Alejandro Mery <amery@jpi.io>
39 lines
780 B
Go
39 lines
780 B
Go
package ceph
|
|
|
|
import (
|
|
"io"
|
|
"net/netip"
|
|
|
|
"github.com/gofrs/uuid/v5"
|
|
|
|
"asciigoat.org/ini/basic"
|
|
)
|
|
|
|
// Config represents a ceph.conf file
|
|
type Config struct {
|
|
Global GlobalConfig `ini:"global"`
|
|
}
|
|
|
|
// 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) {
|
|
doc, err := basic.Decode(r)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
cfg, err := newConfigFromDocument(doc)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return cfg, nil
|
|
}
|