mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-10 11:41:27 +00:00
This introduces a linter to PRs to help with code reviews and code hygiene. I've also gone ahead and fixed (or ignored) the existing lints. I've only setup the default linters right now. There are many more options that are documented at https://golangci-lint.run/. The GitHub Action should add appropriate annotations to the lint job for the PR. Contributors can also lint locally using `make lint`.
59 lines
1.1 KiB
Go
59 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"bytes"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
if err := run(); err != nil {
|
|
fmt.Fprintf(os.Stderr, "%v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func run() error {
|
|
var configMapNames []string
|
|
|
|
output, err := output()
|
|
if err != nil {
|
|
log.Printf("Command failed with output: %s", string(output))
|
|
return err
|
|
}
|
|
|
|
s := bufio.NewScanner(bytes.NewBuffer(output))
|
|
|
|
for s.Scan() {
|
|
if t := s.Text(); strings.Contains(t, "test-info") || strings.Contains(t, "test-result-") {
|
|
configMapNames = append(configMapNames, s.Text())
|
|
}
|
|
}
|
|
|
|
for _, n := range configMapNames {
|
|
println(n)
|
|
|
|
if output, err := delete(n); err != nil {
|
|
log.Printf("Command failed with output: %s", string(output))
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func output() ([]byte, error) {
|
|
cmd := exec.Command("kubectl", "get", "cm", "-o", `jsonpath={range .items[*]}{.metadata.name}{"\n"}{end}`)
|
|
data, err := cmd.CombinedOutput()
|
|
return data, err
|
|
}
|
|
|
|
func delete(cmName string) ([]byte, error) {
|
|
cmd := exec.Command("kubectl", "delete", "cm", cmName)
|
|
return cmd.CombinedOutput()
|
|
}
|