forked from vespa-engine/vespa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (43 loc) · 1.06 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Author: arnej
package main
import (
"fmt"
"os"
"strings"
"github.com/vespa-engine/vespa/client/go/cmd/deploy"
"github.com/vespa-engine/vespa/client/go/cmd/logfmt"
"github.com/vespa-engine/vespa/client/go/vespa"
)
func basename(s string) string {
parts := strings.Split(s, "/")
return parts[len(parts)-1]
}
func main() {
action := basename(os.Args[0])
if action == "script-utils" && len(os.Args) > 1 {
action = os.Args[1]
os.Args = os.Args[1:]
}
switch action {
case "export-env":
vespa.ExportDefaultEnvToSh()
case "ipv6-only":
if vespa.HasOnlyIpV6() {
os.Exit(0)
} else {
os.Exit(1)
}
case "vespa-deploy":
_ = vespa.FindHome()
cobra := deploy.NewDeployCmd()
cobra.Execute()
case "vespa-logfmt":
_ = vespa.FindHome()
cobra := logfmt.NewLogfmtCmd()
cobra.Execute()
default:
fmt.Fprintf(os.Stderr, "unknown action '%s'\n", action)
fmt.Fprintln(os.Stderr, "actions: export-env, ipv6-only, vespa-deploy, vespa-logfmt")
}
}