managers: Add dnf support

Signed-off-by: Thomas Hipp <thomas.hipp@canonical.com>
This commit is contained in:
Thomas Hipp 2018-03-26 16:34:19 +02:00
parent dbebec3c55
commit d00cfc5b70
No known key found for this signature in database
GPG Key ID: 993408D1137B7D51
3 changed files with 34 additions and 3 deletions

28
managers/dnf.go Normal file
View File

@ -0,0 +1,28 @@
package managers
// NewDnf creates a new Manager instance.
func NewDnf() *Manager {
return &Manager{
command: "dnf",
flags: ManagerFlags{
global: []string{
"-y",
},
install: []string{
"install",
},
remove: []string{
"remove",
},
refresh: []string{
"makecache",
},
update: []string{
"upgrade",
},
clean: []string{
"clean", "all",
},
},
}
}

View File

@ -27,14 +27,16 @@ type Manager struct {
// Get returns a Manager specified by name.
func Get(name string) *Manager {
switch name {
case "apk":
return NewApk()
case "apt":
return NewApt()
case "dnf":
return NewDnf()
case "pacman":
return NewPacman()
case "yum":
return NewYum()
case "apk":
return NewApk()
}
return nil

View File

@ -196,8 +196,9 @@ func (d *Definition) Validate() error {
validManagers := []string{
"apk",
"apt",
"yum",
"dnf",
"pacman",
"yum",
}
if !shared.StringInSlice(strings.TrimSpace(d.Packages.Manager), validManagers) {
return fmt.Errorf("packages.manager must be one of %v", validManagers)