forked from cloudfoundry-attic/bosh-ext-cli
/
job_property.go
45 lines (35 loc) · 983 Bytes
/
job_property.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
38
39
40
41
42
43
44
45
package release
import (
"regexp"
boshjob "github.com/cloudfoundry/bosh-cli/release/job"
check "github.com/bosh-tools/bosh-ext-cli/lint/check"
)
var (
preferredJobProperty = regexp.MustCompile("^[a-z0-9]+(([a-z0-9]+\\_?)+[a-z0-9]+)?$")
)
type JobProperty struct {
context check.Context
name string
def boshjob.PropertyDefinition
check.Config
}
func NewJobProperty(context check.Context, name string, def boshjob.PropertyDefinition, config check.Config) JobProperty {
return JobProperty{context, name, def, config}
}
func (c JobProperty) Description() check.Description {
return check.Description{
Context_: c.context,
Purpose_: "if description is present",
}
}
func (c JobProperty) Check() ([]check.Suggestion, error) {
var sugs []check.Suggestion
if len(c.def.Description) == 0 {
sugs = append(sugs, check.Simple{
Context_: c.context,
Problem_: "Description is missing",
Resolution_: "Add description",
})
}
return sugs, nil
}