feat: implement builder plugin

This plugin will allow users to override the builder used for their application, enabling users to use custom builders if desired.
This commit is contained in:
Jose Diaz-Gonzalez
2021-02-28 17:25:03 -05:00
parent 1ec71cd509
commit 8c34cfe64e
21 changed files with 566 additions and 28 deletions

View File

@@ -0,0 +1,56 @@
package main
import (
"flag"
"fmt"
"os"
"strconv"
"strings"
"github.com/dokku/dokku/plugins/common"
)
const (
helpHeader = `Usage: dokku builder[:COMMAND]
Manage builder settings for an app
Additional commands:`
helpContent = `
builder:report [<app>] [<flag>], Displays a builder report for one or more apps
builder:set <app> <property> (<value>), Set or clear a builder property for an app
`
)
func main() {
flag.Usage = usage
flag.Parse()
cmd := flag.Arg(0)
switch cmd {
case "builder", "builder:help":
usage()
case "help":
command := common.NewShellCmd(fmt.Sprintf("ps -o command= %d", os.Getppid()))
command.ShowOutput = false
output, err := command.Output()
if err == nil && strings.Contains(string(output), "--all") {
fmt.Println(helpContent)
} else {
fmt.Print("\n builder, Manage builder settings for an app\n")
}
default:
dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT"))
if err != nil {
fmt.Println("failed to retrieve DOKKU_NOT_IMPLEMENTED_EXIT environment variable")
dokkuNotImplementExitCode = 10
}
os.Exit(dokkuNotImplementExitCode)
}
}
func usage() {
common.CommandUsage(helpHeader, helpContent)
}