Documentation ¶
Overview ¶
Versions API ¶
The Versions API provides information about versions of Constellation components.
This package defines API types that represents objects of the versions API. The types provide helper methods for validation and commonly used operations on the information contained in the objects. Especially the paths used for the API are defined in these helper methods.
The package also provides helper functions that can be used in context of the versions API, e.g. to validate versions.
Index ¶
- Constants
- Variables
- func CanonicalizeRef(ref string) string
- func MeasurementURL(version Version) (measurementURL, signatureURL *url.URL, err error)
- func NewClient(ctx context.Context, region, bucket, distributionID string, dryRun bool, ...) (*Client, CloseFunc, error)
- func NewReadOnlyClient(ctx context.Context, region, bucket, distributionID string, log *logger.Logger) (*Client, CloseFunc, error)
- func ValidateRef(ref string) error
- func ValidateStream(ref, stream string) error
- type CLIInfo
- type Client
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) DeleteRef(ctx context.Context, ref string) error
- func (c *Client) DeleteVersion(ctx context.Context, ver Version) error
- func (c *Client) FetchCLIInfo(ctx context.Context, cliInfo CLIInfo) (CLIInfo, error)
- func (c *Client) FetchImageInfo(ctx context.Context, imageInfo ImageInfo) (ImageInfo, error)
- func (c *Client) FetchVersionLatest(ctx context.Context, latest Latest) (Latest, error)
- func (c *Client) FetchVersionList(ctx context.Context, list List) (List, error)
- func (c *Client) UpdateCLIInfo(ctx context.Context, cliInfo CLIInfo) error
- func (c *Client) UpdateImageInfo(ctx context.Context, imageInfo ImageInfo) error
- func (c *Client) UpdateVersionLatest(ctx context.Context, latest Latest) error
- func (c *Client) UpdateVersionList(ctx context.Context, list List) error
- type CloseFunc
- type Fetcher
- func (f *Fetcher) FetchCLIInfo(ctx context.Context, cliInfo CLIInfo) (CLIInfo, error)
- func (f *Fetcher) FetchImageInfo(ctx context.Context, imageInfo ImageInfo) (ImageInfo, error)
- func (f *Fetcher) FetchVersionLatest(ctx context.Context, latest Latest) (Latest, error)
- func (f *Fetcher) FetchVersionList(ctx context.Context, list List) (List, error)
- type Granularity
- type ImageInfo
- type ImageInfoEntry
- type Latest
- type List
- type Version
- func (v Version) ArtifactPath(apiVer apiVersion) string
- func (v Version) ArtifactsURL(apiVer apiVersion) string
- func (v Version) Equal(other Version) bool
- func (v Version) Kind() VersionKind
- func (v Version) ListPath(gran Granularity) string
- func (v Version) ListURL(gran Granularity) string
- func (v Version) Major() string
- func (v Version) MajorMinor() string
- func (v Version) Ref() string
- func (v Version) ShortPath() string
- func (v Version) Stream() string
- func (v Version) Validate() error
- func (v Version) Version() string
- func (v Version) WithGranularity(gran Granularity) string
- type VersionKind
Constants ¶
const ReleaseRef = "-"
ReleaseRef is the ref used for release versions.
Variables ¶
var ( // APIV1 is the v1 API version. APIV1 = apiVersion{/* contains filtered or unexported fields */} // APIV2 is the v2 API version. APIV2 = apiVersion{/* contains filtered or unexported fields */} )
Functions ¶
func CanonicalizeRef ¶
CanonicalizeRef returns the canonicalized ref for the given ref.
func MeasurementURL ¶
MeasurementURL builds the measurement and signature URLs for the given version.
func NewClient ¶
func NewClient(ctx context.Context, region, bucket, distributionID string, dryRun bool, log *logger.Logger, ) (*Client, CloseFunc, error)
NewClient creates a new client for the versions API.
func NewReadOnlyClient ¶
func NewReadOnlyClient(ctx context.Context, region, bucket, distributionID string, log *logger.Logger, ) (*Client, CloseFunc, error)
NewReadOnlyClient creates a new read-only client. This client can be used to fetch objects but cannot write updates.
func ValidateRef ¶
ValidateRef checks if the given ref is a valid ref. Canonicalize the ref before checking if it is valid.
func ValidateStream ¶
ValidateStream checks if the given stream is a valid stream for the given ref.
Types ¶
type CLIInfo ¶
type CLIInfo struct { // Ref is the reference name of the CLI. Ref string `json:"ref,omitempty"` // Stream is the stream name of the CLI. Stream string `json:"stream,omitempty"` // Version is the version of the CLI. Version string `json:"version,omitempty"` // Kubernetes contains all compatible Kubernetes versions. Kubernetes []string `json:"kubernetes,omitempty"` }
CLIInfo contains information about a specific CLI version (i.e. it's compatibility with Kubernetes versions).
func (CLIInfo) ValidateRequest ¶
ValidateRequest validates the request parameters of the list. The Kubernetes slice must be empty.
type Client ¶
Client is a client for the versions API.
func (*Client) DeleteVersion ¶
DeleteVersion deletes the given version from the versions API. The version will be removed from version lists and latest versions, and the versioned objects are deleted. Notice that the versions API can get into an inconsistent state if the version is the latest version but there is no older version of the same minor version available. Manual update of latest versions is required in this case.
func (*Client) FetchCLIInfo ¶
FetchCLIInfo fetches the given CLI info from the versions API.
func (*Client) FetchImageInfo ¶
FetchImageInfo fetches the given image info from the versions API.
func (*Client) FetchVersionLatest ¶
FetchVersionLatest fetches the latest version from the versions API.
func (*Client) FetchVersionList ¶
FetchVersionList fetches the given version list from the versions API.
func (*Client) UpdateCLIInfo ¶
UpdateCLIInfo updates the given CLI info in the versions API.
func (*Client) UpdateImageInfo ¶
UpdateImageInfo updates the given image info in the versions API.
func (*Client) UpdateVersionLatest ¶
UpdateVersionLatest updates the latest version in the versions API.
type Fetcher ¶
type Fetcher struct { fetcher.HTTPClient // contains filtered or unexported fields }
Fetcher fetches version API resources without authentication.
func (*Fetcher) FetchCLIInfo ¶
FetchCLIInfo fetches the given cli info from the versions API.
func (*Fetcher) FetchImageInfo ¶
FetchImageInfo fetches the given image info from the versions API.
func (*Fetcher) FetchVersionLatest ¶
FetchVersionLatest fetches the latest version from the versions API.
type Granularity ¶
type Granularity int
Granularity represents the granularity of a semantic version.
const ( // GranularityUnknown is the default granularity. GranularityUnknown Granularity = iota // GranularityMajor is the granularity of a major version, e.g. "v1". // Lists with granularity "major" map from a major version to a list of minor versions. GranularityMajor // GranularityMinor is the granularity of a minor version, e.g. "v1.0". // Lists with granularity "minor" map from a minor version to a list of patch versions. GranularityMinor // GranularityPatch is the granularity of a patch version, e.g. "v1.0.0". // There are no lists with granularity "patch". GranularityPatch )
func GranularityFromString ¶
func GranularityFromString(s string) Granularity
GranularityFromString returns the granularity for the given string.
func (Granularity) MarshalJSON ¶
func (g Granularity) MarshalJSON() ([]byte, error)
MarshalJSON marshals the granularity to JSON.
func (Granularity) String ¶
func (g Granularity) String() string
String returns the string representation of the granularity.
func (*Granularity) UnmarshalJSON ¶
func (g *Granularity) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the granularity from JSON.
type ImageInfo ¶
type ImageInfo struct { // Ref is the reference name of the image. Ref string `json:"ref,omitempty"` // Stream is the stream name of the image. Stream string `json:"stream,omitempty"` // Version is the version of the image. Version string `json:"version,omitempty"` // List contains the image variants for this version. List []ImageInfoEntry `json:"list,omitempty"` }
ImageInfo contains information about the OS images for a specific version.
func MergeImageInfos ¶
MergeImageInfos combines the image info entries from multiple sources into a single image info object.
func (ImageInfo) ValidateRequest ¶
ValidateRequest validates the request parameters of the list. The provider specific maps must be empty.
type ImageInfoEntry ¶
type ImageInfoEntry struct { CSP string `json:"csp"` AttestationVariant string `json:"attestationVariant"` Reference string `json:"reference"` Region string `json:"region,omitempty"` }
ImageInfoEntry contains information about a single image variant.
type Latest ¶
type Latest struct { // Ref is the branch name this latest version belongs to. Ref string `json:"ref,omitempty"` // Stream is stream name this latest version belongs to. Stream string `json:"stream,omitempty"` // Kind is the kind of resource this latest version is for. Kind VersionKind `json:"kind,omitempty"` // Version is the latest version for this ref, stream and kind. Version string `json:"version,omitempty"` }
Latest is the latest version of a kind of resource.
func (Latest) ValidateRequest ¶
ValidateRequest checks if this latest version beside values that are fetched.
type List ¶
type List struct { // Ref is the branch name the list belongs to. Ref string `json:"ref,omitempty"` // Stream is the update stream of the list. Stream string `json:"stream,omitempty"` // Granularity is the granularity of the base version of this list. // It can be either "major" or "minor". Granularity Granularity `json:"granularity,omitempty"` // Base is the base version of the list. // Every version in the list is a finer-grained version of this base version. Base string `json:"base,omitempty"` // Kind is the kind of resource this list is for. Kind VersionKind `json:"kind,omitempty"` // Versions is a list of all versions in this list. Versions []string `json:"versions,omitempty"` }
List represents a list of versions for a kind of resource. It has a granularity of either "major" or "minor".
For example, a List with granularity "major" could contain the base version "v1" and a list of minor versions "v1.0", "v1.1", "v1.2" etc. A List with granularity "minor" could contain the base version "v1.0" and a list of patch versions "v1.0.0", "v1.0.1", "v1.0.2" etc.
func (List) StructuredVersions ¶
StructuredVersions returns the versions of the list as slice of Version structs.
func (List) Validate ¶
Validate checks if the list is valid. This performs the following checks: - The ref is set. - The stream is supported. - The granularity is "major" or "minor". - The kind is supported. - The base version is a valid semantic version that matches the granularity. - All versions in the list are valid semantic versions that are finer-grained than the base version.
func (List) ValidateRequest ¶
ValidateRequest validates the request parameters of the list. The versions field must be empty.
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version represents a version. A version has a ref, stream, version string and kind.
Notice that version is a meta object to the versions API and there isn't an actual corresponding object in the S3 bucket. Therefore, the version object doesn't have a URL or JSON path.
Versions fields are private so the type can be used in other packages by defining private interfaces.
func NewVersion ¶ added in v2.10.0
func NewVersion(ref, stream, version string, kind VersionKind) (Version, error)
NewVersion creates a new Version object and validates it.
func NewVersionFromShortPath ¶
func NewVersionFromShortPath(shortPath string, kind VersionKind) (Version, error)
NewVersionFromShortPath creates a new Version from a version short path.
func (Version) ArtifactPath ¶
ArtifactPath returns the path to the artifacts stored for this version. The path points to a directory.
func (Version) ArtifactsURL ¶
ArtifactsURL returns the URL to the artifacts stored for this version. The URL points to a directory.
func (Version) ListPath ¶
func (v Version) ListPath(gran Granularity) string
ListPath returns the path of the list with the given granularity, this version is listed in. For example, assing GranularityMajor returns the path of the versions list that maps the major version of this version to its minor version. In case of an unknown granularity, an empty string is returned.
func (Version) ListURL ¶
func (v Version) ListURL(gran Granularity) string
ListURL returns the URL of the list with the given granularity, this version is listed in. For example, assing GranularityMajor returns the URL of the versions list that maps the major version of this version to its minor version. In case of an unknown granularity, an empty string is returned.
func (Version) Major ¶
Major returns the major version corresponding to the version. For example, if the version is "v1.2.3", the major version is "v1".
func (Version) MajorMinor ¶
MajorMinor returns the major and minor version corresponding to the version. For example, if the version is "v1.2.3", the major and minor version is "v1.2".
func (Version) WithGranularity ¶
func (v Version) WithGranularity(gran Granularity) string
WithGranularity returns the version with the given granularity.
For example, if the version is "v1.2.3" and the granularity is GranularityMajor, the returned version is "v1". This is a helper function for Major() and MajorMinor() and v.version. In case of an unknown granularity, an empty string is returned.
type VersionKind ¶
type VersionKind int
VersionKind represents the kind of resource the version versions.
const ( // VersionKindUnknown is the default value for VersionKind. VersionKindUnknown VersionKind = iota // VersionKindImage is the kind for image versions. VersionKindImage // VersionKindCLI is the kind for CLI versions. VersionKindCLI )
func VersionKindFromString ¶
func VersionKindFromString(s string) VersionKind
VersionKindFromString returns the VersionKind for the given string.
func (VersionKind) MarshalJSON ¶
func (k VersionKind) MarshalJSON() ([]byte, error)
MarshalJSON marshals the VersionKind to JSON.
func (VersionKind) String ¶
func (k VersionKind) String() string
String returns the string representation of the VersionKind.
func (*VersionKind) UnmarshalJSON ¶
func (k *VersionKind) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the VersionKind from JSON.