MCPcopy Index your code
hub / github.com/coder/coder / applyIDPSyncMappingDiff

Function applyIDPSyncMappingDiff

enterprise/coderd/idpsync.go:846–872  ·  view source on GitHub ↗
(
	previous map[string][]IDType,
	add, remove []codersdk.IDPSyncMapping[IDType],
)

Source from the content-addressed store, hash-verified

844}
845
846func applyIDPSyncMappingDiff[IDType uuid.UUID | string](
847 previous map[string][]IDType,
848 add, remove []codersdk.IDPSyncMapping[IDType],
849) map[string][]IDType {
850 next := make(map[string][]IDType)
851
852 // Copy existing mapping
853 for key, ids := range previous {
854 next[key] = append(next[key], ids...)
855 }
856
857 // Add unique entries
858 for _, mapping := range add {
859 if !slice.Contains(next[mapping.Given], mapping.Gets) {
860 next[mapping.Given] = append(next[mapping.Given], mapping.Gets)
861 }
862 }
863
864 // Remove entries
865 for _, mapping := range remove {
866 next[mapping.Given] = slices.DeleteFunc(next[mapping.Given], func(u IDType) bool {
867 return u == mapping.Gets
868 })
869 }
870
871 return next
872}

Calls 1

ContainsFunction · 0.92

Tested by 1