mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-18 17:08:09 +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 (
|
var (
|
||||||
// Default indentation for apparmor profile (2 spaces)
|
// Default indentation for apparmor profile (2 spaces)
|
||||||
TemplateIndentation = " "
|
Indentation = " "
|
||||||
|
|
||||||
// The current indentation level
|
// The current indentation level
|
||||||
TemplateIndentationLevel = 0
|
IndentationLevel = 0
|
||||||
|
|
||||||
//go:embed templates/*.j2
|
//go:embed templates/*.j2
|
||||||
//go:embed templates/rule/*.j2
|
//go:embed templates/rule/*.j2
|
||||||
|
@ -122,7 +122,7 @@ func renderTemplate(name string, data any) string {
|
||||||
var res strings.Builder
|
var res strings.Builder
|
||||||
template, ok := tmpl[name]
|
template, ok := tmpl[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("template not found")
|
panic("template '" + name + "' not found")
|
||||||
}
|
}
|
||||||
err := template.Execute(&res, data)
|
err := template.Execute(&res, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -188,19 +188,19 @@ func typeToValue(i reflect.Type) string {
|
||||||
func setindent(i string) string {
|
func setindent(i string) string {
|
||||||
switch i {
|
switch i {
|
||||||
case "++":
|
case "++":
|
||||||
TemplateIndentationLevel++
|
IndentationLevel++
|
||||||
case "--":
|
case "--":
|
||||||
TemplateIndentationLevel--
|
IndentationLevel--
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func indent(s string) string {
|
func indent(s string) string {
|
||||||
return strings.Repeat(TemplateIndentation, TemplateIndentationLevel) + s
|
return strings.Repeat(Indentation, IndentationLevel) + s
|
||||||
}
|
}
|
||||||
|
|
||||||
func indentDbus(s string) string {
|
func indentDbus(s string) string {
|
||||||
return strings.Join([]string{TemplateIndentation, s}, " ")
|
return strings.Join([]string{Indentation, s}, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLetterIn(alphabet []string, in string) string {
|
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)
|
r = d.talk(opt.ArgMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
aa.TemplateIndentationLevel = strings.Count(
|
aa.IndentationLevel = strings.Count(
|
||||||
strings.SplitN(opt.Raw, Keyword, 1)[0], aa.TemplateIndentation,
|
strings.SplitN(opt.Raw, Keyword, 1)[0], aa.Indentation,
|
||||||
)
|
)
|
||||||
generatedDbus := r.String()
|
generatedDbus := r.String()
|
||||||
lenDbus := len(generatedDbus)
|
lenDbus := len(generatedDbus)
|
||||||
|
|
|
@ -54,8 +54,8 @@ func (d Exec) Apply(opt *Option, profileRaw string) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aa.TemplateIndentationLevel = strings.Count(
|
aa.IndentationLevel = strings.Count(
|
||||||
strings.SplitN(opt.Raw, Keyword, 1)[0], aa.TemplateIndentation,
|
strings.SplitN(opt.Raw, Keyword, 1)[0], aa.Indentation,
|
||||||
)
|
)
|
||||||
rules.Sort()
|
rules.Sort()
|
||||||
new := rules.String()
|
new := rules.String()
|
||||||
|
|
Loading…
Reference in a new issue