chore(aa): cosmetic.

This commit is contained in:
Alexandre Pujol 2024-05-30 20:56:53 +01:00
parent 4282fb336e
commit 16f30007e7
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC
3 changed files with 14 additions and 15 deletions

View File

@ -4,7 +4,7 @@
package aa
const PIVOTROOT = "pivot_root"
const PIVOTROOT Kind = "pivot_root"
type PivotRoot struct {
RuleBase

View File

@ -7,7 +7,6 @@ package aa
import (
"embed"
"fmt"
"reflect"
"strings"
"text/template"
)
@ -176,12 +175,12 @@ func generateRequirementsWeights(requirements map[Kind]requirement) map[Kind]map
}
func join(i any) string {
switch reflect.TypeOf(i).Kind() {
case reflect.Slice:
return strings.Join(i.([]string), " ")
case reflect.Map:
switch i := i.(type) {
case []string:
return strings.Join(i, " ")
case map[string]string:
res := []string{}
for k, v := range i.(map[string]string) {
for k, v := range i {
res = append(res, k+"="+v)
}
return strings.Join(res, " ")
@ -191,16 +190,15 @@ func join(i any) string {
}
func cjoin(i any) string {
switch reflect.TypeOf(i).Kind() {
case reflect.Slice:
s := i.([]string)
if len(s) == 1 {
return s[0]
switch i := i.(type) {
case []string:
if len(i) == 1 {
return i[0]
}
return "(" + strings.Join(s, " ") + ")"
case reflect.Map:
return "(" + strings.Join(i, " ") + ")"
case map[string]string:
res := []string{}
for k, v := range i.(map[string]string) {
for k, v := range i {
res = append(res, k+"="+v)
}
return "(" + strings.Join(res, " ") + ")"

View File

@ -6,6 +6,7 @@ package logs
import (
"os"
"path/filepath"
"reflect"
"strings"
"testing"