diff --git a/go.mod b/go.mod index 2a9c2080..dc18e0cb 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/brotherpowers/ipsubnet v0.0.0-20170914094241-30bc98f0a5b1 github.com/containers/image/v5 v5.7.0 github.com/containers/storage v1.30.0 + github.com/creasty/defaults v1.5.2 github.com/manifoldco/promptui v0.8.0 github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6 github.com/opencontainers/umoci v0.4.6 diff --git a/go.sum b/go.sum index 6ee428de..3ae31d68 100644 --- a/go.sum +++ b/go.sum @@ -212,6 +212,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/creasty/defaults v1.5.2 h1:/VfB6uxpyp6h0fr7SPp7n8WJBoV8jfxQXPCnkVSjyls= +github.com/creasty/defaults v1.5.2/go.mod h1:FPZ+Y0WNrbqOVw+c6av63eyHUAl6pMHZwqLPvXUZGfY= github.com/cyphar/filepath-securejoin v0.2.2 h1:jCwT2GTP+PY5nBz3c/YL5PAIbusElVrPujOBSCj8xRg= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1SMSibvLzxjeJLnrYEVLULFNiHY9YfQ= diff --git a/internal/pkg/warewulfconf/datastructure.go b/internal/pkg/warewulfconf/datastructure.go index 620665f8..4d0caf72 100644 --- a/internal/pkg/warewulfconf/datastructure.go +++ b/internal/pkg/warewulfconf/datastructure.go @@ -3,6 +3,7 @@ package warewulfconf import ( "github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/wwlog" + "github.com/creasty/defaults" ) const ConfigFile = "/etc/warewulf/warewulf.conf" @@ -43,12 +44,23 @@ type TftpConf struct { } type NfsConf struct { - Enabled bool `yaml:"enabled"` + Enabled bool `default:"true" yaml:"enabled"` Exports []string `yaml:"exports"` ExportsExtended []*NfsExportConf `yaml:"exports extended"` SystemdName string `yaml:"systemd name"` } +func (s *NfsConf) UnmarshalYAML(unmarshal func(interface{}) error) error { + defaults.Set(s) + + type plain NfsConf + if err := unmarshal((*plain)(s)); err != nil { + return err + } + + return nil +} + type NfsExportConf struct { Path string `yaml:"path"` Options string `yaml:"options"`