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 committed 2020-12-27 15:14:11 -05:00
1 parent 382dc01b33
commit ffa303092f
8 files changed
+41 -94

No files matched your search

+10 -10
View File
@@ -9,8 +9,8 @@ import (
// CommandAdd implements buildpacks:add
func CommandAdd(appName string, buildpack string, index int) error {
if appName == "" {
return errors.New("Please specify an app to run the command on")
if err := common.VerifyAppName(appName); err != nil {
return err
}
buildpack, err := validBuildpackURL(buildpack)
@@ -23,8 +23,8 @@ func CommandAdd(appName string, buildpack string, index int) error {
// CommandClear implements buildpacks:clear
func CommandClear(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
}
return common.PropertyDelete("buildpacks", appName, "buildpacks")
@@ -32,8 +32,8 @@ func CommandClear(appName string) error {
// CommandList implements buildpacks:list
func CommandList(appName string) (err error) {
if appName == "" {
return errors.New("Please specify an app to run the command on")
if err := common.VerifyAppName(appName); err != nil {
return err
}
buildpacks, err := common.PropertyListGet("buildpacks", appName, "buildpacks")
@@ -50,8 +50,8 @@ func CommandList(appName string) (err error) {
// CommandRemove implements buildpacks:remove
func CommandRemove(appName string, buildpack string, index int) (err error) {
if appName == "" {
return errors.New("Please specify an app to run the command on")
if err := common.VerifyAppName(appName); err != nil {
return err
}
if index != 0 && buildpack != "" {
@@ -123,8 +123,8 @@ func CommandReport(appName string, infoFlag string) error {
// CommandSet implements buildpacks:set
func CommandSet(appName string, buildpack string, index int) error {
if appName == "" {
return errors.New("Please specify an app to run the command on")
if err := common.VerifyAppName(appName); err != nil {
return err
}
buildpack, err := validBuildpackURL(buildpack)