mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-18 08:58:15 +01:00
feat(aa): rename identation variables.
This commit is contained in:
parent
5943e9a24d
commit
1e79d27232
3 changed files with 11 additions and 11 deletions
|
@ -15,10 +15,10 @@ import (
|
|||
|
||||
var (
|
||||
// Default indentation for apparmor profile (2 spaces)
|
||||
TemplateIndentation = " "
|
||||
Indentation = " "
|
||||
|
||||
// The current indentation level
|
||||
TemplateIndentationLevel = 0
|
||||
IndentationLevel = 0
|
||||
|
||||
//go:embed templates/*.j2
|
||||
//go:embed templates/rule/*.j2
|
||||
|
@ -122,7 +122,7 @@ func renderTemplate(name string, data any) string {
|
|||
var res strings.Builder
|
||||
template, ok := tmpl[name]
|
||||
if !ok {
|
||||
panic("template not found")
|
||||
panic("template '" + name + "' not found")
|
||||
}
|
||||
err := template.Execute(&res, data)
|
||||
if err != nil {
|
||||
|
@ -188,19 +188,19 @@ func typeToValue(i reflect.Type) string {
|
|||
func setindent(i string) string {
|
||||
switch i {
|
||||
case "++":
|
||||
TemplateIndentationLevel++
|
||||
IndentationLevel++
|
||||
case "--":
|
||||
TemplateIndentationLevel--
|
||||
IndentationLevel--
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func indent(s string) string {
|
||||
return strings.Repeat(TemplateIndentation, TemplateIndentationLevel) + s
|
||||
return strings.Repeat(Indentation, IndentationLevel) + s
|
||||
}
|
||||
|
||||
func indentDbus(s string) string {
|
||||
return strings.Join([]string{TemplateIndentation, s}, " ")
|
||||
return strings.Join([]string{Indentation, s}, " ")
|
||||
}
|
||||
|
||||
func getLetterIn(alphabet []string, in string) string {
|
||||
|
|
|
@ -61,8 +61,8 @@ func (d Dbus) Apply(opt *Option, profile string) string {
|
|||
r = d.talk(opt.ArgMap)
|
||||
}
|
||||
|
||||
aa.TemplateIndentationLevel = strings.Count(
|
||||
strings.SplitN(opt.Raw, Keyword, 1)[0], aa.TemplateIndentation,
|
||||
aa.IndentationLevel = strings.Count(
|
||||
strings.SplitN(opt.Raw, Keyword, 1)[0], aa.Indentation,
|
||||
)
|
||||
generatedDbus := r.String()
|
||||
lenDbus := len(generatedDbus)
|
||||
|
|
|
@ -54,8 +54,8 @@ func (d Exec) Apply(opt *Option, profileRaw string) string {
|
|||
}
|
||||
}
|
||||
|
||||
aa.TemplateIndentationLevel = strings.Count(
|
||||
strings.SplitN(opt.Raw, Keyword, 1)[0], aa.TemplateIndentation,
|
||||
aa.IndentationLevel = strings.Count(
|
||||
strings.SplitN(opt.Raw, Keyword, 1)[0], aa.Indentation,
|
||||
)
|
||||
rules.Sort()
|
||||
new := rules.String()
|
||||
|
|
Loading…
Reference in a new issue