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

     1  package aws
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/quay/claircore"
     7  	"github.com/quay/claircore/pkg/cpe"
     8  )
     9  
    10  type Release string
    11  
    12  const (
    13  	AmazonLinux1 Release = "AL1"
    14  	AmazonLinux2 Release = "AL2"
    15  	AmazonLinux2023 Release = "AL2023"
    16  	// os-release name ID field consistently available on official amazon linux images
    17  	ID = "amzn"
    18  )
    19  
    20  func (r Release) mirrorlist() string {
    21  	//doc:url updater
    22  	const (
    23  		al1 = "http://repo.us-west-2.amazonaws.com/2018.03/updates/x86_64/mirror.list"
    24  		al2 = "https://cdn.amazonlinux.com/2/core/latest/x86_64/mirror.list"
    25  		al2023 = "https://cdn.amazonlinux.com/al2023/core/mirrors/latest/x86_64/mirror.list"
    26  	)
    27  	switch r {
    28  	case AmazonLinux1:
    29  		return al1
    30  	case AmazonLinux2:
    31  		return al2
    32  	case AmazonLinux2023:
    33  		return al2023
    34  	}
    35  	panic(fmt.Sprintf("unknown release %q", r))
    36  }
    37  
    38  var AL1Dist = &claircore.Distribution{
    39  	Name:       "Amazon Linux AMI",
    40  	DID:        ID,
    41  	Version:    "2018.03",
    42  	VersionID:  "2018.03",
    43  	PrettyName: "Amazon Linux AMI 2018.03",
    44  	CPE:        cpe.MustUnbind("cpe:/o:amazon:linux:2018.03:ga"),
    45  }
    46  
    47  var AL2Dist = &claircore.Distribution{
    48  	Name:       "Amazon Linux",
    49  	DID:        ID,
    50  	Version:    "2",
    51  	VersionID:  "2",
    52  	PrettyName: "Amazon Linux 2",
    53  	CPE:        cpe.MustUnbind("cpe:2.3:o:amazon:amazon_linux:2"),
    54  }
    55  
    56  var AL2023Dist = &claircore.Distribution{
    57  	Name:       "Amazon Linux",
    58  	DID:        ID,
    59  	Version:    "2023",
    60  	VersionID:  "2023",
    61  	PrettyName: "Amazon Linux 2023",
    62  	CPE:        cpe.MustUnbind("cpe:2.3:o:amazon:amazon_linux:2023"),
    63  }
    64  
    65  
    66  func releaseToDist(release Release) *claircore.Distribution {
    67  	switch release {
    68  	case AmazonLinux1:
    69  		return AL1Dist
    70  	case AmazonLinux2:
    71  		return AL2Dist
    72  	case AmazonLinux2023:
    73  		return AL2023Dist
    74  	default:
    75  		// return empty dist
    76  		return &claircore.Distribution{}
    77  	}
    78  }