mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-06 03:10:07 +00:00
tests: move github-labels to main repo
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>
This commit is contained in:
62
tests/cmd/github-labels/clean.go
Normal file
62
tests/cmd/github-labels/clean.go
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright (c) 2019 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import "strings"
|
||||
|
||||
func cleanString(s string) string {
|
||||
result := strings.Replace(s, "\n", " ", -1)
|
||||
result = strings.Replace(result, "\t", "\\t", -1)
|
||||
result = strings.TrimSpace(result)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func cleanLabel(l Label) Label {
|
||||
return Label{
|
||||
Name: cleanString(l.Name),
|
||||
Description: cleanString(l.Description),
|
||||
CategoryName: cleanString(l.CategoryName),
|
||||
Colour: cleanString(l.Colour),
|
||||
From: cleanString(l.From),
|
||||
}
|
||||
}
|
||||
|
||||
func cleanCategory(c *Category) {
|
||||
c.Name = cleanString(c.Name)
|
||||
c.Description = cleanString(c.Description)
|
||||
c.URL = cleanString(c.URL)
|
||||
}
|
||||
|
||||
func cleanCategories(lf *LabelsFile) {
|
||||
var cleaned Categories
|
||||
|
||||
for _, c := range lf.Categories {
|
||||
cleanCategory(&c)
|
||||
cleaned = append(cleaned, c)
|
||||
}
|
||||
|
||||
lf.Categories = cleaned
|
||||
}
|
||||
|
||||
func cleanLabels(lf *LabelsFile) {
|
||||
var cleaned Labels
|
||||
|
||||
for _, l := range lf.Labels {
|
||||
new := cleanLabel(l)
|
||||
cleaned = append(cleaned, new)
|
||||
}
|
||||
|
||||
lf.Labels = cleaned
|
||||
}
|
||||
|
||||
func clean(lf *LabelsFile) {
|
||||
lf.Description = cleanString(lf.Description)
|
||||
lf.Repo = cleanString(lf.Repo)
|
||||
|
||||
cleanCategories(lf)
|
||||
cleanLabels(lf)
|
||||
}
|
Reference in New Issue
Block a user