@@ -3,7 +3,6 @@ package listener
33import (
44 "app/base"
55 "app/base/api"
6- "app/base/candlepin"
76 "app/base/database"
87 "app/base/inventory"
98 "app/base/models"
@@ -51,7 +50,6 @@ const (
5150 RepoPathPattern = "(/content/.*)"
5251 RepoBasearchPlaceholder = "$basearch"
5352 RepoReleaseverPlaceholder = "$releasever"
54- TemplateRepoPattern = `^https://cert\.console.*/api/pulp-content/(cs-)?[[:xdigit:]]+/templates/`
5553)
5654
5755var (
@@ -65,12 +63,10 @@ var (
6563)
6664
6765var (
68- repoPathRegex = regexp .MustCompile (RepoPathPattern )
69- spacesRegex = regexp .MustCompile (`^\s*$` )
70- templateRepoPath = regexp .MustCompile (TemplateRepoPattern )
71- httpClient * api.Client
72- candlepinClient = candlepin .CreateCandlepinClient ()
73- metricByErr = map [error ]string {
66+ repoPathRegex = regexp .MustCompile (RepoPathPattern )
67+ spacesRegex = regexp .MustCompile (`^\s*$` )
68+ httpClient * api.Client
69+ metricByErr = map [error ]string {
7470 ErrNoPackages : ReceivedWarnNoPackages ,
7571 ErrReporter : ReceivedWarnExcludedReporter ,
7672 ErrHostType : ReceivedWarnExcludedHostType ,
@@ -332,31 +328,11 @@ func hostTemplate(tx *gorm.DB, accountID int, host *Host) *int64 {
332328 var templateID * int64
333329 var err error
334330 switch host .Reporter {
335- case rhsmReporter :
331+ case rhsmReporter , puptooReporter :
336332 templateID , err = getTemplate (tx , accountID , host .SystemProfile .Rhsm .Environments )
337333 if err != nil {
338334 utils .LogWarn ("inventoryID" , host .ID , "err" , errors .Wrap (err , "Unable to assign templates" ))
339335 }
340- case puptooReporter :
341- if hasTemplateRepo (& host .SystemProfile ) {
342- // check system's env in candlepin
343- resp , err := callCandlepinEnvironment (base .Context , host .SystemProfile .ConsumerID )
344- if err != nil {
345- utils .LogWarn ("inventoryID" , host .ID , "err" , errors .Wrap (err , "Unable to assign templates" ))
346- }
347-
348- // get template from candlepin
349- if resp != nil {
350- envs := make ([]string , 0 , len (resp .Environments ))
351- for _ , env := range resp .Environments {
352- envs = append (envs , env .ID )
353- }
354- templateID , err = getTemplate (tx , accountID , envs )
355- if err != nil {
356- utils .LogWarn ("inventoryID" , host .ID , "err" , errors .Wrap (err , "Unable to assign templates" ))
357- }
358- }
359- }
360336 }
361337 return templateID
362338}
@@ -667,16 +643,6 @@ func getRepoPath(systemProfile *inventory.SystemProfile, repo *inventory.YumRepo
667643 return repoPath , nil
668644}
669645
670- func hasTemplateRepo (systemProfile * inventory.SystemProfile ) bool {
671- yumRepos := systemProfile .GetYumRepos ()
672- for _ , r := range yumRepos {
673- if r .Enabled && templateRepoPath .MatchString (r .BaseURL ) {
674- return true
675- }
676- }
677- return false
678- }
679-
680646func processRepos (systemProfile * inventory.SystemProfile ) ([]string , []string ) {
681647 yumRepos := systemProfile .GetYumRepos ()
682648 seen := make (map [string ]bool , len (yumRepos ))
0 commit comments