func (c *Config) writeDefConfigFile(filePath string) error { for key, value := range c.defaults { config.Set(key, value) } applog.Infof("Create new config file at %s", filePath) return config.WriteConfigFile(filePath, 0644) }
//############################################################################ func (p beamerBuilder) Run() error { ctx := builder.GetStruct(p).(common.BeamerCtx) pipes := make([]pipe.Pipe, 0) for _, t := range ctx.Tasks { pip, err := t.Assemble(ctx) if err != nil { return err } pipes = append(pipes, pip) } script := pipe.Script(pipes...) output, err := pipe.CombinedOutput(script) if err != nil { return err } applog.Infof("%s", output) return nil }
//############################################################################ func (b dirBuilder) Assemble(ctx common.BeamerCtx) (pipe.Pipe, error) { d, ok := builder.Get(b, "Directory") if !ok { return nil, errors.New("mkdir: directory is undefined") } directory := d.(string) if ok, _ := regexp.MatchString(REGEX_VAR_EXPAND, directory); ok { d, err := ctx.Expand(directory) if err != nil { return nil, errors.Errorf("mkdir: expand error: %s", err) } directory = d.(string) } fm, ok := builder.Get(b, "FileMode") if !ok { return nil, errors.New("mkdir: filemode is undefined") } descr, ok := builder.Get(b, "Description") if !ok { descr = fmt.Sprintf("mkdir:: %q", directory) } strict := false if st, ok := builder.Get(b, "Strict"); ok { strict = st.(bool) } return func(s *pipe.State) error { applog.Infof("execute:: %s", descr) err := os.Mkdir(directory, fm.(os.FileMode)) if !strict && strings.Contains(err.Error(), "file exists") { return nil } return err }, nil }
//############################################################################ func pushInfo(f string, args ...interface{}) { applog.Infof(fmt.Sprintf("yamllinter: %s", f), args...) }