Precompile regex

This commit is contained in:
Patrick Robinson 2016-05-21 06:33:41 +10:00 committed by Chris Bednarski
parent b1d6d28a90
commit f361e1d894
1 changed files with 2 additions and 2 deletions

View File

@ -86,10 +86,10 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
} }
} }
m, _ := regexp.MatchString("(stop|terminate)", c.InstanceInitiatedShutdownBehavior) var reShutdownBehavior = regexp.MustCompile("(stop|terminate)")
if c.InstanceInitiatedShutdownBehavior == "" { if c.InstanceInitiatedShutdownBehavior == "" {
c.InstanceInitiatedShutdownBehavior = "stop" c.InstanceInitiatedShutdownBehavior = "stop"
} else if !m { } else if !reShutdownBehavior.MatchString(c.InstanceInitiatedShutdownBehavior) {
errs = append(errs, fmt.Errorf("shutdown_behaviour only accepts 'stop' or 'terminate' values.")) errs = append(errs, fmt.Errorf("shutdown_behaviour only accepts 'stop' or 'terminate' values."))
} }