refactor: drop extra internal calls to VerifyAppName
These are duplicative of the checks that happen at the subcommand level.
This commit is contained in:
@@ -44,10 +44,6 @@ func createApp(appName string) error {
|
|||||||
|
|
||||||
// destroys an app
|
// destroys an app
|
||||||
func destroyApp(appName string) error {
|
func destroyApp(appName string) error {
|
||||||
if err := common.VerifyAppName(appName); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.Getenv("DOKKU_APPS_FORCE_DELETE") != "1" {
|
if os.Getenv("DOKKU_APPS_FORCE_DELETE") != "1" {
|
||||||
if err := common.AskForDestructiveConfirmation(appName, "app"); err != nil {
|
if err := common.AskForDestructiveConfirmation(appName, "app"); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -90,10 +90,6 @@ func GetGlobalScheduler() string {
|
|||||||
|
|
||||||
// GetDeployingAppImageName returns deploying image identifier for a given app, tag tuple. validate if tag is presented
|
// GetDeployingAppImageName returns deploying image identifier for a given app, tag tuple. validate if tag is presented
|
||||||
func GetDeployingAppImageName(appName, imageTag, imageRepo string) (string, error) {
|
func GetDeployingAppImageName(appName, imageTag, imageRepo string) (string, error) {
|
||||||
if appName == "" {
|
|
||||||
LogFail("(GetDeployingAppImageName) APP must not be empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
b, err := PlugnTriggerOutput("deployed-app-repository", []string{appName}...)
|
b, err := PlugnTriggerOutput("deployed-app-repository", []string{appName}...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -140,10 +136,6 @@ func GetAppImageRepo(appName string) string {
|
|||||||
// GetAppContainerIDs returns a list of docker container ids for given app and optional container_type
|
// GetAppContainerIDs returns a list of docker container ids for given app and optional container_type
|
||||||
func GetAppContainerIDs(appName string, containerType string) ([]string, error) {
|
func GetAppContainerIDs(appName string, containerType string) ([]string, error) {
|
||||||
var containerIDs []string
|
var containerIDs []string
|
||||||
if err := VerifyAppName(appName); err != nil {
|
|
||||||
return containerIDs, err
|
|
||||||
}
|
|
||||||
|
|
||||||
appRoot := AppRoot(appName)
|
appRoot := AppRoot(appName)
|
||||||
containerFilePath := fmt.Sprintf("%v/CONTAINER", appRoot)
|
containerFilePath := fmt.Sprintf("%v/CONTAINER", appRoot)
|
||||||
_, err := os.Stat(containerFilePath)
|
_, err := os.Stat(containerFilePath)
|
||||||
@@ -170,10 +162,6 @@ func GetAppContainerIDs(appName string, containerType string) ([]string, error)
|
|||||||
// GetAppRunningContainerIDs return a list of running docker container ids for given app and optional container_type
|
// GetAppRunningContainerIDs return a list of running docker container ids for given app and optional container_type
|
||||||
func GetAppRunningContainerIDs(appName string, containerType string) ([]string, error) {
|
func GetAppRunningContainerIDs(appName string, containerType string) ([]string, error) {
|
||||||
var runningContainerIDs []string
|
var runningContainerIDs []string
|
||||||
if err := VerifyAppName(appName); err != nil {
|
|
||||||
return runningContainerIDs, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !IsDeployed(appName) {
|
if !IsDeployed(appName) {
|
||||||
LogFail(fmt.Sprintf("App %v has not been deployed", appName))
|
LogFail(fmt.Sprintf("App %v has not been deployed", appName))
|
||||||
}
|
}
|
||||||
@@ -193,10 +181,6 @@ func GetAppRunningContainerIDs(appName string, containerType string) ([]string,
|
|||||||
|
|
||||||
// GetRunningImageTag retrieves current image tag for a given app and returns empty string if no deployed containers are found
|
// GetRunningImageTag retrieves current image tag for a given app and returns empty string if no deployed containers are found
|
||||||
func GetRunningImageTag(appName string) (string, error) {
|
func GetRunningImageTag(appName string) (string, error) {
|
||||||
if err := VerifyAppName(appName); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
containerIDs, err := GetAppContainerIDs(appName, "")
|
containerIDs, err := GetAppContainerIDs(appName, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -241,11 +225,6 @@ func DokkuApps() (apps []string, err error) {
|
|||||||
|
|
||||||
// GetAppImageName returns image identifier for a given app, tag tuple. validate if tag is presented
|
// GetAppImageName returns image identifier for a given app, tag tuple. validate if tag is presented
|
||||||
func GetAppImageName(appName, imageTag, imageRepo string) (imageName string) {
|
func GetAppImageName(appName, imageTag, imageRepo string) (imageName string) {
|
||||||
err := VerifyAppName(appName)
|
|
||||||
if err != nil {
|
|
||||||
LogFail(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
if imageRepo == "" {
|
if imageRepo == "" {
|
||||||
imageRepo = GetAppImageRepo(appName)
|
imageRepo = GetAppImageRepo(appName)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,6 @@ func ContainerIsRunning(containerID string) bool {
|
|||||||
|
|
||||||
// CopyFromImage copies a file from named image to destination
|
// CopyFromImage copies a file from named image to destination
|
||||||
func CopyFromImage(appName string, image string, source string, destination string) error {
|
func CopyFromImage(appName string, image string, source string, destination string) error {
|
||||||
if err := VerifyAppName(appName); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !VerifyImage(image) {
|
if !VerifyImage(image) {
|
||||||
return fmt.Errorf("Invalid docker image for copying content")
|
return fmt.Errorf("Invalid docker image for copying content")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ var (
|
|||||||
|
|
||||||
// BuildConfig builds network config files
|
// BuildConfig builds network config files
|
||||||
func BuildConfig(appName string) error {
|
func BuildConfig(appName string) error {
|
||||||
if err := common.VerifyAppName(appName); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !common.IsDeployed(appName) {
|
if !common.IsDeployed(appName) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,14 +104,6 @@ func TriggerNetworkGetProperty(appName string, property string) {
|
|||||||
|
|
||||||
// TriggerNetworkWriteIpaddr writes the ip to disk
|
// TriggerNetworkWriteIpaddr writes the ip to disk
|
||||||
func TriggerNetworkWriteIpaddr(appName string, processType string, containerIndex string, ip string) {
|
func TriggerNetworkWriteIpaddr(appName string, processType string, containerIndex string, ip string) {
|
||||||
if appName == "" {
|
|
||||||
common.LogFail("Please specify an app to run the command on")
|
|
||||||
}
|
|
||||||
err := common.VerifyAppName(appName)
|
|
||||||
if err != nil {
|
|
||||||
common.LogFail(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
appRoot := common.AppRoot(appName)
|
appRoot := common.AppRoot(appName)
|
||||||
filename := fmt.Sprintf("%v/IP.%v.%v", appRoot, processType, containerIndex)
|
filename := fmt.Sprintf("%v/IP.%v.%v", appRoot, processType, containerIndex)
|
||||||
f, err := os.Create(filename)
|
f, err := os.Create(filename)
|
||||||
@@ -129,14 +121,6 @@ func TriggerNetworkWriteIpaddr(appName string, processType string, containerInde
|
|||||||
|
|
||||||
// TriggerNetworkWritePort writes the port to disk
|
// TriggerNetworkWritePort writes the port to disk
|
||||||
func TriggerNetworkWritePort(appName string, processType string, containerIndex string, port string) {
|
func TriggerNetworkWritePort(appName string, processType string, containerIndex string, port string) {
|
||||||
if appName == "" {
|
|
||||||
common.LogFail("Please specify an app to run the command on")
|
|
||||||
}
|
|
||||||
err := common.VerifyAppName(appName)
|
|
||||||
if err != nil {
|
|
||||||
common.LogFail(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
appRoot := common.AppRoot(appName)
|
appRoot := common.AppRoot(appName)
|
||||||
filename := fmt.Sprintf("%v/PORT.%v.%v", appRoot, processType, containerIndex)
|
filename := fmt.Sprintf("%v/PORT.%v.%v", appRoot, processType, containerIndex)
|
||||||
f, err := os.Create(filename)
|
f, err := os.Create(filename)
|
||||||
|
|||||||
@@ -35,11 +35,6 @@ func inRange(value int, min int, max int) bool {
|
|||||||
|
|
||||||
// IsAppProxyEnabled returns true if proxy is enabled; otherwise return false
|
// IsAppProxyEnabled returns true if proxy is enabled; otherwise return false
|
||||||
func IsAppProxyEnabled(appName string) bool {
|
func IsAppProxyEnabled(appName string) bool {
|
||||||
err := common.VerifyAppName(appName)
|
|
||||||
if err != nil {
|
|
||||||
common.LogFail(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
proxyEnabled := true
|
proxyEnabled := true
|
||||||
disableProxy := config.GetWithDefault(appName, "DOKKU_DISABLE_PROXY", "")
|
disableProxy := config.GetWithDefault(appName, "DOKKU_DISABLE_PROXY", "")
|
||||||
if disableProxy != "" {
|
if disableProxy != "" {
|
||||||
|
|||||||
@@ -11,11 +11,6 @@ import (
|
|||||||
|
|
||||||
// PurgeCache deletes the contents of the build cache stored in the repository
|
// PurgeCache deletes the contents of the build cache stored in the repository
|
||||||
func PurgeCache(appName string) error {
|
func PurgeCache(appName string) error {
|
||||||
err := common.VerifyAppName(appName)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
cacheDir := strings.Join([]string{common.AppRoot(appName), "cache"}, "/")
|
cacheDir := strings.Join([]string{common.AppRoot(appName), "cache"}, "/")
|
||||||
cacheHostDir := strings.Join([]string{common.AppHostRoot(appName), "cache"}, "/")
|
cacheHostDir := strings.Join([]string{common.AppHostRoot(appName), "cache"}, "/")
|
||||||
dokkuGlobalRunArgs := common.MustGetEnv("DOKKU_GLOBAL_RUN_ARGS")
|
dokkuGlobalRunArgs := common.MustGetEnv("DOKKU_GLOBAL_RUN_ARGS")
|
||||||
|
|||||||
Reference in New Issue
Block a user