Skip to content

Commit

Permalink
force revert
Browse files Browse the repository at this point in the history
  • Loading branch information
esilva-everbridge authored May 18, 2018
1 parent 24383f9 commit 74b986b
Showing 1 changed file with 19 additions and 35 deletions.
54 changes: 19 additions & 35 deletions sls/sls.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,48 +270,32 @@ func (s *Sls) ProcessDir(recurseDir string, action string) {
if count == 0 {
logger.Fatalf("%s has no sls files", recurseDir)
}

limChan := make(chan bool, 1)
limChan <- true

for _, file := range slsFiles {
<-limChan
s.ApplyActionToFile(file, action, limChan)
shortFile := shortFileName(file)
logger.Infof("processing %s", shortFile)
var buffer bytes.Buffer
if action == encrypt {
buffer, err = s.CipherTextYamlBuffer(file)
WriteSlsFile(buffer, file)
} else if action == decrypt {
buffer, err = s.PlainTextYamlBuffer(file)
WriteSlsFile(buffer, file)
} else if action == validate {
buffer, err = s.KeysForYamlBuffer(file)
fmt.Printf("%s\n", buffer.String())
} else {
logger.Fatalf("unknown action: %s", action)
}
if err != nil {
logger.Warnf("%s", err)
continue
}
}

close(limChan)

} else {
logger.Fatalf("%s is not a directory", recurseDir)
}
}

// ApplyActionToFile apply an action to a file, for use as a go routine
func (s *Sls) ApplyActionToFile(file string, action string, limChan chan bool) {
var err error
ok := true
shortFile := shortFileName(file)
logger.Infof("processing %s", shortFile)
var buffer bytes.Buffer
if action == encrypt {
buffer, err = s.CipherTextYamlBuffer(file)
WriteSlsFile(buffer, file)
} else if action == decrypt {
buffer, err = s.PlainTextYamlBuffer(file)
WriteSlsFile(buffer, file)
} else if action == validate {
buffer, err = s.KeysForYamlBuffer(file)
fmt.Printf("%s\n", buffer.String())
} else {
logger.Fatalf("unknown action: %s", action)
}
if err != nil {
logger.Warnf("%s", err)
ok = false
}
limChan <- ok
}

// GetValueFromPath returns the value from a path string
func (s *Sls) GetValueFromPath(path string) interface{} {
parts := strings.Split(path, ":")
Expand Down

0 comments on commit 74b986b

Please sign in to comment.