refactor: decrease compile time for golang plugins

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.
This commit is contained in:
Jose Diaz-Gonzalez
2019-09-07 04:47:18 -04:00
parent f83a03a3dc
commit 6a7d2e5252
73 changed files with 865 additions and 1179 deletions

View File

@@ -1,19 +0,0 @@
package main
import (
"flag"
"github.com/dokku/dokku/plugins/common"
"github.com/dokku/dokku/plugins/repo"
)
// destroys the buildpacks property for a given app container
func main() {
flag.Parse()
appName := flag.Arg(0)
err := repo.PurgeCache(appName)
if err != nil {
common.LogFail(err.Error())
}
}

View File

@@ -0,0 +1,31 @@
package main
import (
"flag"
"fmt"
"os"
"strings"
"github.com/dokku/dokku/plugins/common"
"github.com/dokku/dokku/plugins/repo"
)
// main entrypoint to all triggers
func main() {
parts := strings.Split(os.Args[0], "/")
trigger := parts[len(parts)-1]
flag.Parse()
var err error
switch trigger {
case "pre-delete":
appName := flag.Arg(0)
err = repo.PurgeCache(appName)
default:
common.LogFail(fmt.Sprintf("Invalid plugin trigger call: %s", trigger))
}
if err != nil {
common.LogFail(err.Error())
}
}