diff --git a/examples/file5.yaml b/examples/file5.yaml new file mode 100644 index 00000000..fe4d3e95 --- /dev/null +++ b/examples/file5.yaml @@ -0,0 +1,13 @@ +--- +graph: mygraph +resources: + file: + - name: file1 + meta: + limit: .inf + burst: 0 + path: "/tmp/mgmt/hello" + content: | + i am a file + state: exists +edges: [] diff --git a/resources/resources.go b/resources/resources.go index 58794306..93f15a4f 100644 --- a/resources/resources.go +++ b/resources/resources.go @@ -24,6 +24,7 @@ import ( "encoding/gob" "fmt" "log" + "math" "os" "path" "sync" @@ -272,7 +273,8 @@ func (obj *BaseUID) Reversed() bool { // Validate reports any problems with the struct definition. func (obj *BaseRes) Validate() error { - if obj.Meta().Burst == 0 && !(obj.Meta().Limit == rate.Inf) { // blocked + isInf := obj.Meta().Limit == rate.Inf || math.IsInf(float64(obj.Meta().Limit), 1) + if obj.Meta().Burst == 0 && !isInf { // blocked return fmt.Errorf("Permanently limited (rate != Inf, burst: 0)") } return nil @@ -291,6 +293,9 @@ func (obj *BaseRes) Init() error { if obj.Meta().Burst == 0 && obj.Meta().Limit == 0 { // blocked obj.Meta().Limit = rate.Inf } + if math.IsInf(float64(obj.Meta().Limit), 1) { // yaml `.inf` -> rate.Inf + obj.Meta().Limit = rate.Inf + } //dir, err := obj.VarDir("") //if err != nil {