unit: refactor config

- Seperate the config from Destination()
- Add YAML tags for the fields
This commit is contained in:
Alex Crawford
2014-09-21 19:22:38 -07:00
parent 667dbd8fb7
commit 1fbbaaec19
11 changed files with 95 additions and 76 deletions

34
config/unit.go Normal file
View File

@@ -0,0 +1,34 @@
package config
import (
"path/filepath"
"strings"
)
type Unit struct {
Name string `yaml:"name"`
Mask bool `yaml:"mask"`
Enable bool `yaml:"enable"`
Runtime bool `yaml:"runtime"`
Content string `yaml:"content"`
Command string `yaml:"command"`
// For drop-in units, a cloudinit.conf is generated.
// This is currently unbound in YAML (and hence unsettable in cloud-config files)
// until the correct behaviour for multiple drop-in units is determined.
DropIn bool `yaml:"-"`
}
func (u *Unit) Type() string {
ext := filepath.Ext(u.Name)
return strings.TrimLeft(ext, ".")
}
func (u *Unit) Group() string {
switch u.Type() {
case "network", "netdev", "link":
return "network"
default:
return "system"
}
}