mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-02 18:23:12 +00:00
Move tool as part of static checks migration. Fixes #8187 Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com> Signed-off-by: Derek Lee <derlee@redhat.com> Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com> Signed-off-by: Graham Whaley <graham.whaley@intel.com> Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com> Signed-off-by: Marco Vedovati <mvedovati@suse.com> Signed-off-by: Peng Tao <bergwolf@hyper.sh> Signed-off-by: Shiming Zhang <wzshiming@foxmail.com> Signed-off-by: Snir Sheriber <ssheribe@redhat.com> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
103 lines
1.8 KiB
Go
103 lines
1.8 KiB
Go
// Copyright (c) 2019 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
labelNamesSeparator = ","
|
|
)
|
|
|
|
func labelToRecord(l Label, quote bool) (record []string) {
|
|
name := l.Name
|
|
category := l.CategoryName
|
|
colour := l.Colour
|
|
from := l.From
|
|
|
|
if quote {
|
|
name = fmt.Sprintf("`%s`", l.Name)
|
|
category = fmt.Sprintf("`%s`", l.CategoryName)
|
|
colour = fmt.Sprintf("`%s`", l.Colour)
|
|
if from != "" {
|
|
from = fmt.Sprintf("`%s`", l.From)
|
|
}
|
|
}
|
|
|
|
record = append(record, name)
|
|
record = append(record, l.Description)
|
|
record = append(record, category)
|
|
record = append(record, colour)
|
|
record = append(record, from)
|
|
|
|
return record
|
|
}
|
|
|
|
func labelHeaderRecord() []string {
|
|
return []string{
|
|
"Name",
|
|
"Description",
|
|
"Category",
|
|
"Colour",
|
|
"From",
|
|
}
|
|
}
|
|
|
|
func categoryHeaderRecord(showLabels bool) []string {
|
|
var fields []string
|
|
|
|
fields = append(fields, "Name")
|
|
fields = append(fields, "Description")
|
|
fields = append(fields, "URL")
|
|
|
|
if showLabels {
|
|
fields = append(fields, "Labels")
|
|
}
|
|
|
|
return fields
|
|
}
|
|
|
|
func categoryToRecord(lf *LabelsFile, c Category, showLabels, quote bool) ([]string, error) {
|
|
var record []string
|
|
|
|
name := c.Name
|
|
|
|
if quote {
|
|
name = fmt.Sprintf("`%s`", c.Name)
|
|
}
|
|
|
|
record = append(record, name)
|
|
record = append(record, c.Description)
|
|
record = append(record, c.URL)
|
|
|
|
if showLabels {
|
|
var labelNames []string
|
|
|
|
labels, err := getLabelsByCategory(c.Name, lf)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
for _, l := range labels {
|
|
labelName := l.Name
|
|
|
|
if quote {
|
|
labelName = fmt.Sprintf("`%s`", l.Name)
|
|
}
|
|
|
|
labelNames = append(labelNames, labelName)
|
|
}
|
|
|
|
result := strings.Join(labelNames, labelNamesSeparator)
|
|
|
|
record = append(record, result)
|
|
}
|
|
|
|
return record, nil
|
|
}
|