init.go 747 B

123456789101112131415161718192021222324252627282930313233
  1. package config
  2. import (
  3. "strings"
  4. log "github.com/Sirupsen/logrus"
  5. )
  6. type InitFunc func(*Config) error
  7. func RunInitFuncs(cfg *Config, initFuncs []InitFunc) error {
  8. for i, initFunc := range initFuncs {
  9. log.Debugf("[%d/%d] Starting", i+1, len(initFuncs))
  10. if err := initFunc(cfg); err != nil {
  11. log.Errorf("Failed [%d/%d] %d%%", i+1, len(initFuncs), ((i + 1) * 100 / len(initFuncs)))
  12. return err
  13. }
  14. log.Debugf("[%d/%d] Done %d%%", i+1, len(initFuncs), ((i + 1) * 100 / len(initFuncs)))
  15. }
  16. return nil
  17. }
  18. func FilterGlobalConfig(input []string) []string {
  19. result := make([]string, 0, len(input))
  20. for _, value := range input {
  21. if !strings.HasPrefix(value, "--rancher") {
  22. result = append(result, value)
  23. }
  24. }
  25. return result
  26. }