diff --git a/localconfig/host.go b/localconfig/host.go index eeed076..b304ea4 100644 --- a/localconfig/host.go +++ b/localconfig/host.go @@ -11,18 +11,20 @@ type Host struct { MACs []string IPs []string - Kernel string - Initrd string - Layers map[string]string + IPXE string - Config []byte + Kernel string + Initrd string + Versions map[string]string + + Config string } func (h *Host) WriteHashDataTo(w io.Writer) error { return yaml.NewEncoder(w).Encode(Host{ - Kernel: h.Kernel, - Initrd: h.Initrd, - Layers: h.Layers, - Config: h.Config, + Kernel: h.Kernel, + Initrd: h.Initrd, + Versions: h.Versions, + Config: h.Config, }) } diff --git a/localconfig/localconfig.go b/localconfig/localconfig.go index 7f6e9fd..56b0b4e 100644 --- a/localconfig/localconfig.go +++ b/localconfig/localconfig.go @@ -1,6 +1,7 @@ package localconfig import ( + "io" "io/ioutil" "strings" @@ -8,13 +9,14 @@ import ( ) type Config struct { - Clusters []*Cluster - Hosts []*Host + Clusters []*Cluster + Hosts []*Host + SSLConfig string } type Cluster struct { Name string - Addons []byte + Addons string } func FromBytes(data []byte) (*Config, error) { @@ -34,6 +36,19 @@ func FromFile(path string) (*Config, error) { return FromBytes(ba) } +func (c *Config) WriteTo(w io.Writer) error { + return yaml.NewEncoder(w).Encode(c) +} + +func (c *Config) Cluster(name string) *Cluster { + for _, cluster := range c.Clusters { + if cluster.Name == name { + return cluster + } + } + return nil +} + func (c *Config) ClusterByName(name string) *Cluster { for _, cluster := range c.Clusters { if cluster.Name == name { @@ -43,6 +58,15 @@ func (c *Config) ClusterByName(name string) *Cluster { return nil } +func (c *Config) Host(name string) *Host { + for _, host := range c.Hosts { + if host.Name == name { + return host + } + } + return nil +} + func (c *Config) HostByIP(ip string) *Host { for _, host := range c.Hosts { for _, hostIP := range host.IPs { diff --git a/modd.conf b/modd.conf new file mode 100644 index 0000000..8679bbf --- /dev/null +++ b/modd.conf @@ -0,0 +1,3 @@ +**/*.go { + prep: go test ./... +}