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

Method ValidateMachine

pkg/database/machines.go:139–150  ·  view source on GitHub ↗
(ctx context.Context, machineID string)

Source from the content-addressed store, hash-verified

137}
138
139func (c *Client) ValidateMachine(ctx context.Context, machineID string) error {
140 rets, err := c.Ent.Machine.Update().Where(machine.MachineIdEQ(machineID)).SetIsValidated(true).Save(ctx)
141 if err != nil {
142 return fmt.Errorf("validating machine: %w: %w", err, UpdateFail)
143 }
144
145 if rets == 0 {
146 return errors.New("machine not found")
147 }
148
149 return nil
150}
151
152func (c *Client) QueryPendingMachine(ctx context.Context) ([]*ent.Machine, error) {
153 machines, err := c.Ent.Machine.Query().Where(machine.IsValidatedEQ(false)).All(ctx)

Callers 2

ValidateMachineFunction · 0.95
validateMethod · 0.80

Calls 5

MachineIdEQFunction · 0.92
SaveMethod · 0.45
SetIsValidatedMethod · 0.45
WhereMethod · 0.45
UpdateMethod · 0.45

Tested by 1

ValidateMachineFunction · 0.76