series

package
Version: v2.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2021 License: LGPL-3.0 Imports: 12 Imported by: 22

Documentation

Overview

series provides helpers for determining the series of a host, and translating from os to series.

Index

Constants

This section is empty.

Variables

View Source
var (
	// HostSeries returns the series of the machine the current process is
	// running on (overrideable var for testing).
	HostSeries func() (string, error) = hostSeries

	// MustHostSeries calls HostSeries and panics if there is an error.
	MustHostSeries = mustHostSeries
)
View Source
var UbuntuDistroInfo = "/usr/share/distro-info/ubuntu.csv"

UbuntuDistroInfo references a csv that contains all the distro information about info. This includes what the names and versions of a distro and if the distro is supported or not.

Functions

func CentOSVersionSeries

func CentOSVersionSeries(version string) (string, error)

CentOSVersionSeries validates that the supplied series (eg: centos7) is supported.

func ESMSupportedJujuSeries

func ESMSupportedJujuSeries() []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 GetOSFromSeries

func GetOSFromSeries(series string) (os.OSType, error)

GetOSFromSeries will return the operating system based on the series that is passed to it

func IsUnknownOSForSeriesError

func IsUnknownOSForSeriesError(err error) bool

IsUnknownOSForSeriesError returns true if err is of type unknownOSForSeriesError.

func IsUnknownSeriesVersionError

func IsUnknownSeriesVersionError(err error) bool

IsUnknownSeriesVersionError returns true if err is of type unknownSeriesVersionError.

func IsUnknownVersionSeriesError

func IsUnknownVersionSeriesError(err error) bool

IsUnknownVersionSeriesError returns true if err is of type unknownVersionSeriesError.

func IsWindowsNano

func IsWindowsNano(series string) bool

IsWindowsNano tells us whether the provided series is a nano series. It may seem futile at this point, but more nano series will come up with time. This is here and not in a windows specific package because we might want to take decisions dependant on whether we have a nano series or not in more general code.

func LatestLts

func LatestLts() string

LatestLts returns the Latest LTS Series found in distro-info

func LocalSeriesVersionInfo added in v2.1.1

func LocalSeriesVersionInfo() (jujuos.OSType, map[string]SeriesVersionInfo, error)

LocalSeriesVersionInfo returns the local series versions and OS type.

func MustOSFromSeries

func MustOSFromSeries(series string) os.OSType

MustOSFromSeries will panic if the series represents an "unknown" operating system.

func OSSupportedSeries

func OSSupportedSeries(os os.OSType) []string

OSSupportedSeries returns the series of the specified OS on which we can run Juju workloads.

func OverwrittenWindowsVersions

func OverwrittenWindowsVersions() []string

func ReleaseVersion

func ReleaseVersion() string

ReleaseVersion looks for the value of VERSION_ID in the content of the os-release. If the value is not found, the file is not found, or an error occurs reading the file, an empty string is returned.

func SeriesVersion

func SeriesVersion(series string) (string, error)

SeriesVersion returns the version for the specified series.

func SetLatestLtsForTesting

func SetLatestLtsForTesting(series string) string

SetLatestLtsForTesting is provided to allow tests to override the lts series used and decouple the tests from the host by avoiding calling out to distro-info. It returns the previous setting so that it may be set back to the original value by the caller.

func SupportedJujuControllerSeries

func SupportedJujuControllerSeries() []string

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 SupportedJujuSeries

func SupportedJujuSeries() []string

SupportedJujuSeries returns a slice of juju supported series that also target a workload.

func SupportedJujuWorkloadSeries

func SupportedJujuWorkloadSeries() []string

SupportedJujuWorkloadSeries returns a slice of juju supported series that target a workload (deploying a charm).

The series are sorted in ubuntu release version, anything that isn't ubuntu release is then sorted by name.

- focal (20.04)
- bionic (18.04)
- xenial (16.04)
- centos7
- centos8
- genericlinux
- kubernetes
- opensuseleap
- win10
- win2008r2

Anything not supported is left out.

func SupportedLts

func SupportedLts() []string

SupportedLts are the current supported LTS series in ascending order.

func SupportedSeries

func SupportedSeries() []string

SupportedSeries returns the series on which we can run Juju workloads.

func UbuntuSeriesVersion

func UbuntuSeriesVersion(series string) (string, error)

UbuntuSeriesVersion returns the ubuntu version for the specified series.

func UpdateSeriesVersions

func UpdateSeriesVersions() error

UpdateSeriesVersions forces an update of the series versions by querying distro-info if possible.

func VersionSeries

func VersionSeries(version string) (string, error)

VersionSeries returns the series (e.g.trusty) for the specified version (e.g. 14.04).

func WindowsVersionSeries

func WindowsVersionSeries(version string) (string, error)

WindowsVersionSeries returns the series (eg: win2012r2) for the specified version (eg: Windows Server 2012 R2 Standard)

func WindowsVersions

func WindowsVersions() map[string]string

WindowsVersions returns all windows versions as a map If we have nan and windows version in common, nano takes precedence

Types

type DistroInfo

type DistroInfo struct {
	// contains filtered or unexported fields
}

DistroInfo holds records of which distro is supported or not. Refreshing will cause the distro to go out and fetch new information from the local file system to update itself.

func NewDistroInfo

func NewDistroInfo(path string) *DistroInfo

NewDistroInfo creates a new DistroInfo for querying the distro.

func (*DistroInfo) Refresh

func (d *DistroInfo) Refresh() error

Refresh will attempt to update the information it has about each distro and if the distro is supported or not.

func (*DistroInfo) SeriesInfo

func (d *DistroInfo) SeriesInfo(seriesName string) (DistroInfoSerie, bool)

SeriesInfo returns the DistroInfoSerie for the series name.

type DistroInfoSerie

type DistroInfoSerie struct {
	Version  string
	CodeName string
	Series   string
	Created  time.Time
	Released time.Time
	EOL      time.Time
}

DistroInfoSerie holds the information about each distro.

func (*DistroInfoSerie) LTS

func (d *DistroInfoSerie) LTS() bool

LTS returns true if the series is an LTS or not.

func (*DistroInfoSerie) Supported

func (d *DistroInfoSerie) Supported(now time.Time) bool

Supported returns true if the underlying series is supported or not. It expects the time to be in UTC.

type FileSystem

type FileSystem interface {
	Open(string) (*os.File, error)
	Exists(string) bool
}

FileSystem defines a interface for interacting with the host os.

type SeriesVersionInfo added in v2.1.1

type SeriesVersionInfo struct {
	Version string
	// LTS provides a lookup for a LTS series.  Like seriesVersions,
	// the values here are current at the time of writing.
	LTS bool
	// Supported defines if Juju classifies the series as officially supported.
	Supported bool
	// Extended security maintenance for customers, extends the supported bool
	// for how Juju classifies the series.
	ESMSupported bool
	// WarningInfo shows any potential issues when parsing the series version
	// information.
	WarningInfo []string
	// CreatedByLocalDistroInfo indicates that the series version was created
	// by the local distro-info information on the system.
	// This is useful to understand why a version appears yet is not supported.
	CreatedByLocalDistroInfo bool
}

SeriesVersionInfo represents a ubuntu series that includes the version, if the series is an LTS and the supported defines if Juju supports the series version.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL