Files
dokku/plugins/ports/report.go
Jose Diaz-Gonzalez 4bc3de5540 feat: write auto-detected port mappings during a deploy
During an app build, we now auto-detect ports based on the source code. This is usually http:80:5000, with Dockerfile-based deploys having their ports extracted from the docker image or Dockerfile. Additionally, we add an https:443 mapping for any detected http:80 mapping when there is an ssl certificate, and all http port mappings are transformed to https mappings for Dockerfile-based deploys.

While the ports aren't currently consumed, a future refactor will provide the ability to fallback to the new detected ports when there is no user-specified port mapping.
2023-08-05 10:58:57 -04:00

48 lines
1.2 KiB
Go

package ports
import (
"strings"
"github.com/dokku/dokku/plugins/common"
)
// ReportSingleApp is an internal function that displays the ports report for one or more apps
func ReportSingleApp(appName string, format string, infoFlag string) error {
if err := common.VerifyAppName(appName); err != nil {
return err
}
flags := map[string]common.ReportFunc{
"--ports-map": reportPortMap,
"--ports-map-detected": reportPortMapDetected,
}
flagKeys := []string{}
for flagKey := range flags {
flagKeys = append(flagKeys, flagKey)
}
trimPrefix := false
uppercaseFirstCharacter := true
infoFlags := common.CollectReport(appName, infoFlag, flags)
return common.ReportSingleApp("ports", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
}
func reportPortMap(appName string) string {
var portMaps []string
for _, portMap := range getPortMaps(appName) {
portMaps = append(portMaps, portMap.String())
}
return strings.Join(portMaps, " ")
}
func reportPortMapDetected(appName string) string {
var portMaps []string
for _, portMap := range getDetectedPortMaps(appName) {
portMaps = append(portMaps, portMap.String())
}
return strings.Join(portMaps, " ")
}