As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit a2cd7f43 authored by Vasilii Iakliushin's avatar Vasilii Iakliushin
Browse files

Fix linter warnings for healthcheck client

parent d21a781b
No related branches found
No related tags found
No related merge requests found
// Package healthcheck implements a HTTP client to request healthcheck endpoint
package healthcheck
import (
Loading
Loading
@@ -14,11 +15,13 @@ const (
checkPath = "/check"
)
// Client defines configuration for healthcheck client
type Client struct {
config *config.Config
client *client.GitlabNetClient
}
// Response contains healthcheck endpoint response data
type Response struct {
APIVersion string `json:"api_version"`
GitlabVersion string `json:"gitlab_version"`
Loading
Loading
@@ -26,22 +29,26 @@ type Response struct {
Redis bool `json:"redis"`
}
// NewClient initializes a client's struct
func NewClient(config *config.Config) (*Client, error) {
client, err := gitlabnet.GetClient(config)
if err != nil {
return nil, fmt.Errorf("Error creating http client: %v", err)
return nil, fmt.Errorf("error creating http client: %v", err)
}
return &Client{config: config, client: client}, nil
}
func (c *Client) Check(ctx context.Context) (*Response, error) {
// Check makes a GET request to healthcheck endpoint
func (c *Client) Check(ctx context.Context) (response *Response, err error) {
resp, err := c.client.Get(ctx, checkPath)
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() {
err = resp.Body.Close()
}()
return parse(resp)
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment