Skip to content

Commit

Permalink
Mount (#601)
Browse files Browse the repository at this point in the history
* Add stale.yml config

* Change stale.yml label

* Add VfsOpts to mount

* Use mountinfo filter
  • Loading branch information
aelsabbahy authored Nov 13, 2020
1 parent 85ce2c8 commit 6c123f8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
16 changes: 16 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- approved
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ require (
github.com/aelsabbahy/GOnetstat v0.0.0-20160428114218-edf89f784e08
github.com/blang/semver v3.5.1+incompatible
github.com/cheekybits/genny v1.0.0
github.com/docker/docker v1.13.1
github.com/fatih/color v1.9.0
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/huandu/xstrings v1.3.0 // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/miekg/dns v1.1.27
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/moby/sys/mountinfo v0.1.3
github.com/oleiade/reflections v0.0.0-20160817071559-0e86b3c98b2f
github.com/onsi/gomega v1.9.0
github.com/opencontainers/runc v0.0.0-20161107232042-8779fa57eb4a
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/shirou/gopsutil v2.20.6+incompatible
github.com/stretchr/testify v1.4.0
github.com/thoas/go-funk v0.7.0
github.com/urfave/cli v0.0.0-20161102131801-d86a009f5e13
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
gopkg.in/yaml.v2 v2.2.8
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitf
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=
github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
Expand Down Expand Up @@ -45,6 +43,8 @@ github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMK
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/moby/sys/mountinfo v0.1.3 h1:KIrhRO14+AkwKvG/g2yIpNMOUVZ02xNhOw8KY1WsLOI=
github.com/moby/sys/mountinfo v0.1.3/go.mod h1:w2t2Avltqx8vE7gX5l+QiBKxODu2TX0+Syr3h52Tw4o=
github.com/oleiade/reflections v0.0.0-20160817071559-0e86b3c98b2f h1:I6mXuorHlvwNDFelz7a+j0HaGYSzX7+Gq60DqLVypfc=
github.com/oleiade/reflections v0.0.0-20160817071559-0e86b3c98b2f/go.mod h1:RbATFBbKYkVdqmSFtx13Bb/tVhR0lgOBXunWTZKeL4w=
github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
Expand All @@ -62,6 +62,8 @@ github.com/shirou/gopsutil v2.20.6+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/thoas/go-funk v0.7.0 h1:GmirKrs6j6zJbhJIficOsz2aAI7700KsU/5YrdHRM1Y=
github.com/thoas/go-funk v0.7.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/urfave/cli v0.0.0-20161102131801-d86a009f5e13 h1:niRuEF0NOlFnqraxzjuvvOdCM6gxmHiaBABjvg3/kDo=
github.com/urfave/cli v0.0.0-20161102131801-d86a009f5e13/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
22 changes: 10 additions & 12 deletions system/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"strings"

"github.com/aelsabbahy/goss/util"
"github.com/docker/docker/pkg/mount"
"github.com/moby/sys/mountinfo"
"github.com/thoas/go-funk"
)

type Mount interface {
Expand All @@ -21,7 +22,7 @@ type DefMount struct {
mountPoint string
loaded bool
exists bool
mountInfo *mount.Info
mountInfo *mountinfo.Info
usage int
err error
}
Expand Down Expand Up @@ -77,8 +78,9 @@ func (m *DefMount) Opts() ([]string, error) {
if err := m.setup(); err != nil {
return nil, err
}
allOpts := strings.Split(strings.Join([]string{m.mountInfo.Opts, m.mountInfo.VfsOpts}, ","), ",")

return strings.Split(m.mountInfo.Opts, ","), nil
return funk.UniqString(allOpts), nil
}

func (m *DefMount) Source() (string, error) {
Expand All @@ -105,17 +107,13 @@ func (m *DefMount) Usage() (int, error) {
return m.usage, nil
}

func getMount(mountpoint string) (*mount.Info, error) {
entries, err := mount.GetMounts()
func getMount(mountpoint string) (*mountinfo.Info, error) {
entries, err := mountinfo.GetMounts(mountinfo.SingleEntryFilter(mountpoint))
if err != nil {
return nil, err
}

// Search the table for the mountpoint
for _, e := range entries {
if e.Mountpoint == mountpoint {
return e, nil
}
if len(entries) == 0 {
return nil, fmt.Errorf("Mountpoint not found")
}
return nil, fmt.Errorf("Mountpoint not found")
return entries[0], nil
}

0 comments on commit 6c123f8

Please sign in to comment.