feat(prebuild): add err reporting to builder & directive tasks.
This commit is contained in:
parent
865ce4c66b
commit
02e3334949
19 changed files with 108 additions and 53 deletions
|
|
@ -38,13 +38,13 @@ func init() {
|
|||
})
|
||||
}
|
||||
|
||||
func (s Stack) Apply(opt *Option, profile string) string {
|
||||
func (s Stack) Apply(opt *Option, profile string) (string, error) {
|
||||
res := ""
|
||||
for name := range opt.ArgMap {
|
||||
stackedProfile := util.MustReadFile(cfg.RootApparmord.Join(name))
|
||||
m := regRules.FindStringSubmatch(stackedProfile)
|
||||
if len(m) < 2 {
|
||||
panic(fmt.Sprintf("No profile found in %s", name))
|
||||
return "", fmt.Errorf("No profile found in %s", name)
|
||||
}
|
||||
stackedRules := m[1]
|
||||
stackedRules = regCleanStakedRules.Replace(stackedRules)
|
||||
|
|
@ -54,9 +54,9 @@ func (s Stack) Apply(opt *Option, profile string) string {
|
|||
// Insert the stacked profile at the end of the current profile, remove the stack directive
|
||||
m := regEndOfRules.FindStringSubmatch(profile)
|
||||
if len(m) <= 1 {
|
||||
panic(fmt.Sprintf("No end of rules found in %s", opt.File))
|
||||
return "", fmt.Errorf("No end of rules found in %s", opt.File)
|
||||
}
|
||||
profile = strings.Replace(profile, m[0], res+m[0], -1)
|
||||
profile = strings.Replace(profile, opt.Raw, "", -1)
|
||||
return profile
|
||||
return profile, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue