Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
absolutelightning committed Nov 1, 2023
1 parent 20615bf commit 1c673af
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cli/cmd/envoy-stats/envoy_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (c *Command) validateFlags() error {

func (c *Command) Run(args []string) int {
c.once.Do(c.init)

if err := c.set.Parse(args); err != nil {
c.UI.Output(err.Error())
return 1
Expand All @@ -91,6 +92,11 @@ func (c *Command) Run(args []string) int {
return 1
}

if c.flagPod == "" || c.flagNamespace == "" {
c.UI.Output("namespace and pod name are required")
return 1
}

// helmCLI.New() will create a settings object which is used by the Helm Go SDK calls.
settings := helmCLI.New()
if c.flagKubeConfig != "" {
Expand All @@ -113,11 +119,6 @@ func (c *Command) Run(args []string) int {
}
}

if c.flagPod == "" || c.flagNamespace == "" {
c.UI.Output("namespace and pod name are required")
return 1
}

pf := common.PortForward{
Namespace: c.flagNamespace,
PodName: c.flagPod,
Expand All @@ -135,13 +136,13 @@ func (c *Command) Run(args []string) int {

resp, err := http.Get(fmt.Sprintf("http://localhost:%s/stats", strconv.Itoa(pf.GetLocalPort())))
if err != nil {
c.UI.Output("error hitting stats endpoint of envoy")
c.UI.Output("error hitting stats endpoint of envoy %s", err)
return 1
}

bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
c.UI.Output("error reading body of http response")
c.UI.Output("error reading body of http response %s", err)
return 1
}

Expand Down

0 comments on commit 1c673af

Please sign in to comment.