github.com/quay/claircore@v1.5.28/rhel/releases.go (about)

     1  package rhel
     2  
     3  import (
     4  	"strconv"
     5  	"sync"
     6  
     7  	"github.com/quay/claircore"
     8  	"github.com/quay/claircore/toolkit/types/cpe"
     9  )
    10  
    11  // RelMap memoizes the Distributions handed out by this package.
    12  //
    13  // Doing this is a cop-out to the previous approach of having a hard-coded set of structs.
    14  // In the case something is (mistakenly) doing pointer comparisons, this will make that work
    15  // but still allows us to have the list of distributions grow ad-hoc.
    16  var relMap sync.Map
    17  
    18  func mkRelease(n int64) *claircore.Distribution {
    19  	v, ok := relMap.Load(n)
    20  	if !ok {
    21  		s := strconv.FormatInt(n, 10)
    22  		v, _ = relMap.LoadOrStore(n, &claircore.Distribution{
    23  			Name:       "Red Hat Enterprise Linux Server",
    24  			Version:    s,
    25  			VersionID:  s,
    26  			DID:        "rhel",
    27  			PrettyName: "Red Hat Enterprise Linux Server " + s,
    28  			CPE:        cpe.MustUnbind("cpe:/o:redhat:enterprise_linux:" + s),
    29  		})
    30  	}
    31  	return v.(*claircore.Distribution)
    32  }