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

@@ -1,18 +1,12 @@
package repo
import (
"errors"
"github.com/dokku/dokku/plugins/common"
)
// CommandGc runs 'git gc --aggressive' against the application's repo
func CommandGc(appName string) error {
if appName == "" {
return errors.New("Please specify an app to run the command on")
}
err := common.VerifyAppName(appName)
if err != nil {
if err := common.VerifyAppName(appName); err != nil {
return err
}
@@ -28,8 +22,8 @@ func CommandGc(appName string) error {
// CommandPurgeCache deletes the contents of the build cache stored in the repository
func CommandPurgeCache(appName string) error {
if appName == "" {
common.LogFail("Please specify an app to run the command on")
if err := common.VerifyAppName(appName); err != nil {
return err
}
return PurgeCache(appName)