Skip to content

Commit 513cb6b

Browse files
committed
add skip-files flag to allow skipping specific files
1 parent 77184c2 commit 513cb6b

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

semvalidator/main.go

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,21 @@ import (
2828
)
2929

3030
var (
31-
dir string
32-
skipDir string
33-
file string
34-
org string
35-
orgURL string
36-
token string
37-
debug bool
31+
dir string
32+
skipDir string
33+
skipFile string
34+
file string
35+
org string
36+
orgURL string
37+
token string
38+
debug bool
3839
)
3940

4041
func init() {
4142
flag.StringVar(&dir, "dirs", "", "comma separated list of directories to search for Semaphore pipeline files")
4243
flag.StringVar(&skipDir, "skip-dirs", "", "comma separated list of directories to skip")
4344
flag.StringVar(&file, "files", "", "comma separated list of Semaphore pipeline files")
45+
flag.StringVar(&skipFile, "skip-files", "", "comma separated list of files to skip")
4446
flag.StringVar(&org, "org", "", "Semaphore organization")
4547
flag.StringVar(&orgURL, "org-url", "", "Semaphore organization URL")
4648
flag.StringVar(&token, "token", "", "Semaphore API token")
@@ -59,6 +61,18 @@ func inSkipDirs(path string, skipDirs []string) bool {
5961
return false
6062
}
6163

64+
func inSkipFiles(path string, skipFiles []string) bool {
65+
if len(skipFiles) == 0 {
66+
return false
67+
}
68+
for _, skipFile := range skipFiles {
69+
if path == skipFile {
70+
return true
71+
}
72+
}
73+
return false
74+
}
75+
6276
func getPipelineYAMLFiles(dir string, skipDirs []string) ([]string, error) {
6377
var files []string
6478
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
@@ -143,7 +157,7 @@ func main() {
143157
if file != "" {
144158
files := strings.Split(file, ",")
145159
for _, f := range files {
146-
if !inSkipDirs(f, strings.Split(skipDir, ",")) {
160+
if !inSkipDirs(f, strings.Split(skipDir, ",")) && !inSkipFiles(f, strings.Split(skipFile, ",")) {
147161
yamlFiles = append(yamlFiles, f)
148162
}
149163
}

0 commit comments

Comments
 (0)