New creates a new HTTP client
(configMgr *config.Manager, logger *logrus.Logger)
| 42 | |
| 43 | // New creates a new HTTP client |
| 44 | func New(configMgr *config.Manager, logger *logrus.Logger) *Client { |
| 45 | client := resty.New() |
| 46 | client.SetTimeout(30 * time.Second) |
| 47 | client.SetRetryCount(3) |
| 48 | client.SetRetryWaitTime(2 * time.Second) |
| 49 | |
| 50 | // Configure Resty to use our logger |
| 51 | client.SetLogger(logger) |
| 52 | |
| 53 | // Configure TLS based on skip_ssl_verify (config or PATCHMON_SKIP_SSL_VERIFY env) |
| 54 | cfg := configMgr.GetConfig() |
| 55 | skipVerify := cfg.SkipSSLVerify || IsSkipSSLVerifyEnvSet() |
| 56 | if skipVerify { |
| 57 | // Operator-gated insecure TLS for lab/air-gapped deployments. |
| 58 | logger.Warn("TLS certificate verification disabled - use only with trusted self-signed or internal CA certificates") |
| 59 | client.SetTLSClientConfig(&tls.Config{ |
| 60 | InsecureSkipVerify: true, |
| 61 | }) |
| 62 | } |
| 63 | |
| 64 | return &Client{ |
| 65 | client: client, |
| 66 | config: cfg, |
| 67 | credentials: configMgr.GetCredentials(), |
| 68 | logger: logger, |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // Ping sends a ping request to the server |
| 73 | func (c *Client) Ping(ctx context.Context) (*models.PingResponse, error) { |
nothing calls this directly
no test coverage detected