forked from goss-org/goss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.go
37 lines (30 loc) · 1.07 KB
/
process.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package resource
import (
"github.com/aelsabbahy/goss/system"
"github.com/aelsabbahy/goss/util"
)
type Process struct {
Title string `json:"title,omitempty" yaml:"title,omitempty"`
Meta meta `json:"meta,omitempty" yaml:"meta,omitempty"`
Executable string `json:"-" yaml:"-"`
Running matcher `json:"running" yaml:"running"`
}
func (p *Process) ID() string { return p.Executable }
func (p *Process) SetID(id string) { p.Executable = id }
func (p *Process) GetTitle() string { return p.Title }
func (p *Process) GetMeta() meta { return p.Meta }
func (p *Process) Validate(sys *system.System) []TestResult {
skip := false
sysProcess := sys.NewProcess(p.Executable, sys, util.Config{})
var results []TestResult
results = append(results, ValidateValue(p, "running", p.Running, sysProcess.Running, skip))
return results
}
func NewProcess(sysProcess system.Process, config util.Config) (*Process, error) {
executable := sysProcess.Executable()
running, _ := sysProcess.Running()
return &Process{
Executable: executable,
Running: running,
}, nil
}