MCPcopy
hub / github.com/crowdsecurity/crowdsec / GetConfigItem

Method GetConfigItem

pkg/database/config.go:11–22  ·  view source on GitHub ↗
(ctx context.Context, key string)

Source from the content-addressed store, hash-verified

9)
10
11func (c *Client) GetConfigItem(ctx context.Context, key string) (string, error) {
12 result, err := c.Ent.ConfigItem.Query().Where(configitem.NameEQ(key)).First(ctx)
13
14 switch {
15 case ent.IsNotFound(err):
16 return "", nil
17 case err != nil:
18 return "", fmt.Errorf("select config item: %w: %w", err, QueryFail)
19 default:
20 return result.Value, nil
21 }
22}
23
24func (c *Client) SetConfigItem(ctx context.Context, key string, value string) error {
25 err := c.Ent.ConfigItem.

Callers 5

LoadAPICTokenMethod · 0.95
updateBlocklistMethod · 0.80
PullMethod · 0.80
StatusMethod · 0.80

Calls 5

NameEQFunction · 0.92
IsNotFoundFunction · 0.92
FirstMethod · 0.45
WhereMethod · 0.45
QueryMethod · 0.45

Tested by 1