From 828c5dcaaa70b1c07090b476ff834bb9f1a20f40 Mon Sep 17 00:00:00 2001 From: Arne Juul Date: Thu, 29 Jun 2023 08:47:21 +0000 Subject: allow "vespa-logfmt" to work without full vespa install --- client/go/internal/admin/vespa-wrapper/logfmt/cmd.go | 12 ++++++++++++ client/go/internal/admin/vespa-wrapper/main.go | 10 ++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'client/go') diff --git a/client/go/internal/admin/vespa-wrapper/logfmt/cmd.go b/client/go/internal/admin/vespa-wrapper/logfmt/cmd.go index 4406457ac23..e0124a5970e 100644 --- a/client/go/internal/admin/vespa-wrapper/logfmt/cmd.go +++ b/client/go/internal/admin/vespa-wrapper/logfmt/cmd.go @@ -5,10 +5,22 @@ package logfmt import ( + "os" + "github.com/spf13/cobra" "github.com/vespa-engine/vespa/client/go/internal/build" + "github.com/vespa-engine/vespa/client/go/internal/vespa" ) +func RunCmdLine() { + _ = vespa.FindHome() + cobra := NewLogfmtCmd() + err := cobra.Execute() + if err != nil { + os.Exit(1) + } +} + func NewLogfmtCmd() *cobra.Command { var ( curOptions Options = NewOptions() diff --git a/client/go/internal/admin/vespa-wrapper/main.go b/client/go/internal/admin/vespa-wrapper/main.go index eed8ac5b57b..8f822483534 100644 --- a/client/go/internal/admin/vespa-wrapper/main.go +++ b/client/go/internal/admin/vespa-wrapper/main.go @@ -28,12 +28,17 @@ func basename(s string) string { func main() { defer handleSimplePanic() - _ = vespa.FindAndVerifyVespaHome() action := basename(os.Args[0]) if action == "vespa-wrapper" && len(os.Args) > 1 { action = os.Args[1] os.Args = os.Args[1:] } + if action == "vespa-logfmt" { + // "vespa-logfmt" does not require verified VESPA_HOME + logfmt.RunCmdLine() + return + } + _ = vespa.FindAndVerifyVespaHome() switch action { case "vespa-stop-services": os.Exit(services.VespaStopServices()) @@ -73,9 +78,6 @@ func main() { case "vespa-deploy": cobra := deploy.NewDeployCmd() cobra.Execute() - case "vespa-logfmt": - cobra := logfmt.NewLogfmtCmd() - cobra.Execute() case "vespa-get-cluster-state": cobra := clusterstate.NewGetClusterStateCmd() cobra.Execute() -- cgit v1.2.3