resources: augeas: Turn augeas namespace into a constant

This commit is contained in:
James Shubin
2017-02-12 19:46:16 -05:00
parent c2034bc0c0
commit e96041d76f

View File

@@ -33,6 +33,11 @@ import (
"honnef.co/go/augeas" "honnef.co/go/augeas"
) )
const (
// NS is a namespace for augeas operations
NS = "Xmgmt"
)
func init() { func init() {
gob.Register(&AugeasRes{}) gob.Register(&AugeasRes{})
} }
@@ -202,10 +207,10 @@ func (obj *AugeasRes) CheckApply(apply bool) (bool, error) {
// We pick Xmgmt, as this name will not collide with any other lens name. // We pick Xmgmt, as this name will not collide with any other lens name.
// We do not pick Mgmt as in the future there might be an Mgmt lens. // We do not pick Mgmt as in the future there might be an Mgmt lens.
// https://github.com/hercules-team/augeas/wiki/Loading-specific-files // https://github.com/hercules-team/augeas/wiki/Loading-specific-files
if err = ag.Set("/augeas/load/Xmgmt/lens", obj.Lens); err != nil { if err = ag.Set(fmt.Sprintf("/augeas/load/%s/lens", NS), obj.Lens); err != nil {
return false, errwrap.Wrapf(err, "augeas: error while initializing lens") return false, errwrap.Wrapf(err, "augeas: error while initializing lens")
} }
if err = ag.Set("/augeas/load/Xmgmt/incl", obj.File); err != nil { if err = ag.Set(fmt.Sprintf("/augeas/load/%s/incl", NS), obj.File); err != nil {
return false, errwrap.Wrapf(err, "augeas: error while initializing incl") return false, errwrap.Wrapf(err, "augeas: error while initializing incl")
} }
if err = ag.Load(); err != nil { if err = ag.Load(); err != nil {