-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from justenwalker/gh128_refactor-app-state
Refactor: Config to Application State
- Loading branch information
Showing
29 changed files
with
930 additions
and
654 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
|
||
log "github.com/Sirupsen/logrus" | ||
"github.com/joyent/containerpilot/utils" | ||
) | ||
|
||
// ParsePreStart ... | ||
func (cfg *Config) ParsePreStart() (*exec.Cmd, error) { | ||
// onStart has been deprecated for preStart. Remove in 2.0 | ||
if cfg.PreStart != nil && cfg.OnStart != nil { | ||
log.Warnf("The onStart option has been deprecated in favor of preStart. ContainerPilot will use only the preStart option provided") | ||
} | ||
|
||
// alias the onStart behavior to preStart | ||
if cfg.PreStart == nil && cfg.OnStart != nil { | ||
log.Warnf("The onStart option has been deprecated in favor of preStart. ContainerPilot will use the onStart option as a preStart") | ||
cfg.PreStart = cfg.OnStart | ||
} | ||
return parseCommand("preStart", cfg.PreStart) | ||
} | ||
|
||
// ParsePreStop ... | ||
func (cfg *Config) ParsePreStop() (*exec.Cmd, error) { | ||
return parseCommand("preStop", cfg.PreStop) | ||
} | ||
|
||
// ParsePostStop ... | ||
func (cfg *Config) ParsePostStop() (*exec.Cmd, error) { | ||
return parseCommand("postStop", cfg.PostStop) | ||
} | ||
|
||
func parseCommand(name string, args interface{}) (*exec.Cmd, error) { | ||
cmd, err := utils.ParseCommandArgs(args) | ||
if err != nil { | ||
return nil, fmt.Errorf("Could not parse `%s`: %s", name, err) | ||
} | ||
return cmd, nil | ||
} |
Oops, something went wrong.