feat(aa): ensure the template does not append useless space.

This commit is contained in:
Alexandre Pujol 2023-09-29 20:17:38 +01:00
parent eb98d2b49f
commit cb441733c0
Failed to generate hash of commit

View file

@ -33,20 +33,20 @@
{{- end }} {{- end }}
{{ end -}} {{ end -}}
{{- "profile " -}} {{- "profile" -}}
{{- with .Name -}} {{- with .Name -}}
{{ . }}{{ " " }} {{ " " }}{{ . }}
{{- end -}} {{- end -}}
{{- with .Attachments -}} {{- with .Attachments -}}
{{ join . }}{{ " " }} {{ " " }}{{ join . }}
{{- end -}} {{- end -}}
{{- with .Attributes -}} {{- with .Attributes -}}
{{ "xattrs=(" }}{{ join . }}{{ ") " }} {{ " xattrs=(" }}{{ join . }}{{ ")" }}
{{- end -}} {{- end -}}
{{- with .Flags -}} {{- with .Flags -}}
{{ "flags=(" }}{{ join . }}{{ ") " }} {{ " flags=(" }}{{ join . }}{{ ")" }}
{{- end -}} {{- end -}}
{{ "{\n" }} {{ " {\n" }}
{{- $oldtype := "" -}} {{- $oldtype := "" -}}
{{- range .Rules -}} {{- range .Rules -}}
@ -77,81 +77,78 @@
{{- end -}} {{- end -}}
{{- if eq $type "Network" -}} {{- if eq $type "Network" -}}
{{- if eq .AccessType "deny" -}} {{ "network" }}
{{ "deny " }}
{{- end -}}
{{ "network " }}
{{- with .Domain -}} {{- with .Domain -}}
{{ . }}{{ " " }} {{ " " }}{{ . }}
{{- end -}} {{- end -}}
{{- with .Type -}} {{- with .Type -}}
{{ . }} {{ " " }}{{ . }}
{{- else -}} {{- else -}}
{{- with .Protocol -}} {{- with .Protocol -}}
{{ . }} {{ " " }}{{ . }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- "," -}} {{- "," -}}
{{- end -}} {{- end -}}
{{- if eq $type "Mount" -}} {{- if eq $type "Mount" -}}
{{- "mount " -}} {{- "mount" -}}
{{- with .FsType -}} {{- with .FsType -}}
{{ "fstype=" }}{{ . }}{{ " " }} {{ " fstype=" }}{{ . }}
{{- end -}} {{- end -}}
{{- with .Options -}} {{- with .Options -}}
{{ "options=(" }}{{ join . }}{{ ") " }} {{ " options=(" }}{{ join . }}{{ ")" }}
{{- end -}} {{- end -}}
{{- with .Source -}} {{- with .Source -}}
{{ . }}{{ " " }} {{ " " }}{{ . }}
{{- end -}} {{- end -}}
{{- with .MountPoint -}} {{- with .MountPoint -}}
{{ "-> " }}{{ . }} {{ " -> " }}{{ . }}
{{- end -}} {{- end -}}
{{- "," -}} {{- "," -}}
{{- end -}} {{- end -}}
{{- if eq $type "Umount" -}} {{- if eq $type "Umount" -}}
{{- "umount " -}} {{- "umount" -}}
{{- with .FsType -}} {{- with .FsType -}}
{{ "fstype=" }}{{ . }}{{ " " }} {{ " fstype=" }}{{ . }}
{{- end -}} {{- end -}}
{{- with .Options -}} {{- with .Options -}}
{{ "options=(" }}{{ join . }}{{ ") " }} {{ " options=(" }}{{ join . }}{{ ")" }}
{{- end -}} {{- end -}}
{{- with .MountPoint -}} {{- with .MountPoint -}}
{{ . }} {{ " " }}{{ . }}
{{- end -}} {{- end -}}
{{- "," -}} {{- "," -}}
{{- end -}} {{- end -}}
{{- if eq $type "Remount" -}} {{- if eq $type "Remount" -}}
{{- "remount " -}} {{- "remount" -}}
{{- with .FsType -}} {{- with .FsType -}}
{{ "fstype=" }}{{ . }}{{ " " }} {{ " fstype=" }}{{ . }}
{{- end -}} {{- end -}}
{{- with .Options -}} {{- with .Options -}}
{{ "options=(" }}{{ join . }}{{ ") " }} {{ " options=(" }}{{ join . }}{{ ")" }}
{{- end -}} {{- end -}}
{{- with .Remount -}} {{- with .Remount -}}
{{ . }} {{ " " }}{{ . }}
{{- end -}} {{- end -}}
{{- "," -}} {{- "," -}}
{{- end -}} {{- end -}}
{{- if eq $type "Unix" -}} {{- if eq $type "Unix" -}}
{{- "unix " -}} {{- "unix" -}}
{{- with .Access -}} {{- with .Access -}}
{{ "(" }}{{ . }}{{ ") " }} {{ " (" }}{{ . }}{{ ")" }}
{{- end -}} {{- end -}}
{{- with .Type -}} {{- with .Type -}}
{{ "type=" }}{{ . }}{{ " " }} {{ " type=" }}{{ . }}
{{- end -}} {{- end -}}
{{- with .Address -}} {{- with .Address -}}
{{ "addr=" }}{{ . }}{{ " " }} {{ " addr=" }}{{ . }}
{{- end -}} {{- end -}}
{{- if .Peer -}} {{- if .Peer -}}
{{ "peer=(label=" }}{{ .Peer }} {{ " peer=(label=" }}{{ .Peer }}
{{- with .PeerAddr -}} {{- with .PeerAddr -}}
{{ ", addr="}}{{ . }} {{ ", addr="}}{{ . }}
{{- end -}} {{- end -}}
@ -161,36 +158,43 @@
{{- end -}} {{- end -}}
{{- if eq $type "Ptrace" -}} {{- if eq $type "Ptrace" -}}
{{- "ptrace " -}} {{- "ptrace" -}}
{{- with .Access -}} {{- with .Access -}}
{{ "(" }}{{ . }}{{ ") " }} {{ " (" }}{{ . }}{{ ")" }}
{{- end -}} {{- end -}}
{{- with .Peer -}} {{- with .Peer -}}
{{ "peer=" }}{{ . }} {{ " peer=" }}{{ . }}
{{- end -}} {{- end -}}
{{- "," -}} {{- "," -}}
{{- end -}} {{- end -}}
{{- if eq $type "Signal" -}} {{- if eq $type "Signal" -}}
{{- "signal " -}} {{- "signal" -}}
{{- with .Access -}} {{- with .Access -}}
{{ "(" }}{{ . }}{{ ") " }} {{ " (" }}{{ . }}{{ ")" }}
{{- end -}} {{- end -}}
{{- with .Set -}} {{- with .Set -}}
{{ "set=(" }}{{ . }}{{ ") " }} {{ " set=(" }}{{ . }}{{ ")" }}
{{- end -}} {{- end -}}
{{- with .Peer -}} {{- with .Peer -}}
{{ "peer=" }}{{ . }} {{ " peer=" }}{{ . }}
{{- end -}} {{- end -}}
{{- "," -}} {{- "," -}}
{{- end -}} {{- end -}}
{{- if eq $type "Dbus" -}} {{- if eq $type "Dbus" -}}
{{- "dbus " -}} {{- "dbus" -}}
{{- if eq .Access "bind" -}} {{- if eq .Access "bind" -}}
bind bus={{ .Bus }} name={{ .Name }} {{ " bind bus=" }}{{ .Bus }}{{ " name=" }}{{ .Name }}
{{- else -}} {{- else -}}
{{ .Access }} bus={{ .Bus }} path={{ .Path }}{{ "\n" }} {{ " " }}{{ .Access }}
{{- with .Bus -}}
{{ " bus=" }}{{ . }}
{{- end -}}
{{- with .Path -}}
{{ " path=" }}{{ . }}
{{- end -}}
{{ "\n" }}
{{- with .Interface -}} {{- with .Interface -}}
{{ overindent "interface=" }}{{ . }}{{ "\n" }} {{ overindent "interface=" }}{{ . }}{{ "\n" }}
{{- end -}} {{- end -}}