From a6d73e3dc2c8dfc99b3461bdc581903f01514bd3 Mon Sep 17 00:00:00 2001 From: hghaf099 <83242695+hghaf099@users.noreply.github.com> Date: Wed, 23 Jun 2021 18:35:52 -0400 Subject: [PATCH] Fix diagnose panic when configuration file does not exist (#11932) * Fix diagnose panic when configuration file does not exist * Addressing comments * Update command/operator_diagnose.go Co-authored-by: Hridoy Roy Co-authored-by: Hridoy Roy --- command/operator_diagnose.go | 3 +++ internalshared/configutil/config.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/command/operator_diagnose.go b/command/operator_diagnose.go index 941296764d..8a999c02cf 100644 --- a/command/operator_diagnose.go +++ b/command/operator_diagnose.go @@ -242,6 +242,9 @@ func (c *OperatorDiagnoseCommand) offlineDiagnostics(ctx context.Context) error } return nil }) + if config == nil { + return fmt.Errorf("No vault server configuration found.") + } var metricSink *metricsutil.ClusterMetricSink var metricsHelper *metricsutil.MetricsHelper diff --git a/internalshared/configutil/config.go b/internalshared/configutil/config.go index 81d13aed1a..0f448aba69 100644 --- a/internalshared/configutil/config.go +++ b/internalshared/configutil/config.go @@ -2,12 +2,12 @@ package configutil import ( "fmt" - "github.com/hashicorp/hcl/hcl/token" "io/ioutil" "time" "github.com/hashicorp/hcl" "github.com/hashicorp/hcl/hcl/ast" + "github.com/hashicorp/hcl/hcl/token" "github.com/hashicorp/vault/sdk/helper/parseutil" )