feat(aa-log): an empty profile now return empty string.

This commit is contained in:
Alexandre Pujol 2024-02-24 17:01:03 +00:00
parent 48b39fa816
commit 1bc63becaf
Failed to generate hash of commit
2 changed files with 19 additions and 17 deletions

View file

@ -37,9 +37,7 @@ func TestAppArmorProfile_String(t *testing.T) {
{
name: "empty",
p: &AppArmorProfile{},
want: `profile {
}
`,
want: ``,
},
{
name: "foo",

View file

@ -22,20 +22,22 @@
{{ "@{" }}{{ .Name }}{{ "} = " }}{{ join .Values }}
{{ end -}}
{{- "profile" -}}
{{- with .Name -}}
{{ " " }}{{ . }}
{{- if or .Name .Attachments .Attributes .Flags -}}
{{- "profile" -}}
{{- with .Name -}}
{{ " " }}{{ . }}
{{- end -}}
{{- with .Attachments -}}
{{ " " }}{{ join . }}
{{- end -}}
{{- with .Attributes -}}
{{ " xattrs=(" }}{{ join . }}{{ ")" }}
{{- end -}}
{{- with .Flags -}}
{{ " flags=(" }}{{ join . }}{{ ")" }}
{{- end -}}
{{ " {\n" }}
{{- end -}}
{{- with .Attachments -}}
{{ " " }}{{ join . }}
{{- end -}}
{{- with .Attributes -}}
{{ " xattrs=(" }}{{ join . }}{{ ")" }}
{{- end -}}
{{- with .Flags -}}
{{ " flags=(" }}{{ join . }}{{ ")" }}
{{- end -}}
{{ " {\n" }}
{{- $oldtype := "" -}}
{{- range .Rules -}}
@ -288,4 +290,6 @@
{{- $oldtype = $type -}}
{{- end -}}
{{- "}\n" -}}
{{- if or .Name .Attachments .Attributes .Flags -}}
{{- "}\n" -}}
{{- end -}}