This change refactors the compiled golang plugins into 3 distinct binaries: - commands: already existing - subcommands/subcommands: entrypoint into all subcommands - triggers: entrypoint into all triggers It then further symlinks triggers and subcommands to the built binaries. This results in both a much faster build process as well as smaller package size.
36 lines
634 B
Go
36 lines
634 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/dokku/dokku/plugins/common"
|
|
"github.com/dokku/dokku/plugins/repo"
|
|
)
|
|
|
|
// main entrypoint to all subcommands
|
|
func main() {
|
|
parts := strings.Split(os.Args[0], "/")
|
|
subcommand := parts[len(parts)-1]
|
|
flag.Parse()
|
|
|
|
var err error
|
|
switch subcommand {
|
|
case "gc":
|
|
flag.Parse()
|
|
appName := flag.Arg(1)
|
|
err = repo.CommandGc(appName)
|
|
case "purge-cache":
|
|
appName := flag.Arg(1)
|
|
err = repo.CommandPurgeCache(appName)
|
|
default:
|
|
common.LogFail(fmt.Sprintf("Invalid plugin subcommand call: %s", subcommand))
|
|
}
|
|
|
|
if err != nil {
|
|
common.LogFail(err.Error())
|
|
}
|
|
}
|