mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-17 22:34:25 +01: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:
66
tests/cmd/github-labels/display_tsv.go
Normal file
66
tests/cmd/github-labels/display_tsv.go
Normal file
@@ -0,0 +1,66 @@
|
||||
// Copyright (c) 2019 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"os"
|
||||
)
|
||||
|
||||
type displayTSV struct {
|
||||
writer *csv.Writer
|
||||
}
|
||||
|
||||
func NewDisplayTSV(file *os.File) DisplayHandler {
|
||||
tsv := &displayTSV{}
|
||||
tsv.writer = csv.NewWriter(file)
|
||||
|
||||
// Tab separator
|
||||
tsv.writer.Comma = rune('\t')
|
||||
|
||||
return tsv
|
||||
}
|
||||
|
||||
func (d *displayTSV) DisplayLabels(lf *LabelsFile) error {
|
||||
record := labelHeaderRecord()
|
||||
if err := d.writer.Write(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, l := range lf.Labels {
|
||||
record := labelToRecord(l, false)
|
||||
|
||||
if err := d.writer.Write(record); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
d.writer.Flush()
|
||||
|
||||
return d.writer.Error()
|
||||
}
|
||||
|
||||
func (d *displayTSV) DisplayCategories(lf *LabelsFile, showLabels bool) error {
|
||||
record := categoryHeaderRecord(showLabels)
|
||||
if err := d.writer.Write(record); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, c := range lf.Categories {
|
||||
record, err := categoryToRecord(lf, c, showLabels, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := d.writer.Write(record); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
d.writer.Flush()
|
||||
|
||||
return d.writer.Error()
|
||||
}
|
||||
Reference in New Issue
Block a user