The bash :report implementations for the dockerfile, herokuish, lambda, nixpacks, pack, and railpack builders are replaced with a compiled golang binary that collects report keys in parallel and marshals json directly, avoiding the per-key subshell and jq forks that made the bash reports slow. The subcommands/report and root report trigger become symlinks to the compiled binary, while the non-report bash helpers each plugin still relies on are left in place.
41 lines
944 B
Go
41 lines
944 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
builderlambda "github.com/dokku/dokku/plugins/builder-lambda"
|
|
"github.com/dokku/dokku/plugins/common"
|
|
|
|
flag "github.com/spf13/pflag"
|
|
)
|
|
|
|
// main entrypoint to all subcommands
|
|
func main() {
|
|
parts := strings.Split(os.Args[0], "/")
|
|
subcommand := parts[len(parts)-1]
|
|
|
|
var err error
|
|
switch subcommand {
|
|
case "report":
|
|
args := flag.NewFlagSet("builder-lambda:report", flag.ExitOnError)
|
|
format := args.String("format", "stdout", "format: [ stdout | json ]")
|
|
reportArgs, flagErr := common.ParseReportArgs("builder-lambda", os.Args[2:])
|
|
if flagErr == nil {
|
|
args.Parse(reportArgs.OSArgs)
|
|
appName := args.Arg(0)
|
|
if reportArgs.IsGlobal {
|
|
appName = "--global"
|
|
}
|
|
err = builderlambda.CommandReport(appName, *format, reportArgs.InfoFlag)
|
|
}
|
|
default:
|
|
err = fmt.Errorf("Invalid plugin subcommand call: %s", subcommand)
|
|
}
|
|
|
|
if err != nil {
|
|
common.LogFailWithError(err)
|
|
}
|
|
}
|