feat: add ability to specify a custom Procfile path

This commit is contained in:
Jose Diaz-Gonzalez
2021-03-21 21:45:46 -04:00
parent 9082c51074
commit c3ece32145
5 changed files with 67 additions and 9 deletions

View File

@@ -21,7 +21,7 @@ func canScaleApp(appName string) bool {
func extractProcfile(appName, image string) error {
destination := getProcfilePath(appName)
common.CopyFromImage(appName, image, "Procfile", destination)
common.CopyFromImage(appName, image, reportComputedProcfilePath(appName), destination)
if !common.FileExists(destination) {
common.LogInfo1Quiet("No Procfile found in app image")
return nil

View File

@@ -15,10 +15,13 @@ var (
// DefaultProperties is a map of all valid ps properties with corresponding default property values
DefaultProperties = map[string]string{
"restart-policy": "on-failure:10",
"procfile-path": "",
}
// GlobalProperties is a map of all valid global ps properties
GlobalProperties = map[string]bool{}
GlobalProperties = map[string]bool{
"procfile-path": true,
}
)
// Rebuild rebuilds app from base image

View File

@@ -15,12 +15,15 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
}
flags := map[string]common.ReportFunc{
"--deployed": reportDeployed,
"--processes": reportProcesses,
"--ps-can-scale": reportCanScale,
"--ps-restart-policy": reportRestartPolicy,
"--restore": reportRestore,
"--running": reportRunningState,
"--deployed": reportDeployed,
"--processes": reportProcesses,
"--ps-can-scale": reportCanScale,
"--ps-restart-policy": reportRestartPolicy,
"--ps-computed-procfile-path": reportComputedProcfilePath,
"--ps-global-procfile-path": reportGlobalProcfilePath,
"--ps-procfile-path": reportProcfilePath,
"--restore": reportRestore,
"--running": reportRunningState,
}
extraFlags := addStatusFlags(appName, infoFlag)
@@ -81,6 +84,23 @@ func reportCanScale(appName string) string {
return canScale
}
func reportComputedProcfilePath(appName string) string {
value := reportProcfilePath(appName)
if value == "" {
value = reportGlobalProcfilePath(appName)
}
return value
}
func reportGlobalProcfilePath(appName string) string {
return common.PropertyGetDefault("ps", "--global", "procfile-path", "Procfile")
}
func reportProcfilePath(appName string) string {
return common.PropertyGetDefault("ps", appName, "procfile-path", "")
}
func reportDeployed(appName string) string {
deployed := "false"
if common.IsDeployed(appName) {

View File

@@ -142,7 +142,7 @@ func TriggerPostDelete(appName string) error {
// TriggerPostExtract validates a procfile
func TriggerPostExtract(appName string, tempWorkDir string) error {
procfile := filepath.Join(tempWorkDir, "Procfile")
procfile := filepath.Join(tempWorkDir, reportComputedProcfilePath(appName))
if !common.FileExists(procfile) {
return nil
}