本文整理匯總了Golang中github.com/apex/apex/utils.ReadIgnoreFile函數的典型用法代碼示例。如果您正苦於以下問題:Golang ReadIgnoreFile函數的具體用法?Golang ReadIgnoreFile怎麽用?Golang ReadIgnoreFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ReadIgnoreFile函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Open
// Open the function.json file and prime the config.
func (f *Function) Open() error {
f.Log = f.Log.WithField("function", f.Name)
if f.Plugins == nil {
f.Plugins = defaultPlugins
}
if f.Environment == nil {
f.Environment = make(map[string]string)
}
p, err := os.Open(filepath.Join(f.Path, "function.json"))
if err == nil {
if err := json.NewDecoder(p).Decode(&f.Config); err != nil {
return err
}
}
if err := f.hookOpen(); err != nil {
return err
}
if err := validator.Validate(&f.Config); err != nil {
return fmt.Errorf("error opening function %s: %s", f.Name, err.Error())
}
patterns, err := utils.ReadIgnoreFile(f.Path)
if err != nil {
return err
}
f.IgnoredPatterns = append(f.IgnoredPatterns, patterns...)
return nil
}
示例2: Open
// Open the function.json file and prime the config.
func (f *Function) Open(environment string) error {
f.defaults()
f.Log = f.Log.WithFields(log.Fields{
"function": f.Name,
"env": environment,
})
f.Log.Debug("open")
if err := f.loadConfig(environment); err != nil {
return err
}
if err := f.hookOpen(); err != nil {
return err
}
if err := validator.Validate(&f.Config); err != nil {
return fmt.Errorf("error opening function %s: %s", f.Name, err.Error())
}
ignoreFile, err := utils.ReadIgnoreFile(f.Path)
if err != nil {
return err
}
f.IgnoreFile = append(f.IgnoreFile, []byte("\n")...)
f.IgnoreFile = append(f.IgnoreFile, ignoreFile...)
return nil
}
示例3: Open
// Open the function.json file and prime the config.
func (f *Function) Open() error {
f.defaults()
f.Log = f.Log.WithField("function", f.Name)
p, err := os.Open(filepath.Join(f.Path, "function.json"))
if err == nil {
if err := json.NewDecoder(p).Decode(&f.Config); err != nil {
return err
}
}
if err := f.hookOpen(); err != nil {
return err
}
if err := validator.Validate(&f.Config); err != nil {
return fmt.Errorf("error opening function %s: %s", f.Name, err.Error())
}
ignoreFile, err := utils.ReadIgnoreFile(f.Path)
if err != nil {
return err
}
f.IgnoreFile = append(f.IgnoreFile, []byte("\n")...)
f.IgnoreFile = append(f.IgnoreFile, ignoreFile...)
return nil
}
示例4: Open
// Open the project.json file and prime the config.
func (p *Project) Open() error {
p.defaults()
f, err := os.Open(filepath.Join(p.Path, "project.json"))
if err != nil {
return err
}
if err := json.NewDecoder(f).Decode(&p.Config); err != nil {
return err
}
if err := validator.Validate(&p.Config); err != nil {
return err
}
t, err := template.New("nameTemplate").Parse(p.NameTemplate)
if err != nil {
return err
}
p.nameTemplate = t
ignoreFile, err := utils.ReadIgnoreFile(p.Path)
if err != nil {
return err
}
p.IgnoreFile = append(p.IgnoreFile, ignoreFile...)
return nil
}
示例5: Open
// Open the project.json file and prime the config.
func (p *Project) Open() error {
p.defaults()
f, err := os.Open(filepath.Join(p.Path, "project.json"))
if err != nil {
return err
}
if err := json.NewDecoder(f).Decode(&p.Config); err != nil {
return err
}
if err := validator.Validate(&p.Config); err != nil {
return err
}
t, err := template.New("nameTemplate").Parse(p.NameTemplate)
if err != nil {
return err
}
p.nameTemplate = t
p.IgnoredPatterns, err = utils.ReadIgnoreFile(p.Path)
if err != nil {
return err
}
return p.loadFunctions()
}
示例6: Open
// Open the function.json file and prime the config.
func (f *Function) Open() error {
p, err := os.Open(filepath.Join(f.Path, "function.json"))
if err == nil {
if err := json.NewDecoder(p).Decode(&f.Config); err != nil {
return err
}
}
if f.Runtime == "" {
if runtimeName, err := runtime.Detect(f.Path); err == nil {
f.Runtime = runtimeName
}
}
if err := validator.Validate(&f.Config); err != nil {
return fmt.Errorf("error opening function %s: %s", f.Name, err.Error())
}
r, err := runtime.ByName(f.Runtime)
if err != nil {
return err
}
f.runtime = r
patterns, err := utils.ReadIgnoreFile(f.Path)
if err != nil {
return err
}
f.IgnoredPatterns = append(f.IgnoredPatterns, patterns...)
f.Log = f.Log.WithField("function", f.Name)
return nil
}
示例7: Open
// Open the project.json file and prime the config.
func (p *Project) Open() error {
p.defaults()
configFile := "project.json"
if p.Environment != "" {
configFile = fmt.Sprintf("project.%s.json", p.Environment)
}
f, err := os.Open(filepath.Join(p.Path, configFile))
if err != nil {
return err
}
if err := json.NewDecoder(f).Decode(&p.Config); err != nil {
return err
}
if p.InfraEnvironment == "" {
p.InfraEnvironment = p.Config.DefaultEnvironment
}
if p.Role == "" {
p.Role = p.readInfraRole()
}
if err := validator.Validate(&p.Config); err != nil {
return err
}
t, err := template.New("nameTemplate").Parse(p.NameTemplate)
if err != nil {
return err
}
p.nameTemplate = t
ignoreFile, err := utils.ReadIgnoreFile(p.Path)
if err != nil {
return err
}
p.IgnoreFile = append(p.IgnoreFile, ignoreFile...)
return nil
}
示例8: Test_ReadIgnoreFile_missing
func Test_ReadIgnoreFile_missing(t *testing.T) {
patterns, err := utils.ReadIgnoreFile("_fixtures/fileAndDir")
assert.NoError(t, err)
assert.Equal(t, []string(nil), patterns)
}
示例9: Test_ReadIgnoreFile_found
func Test_ReadIgnoreFile_found(t *testing.T) {
patterns, err := utils.ReadIgnoreFile("_fixtures")
assert.NoError(t, err)
assert.Equal(t, []string{"*.go", "*.log", "whatever"}, patterns)
}
示例10: Test_ReadIgnoreFile_found
func Test_ReadIgnoreFile_found(t *testing.T) {
file, err := utils.ReadIgnoreFile("_fixtures")
assert.NoError(t, err)
assert.Equal(t, []byte("*.go\n*.log\nwhatever"), file)
}