metadata

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// defaults
	SEMANTIC_PREFIX = "v"
	MORPHEUS_PREFIX = "morpheus"
)

Variables

View Source
var (
	ERR_TEMPLATE_ID_NOT_FOUND   = errors.New("no template with that id found")
	ERR_TEMPLATE_NAME_NOT_FOUND = errors.New("no template with that name found")

	ERR_PLUGIN_ID_NOT_FOUND   = errors.New("no plugin with that id found")
	ERR_PLUGIN_NAME_NOT_FOUND = errors.New("no plugin with that name found")
)
View Source
var ERR_UNMARSHALLING = errors.New("could not unmarshal the YAML")
View Source
var ERR_UNMARSHALLING_RSS = errors.New("could not unmarshal the RSS XML")

Functions

func GetMetadata

func GetMetadata(remoteUri, cache string, cacheTTL time.Duration, logger *koan.Logger) ([]byte, error)

GetMetadata wraps a http request to obtain metadata from the or from a local cache, since this is a CLI we don't want to make the same HTTP request on every invocation so we cache the data with a TTL

Types

type Channel added in v0.2.0

type Channel struct {
	Title       string `xml:"title"`
	Link        string `xml:"link"`
	Description string `xml:"description"`
	Language    string `xml:"language"`
	PubDate     string `xml:"pubDate"`
	Items       []Item `xml:"item"`
}

Channel captures RSS channel info it is not of much interest to us but included for completeness

type Item added in v0.2.0

type Item struct {
	Name                string `xml:"name"`
	Code                string `xml:"code"`
	WebLink             string `xml:"webLink"`
	FileLink            string `xml:"fileLink"`
	FileName            string `xml:"fileName"`
	Version             string `xml:"version"`
	MinApplianceVersion string `xml:"minApplianceVersion"`
	MaxApplianceVersion string `xml:"maxApplianceVersion"`
	Description         string `xml:"description"`
	PubDate             string `xml:"pubDate"`
}

Item represents a single <item></item> element from the feed, again we capture it all for completeness TODO are there more properties which could be included in he feed, such as repository, provider type, and tags

type Metadata

type Metadata []struct {
	Plugin `yaml:"plugin"`
}

Metadata is a representation of the parsed YAML metadata

func ParseMetadataYAML

func ParseMetadataYAML(data []byte, logger *koan.Logger) (Metadata, error)

ParseMetadataYAML parses the YAML metadata to the Metadata type then sets defaults on string types which would otherwise be default empty, we also check the category is one of those allowed

func (*Metadata) GetTemplateByIndex added in v0.4.0

func (md *Metadata) GetTemplateByIndex(id int) (Plugin, error)

GetTemplateByIndex will iterate the metadata to retrieve by index

func (*Metadata) GetTemplateByName added in v0.4.0

func (md *Metadata) GetTemplateByName(key string) (Plugin, int, error)

GetTemplateByName will iterate the metadata to retrieve by name key we also return the index as useful

type Plugin

type Plugin struct {
	Name            string
	Category        string     `yaml:"category"`
	Description     string     `yaml:"description"`
	URL             string     `yaml:"url"`
	Tags            string     `yaml:"tags"`
	Versioning      Versioning `yaml:"versioning"`
	MinimumMorpheus string     `yaml:"minimumMorpheus"`
	Disabled        bool       `yaml:"disabled"`
}

Plugin represents the metadata for a single plugin starter

type RssMetadata added in v0.2.0

type RssMetadata struct {
	XMLName xml.Name `xml:"rss"`
	Channel Channel  `xml:"channel"`
}

RssMetadata is a representation of the parsed XML RSS metadata

func ParseMetadataXML added in v0.2.0

func ParseMetadataXML(data []byte, logger *koan.Logger) (RssMetadata, error)

ParseMetadataXML parses the XML RSS feed to the Metadata type

func (*RssMetadata) GetPluginByIndex added in v0.4.0

func (md *RssMetadata) GetPluginByIndex(id int) (Item, []string, []string, []string, []string, error)

GetPluginByIndex will iterate the rss metadata to retrieve by index

func (*RssMetadata) GetPluginByName added in v0.4.0

func (md *RssMetadata) GetPluginByName(key string) (Item, int, []string, []string, []string, []string, error)

GetPluginByName will iterate the rss metadata to retrieve by name key we also return the index as useful TODO five return values because it evolved, need to refactor

type Versioning

type Versioning struct {
	Semantic       bool   `yaml:"semantic"`
	SemanticPrefix string `yaml:"semanticPrefix"`
	Morpheus       bool   `yaml:"morpheus"`
	MorpheusPrefix string `yaml:"morpheusPrefix"`
}

Versioning represents metadata which describes versioning semantics

Jump to

Keyboard shortcuts

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