Skip to content

Commit

Permalink
Merge pull request #26 from SimonRichardson/focal-esm-supported
Browse files Browse the repository at this point in the history
#26

I've re-worked the supported series so that it correctly sorts for esm
releases as well. This should make this package easier to manage with I
the series is correctly sorted when using it.
  • Loading branch information
jujubot authored Oct 9, 2020
2 parents 2df8a6f + 13cf2cf commit 9ea36b3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 29 deletions.
64 changes: 38 additions & 26 deletions series/supportedseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ var ubuntuSeries = map[string]seriesVersion{
Supported: true,
},
"focal": {
Version: "20.04",
LTS: true,
Supported: true,
Version: "20.04",
LTS: true,
Supported: true,
ESMSupported: true,
},
"groovy": {
Version: "20.10",
Expand Down Expand Up @@ -596,26 +597,17 @@ func SupportedSeries() []string {
return series
}

// SupportedJujuControllerSeries returns a slice of juju supported series that
// target a controller (bootstrapping).
//
// The series are sorted in release version.
// - focal (20.4)
// - bionic (18.04)
// - xenial (16.04)
//
// Anything not supported is left out.
func SupportedJujuControllerSeries() []string {
type namedSeriesVersion struct {
Name string
SeriesVersion seriesVersion
Version float64
}

func ubuntuSeriesSortedByVersion() []namedSeriesVersion {
seriesVersionsMutex.Lock()
defer seriesVersionsMutex.Unlock()
updateSeriesVersionsOnce()

type namedSeriesVersion struct {
Name string
SeriesVersion seriesVersion
Version float64
}

s := make([]namedSeriesVersion, 0, len(ubuntuSeries))
for name, series := range ubuntuSeries {
ver, err := strconv.ParseFloat(series.Version, 10)
Expand All @@ -640,6 +632,21 @@ func SupportedJujuControllerSeries() []string {
return s[i].Name < s[j].Name
})

return s
}

// SupportedJujuControllerSeries returns a slice of juju supported series that
// target a controller (bootstrapping).
//
// The series are sorted in release version.
// - focal (20.04)
// - bionic (18.04)
// - xenial (16.04)
//
// Anything not supported is left out.
func SupportedJujuControllerSeries() []string {
s := ubuntuSeriesSortedByVersion()

var series []string
for _, version := range s {
if !version.SeriesVersion.Supported {
Expand All @@ -655,7 +662,7 @@ func SupportedJujuControllerSeries() []string {
//
// The series are sorted in ubuntu release version, anything that isn't
// ubuntu release is then sorted by name.
// - focal (20.4)
// - focal (20.04)
// - bionic (18.04)
// - xenial (16.04)
// - centos7
Expand Down Expand Up @@ -696,16 +703,21 @@ func SupportedJujuSeries() []string {

// ESMSupportedJujuSeries returns a slice of just juju extended security
// maintenance supported ubuntu series.
// The series are sorted in release version.
// - focal (20.04)
// - bionic (18.04)
// - xenial (16.04)
//
// Anything not supported is left out.
func ESMSupportedJujuSeries() []string {
seriesVersionsMutex.Lock()
defer seriesVersionsMutex.Unlock()
updateSeriesVersionsOnce()
s := ubuntuSeriesSortedByVersion()

var series []string
for s, version := range ubuntuSeries {
if !version.ESMSupported {
for _, version := range s {
if !version.SeriesVersion.ESMSupported {
continue
}
series = append(series, s)
series = append(series, version.Name)
}
return series
}
Expand Down
5 changes: 2 additions & 3 deletions series/supportedseries_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ func (s *supportedSeriesSuite) TestESMSupportedJujuSeries(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
s.PatchValue(series.UbuntuDistroInfoPath, filename)

expectedSeries := []string{"bionic", "trusty", "xenial"}
expectedSeries := []string{"focal", "bionic", "xenial", "trusty"}
series := series.ESMSupportedJujuSeries()
sort.Strings(series)
c.Assert(series, jc.SameContents, expectedSeries)
c.Assert(series, jc.DeepEquals, expectedSeries)
}

func (s *supportedSeriesSuite) TestOSSeries(c *gc.C) {
Expand Down

0 comments on commit 9ea36b3

Please sign in to comment.