{{- /* apparmor.d - Full set of apparmor profiles */ -}}
{{- /* Copyright (C) 2021-2024 Alexandre Pujol <alexandre@pujol.io> */ -}}
{{- /* SPDX-License-Identifier: GPL-2.0-only */ -}}

{{- define "unix" -}}
    {{- template "qualifier" . -}}
    {{- "unix" -}}
    {{- with .Access -}}
        {{ " " }}{{ cjoin . }}
    {{- end -}}
    {{- .Padding 2 -}}
    {{- with .Type -}}
        {{ " type=" }}{{ . }}
    {{- end -}}
    {{- .Padding 3 -}}
    {{- with .Protocol -}}
        {{ " protocol=" }}{{ . }}
    {{- end -}}
    {{- .Padding 4 -}}
    {{- with .Address -}}
        {{ " addr=" }}{{ . }}
    {{- end -}}
    {{- .Padding 5 -}}
    {{- with .Label -}}
        {{ " label=" }}{{ . }}
    {{- end -}}
    {{- .Padding 6 -}}
    {{- if and .PeerLabel .PeerAddr -}}
        {{ " peer=(label=" }}{{ .PeerLabel }}{{ ", addr="}}{{ .PeerAddr }}{{ ")" }}
    {{- else -}}
        {{- with .PeerLabel -}}
            {{ overindent "peer=(label=" }}{{ . }}{{ ")" }}
        {{- end -}}
        {{- with .PeerAddr -}}
            {{ overindent "peer=(addr=" }}{{ . }}{{ ")" }}
        {{- end -}}
    {{- end -}}
    {{- "," -}}
    {{- template "comment" . -}}
{{- end -}}