descriptor

package
v0.4.1-0...-1fefb53 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeLink       = "core-link"
	TypeDescriptor = "core-descriptor"
	TypeSchema     = "core-schema"
	TypeRuntime    = "core-runtime"
	TypeFile       = "core-file"
)

Variables

This section is empty.

Functions

func AnnotationsFromAttributeSet

func AnnotationsFromAttributeSet(set model.AttributeSet) (map[string]string, error)

AnnotationsFromAttributeSet converts an AttributeSet to annotations. All annotation values are saved in a JSON valid syntax to allow for typing upon retrieval.

func AnnotationsFromAttributes

func AnnotationsFromAttributes(attributes map[string]json.RawMessage) (map[string]string, error)

AnnotationsFromAttributes converts collection spec attributes to collection annotations // for OCI descriptor compatibility.

func AnnotationsToAttributeSet

func AnnotationsToAttributeSet(annotations map[string]string, skip func(string) bool) (model.AttributeSet, error)

AnnotationsToAttributeSet converts annotations from descriptors to an AttributeSet. This also performs annotation validation.

func AnnotationsToAttributes

func AnnotationsToAttributes(annotations map[string]string) (map[string]json.RawMessage, error)

AnnotationsToAttributes OCI descriptor annotations to collection spec attributes if the AnnotationsEmporousAttributes key is found.

func AttributesFromAttributeSet

func AttributesFromAttributeSet(set model.AttributeSet) (map[string]json.RawMessage, error)

AttributesFromAttributeSet converts an attribute set on collection spec attributes.

func AttributesToAttributeSet

func AttributesToAttributeSet(specAttributes map[string]json.RawMessage) (model.AttributeSet, error)

AttributesToAttributeSet converts collection spec attributes to an attribute set.

func CollectionToOCI

func CollectionToOCI(desc empspec.Descriptor) (ocispec.Descriptor, error)

CollectionToOCI converts collection descriptor to OCI descriptor.

func OCIToCollection

func OCIToCollection(desc ocispec.Descriptor) (empspec.Descriptor, error)

OCIToCollection converts OCI descriptor to collection descriptor.

Types

type JSONSubsetMatcher

type JSONSubsetMatcher json.RawMessage

JSONSubsetMatcher check that the node attributes are a superset or an exact match to the given json input. The JSONSubsetMatcher should be used when to filter descriptor type nodes to include core schema fields.

func (JSONSubsetMatcher) Matches

func (m JSONSubsetMatcher) Matches(n model.Node) (bool, error)

Matches determines whether a node has all required attributes.

type ParseError

type ParseError struct {
	Key string
	Err error
}

ParseError defines an error when parsing attributes into Properties.

func (ParseError) Error

func (e ParseError) Error() string

type Properties

type Properties struct {
	Runtime    *ocispec.ImageConfig          `json:"core-runtime,omitempty"`
	Link       *empspec.LinkAttributes       `json:"core-link,omitempty"`
	Descriptor *empspec.DescriptorAttributes `json:"core-descriptor,omitempty"`
	Schema     *empspec.SchemaAttributes     `json:"core-schema,omitempty"`
	File       *empspec.File                 `json:"core-file,omitempty"`
	// A map of attribute sets where the string is the schema ID.
	Others map[string]model.AttributeSet `json:"-"`
}

Properties define all properties an Emporous collection descriptor can have.

func Parse

func Parse(in map[string]json.RawMessage) (*Properties, error)

Parse attempt to resolve attribute types in a set of json.RawMessage types into known types and adds unknown attributes to an attribute set, if supported.

func (*Properties) Exists

func (p *Properties) Exists(attribute model.Attribute) (bool, error)

Exists checks for the existence of an attribute pair in the AttributeSet in the Properties. Only the "Others" field is evaluated during the search.

func (*Properties) ExistsBySchema

func (p *Properties) ExistsBySchema(schema string, attribute model.Attribute) (bool, error)

ExistsBySchema checks the existence of the attributes in the AttributeSet matching the given schema ID. Only the "Others" field is evaluated during the search.

func (*Properties) Find

func (p *Properties) Find(s string) model.Attribute

Find searches all AttributeSets in the Properties for a key and returns an attribute value. Only the "Others" field is evaluated during the search.

func (*Properties) FindBySchema

func (p *Properties) FindBySchema(schema, key string) model.Attribute

FindBySchema find the attribute value in the AttributeSet matching the given schema ID. Only the "Others" field is evaluated during the search.

func (*Properties) HasFileInfo

func (p *Properties) HasFileInfo() bool

HasFileInfo returns whether the descriptor has file information set.

func (*Properties) HasRuntimeInfo

func (p *Properties) HasRuntimeInfo() bool

HasRuntimeInfo returns whether the descriptor has runtime information set.

func (*Properties) IsAComponent

func (p *Properties) IsAComponent() bool

IsAComponent returns whether the descriptor has a component name.

func (p *Properties) IsALink() bool

IsALink returns whether a descriptor is a link.

func (*Properties) IsASchema

func (p *Properties) IsASchema() bool

IsASchema returns whether the descriptor is a schema.

func (*Properties) Len

func (p *Properties) Len() int

Len returns the length of the all AttributeSets in the Properties. Only the "Others" field is evaluated.

func (*Properties) List

func (p *Properties) List() map[string]model.Attribute

List lists the AttributeSet attributes in the Properties. If the attribute under different schemas cannot merge, nil will be returned. Only the "Others" field is evaluated.

func (*Properties) MarshalJSON

func (p *Properties) MarshalJSON() ([]byte, error)

MarshalJSON marshal an instance of Properties into the JSON format.

func (*Properties) Merge

func (p *Properties) Merge(sets map[string]model.AttributeSet) error

Merge merges a given AttributeSet into the descriptor Others AttributeSets.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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