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
Unverified Commit ab217b6b authored by Ash McKenzie's avatar Ash McKenzie Committed by GitLab
Browse files

Merge branch '737_fix_linter_warnings' into 'main'

parents 556cba2b a2cd7f43
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