@@ -28,19 +28,21 @@ import (
2828)
2929
3030var (
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
4041func 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,7 +61,19 @@ func inSkipDirs(path string, skipDirs []string) bool {
5961 return false
6062}
6163
62- func getPipelineYAMLFiles (dir string , skipDirs []string ) ([]string , error ) {
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+
76+ func getPipelineYAMLFiles (dir string , skipDirs , skipFiles []string ) ([]string , error ) {
6377 var files []string
6478 err := filepath .Walk (dir , func (path string , info os.FileInfo , err error ) error {
6579 if err != nil {
@@ -71,7 +85,7 @@ func getPipelineYAMLFiles(dir string, skipDirs []string) ([]string, error) {
7185 if info .IsDir () && ! inSkipDirs (info .Name (), skipDirs ) {
7286 return filepath .SkipDir
7387 }
74- if ! info .IsDir () && (filepath .Ext (path ) == ".yml" || filepath .Ext (path ) == ".yaml" ) {
88+ if ! info .IsDir () && ! inSkipFiles ( path , skipFiles ) && (filepath .Ext (path ) == ".yml" || filepath .Ext (path ) == ".yaml" ) {
7589 files = append (files , path )
7690 }
7791 return nil
@@ -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 }
@@ -152,7 +166,7 @@ func main() {
152166 semaphoreDirs := strings .Split (dir , "," )
153167 logrus .WithField ("semaphoreDirs" , semaphoreDirs ).Debug ("looking for pipeline YAML files" )
154168 for _ , semaphoreDir := range semaphoreDirs {
155- files , err := getPipelineYAMLFiles (semaphoreDir , strings .Split (skipDir , "," ))
169+ files , err := getPipelineYAMLFiles (semaphoreDir , strings .Split (skipDir , "," ), strings . Split ( skipFile , "," ) )
156170 if err != nil {
157171 logrus .WithError (err ).Errorf ("failed to get YAML files in %s" , semaphoreDir )
158172 continue
0 commit comments