feat(api): improve codegen outputs (#41)
* Use `[]byte` for generated request bodies when the source schema has `format: byte` * Gzip-compress request bodies when `Content-Encoding: gzip` is set * Require that all models returned as error conditions in our API implement the `error` interface * Move the implementation for `api.HealthCheck` out of `ping.go` and into `api/error.go` Co-authored-by: William Baker <55118525+wbaker85@users.noreply.github.com>
This commit is contained in:
@ -2,7 +2,6 @@ package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/influxdata/influx-cli/v2/internal/api"
|
||||
)
|
||||
@ -13,21 +12,10 @@ func (c *CLI) Ping(ctx context.Context, client api.HealthApi) error {
|
||||
if c.TraceId != "" {
|
||||
req = req.ZapTraceSpan(c.TraceId)
|
||||
}
|
||||
resp, _, err := client.GetHealthExecute(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to make health check request: %w", err)
|
||||
if _, _, err := client.GetHealthExecute(req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.Status == api.HEALTHCHECKSTATUS_FAIL {
|
||||
var message string
|
||||
if resp.Message != nil {
|
||||
message = *resp.Message
|
||||
} else {
|
||||
message = fmt.Sprintf("check %s failed", resp.Name)
|
||||
}
|
||||
return fmt.Errorf("health check failed: %s", message)
|
||||
}
|
||||
|
||||
_, err = c.StdIO.Write([]byte("OK\n"))
|
||||
_, err := c.StdIO.Write([]byte("OK\n"))
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user