-
Notifications
You must be signed in to change notification settings - Fork 70
/
command_validate.go
43 lines (37 loc) · 1.23 KB
/
command_validate.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
package diagnose
import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/newrelic/newrelic-cli/internal/client"
"github.com/newrelic/newrelic-cli/internal/utils"
"github.com/newrelic/newrelic-client-go/newrelic"
)
var cmdValidate = &cobra.Command{
Use: "validate",
Short: "Validate your CLI configuration and connectivity",
Long: `Validate your CLI configuration and connectivity.
Checks the configuration in the default or specified configuation profile by sending
data to the New Relic platform and verifying that it has been received.`,
Example: "\tnewrelic diagnose validate",
Run: func(cmd *cobra.Command, args []string) {
client.WithClient(func(nrClient *newrelic.NewRelic) {
v := NewConfigValidator(nrClient)
err := v.ValidateConfig(utils.SignalCtx)
if err != nil {
if err == ErrDiscovery {
log.Fatal("Failed to detect your system's hostname. Please contact New Relic support.")
}
if err == ErrPostEvent {
log.Fatal("There was a failure posting data to New Relic.")
}
if err == ErrValidation {
log.Fatal("There was a failure locating the data that was posted to New Relic.")
}
log.Fatal(err)
}
})
},
}
func init() {
Command.AddCommand(cmdValidate)
}