refactor: transition logs plugin to go

This commit is contained in:
László Görög authored and Jose Diaz-Gonzalez committed 2020-11-22 15:01:36 -05:00
1 parent 5f1dc46392
commit 9a02f3f1dc
11 files changed
+172 -156

No files matched your search

@@ -0,0 +1,31 @@
package main
import (
"flag"
"fmt"
"github.com/dokku/dokku/plugins/common"
"github.com/dokku/dokku/plugins/logs"
"os"
"strings"
)
// main entrypoint to all subcommands
func main() {
parts := strings.Split(os.Args[0], "/")
subcommand := parts[len(parts)-1]
var err error
switch subcommand {
case "failed":
args := flag.NewFlagSet("logs:failed", flag.ExitOnError)
args.Parse(os.Args[2:])
appName := args.Arg(0)
err = logs.CommandFailed(appName)
default:
common.LogFail(fmt.Sprintf("Invalid plugin subcommand call: %s", subcommand))
}
if err != nil {
common.LogFail(err.Error())
}
}