2020-03-10 14:14:37 -04:00
|
|
|
package apps
|
|
|
|
|
|
|
|
|
|
import (
|
2021-10-27 21:03:04 -04:00
|
|
|
"fmt"
|
2022-09-06 05:14:52 +03:00
|
|
|
"strings"
|
2021-10-27 21:03:04 -04:00
|
|
|
|
2020-03-10 14:14:37 -04:00
|
|
|
"github.com/dokku/dokku/plugins/common"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ReportSingleApp is an internal function that displays the app report for one or more apps
|
2021-02-01 22:23:05 -05:00
|
|
|
func ReportSingleApp(appName string, format string, infoFlag string) error {
|
2020-03-10 14:14:37 -04:00
|
|
|
if err := common.VerifyAppName(appName); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-29 23:56:10 -05:00
|
|
|
flags := map[string]common.ReportFunc{
|
2021-10-27 21:03:04 -04:00
|
|
|
"--app-created-at": reportCreatedAt,
|
2021-10-09 23:37:53 -04:00
|
|
|
"--app-deploy-source": reportDeploySource,
|
|
|
|
|
"--app-deploy-source-metadata": reportDeploySourceMetadata,
|
|
|
|
|
"--app-dir": reportDir,
|
|
|
|
|
"--app-locked": reportLocked,
|
2020-12-29 23:56:10 -05:00
|
|
|
}
|
|
|
|
|
|
2021-01-07 01:34:05 -05:00
|
|
|
flagKeys := []string{}
|
|
|
|
|
for flagKey := range flags {
|
|
|
|
|
flagKeys = append(flagKeys, flagKey)
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-29 23:56:10 -05:00
|
|
|
trimPrefix := false
|
|
|
|
|
uppercaseFirstCharacter := true
|
2020-12-30 00:37:43 -05:00
|
|
|
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
2021-02-01 22:23:05 -05:00
|
|
|
return common.ReportSingleApp("app", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
|
2020-12-29 23:56:10 -05:00
|
|
|
}
|
|
|
|
|
|
2021-10-27 21:03:04 -04:00
|
|
|
func reportCreatedAt(appName string) string {
|
2022-09-06 05:14:52 +03:00
|
|
|
createdAt, err := common.PropertyListGet("apps", appName, "created-at")
|
2021-10-27 21:03:04 -04:00
|
|
|
if err != nil {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
2022-09-06 05:14:52 +03:00
|
|
|
return fmt.Sprint(strings.Join(createdAt, ","))
|
2021-10-27 21:03:04 -04:00
|
|
|
}
|
|
|
|
|
|
2021-10-09 23:37:53 -04:00
|
|
|
func reportDeploySource(appName string) string {
|
|
|
|
|
return common.PropertyGet("apps", appName, "deploy-source")
|
2020-12-29 23:56:10 -05:00
|
|
|
}
|
|
|
|
|
|
2021-10-09 23:37:53 -04:00
|
|
|
func reportDeploySourceMetadata(appName string) string {
|
|
|
|
|
return common.PropertyGet("apps", appName, "deploy-source-metadata")
|
|
|
|
|
}
|
2020-03-10 14:14:37 -04:00
|
|
|
|
2021-10-09 23:37:53 -04:00
|
|
|
func reportDir(appName string) string {
|
|
|
|
|
return common.AppRoot(appName)
|
2020-12-29 23:56:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func reportLocked(appName string) string {
|
2020-03-10 14:14:37 -04:00
|
|
|
locked := "false"
|
|
|
|
|
if appIsLocked(appName) {
|
|
|
|
|
locked = "true"
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-29 23:56:10 -05:00
|
|
|
return locked
|
2020-03-10 14:14:37 -04:00
|
|
|
}
|