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

Method SetHostGroups

server-source-code/internal/store/hosts.go:347–362  ·  view source on GitHub ↗

SetHostGroups replaces host group memberships for a host.

(ctx context.Context, hostID string, groupIDs []string)

Source from the content-addressed store, hash-verified

345
346// SetHostGroups replaces host group memberships for a host.
347func (s *HostsStore) SetHostGroups(ctx context.Context, hostID string, groupIDs []string) error {
348 d := s.db.DB(ctx)
349 if err := d.Queries.DeleteHostGroupMemberships(ctx, hostID); err != nil {
350 return err
351 }
352 for _, gid := range groupIDs {
353 if err := d.Queries.InsertHostGroupMembership(ctx, db.InsertHostGroupMembershipParams{
354 ID: uuid.New().String(),
355 HostID: hostID,
356 HostGroupID: gid,
357 }); err != nil {
358 return err
359 }
360 }
361 return nil
362}
363
364// SetHostGroupsBulk updates group memberships for multiple hosts.
365func (s *HostsStore) SetHostGroupsBulk(ctx context.Context, hostIDs, groupIDs []string) error {

Callers 4

SetHostGroupsBulkMethod · 0.95
CreateMethod · 0.80
UpdateGroupsMethod · 0.80
EnrollMethod · 0.80

Calls 3

DBMethod · 0.65

Tested by

no test coverage detected