2018-07-12 19:06:14 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2018-07-27 03:11:58 +00:00
|
|
|
hclog "github.com/hashicorp/go-hclog"
|
2018-07-12 19:06:14 +00:00
|
|
|
"github.com/hashicorp/nomad/e2e/cli/command"
|
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
)
|
|
|
|
|
2018-07-31 15:41:20 +00:00
|
|
|
const (
|
|
|
|
NomadE2ECli = "nomad-e2e"
|
|
|
|
NomadE2ECliVersion = "0.0.1"
|
|
|
|
)
|
|
|
|
|
2018-07-12 19:06:14 +00:00
|
|
|
func main() {
|
2018-07-27 03:11:58 +00:00
|
|
|
|
|
|
|
ui := &cli.BasicUi{
|
|
|
|
Reader: os.Stdin,
|
|
|
|
Writer: os.Stdout,
|
|
|
|
ErrorWriter: os.Stderr,
|
|
|
|
}
|
|
|
|
|
|
|
|
logger := hclog.New(&hclog.LoggerOptions{
|
2018-07-31 15:41:20 +00:00
|
|
|
Name: NomadE2ECli,
|
|
|
|
Output: &cli.UiWriter{Ui: ui},
|
2018-07-27 03:11:58 +00:00
|
|
|
})
|
2018-07-12 19:06:14 +00:00
|
|
|
|
2018-07-31 15:41:20 +00:00
|
|
|
c := cli.NewCLI(NomadE2ECli, NomadE2ECliVersion)
|
2018-07-12 19:06:14 +00:00
|
|
|
c.Args = os.Args[1:]
|
2018-07-31 15:41:20 +00:00
|
|
|
|
|
|
|
meta := command.NewMeta(ui, logger)
|
2018-07-12 19:06:14 +00:00
|
|
|
c.Commands = map[string]cli.CommandFactory{
|
2018-07-31 15:41:20 +00:00
|
|
|
"provision": command.ProvisionCommandFactory(meta),
|
|
|
|
"run": command.RunCommandFactory(meta),
|
2018-07-12 19:06:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exitStatus, err := c.Run()
|
|
|
|
if err != nil {
|
2018-07-27 03:11:58 +00:00
|
|
|
logger.Error("command exited with non-zero status", "status", exitStatus, "error", err)
|
2018-07-12 19:06:14 +00:00
|
|
|
}
|
|
|
|
os.Exit(exitStatus)
|
|
|
|
}
|