bond

package module
v0.0.0-...-baa34e0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

README

=================================================
``bond`` -- MongoDB Artifact Download API Utility
=================================================

MongoDB publishes data feeds regarding all publically available versions. Bond
is a library for interacting with this data and for downloading different
versions of MongoDB primarily targeted at using MongoDB in various testing and
integration workflows.  

While the data provided by the API is stable, there has been some evolution of
the naming and content of MongoDB release artifacts over time, and there may
be some cases that bond may handle incorrectly as a result. Please feel free
to create issues if you encounter problems or would like to add a feature.

Bond is available for use under the terms of the Apache License (v2). Please
see the `godoc for complete API documentation and examples
<https://godoc.org/github.com/deciduosity/bond>`_.




Documentation

Overview

MongoDB Versions

The MongoDBVersion type provides support for interacting with MongoDB versions. This type makes it possible to validate MongoDB version numbers and ask common questions about MongoDB versions.

Index

Constants

View Source
const (
	Enterprise        MongoDBEdition = "enterprise"
	CommunityTargeted                = "targeted"
	Base                             = "base"
)

Specific values for Editions.

View Source
const (
	ZSeries MongoDBArch = "s390x"
	POWER               = "ppc64le"
	AMD64               = "x86_64"
	X86                 = "i686"
)

Specific values for Architectures.

Variables

This section is empty.

Functions

func CacheDownload

func CacheDownload(ctx context.Context, ttl time.Duration, url, path string, force bool) ([]byte, error)

CacheDownload downloads a resource (url) into a file (path); if the file already exists CaceheDownlod does not download a new copy of the file, unless local file is older than the ttl, or the force option is specified. CacheDownload returns the contents of the file.

func DownloadFile

func DownloadFile(ctx context.Context, url, fileName string) error

DownloadFile downloads a resource (url) into a file specified by fileName. Also creates enclosing directories as needed.

func GetHTTPClient

func GetHTTPClient() *http.Client

func GetTargetDistro

func GetTargetDistro() string

GetTargetDistro attempts to discover the targeted distro name based on the current environment and falls back to the generic builds for a platform.

In situations builds target a specific minor release of a platform (and specify that version in their name) (e.g. debian and rhel), the current platform must match the build platform exactly.

func PutHTTPClient

func PutHTTPClient(c *http.Client)

Types

type ArtifactDownload

type ArtifactDownload struct {
	Arch    MongoDBArch
	Edition MongoDBEdition
	Target  string
	Archive struct {
		Debug  string `bson:"debug_symbols" json:"debug_symbols" yaml:"debug_symbols"`
		Sha1   string
		Sha256 string
		URL    string `bson:"url" json:"url" yaml:"url"`
	}
	Msi      string
	Packages []string
}

ArtifactDownload represents a single build or download in the MongoDB build artifacts feed. A version has many builds. See http://downloads.mongodb.org/full.json for an example.

func (ArtifactDownload) GetArchive

func (dl ArtifactDownload) GetArchive() string

GetArchive returns the URL for the artifacts archive for a given download or build.

func (ArtifactDownload) GetBuildOptions

func (dl ArtifactDownload) GetBuildOptions() BuildOptions

GetBuildOptions returns a BuildOptions object that represents the download.

func (ArtifactDownload) GetPackages

func (dl ArtifactDownload) GetPackages() []string

GetPackages returns a slice of urls of all packages for a given build.

type ArtifactVersion

type ArtifactVersion struct {
	Version   string
	Downloads []ArtifactDownload
	GitHash   string

	ProductionRelease  bool `json:"production_release"`
	DevelopmentRelease bool `json:"development_release"`
	Current            bool
	// contains filtered or unexported fields
}

ArtifactVersion represents a document in the Version field of the MongoDB build information feed. See http://downloads.mongodb.org/full.json for an example.ownload

func (*ArtifactVersion) GetBuildTypes

func (version *ArtifactVersion) GetBuildTypes() *BuildTypes

GetBuildTypes builds, from an ArtifactsVersion object a BuildTypes object that reports on the available builds for this version.

func (*ArtifactVersion) GetDownload

func (version *ArtifactVersion) GetDownload(key BuildOptions) (ArtifactDownload, error)

GetDownload returns a matching ArtifactDownload object given a BuildOptions object.

func (*ArtifactVersion) String

func (version *ArtifactVersion) String() string

type ArtifactsFeed

type ArtifactsFeed struct {
	Versions []*ArtifactVersion
	// contains filtered or unexported fields
}

ArtifactsFeed represents the entire structure of the MongoDB build information feed. See http://downloads.mongodb.org/full.json for an example.

func GetArtifactsFeed

func GetArtifactsFeed(ctx context.Context, path string) (*ArtifactsFeed, error)

GetArtifactsFeed parses a ArtifactsFeed object from a file on the file system. This operation will automatically refresh the feed from http://downloads.mongodb.org/full.json if the modification time of the file on the file system is more than 48 hours old.

func NewArtifactsFeed

func NewArtifactsFeed(path string) (*ArtifactsFeed, error)

NewArtifactsFeed takes the path of a file and returns an empty ArtifactsFeed object. You may specify an empty string as an argument to return a feed object homed on a temporary directory.

func (*ArtifactsFeed) GetArchives

func (feed *ArtifactsFeed) GetArchives(releases []string, options BuildOptions) (<-chan string, <-chan error)

GetArchives provides an iterator for all archives given a list of releases (versions) for a specific set of build operations. Returns channels of urls (strings) and errors. Read from the error channel, after completing all results.

func (*ArtifactsFeed) GetCurrentArchive

func (feed *ArtifactsFeed) GetCurrentArchive(series string, options BuildOptions) (string, error)

GetCurrentArchive is a helper to download the latest stable release for a specific series.

func (*ArtifactsFeed) GetLatestArchive

func (feed *ArtifactsFeed) GetLatestArchive(series string, options BuildOptions) (string, error)

GetLatestArchive given a release series (e.g. 3.2, 3.0, or 3.0), return the URL of the "latest" (e.g. nightly) build archive. These builds are atypical, and given how they're produced, may not necessarily reflect the most recent released or unreleased changes on a branch.

func (*ArtifactsFeed) GetStableRelease

func (feed *ArtifactsFeed) GetStableRelease(series string) (*ArtifactVersion, error)

GetStableRelease returns the latest official release for a specific series.

func (*ArtifactsFeed) GetVersion

func (feed *ArtifactsFeed) GetVersion(release string) (*ArtifactVersion, bool)

GetVersion takes a version string and returns the entire Artifacts version. The second value indicates if that release exists in the current feed.

func (*ArtifactsFeed) Populate

func (feed *ArtifactsFeed) Populate(ctx context.Context, ttl time.Duration) error

Populate updates the local copy of the full feed in the the feed's cache if the local file doesn't exist or is older than the specified TTL. Additional Populate parses the data feed, using the Reload method.

func (*ArtifactsFeed) Reload

func (feed *ArtifactsFeed) Reload(data []byte) error

Reload takes the content of the full.json file and loads this data into the current ArtifactsFeed object, overwriting any existing data.

type BuildCatalog

type BuildCatalog struct {
	Path string
	// contains filtered or unexported fields
}

BuildCatalog is a structure that represents a group of MongoDB artifacts managed by bond, and provides an interface for retrieving artifacts.

func NewCatalog

func NewCatalog(ctx context.Context, path string) (*BuildCatalog, error)

NewCatalog populates and returns a BuildCatalog object from a given path.

func (*BuildCatalog) Add

func (c *BuildCatalog) Add(fileName string) error

Add adds a build to the catalog, and returns an error if it's not a valid build. The build file name must be a part of the path specified when creating the BuildCatalog object, otherwise Add will not add this item to the cache and return an error and .

func (*BuildCatalog) Contents

func (c *BuildCatalog) Contents() map[BuildInfo]string

Contents returns a copy of the contents of the catalog.

func (*BuildCatalog) Get

func (c *BuildCatalog) Get(version, edition, target, arch string, debug bool) (string, error)

Get returns the path to a build in the BuildCatalog based on the parameters presented. Returns an error if a build matching the parameters specified does not exist in the cache.

func (*BuildCatalog) String

func (c *BuildCatalog) String() string

type BuildInfo

type BuildInfo struct {
	Version string       `json:"version"`
	Options BuildOptions `json:"options"`
}

BuildInfo captures information about a specific, single, build, and includes information about the build variant (i.e. edition, target platform, and architecture) as well as the version.

func GetInfoFromFileName

func GetInfoFromFileName(fileName string) (BuildInfo, error)

GetInfoFromFileName given a path, parses information about the build from that string and returns a BuildInfo object.

func (*BuildInfo) String

func (i *BuildInfo) String() string

type BuildOptions

type BuildOptions struct {
	Target  string         `json:"target"`
	Arch    MongoDBArch    `json:"arch"`
	Edition MongoDBEdition `json:"edition"`
	Debug   bool           `json:"debug"`
}

BuildOptions is a common method to describe a build variant.

func (BuildOptions) GetBuildInfo

func (o BuildOptions) GetBuildInfo(version string) BuildInfo

GetBuildInfo given a version string, generates a BuildInfo object from a BuildOptions object.

func (BuildOptions) String

func (o BuildOptions) String() string

func (BuildOptions) Validate

func (o BuildOptions) Validate() error

Validate checks a BuildOption structure and ensures that there are no errors.

type BuildTypes

type BuildTypes struct {
	Version       string           `bson:"version" json:"version" yaml:"version"`
	Targets       []string         `bson:"targets" json:"targets" yaml:"targets"`
	Editions      []MongoDBEdition `bson:"editions" json:"editions" yaml:"editions"`
	Architectures []MongoDBArch    `bson:"architectures" json:"architectures" yaml:"architectures"`
}

BuildTypes represents all information about builds in a cache.

func (BuildTypes) String

func (b BuildTypes) String() string

type MongoDBArch

type MongoDBArch string

MongoDBArch provides values that appear in the "arch" field of the feed and map onto specific processor architectures.

type MongoDBEdition

type MongoDBEdition string

MongoDBEdition provides values that appear in the "edition" field of the feed, and map to specific builds of MongoDB.

type MongoDBVersion

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

MongoDBVersion is a structure representing a version identifier for MongoDB. Use the associated methods to ask questions about MongoDB versions. All parsing of versions happens during construction, and individual method calls are very light-weight.

func ConvertVersion

func ConvertVersion(v interface{}) (*MongoDBVersion, error)

ConvertVersion takes an un-typed object and attempts to convert it to a version object. For use with compactor functions.

func NewMongoDBVersion

func NewMongoDBVersion(version string) (*MongoDBVersion, error)

NewMongoDBVersion takes a string representing a MongoDB version and returns a MongoDBVersion object. If the input string is not a valid version, or there were problems parsing the string, the error value is non-nil. All parsing of a version happens during this phase.

func (*MongoDBVersion) IsDevelopmentBuild

func (v *MongoDBVersion) IsDevelopmentBuild() bool

IsDevelopmentBuild returns true for all non-release builds, including nightly snapshots and all testing and development builds.

func (*MongoDBVersion) IsDevelopmentSeries

func (v *MongoDBVersion) IsDevelopmentSeries() bool

IsDevelopmentSeries returns true for development (snapshot) releases. These versions are those where the second component (e.g. "Minor" in semantic versioning terms) are odd, and false otherwise.

func (*MongoDBVersion) IsEqualTo

func (v *MongoDBVersion) IsEqualTo(version *MongoDBVersion) bool

IsEqualTo returns true when "version" is the same as the object itself.

func (*MongoDBVersion) IsGreaterThan

func (v *MongoDBVersion) IsGreaterThan(version *MongoDBVersion) bool

IsGreaterThan returns true when "version" is greater than (e.g. later) than the object itself.

func (*MongoDBVersion) IsGreaterThanOrEqualTo

func (v *MongoDBVersion) IsGreaterThanOrEqualTo(version *MongoDBVersion) bool

IsGreaterThanOrEqualTo returns true when "version" is greater than or equal to (e.g. the same as or later than) the object itself.

func (*MongoDBVersion) IsInitialStableReleaseCandidate

func (v *MongoDBVersion) IsInitialStableReleaseCandidate() bool

IsInitialStableReleaseCandidate returns true for release candidates for the initial public release of a new stable release series.

func (*MongoDBVersion) IsLessThan

func (v *MongoDBVersion) IsLessThan(version *MongoDBVersion) bool

IsLessThan returns true when "version" is less than (e.g. earlier) than the object itself.

func (*MongoDBVersion) IsLessThanOrEqualTo

func (v *MongoDBVersion) IsLessThanOrEqualTo(version *MongoDBVersion) bool

IsLessThanOrEqualTo returns true when "version" is less than or equal to (e.g. earlier or the same as) the object itself.

func (*MongoDBVersion) IsNotEqualTo

func (v *MongoDBVersion) IsNotEqualTo(version *MongoDBVersion) bool

IsNotEqualTo returns true when "version" is the different from the object itself.

func (*MongoDBVersion) IsRelease

func (v *MongoDBVersion) IsRelease() bool

IsRelease returns true for all version strings that refer to a release, including development, release candidate and GA releases, and false otherwise. Other builds, including test builds and "nightly" snapshots of MongoDB have version strings, but are not releases.

func (*MongoDBVersion) IsReleaseCandidate

func (v *MongoDBVersion) IsReleaseCandidate() bool

IsReleaseCandidate returns true for releases that have the "rc[0-9]" tag and false otherwise.

func (*MongoDBVersion) IsStableSeries

func (v *MongoDBVersion) IsStableSeries() bool

IsStableSeries returns true for stable releases, ones where the second component of the version string (i.e. "Minor" in semantic versioning terms) are even, and false otherwise.

func (*MongoDBVersion) RcNumber

func (v *MongoDBVersion) RcNumber() int

RcNumber returns an integer for the RC counter. For non-rc releases, returns -1.

func (*MongoDBVersion) Series

func (v *MongoDBVersion) Series() string

Series return the release series, generally the first two components of a version. For example for 3.2.6, the series is 3.2.

func (*MongoDBVersion) StableReleaseSeries

func (v *MongoDBVersion) StableReleaseSeries() string

StableReleaseSeries returns a series string (e.g. X.Y) for this version. For stable releases, the output is the same as .Series(). For development releases, this method returns the *next* stable series.

func (*MongoDBVersion) String

func (v *MongoDBVersion) String() string

String returns a string representation of the MongoDB version number.

type MongoDBVersionSlice

type MongoDBVersionSlice []MongoDBVersion

MongoDBVersionSlice is an alias for []MongoDBVersion that supports the sort.Sorter interface, and makes it possible to sort slices of MongoDB versions.

func (MongoDBVersionSlice) Len

func (s MongoDBVersionSlice) Len() int

Len is required by the sort.Sorter interface. Returns the length of the slice.

func (MongoDBVersionSlice) Less

func (s MongoDBVersionSlice) Less(i, j int) bool

Less is a required by the sort.Sorter interface. Uses blang/semver to compare two versions.

func (MongoDBVersionSlice) Sort

func (s MongoDBVersionSlice) Sort()

Sort provides a wrapper around sort.Sort() for slices of MongoDB versions objects.

func (MongoDBVersionSlice) String

func (s MongoDBVersionSlice) String() string

String() adds suport for the Stringer interface, which makes it possible to print slices of MongoDB versions as comma separated lists.

func (MongoDBVersionSlice) Swap

func (s MongoDBVersionSlice) Swap(i, j int)

Swap is a required by the sort.Sorter interface. Changes the position of two elements in the slice.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL