1package interactors 2 3import ( 4 cst "repodiff/constants" 5 ent "repodiff/entities" 6) 7 8func ProjectNamesToType(manifests *ent.ManifestFileGroup) TypeMap { 9 commonProjects := extractProjectNames(manifests.Common) 10 distinctProjects := SetSubtract( 11 SetUnion( 12 extractProjectNames(manifests.Downstream), 13 extractProjectNames(manifests.Upstream), 14 ), 15 commonProjects, 16 ) 17 return toMap(commonProjects, distinctProjects) 18} 19 20func extractProjectNames(m ent.ManifestFile) []string { 21 projects := make([]string, len(m.Projects)) 22 for i, p := range m.Projects { 23 projects[i] = p.Name 24 } 25 return projects 26} 27 28func toMap(common, distinct []string) TypeMap { 29 ret := make(map[string]cst.ProjectType, len(common)+len(distinct)) 30 for _, k := range common { 31 ret[k] = cst.Global 32 } 33 for _, k := range distinct { 34 ret[k] = cst.DifferentialSpecific 35 } 36 return ret 37} 38