MCPcopy Create free account
hub / github.com/PatchMon/PatchMon / New

Function New

agent-source-code/internal/client/client.go:44–70  ·  view source on GitHub ↗

New creates a new HTTP client

(configMgr *config.Manager, logger *logrus.Logger)

Source from the content-addressed store, hash-verified

42
43// New creates a new HTTP client
44func 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
73func (c *Client) Ping(ctx context.Context) (*models.PingResponse, error) {

Callers

nothing calls this directly

Calls 3

IsSkipSSLVerifyEnvSetFunction · 0.85
GetConfigMethod · 0.80
GetCredentialsMethod · 0.80

Tested by

no test coverage detected