From 6acf004eab8f530e73d5d374a80eab7230b5b3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Mon, 10 Dec 2018 18:28:24 +1100 Subject: [PATCH] feat(local-config): host hash helper --- localconfig/host.go | 28 ++++++++++++++++++++++++++++ localconfig/localconfig.go | 12 ------------ 2 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 localconfig/host.go diff --git a/localconfig/host.go b/localconfig/host.go new file mode 100644 index 0000000..eeed076 --- /dev/null +++ b/localconfig/host.go @@ -0,0 +1,28 @@ +package localconfig + +import ( + "io" + + yaml "gopkg.in/yaml.v2" +) + +type Host struct { + Name string + MACs []string + IPs []string + + Kernel string + Initrd string + Layers map[string]string + + Config []byte +} + +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, + }) +} diff --git a/localconfig/localconfig.go b/localconfig/localconfig.go index 322cf0b..7f6e9fd 100644 --- a/localconfig/localconfig.go +++ b/localconfig/localconfig.go @@ -17,18 +17,6 @@ type Cluster struct { Addons []byte } -type Host struct { - Name string - MACs []string - IPs []string - - Kernel string - Initrd string - Layers map[string]string - - Config []byte -} - func FromBytes(data []byte) (*Config, error) { config := &Config{} if err := yaml.Unmarshal(data, config); err != nil {