LoadPolicyLine loads a text line as a policy rule to model.
(line string, m model.Model)
| 23 | |
| 24 | // LoadPolicyLine loads a text line as a policy rule to model. |
| 25 | func LoadPolicyLine(line string, m model.Model) error { |
| 26 | if line == "" || strings.HasPrefix(line, "#") { |
| 27 | return nil |
| 28 | } |
| 29 | |
| 30 | r := csv.NewReader(strings.NewReader(line)) |
| 31 | r.Comma = ',' |
| 32 | r.Comment = '#' |
| 33 | r.TrimLeadingSpace = true |
| 34 | |
| 35 | tokens, err := r.Read() |
| 36 | if err != nil { |
| 37 | return err |
| 38 | } |
| 39 | |
| 40 | return LoadPolicyArray(tokens, m) |
| 41 | } |
| 42 | |
| 43 | // LoadPolicyArray loads a policy rule to model. |
| 44 | func LoadPolicyArray(rule []string, m model.Model) error { |
no test coverage detected
searching dependent graphs…