Post-deploy abra.sh hooks #292
@ -207,9 +207,9 @@ recipes.
|
|||||||
|
|
||||||
postDeployCmds, ok := app.Env["POST_UPGRADE_CMDS"]
|
postDeployCmds, ok := app.Env["POST_UPGRADE_CMDS"]
|
||||||
if ok && !internal.DontWaitConverge {
|
if ok && !internal.DontWaitConverge {
|
||||||
logrus.Debugf("Run the following post-deploy commands: %s", postDeployCmds)
|
logrus.Debugf("run the following post-deploy commands: %s", postDeployCmds)
|
||||||
moritz marked this conversation as resolved
|
|||||||
if err := internal.PostCmds(cl, app, postDeployCmds); err != nil {
|
if err := internal.PostCmds(cl, app, postDeployCmds); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatalf("attempting to run post deploy commands, saw: %s", err)
|
||||||
moritz marked this conversation as resolved
decentral1se
commented
`logrus.Fatalf("attempting to run post deploy commands, saw: %s", err)`?
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// RunCmdRemote executes an abra.sh command in the target service
|
||||||
moritz marked this conversation as resolved
decentral1se
commented
Missing docstring? Missing docstring?
|
|||||||
func RunCmdRemote(cl *dockerClient.Client, app config.App, abraSh, serviceName, cmdName, cmdArgs string) error {
|
func RunCmdRemote(cl *dockerClient.Client, app config.App, abraSh, serviceName, cmdName, cmdArgs string) error {
|
||||||
filters := filters.NewArgs()
|
filters := filters.NewArgs()
|
||||||
moritz marked this conversation as resolved
decentral1se
commented
I'd recommend using the I'd recommend using the `app.Filters` if possible due to the often bizarre handling of filters in the Docker API. You'd pass `exactMatch = true` which I think is more readable for our future selves.
moritz
commented
I just moved this function from I just moved this function from `cli/app/cmd.go` without touching it.
I think `app.Filters` doesn't make sense here, because it filters for all services and in this case only a filter for `serviceName` is required.
|
|||||||
filters.Add("name", fmt.Sprintf("^%s_%s", app.StackName(), serviceName))
|
filters.Add("name", fmt.Sprintf("^%s_%s", app.StackName(), serviceName))
|
||||||
|
@ -167,15 +167,18 @@ func DeployAction(c *cli.Context) error {
|
|||||||
|
|
||||||
postDeployCmds, ok := app.Env["POST_DEPLOY_CMDS"]
|
postDeployCmds, ok := app.Env["POST_DEPLOY_CMDS"]
|
||||||
if ok && !DontWaitConverge {
|
if ok && !DontWaitConverge {
|
||||||
logrus.Debugf("Run the following post-deploy commands: %s", postDeployCmds)
|
logrus.Debugf("run the following post-deploy commands: %s", postDeployCmds)
|
||||||
moritz marked this conversation as resolved
decentral1se
commented
nitpick: Run -> run since the rest of the codebase uses lowercase nitpick: Run -> run since the rest of the codebase uses lowercase
|
|||||||
if err := PostCmds(cl, app, postDeployCmds); err != nil {
|
if err := PostCmds(cl, app, postDeployCmds); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatalf("attempting to run post deploy commands, saw: %s", err)
|
||||||
moritz marked this conversation as resolved
decentral1se
commented
logrus.Fatalf("attempting to run post deploy commands, saw: %s", err)? logrus.Fatalf("attempting to run post deploy commands, saw: %s", err)?
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PostCmds parses a string of commands and executes them inside of the respective services
|
||||||
moritz marked this conversation as resolved
decentral1se
commented
Missing doc string? Missing doc string?
|
|||||||
|
// the commands string must have the following format:
|
||||||
|
// "<service> <command> <arguments>|<service> <command> <arguments>|... "
|
||||||
func PostCmds(cl *dockerClient.Client, app config.App, commands string) error {
|
func PostCmds(cl *dockerClient.Client, app config.App, commands string) error {
|
||||||
abraSh := path.Join(config.RECIPES_DIR, app.Recipe, "abra.sh")
|
abraSh := path.Join(config.RECIPES_DIR, app.Recipe, "abra.sh")
|
||||||
if _, err := os.Stat(abraSh); err != nil {
|
if _, err := os.Stat(abraSh); err != nil {
|
||||||
@ -196,7 +199,7 @@ func PostCmds(cl *dockerClient.Client, app config.App, commands string) error {
|
|||||||
if len(commandParts) > 2 {
|
if len(commandParts) > 2 {
|
||||||
moritz marked this conversation as resolved
decentral1se
commented
nitpick: Running -> running since the rest of the codebase uses lowercase nitpick: Running -> running since the rest of the codebase uses lowercase
|
|||||||
parsedCmdArgs = fmt.Sprintf("%s ", strings.Join(commandParts[2:], " "))
|
parsedCmdArgs = fmt.Sprintf("%s ", strings.Join(commandParts[2:], " "))
|
||||||
}
|
}
|
||||||
logrus.Infof("Running post-command '%s %s' in container %s", cmdName, parsedCmdArgs, targetServiceName)
|
logrus.Infof("running post-command '%s %s' in container %s", cmdName, parsedCmdArgs, targetServiceName)
|
||||||
|
|
||||||
if err := EnsureCommand(abraSh, app.Recipe, cmdName); err != nil {
|
if err := EnsureCommand(abraSh, app.Recipe, cmdName); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user
nitpick:
Run
->run
since the rest of the codebase uses lowercase