Documentation ¶
Index ¶
Constants ¶
const ( // BlueprintType is the name of the blueprint type in a component descriptor. BlueprintType = "landscaper.gardener.cloud/blueprint" // OldBlueprintType is the old name of the blueprint type in a component descriptor. OldBlueprintType = "blueprint" // BlueprintArtifactsMediaTypeV0 is the reserved media type for a blueprint that is stored as its own artifact. // This is the legacy deprecated artifact media type that was used for the layer and the config type. // Use BlueprintArtifactsConfigMediaTypeV1 or BlueprintArtifactsLayerMediaTypeV1 instead. // DEPRECATED BlueprintArtifactsMediaTypeV0 = "application/vnd.gardener.landscaper.blueprint.v1+tar+gzip" // BlueprintArtifactsConfigMediaTypeV1 is the config reserved media type for a blueprint that is stored as its own artifact. // This describes the config media type of the blueprint artifact. // The suffix can be yaml or json whereas yaml is the default. BlueprintArtifactsConfigMediaTypeV1 = "application/vnd.gardener.landscaper.blueprint.config.v1" // BlueprintArtifactsLayerMediaTypeV1 is the reserved layer media type for a blueprint that is stored as its own artifact. // This describes the layer media type of the blueprint artifact as well as the media type of a localOciBlob. // Optionally the compression can be added as "+gzip" BlueprintArtifactsLayerMediaTypeV1 = "application/vnd.gardener.landscaper.blueprint.layer.v1.tar" // JSONSchemaType is the name of json schema type in a component descriptor. // Although it is not a media or MIME type, this currently seems like the best place to put it. JSONSchemaType = "landscaper.gardener.cloud/jsonschema" // JSONSchemaArtifactsMediaTypeV0 is the reserved media type for a jsonschema that is stored as layer in an oci artifact. // This is the legacy deprecated artifact media type use JSONSchemaArtifactsMediaTypeV1 instead. // DEPRECATED JSONSchemaArtifactsMediaTypeV0 = "application/vnd.gardener.landscaper.jsonscheme.v1+json" // JSONSchemaArtifactsMediaTypeV1 is the reserved media type for a jsonschema that is stored as layer in an oci artifact. // This is the legacy deprecated artifact media type. JSONSchemaArtifactsMediaTypeV1 = "application/vnd.gardener.landscaper.jsonschema.layer.v1.json" // GZipCompression is the identifier for a gzip compressed file. GZipCompression = "gzip" // MediaTypeGZip defines the media type for a gzipped file MediaTypeGZip = "application/gzip" )
Variables ¶
var InvalidTypeError = errors.New("INVALID_MEDIA_TYPE")
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
Type MediaType
}
Builder is a media type builder
func (*Builder) Compression ¶
Compression sets the compression format
func (*Builder) FileFormat ¶
FileFormat sets the file format of the media type. Will be automatically parsed from the type if it is not a config type.
func (*Builder) IsConfigType ¶
IsConfigType configures the media type as oci config.
func (*Builder) IsLayerType ¶
IsLayerType configures the media type as oci layer.
type ConversionFunc ¶
ConversionFunc describes a conversion func for a media type
type MediaType ¶
type MediaType struct { // Orig contains the complete original type Orig string // Format describes the specific format of the media type Format MediaTypeFormat // Type contain the parsed type without suffix. Type string // Suffix contains the suffix of a media that is given after the "+"-char Suffix *string // Version describes the config or layer version. Version *string // FileFormat contains only the file format. // This is part of the Type if the mediatype is not a ConfigType. // If it is a ConfigType the FileFormat is not part of the type. FileFormat *string // CompressionFormat contains the optional compression format. CompressionFormat *string }
MediaType describes a media type (formerly known as MIME type) defined by the IANA in THE RFC 2045. In addition oci specific media types as defined in https://github.com/opencontainers/artifacts/blob/master/artifact-authors.md#defining-layermediatypes are parsed.
func Parse ¶
func Parse(mediaType string, conversions ...ConversionFunc) (MediaType, error)
Parse parses a config and layer media type according to the oci spec. Config: [registration-tree].[org|company|entity].[objectType].[optional-subType].config.[version]+[optional-configFormat] Layers: [registration-tree].[org|company|entity].[layerType].[optional-layerSubType].layer.[version].[fileFormat]+[optional-compressionFormat] Layers also allow any IANA media type
https://github.com/opencontainers/artifacts/blob/master/artifact-authors.md#defining-layermediatypes
This method is highly landscaper specific and can also handle legacy types that are automatically converted.
func (MediaType) HasFileFormat ¶
HasFileFormat checks if the media type contains the given file format. if the given format is empty this functions only validates if a format is given
func (MediaType) HasSuffix ¶
HasSuffix checks if the media type contains the given suffix. if the given format is empty this functions only validates if a format is given
func (MediaType) IsCompressed ¶
IsCompressed checks if the media type is compressed with the given format. if the given format is empty this functions only validates if a compression is given
type MediaTypeFormat ¶
type MediaTypeFormat string
const ( DefaultFormat MediaTypeFormat = "" OCIConfigFormat MediaTypeFormat = "ociConfig" OCILayerFormat MediaTypeFormat = "ociLayer" )