feat: add app name verification to all golang plugins

Moving verification of input to the earliest place is the best way to decrease the need to validate this further downstream.

Additionally, some of the existing checks were.... lacking :)
This commit is contained in:
Jose Diaz-Gonzalez
2020-12-25 00:00:26 -05:00
parent 382dc01b33
commit ffa303092f
8 changed files with 41 additions and 94 deletions

View File

@@ -13,10 +13,6 @@ import (
// CommandInspect displays a sanitized version of docker inspect for an app
func CommandInspect(appName string) error {
if appName == "" {
return errors.New("Please specify an app to run the command on")
}
if err := common.VerifyAppName(appName); err != nil {
return err
}
@@ -31,10 +27,6 @@ func CommandRebuild(appName string, allApps bool, parallelCount int) error {
return common.RunCommandAgainstAllApps(Rebuild, "rebuild", parallelCount)
}
if appName == "" {
return errors.New("Please specify an app to run the command on")
}
if err := common.VerifyAppName(appName); err != nil {
return err
}
@@ -66,10 +58,6 @@ func CommandRestart(appName string, allApps bool, parallelCount int) error {
return common.RunCommandAgainstAllApps(Restart, "restart", parallelCount)
}
if appName == "" {
return errors.New("Please specify an app to run the command on")
}
if err := common.VerifyAppName(appName); err != nil {
return err
}
@@ -128,10 +116,6 @@ func CommandRetire() error {
// CommandScale gets or sets how many instances of a given process to run
func CommandScale(appName string, skipDeploy bool, processTuples []string) error {
if appName == "" {
return errors.New("Please specify an app to run the command on")
}
if err := common.VerifyAppName(appName); err != nil {
return err
}
@@ -189,10 +173,6 @@ func CommandStart(appName string, allApps bool, parallelCount int) error {
return common.RunCommandAgainstAllApps(Start, "start", parallelCount)
}
if appName == "" {
return errors.New("Please specify an app to run the command on")
}
if err := common.VerifyAppName(appName); err != nil {
return err
}
@@ -206,10 +186,6 @@ func CommandStop(appName string, allApps bool, parallelCount int) error {
return common.RunCommandAgainstAllApps(Stop, "stop", parallelCount)
}
if appName == "" {
return errors.New("Please specify an app to run the command on")
}
if err := common.VerifyAppName(appName); err != nil {
return err
}