refactor: transition logs plugin to go

This commit is contained in:
László Görög
2020-10-18 12:38:25 +02:00
committed by Jose Diaz-Gonzalez
parent 5f1dc46392
commit 9a02f3f1dc
11 changed files with 172 additions and 156 deletions

View File

@@ -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())
}
}