Skip to content

Commit

Permalink
Support apk packages in addition to pacman, deb, rpm
Browse files Browse the repository at this point in the history
Progress on #113
  • Loading branch information
langston-barrett committed Apr 11, 2016
1 parent 368a6f6 commit cf3f5a5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
17 changes: 14 additions & 3 deletions checks/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,22 @@ func (chk Installed) New(params []string) (chkutil.Check, error) {
}

func (chk Installed) Status() (int, string, error) {
nullPkg := gosssystem.NewNullPackage(chk.pkg, nil, gossutil.Config{})
pkg, err := gossresource.NewPackage(nullPkg, gossutil.Config{})
var pkg gosssystem.Package
switch gosssystem.DetectPackageManager() {
case "deb":
pkg = gosssystem.NewDebPackage(chk.pkg, nil, gossutil.Config{})
case "apk":
pkg = gosssystem.NewAlpinePackage(chk.pkg, nil, gossutil.Config{})
case "pacman":
pkg = gosssystem.NewPacmanPackage(chk.pkg, nil, gossutil.Config{})
default:
pkg = gosssystem.NewRpmPackage(chk.pkg, nil, gossutil.Config{})
}
// initialize the package
pkg2, err := gossresource.NewPackage(pkg, gossutil.Config{})
if err != nil {
return 1, "", err
} else if pkg.Installed {
} else if pkg2.Installed {
return errutil.Success()
}
return 1, "Package not found", nil
Expand Down
26 changes: 0 additions & 26 deletions checks/users-and-groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,6 @@ func TestGroupID(t *testing.T) {
testCheck(goodEggs, badEggs, GroupID{}, t)
}

func TestLookupUser(t *testing.T) {
t.Parallel()
user, err := lookupUser("root")
user2, err2 := lookupUser("0")
msg := "Couldn't successfully lookup root user"
if user == nil || err != nil {
msg += "\n\tUsername: root"
msg += "\n\tError: " + err.Error()
t.Error(msg)
} else if user2 == nil || err2 != nil {
msg += "\n\tUID: 0"
msg += "\n\tError: " + err2.Error()
t.Error(msg)
}
}

func TestUserExists(t *testing.T) {
t.Parallel()
testParameters(names, notLengthOne, UserExists{}, t)
Expand All @@ -73,16 +57,6 @@ func TestUserHasGID(t *testing.T) {
testCheck(goodEggs, badEggs, UserHasGID{}, t)
}

func TestUserHasUsername(t *testing.T) {
t.Parallel()
validInputs := reverseAppendParameter(names, "0")
invalidInputs := notLengthTwo
goodEggs := [][]string{[]string{"0", "root"}} // not always true
badEggs := appendParameter(names, "nonsense")
testParameters(validInputs, invalidInputs, UserHasUsername{}, t)
testCheck(goodEggs, badEggs, UserHasUsername{}, t)
}

func TestUserHasHomeDir(t *testing.T) {
t.Parallel()
validInputs := appendParameter(names, "/home/")
Expand Down
23 changes: 21 additions & 2 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cf3f5a5

Please sign in to comment.