jpappa200 commented on code in PR #7652:
URL: https://github.com/apache/trafficcontrol/pull/7652#discussion_r1272741060


##########
cache-config/t3c-apply/torequest/torequest.go:
##########
@@ -1030,6 +1034,45 @@ func (r *TrafficOpsReq) ProcessPackages() error {
        return nil
 }
 
+func pkgMetaDataToMap(pmd []string) map[string]bool {
+       pkgMap := map[string]bool{}
+       for _, pkg := range pmd {
+               pkgMap[pkg] = true
+       }
+       return pkgMap
+}
+
+func pkgMatch(pkgMetaData []string, pk string) bool {
+       for _, pkg := range pkgMetaData {
+               if ok := strings.Contains(pk, pkg); ok {
+                       return true
+               }
+       }
+       return false
+
+}
+
+func (r *TrafficOpsReq) ProcessPackagesWithMetaData(packageMetaData []string) 
error {
+       pkgs, err := getPackages(r.Cfg)
+       pkgMdataMap := pkgMetaDataToMap(packageMetaData)
+       if err != nil {
+               return errors.New("getting packages: " + err.Error())
+       }
+       for _, pkg := range pkgs {
+               fullPackage := pkg.Name + "-" + pkg.Version
+               if pkgMdataMap[fullPackage] {
+                       log.Infof("package %v is assumed to be installed 
according to metadata file", fullPackage)
+                       r.Pkgs[fullPackage] = true
+               } else if pkgMatch(packageMetaData, pkg.Name) {
+                       log.Infof("package %v is assumed to be installed 
according to metadata, but doesn't match traffic ops pkg", fullPackage)
+                       r.Pkgs[fullPackage] = true
+               } else {
+                       log.Infof("package %v does not appear to be 
installed.", pkg.Name+"-"+pkg.Version)

Review Comment:
   updaed to `%s` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to