feat(aa): add rule constructors from internal parser.
This commit is contained in:
parent
ac9d6d859f
commit
163c5be61c
19 changed files with 456 additions and 75 deletions
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
package aa
|
||||
|
||||
import "fmt"
|
||||
|
||||
const PIVOTROOT Kind = "pivot_root"
|
||||
|
||||
type PivotRoot struct {
|
||||
|
|
@ -14,6 +16,30 @@ type PivotRoot struct {
|
|||
TargetProfile string
|
||||
}
|
||||
|
||||
func newPivotRoot(q Qualifier, rule rule) (Rule, error) {
|
||||
newroot, target := "", ""
|
||||
r := rule.GetSlice()
|
||||
if len(r) > 0 {
|
||||
if r[0] != tokARROW {
|
||||
newroot = r[0]
|
||||
r = r[1:]
|
||||
}
|
||||
if len(r) == 2 {
|
||||
if r[0] != tokARROW {
|
||||
return nil, fmt.Errorf("missing '%s' in rule: %s", tokARROW, rule)
|
||||
}
|
||||
target = r[1]
|
||||
}
|
||||
}
|
||||
return &PivotRoot{
|
||||
RuleBase: newBase(rule),
|
||||
Qualifier: q,
|
||||
OldRoot: rule.GetValuesAsString("oldroot"),
|
||||
NewRoot: newroot,
|
||||
TargetProfile: target,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func newPivotRootFromLog(log map[string]string) Rule {
|
||||
return &PivotRoot{
|
||||
RuleBase: newBaseFromLog(log),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue