{"modulePath":"github.com/flashbots/cvm-reverse-proxy","version":"v0.1.9","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package versionsapi\n\n### Versions API {#hdr-Versions_API}\n\nThe Versions API provides information about versions of Constellation components.\n\nThis 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.\n\nThe package also provides helper functions that can be used in context of the versions API, e.g. to validate versions.\n\n## Constants\n\n```go\nconst ReleaseRef = \"-\"\n```\nReleaseRef is the ref used for release versions.\n\n## Variables\n\n```go\nvar (\n\t// APIV1 is the v1 API version.\n\tAPIV1 = apiVersion{/* contains filtered or unexported fields */}\n\t// APIV2 is the v2 API version.\n\tAPIV2 = apiVersion{/* contains filtered or unexported fields */}\n)\n```\n\n## Functions\n\n```go\nfunc CanonicalizeRef(ref string) string\n```\nCanonicalizeRef returns the canonicalized ref for the given ref.\n\n```go\nfunc MeasurementURL(version Version) (measurementURL, signatureURL *url.URL, err error)\n```\nMeasurementURL builds the measurement and signature URLs for the given version.\n\n```go\nfunc NewClient(ctx context.Context, region, bucket, distributionID string, dryRun bool,\n\tlog *slog.Logger,\n) (*Client, CloseFunc, error)\n```\nNewClient creates a new client for the versions API.\n\n```go\nfunc NewReadOnlyClient(ctx context.Context, region, bucket, distributionID string,\n\tlog *slog.Logger,\n) (*Client, CloseFunc, error)\n```\nNewReadOnlyClient creates a new read-only client. This client can be used to fetch objects but cannot write updates.\n\n```go\nfunc ValidateRef(ref string) error\n```\nValidateRef checks if the given ref is a valid ref. Canonicalize the ref before checking if it is valid.\n\n```go\nfunc ValidateStream(ref, stream string) error\n```\nValidateStream checks if the given stream is a valid stream for the given ref.\n\n## Types\n\n```go\ntype CLIInfo struct {\n\t// Ref is the reference name of the CLI.\n\tRef string `json:\"ref,omitempty\"`\n\t// Stream is the stream name of the CLI.\n\tStream string `json:\"stream,omitempty\"`\n\t// Version is the version of the CLI.\n\tVersion string `json:\"version,omitempty\"`\n\t// Kubernetes contains all compatible Kubernetes versions.\n\tKubernetes []string `json:\"kubernetes,omitempty\"`\n}\n```\nCLIInfo contains information about a specific CLI version (i.e. it's compatibility with Kubernetes versions).\n\n```go\nfunc (c CLIInfo) JSONPath() string\n```\nJSONPath returns the S3 JSON path for this object.\n\n```go\nfunc (c CLIInfo) URL() (string, error)\n```\nURL returns the URL to the JSON file for this object.\n\n```go\nfunc (c CLIInfo) Validate() error\n```\nValidate checks if the CLI info is valid.\n\n```go\nfunc (c CLIInfo) ValidateRequest() error\n```\nValidateRequest validates the request parameters of the list. The Kubernetes slice must be empty.\n\n```go\ntype Client struct {\n\t*apiclient.Client\n\t// contains filtered or unexported fields\n}\n```\nClient is a client for the versions API.\n\n```go\nfunc (c *Client) Close(ctx context.Context) error\n```\nClose closes the client.\n\n```go\nfunc (c *Client) DeleteRef(ctx context.Context, ref string) error\n```\nDeleteRef deletes the given ref from the versions API.\n\n```go\nfunc (c *Client) DeleteVersion(ctx context.Context, ver Version) error\n```\nDeleteVersion 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.\n\n```go\nfunc (c *Client) FetchCLIInfo(ctx context.Context, cliInfo CLIInfo) (CLIInfo, error)\n```\nFetchCLIInfo fetches the given CLI info from the versions API.\n\n```go\nfunc (c *Client) FetchImageInfo(ctx context.Context, imageInfo ImageInfo) (ImageInfo, error)\n```\nFetchImageInfo fetches the given image info from the versions API.\n\n```go\nfunc (c *Client) FetchVersionLatest(ctx context.Context, latest Latest) (Latest, error)\n```\nFetchVersionLatest fetches the latest version from the versions API.\n\n```go\nfunc (c *Client) FetchVersionList(ctx context.Context, list List) (List, error)\n```\nFetchVersionList fetches the given version list from the versions API.\n\n```go\nfunc (c *Client) UpdateCLIInfo(ctx context.Context, cliInfo CLIInfo) error\n```\nUpdateCLIInfo updates the given CLI info in the versions API.\n\n```go\nfunc (c *Client) UpdateImageInfo(ctx context.Context, imageInfo ImageInfo) error\n```\nUpdateImageInfo updates the given image info in the versions API.\n\n```go\nfunc (c *Client) UpdateVersionLatest(ctx context.Context, latest Latest) error\n```\nUpdateVersionLatest updates the latest version in the versions API.\n\n```go\nfunc (c *Client) UpdateVersionList(ctx context.Context, list List) error\n```\nUpdateVersionList updates the given version list in the versions API.\n\n```go\ntype CloseFunc func(ctx context.Context) error\n```\nCloseFunc is a function that closes the client.\n\n```go\ntype Fetcher struct {\n\tfetcher.HTTPClient\n\t// contains filtered or unexported fields\n}\n```\nFetcher fetches version API resources without authentication.\n\n```go\nfunc NewFetcher() *Fetcher\n```\nNewFetcher returns a new Fetcher.\n\n```go\nfunc (f *Fetcher) FetchCLIInfo(ctx context.Context, cliInfo CLIInfo) (CLIInfo, error)\n```\nFetchCLIInfo fetches the given cli info from the versions API.\n\n```go\nfunc (f *Fetcher) FetchImageInfo(ctx context.Context, imageInfo ImageInfo) (ImageInfo, error)\n```\nFetchImageInfo fetches the given image info from the versions API.\n\n```go\nfunc (f *Fetcher) FetchVersionLatest(ctx context.Context, latest Latest) (Latest, error)\n```\nFetchVersionLatest fetches the latest version from the versions API.\n\n```go\nfunc (f *Fetcher) FetchVersionList(ctx context.Context, list List) (List, error)\n```\nFetchVersionList fetches the given version list from the versions API.\n\n```go\ntype Granularity int\n```\nGranularity represents the granularity of a semantic version.\n\n```go\nconst (\n\t// GranularityUnknown is the default granularity.\n\tGranularityUnknown Granularity = iota\n\t// GranularityMajor is the granularity of a major version, e.g. \"v1\".\n\t// Lists with granularity \"major\" map from a major version to a list of minor versions.\n\tGranularityMajor\n\t// GranularityMinor is the granularity of a minor version, e.g. \"v1.0\".\n\t// Lists with granularity \"minor\" map from a minor version to a list of patch versions.\n\tGranularityMinor\n\t// GranularityPatch is the granularity of a patch version, e.g. \"v1.0.0\".\n\t// There are no lists with granularity \"patch\".\n\tGranularityPatch\n)\n```\n\n```go\nfunc GranularityFromString(s string) Granularity\n```\nGranularityFromString returns the granularity for the given string.\n\n```go\nfunc (g Granularity) MarshalJSON() ([]byte, error)\n```\nMarshalJSON marshals the granularity to JSON.\n\n```go\nfunc (g Granularity) String() string\n```\nString returns the string representation of the granularity.\n\n```go\nfunc (g *Granularity) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON unmarshals the granularity from JSON.\n\n```go\ntype ImageInfo struct {\n\t// Ref is the reference name of the image.\n\tRef string `json:\"ref,omitempty\"`\n\t// Stream is the stream name of the image.\n\tStream string `json:\"stream,omitempty\"`\n\t// Version is the version of the image.\n\tVersion string `json:\"version,omitempty\"`\n\t// List contains the image variants for this version.\n\tList []ImageInfoEntry `json:\"list,omitempty\"`\n}\n```\nImageInfo contains information about the OS images for a specific version.\n\n```go\nfunc MergeImageInfos(infos ...ImageInfo) (ImageInfo, error)\n```\nMergeImageInfos combines the image info entries from multiple sources into a single image info object.\n\n```go\nfunc (i ImageInfo) JSONPath() string\n```\nJSONPath returns the S3 JSON path for this object.\n\n```go\nfunc (i ImageInfo) URL() (string, error)\n```\nURL returns the URL to the JSON file for this object.\n\n```go\nfunc (i ImageInfo) Validate() error\n```\nValidate checks if the image info is valid.\n\n```go\nfunc (i ImageInfo) ValidateRequest() error\n```\nValidateRequest validates the request parameters of the list. The provider specific maps must be empty.\n\n```go\ntype ImageInfoEntry struct {\n\tCSP                string `json:\"csp\"`\n\tAttestationVariant string `json:\"attestationVariant\"`\n\tReference          string `json:\"reference\"`\n\tRegion             string `json:\"region,omitempty\"`\n}\n```\nImageInfoEntry contains information about a single image variant.\n\n```go\ntype Latest struct {\n\t// Ref is the branch name this latest version belongs to.\n\tRef string `json:\"ref,omitempty\"`\n\t// Stream is stream name this latest version belongs to.\n\tStream string `json:\"stream,omitempty\"`\n\t// Kind is the kind of resource this latest version is for.\n\tKind VersionKind `json:\"kind,omitempty\"`\n\t// Version is the latest version for this ref, stream and kind.\n\tVersion string `json:\"version,omitempty\"`\n}\n```\nLatest is the latest version of a kind of resource.\n\n```go\nfunc (l Latest) JSONPath() string\n```\nJSONPath returns the S3 JSON path for this object.\n\n```go\nfunc (l Latest) ShortPath() string\n```\nShortPath returns the short path of the latest version.\n\n```go\nfunc (l Latest) URL() (string, error)\n```\nURL returns the URL for this object.\n\n```go\nfunc (l Latest) Validate() error\n```\nValidate checks if this latest version is valid.\n\n```go\nfunc (l Latest) ValidateRequest() error\n```\nValidateRequest checks if this latest version beside values that are fetched.\n\n```go\ntype List struct {\n\t// Ref is the branch name the list belongs to.\n\tRef string `json:\"ref,omitempty\"`\n\t// Stream is the update stream of the list.\n\tStream string `json:\"stream,omitempty\"`\n\t// Granularity is the granularity of the base version of this list.\n\t// It can be either \"major\" or \"minor\".\n\tGranularity Granularity `json:\"granularity,omitempty\"`\n\t// Base is the base version of the list.\n\t// Every version in the list is a finer-grained version of this base version.\n\tBase string `json:\"base,omitempty\"`\n\t// Kind is the kind of resource this list is for.\n\tKind VersionKind `json:\"kind,omitempty\"`\n\t// Versions is a list of all versions in this list.\n\tVersions []string `json:\"versions,omitempty\"`\n}\n```\nList represents a list of versions for a kind of resource. It has a granularity of either \"major\" or \"minor\".\n\nFor 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.\n\n```go\nfunc (l List) Contains(version string) bool\n```\nContains returns true if the list contains the given version.\n\n```go\nfunc (l List) JSONPath() string\n```\nJSONPath returns the S3 JSON path for this object.\n\n```go\nfunc (l List) StructuredVersions() []Version\n```\nStructuredVersions returns the versions of the list as slice of Version structs.\n\n```go\nfunc (l List) URL() (string, error)\n```\nURL returns the URL for this object.\n\n```go\nfunc (l List) Validate() error\n```\nValidate 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.\n\n```go\nfunc (l List) ValidateRequest() error\n```\nValidateRequest validates the request parameters of the list. The versions field must be empty.\n\n```go\ntype Version struct {\n\t// contains filtered or unexported fields\n}\n```\nVersion represents a version. A version has a ref, stream, version string and kind.\n\nNotice 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.\n\nVersions fields are private so the type can be used in other packages by defining private interfaces.\n\n```go\nfunc NewVersion(ref, stream, version string, kind VersionKind) (Version, error)\n```\nNewVersion creates a new Version object and validates it.\n\n```go\nfunc NewVersionFromShortPath(shortPath string, kind VersionKind) (Version, error)\n```\nNewVersionFromShortPath creates a new Version from a version short path.\n\n```go\nfunc (v Version) ArtifactPath(apiVer apiVersion) string\n```\nArtifactPath returns the path to the artifacts stored for this version. The path points to a directory.\n\n```go\nfunc (v Version) ArtifactsURL(apiVer apiVersion) string\n```\nArtifactsURL returns the URL to the artifacts stored for this version. The URL points to a directory.\n\n```go\nfunc (v Version) Equal(other Version) bool\n```\nEqual returns true if the versions are equal.\n\n```go\nfunc (v Version) Kind() VersionKind\n```\nKind returns the kind of the version.\n\n```go\nfunc (v Version) ListPath(gran Granularity) string\n```\nListPath 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.\n\n```go\nfunc (v Version) ListURL(gran Granularity) string\n```\nListURL 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.\n\n```go\nfunc (v Version) Major() string\n```\nMajor returns the major version corresponding to the version. For example, if the version is \"v1.2.3\", the major version is \"v1\".\n\n```go\nfunc (v Version) MajorMinor() string\n```\nMajorMinor 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\".\n\n```go\nfunc (v Version) Ref() string\n```\nRef returns the ref of the version.\n\n```go\nfunc (v Version) ShortPath() string\n```\nShortPath returns the short path of the version.\n\n```go\nfunc (v Version) Stream() string\n```\nStream returns the stream of the version.\n\n```go\nfunc (v Version) Validate() error\n```\nValidate validates the version.\n\n```go\nfunc (v Version) Version() string\n```\nVersion returns the version string of the version.\n\n```go\nfunc (v Version) WithGranularity(gran Granularity) string\n```\nWithGranularity returns the version with the given granularity.\n\nFor 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.\n\n```go\ntype VersionKind int\n```\nVersionKind represents the kind of resource the version versions.\n\n```go\nconst (\n\t// VersionKindUnknown is the default value for VersionKind.\n\tVersionKindUnknown VersionKind = iota\n\t// VersionKindImage is the kind for image versions.\n\tVersionKindImage\n\t// VersionKindCLI is the kind for CLI versions.\n\tVersionKindCLI\n)\n```\n\n```go\nfunc VersionKindFromString(s string) VersionKind\n```\nVersionKindFromString returns the VersionKind for the given string.\n\n```go\nfunc (k VersionKind) MarshalJSON() ([]byte, error)\n```\nMarshalJSON marshals the VersionKind to JSON.\n\n```go\nfunc (k VersionKind) String() string\n```\nString returns the string representation of the VersionKind.\n\n```go\nfunc (k *VersionKind) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON unmarshals the VersionKind from JSON.\n\n","path":"github.com/flashbots/cvm-reverse-proxy/internal/api/versionsapi","name":"versionsapi","synopsis":"","isRedistributable":true}
