github.com/cilium/cilium@v1.16.2/cilium-health/cmd/ping.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package cmd 5 6 import ( 7 "fmt" 8 9 "github.com/spf13/cobra" 10 ) 11 12 // pingCmd represents the ping command 13 var pingCmd = &cobra.Command{ 14 Use: "ping", 15 Short: "Check whether the cilium-health API is up", 16 Run: func(cmd *cobra.Command, args []string) { 17 _, err := client.Restapi.GetHealthz(nil) 18 if err != nil { 19 Fatalf("Cannot ping: %s\n", err) 20 } 21 fmt.Println("OK") 22 }, 23 } 24 25 func init() { 26 rootCmd.AddCommand(pingCmd) 27 }