Documentation

Overview

Package resource contains core abstract types for representing configuration resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustSerialize

func MustSerialize(r *Instance) *mcp.Resource

MustSerialize converts a resource entry into its enveloped form or panics if it cannot.

func Serialize

func Serialize(r *Instance) (*mcp.Resource, error)

Serialize converts a resource entry into its enveloped form.

func SerializeAll

func SerializeAll(resources []*Instance) ([]*mcp.Resource, error)

SerializeAll envelopes and returns all the entries.

func SerializeMetadata

func SerializeMetadata(m Metadata) (*mcp.Metadata, error)

SerializeMetadata converts the given metadata to its enveloped form.

Types

type FullName

type FullName struct {
	Namespace Namespace
	Name      LocalName
}

FullName is a name that uniquely identifies a resource within the mesh.

func NewFullName

func NewFullName(ns Namespace, n LocalName) FullName

NewFullName creates a new FullName from the given Namespace and Name.

func NewShortOrFullName

func NewShortOrFullName(defaultNamespace Namespace, name string) FullName

NewShortOrFullName tries to parse the given name to resource.Name. If the name does not include namespace information, the defaultNamespace is used.

func ParseFullName

func ParseFullName(name string) (FullName, error)

ParseFullName parses the given name string that was serialized via FullName.String()

func ParseFullNameWithDefaultNamespace

func ParseFullNameWithDefaultNamespace(defaultNamespace Namespace, name string) (FullName, error)

ParseFullName parses the given name string using defaultNamespace if no namespace is found.

func (FullName) String

func (n FullName) String() string

String interface implementation.

func (FullName) Validate

func (n FullName) Validate() error

Validate that the Name and Namespace are set.

type Instance

type Instance struct {
	Metadata Metadata
	Message  proto.Message
	Origin   Origin
}

Instance is the abstract representation of a versioned config resource in Istio.

func Deserialize

func Deserialize(e *mcp.Resource, s resource.Schema) (*Instance, error)

Deserialize an entry from an envelope.

func DeserializeAll

func DeserializeAll(es []*mcp.Resource, s resource.Schema) ([]*Instance, error)

DeserializeAll extracts all entries from the given envelopes and returns.

func MustDeserialize

func MustDeserialize(e *mcp.Resource, s resource.Schema) *Instance

MustDeserialize deserializes an entry from an envelope or panics.

func (*Instance) Clone

func (r *Instance) Clone() *Instance

Clone returns a deep-copy of this entry. Warning, this is expensive!

func (*Instance) IsEmpty

func (r *Instance) IsEmpty() bool

IsEmpty returns true if the resource Instance.Message is nil.

type LocalName

type LocalName string

LocalName that uniquely identifies the resource within the Namespace.

func (LocalName) String

func (n LocalName) String() string

type Metadata

type Metadata struct {
	Schema      resource.Schema
	FullName    FullName
	CreateTime  time.Time
	Version     Version
	Labels      StringMap
	Annotations StringMap
}

Metadata about a resource.

func DeserializeMetadata

func DeserializeMetadata(m *mcp.Metadata, s resource.Schema) (Metadata, error)

DeserializeMetadata extracts metadata portion of the envelope

func (*Metadata) Clone

func (m *Metadata) Clone() Metadata

Clone Metadata. Warning, this is expensive!

type Namespace

type Namespace string

Namespace containing the resource.

func (Namespace) String

func (n Namespace) String() string

type Origin

type Origin interface {
	FriendlyName() string

	Namespace() Namespace

	Reference() Reference
}

Origin of a resource. This is source-implementation dependent.

type Reference

type Reference interface {
	String() string
}

Reference provides more information about an Origin. This is also source-implementation dependant.

type StringMap

type StringMap map[string]string

StringMap is used to store labels and annotations.

func (StringMap) Clone

func (s StringMap) Clone() StringMap

Clone the StringMap

func (StringMap) CloneOrCreate

func (s StringMap) CloneOrCreate() StringMap

CloneOrCreate clones a StringMap. It creates the map if it doesn't exist.

func (StringMap) Delete

func (s StringMap) Delete(name string)

Remove the given name from the string map

type Version

type Version string

Version is the version identifier of a resource.