resource

package
v0.0.0-...-6b6aee0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidServiceID = errors.New("invalid service ID")

	LegacyServiceIDRegexp = regexp.MustCompile("^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$")
	// The namespace and name components are (apparently
	// non-normatively) defined in
	// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/architecture/identifiers.md
	// In practice, more punctuation is used than allowed there;
	// specifically, people use underscores as well as dashes and dots, and in names, colons.
	IDRegexp            = regexp.MustCompile("^(<cluster>|[a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)/([a-zA-Z0-9_.:-]+)$")
	UnqualifiedIDRegexp = regexp.MustCompile("^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_.:-]+)$")
)

Functions

This section is empty.

Types

type ID

type ID struct {
	// contains filtered or unexported fields
}

ID is an opaque type which uniquely identifies a resource in an orchestrator.

func MakeID

func MakeID(namespace, kind, name string) ID

MakeID constructs a ID from constituent components.

func MustParseID

func MustParseID(s string) ID

MustParseID constructs a ID from a string representation, panicing if the format is invalid.

func ParseID

func ParseID(s string) (ID, error)

ParseID constructs a ID from a string representation if possible, returning an error value otherwise.

func ParseIDOptionalNamespace

func ParseIDOptionalNamespace(namespace, s string) (ID, error)

ParseIDOptionalNamespace constructs a ID from either a fully qualified string representation, or an unqualified kind/name representation and the supplied namespace.

func (ID) Components

func (id ID) Components() (namespace, kind, name string)

Components returns the constituent components of a ID

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

MarshalJSON encodes a ID as a JSON string. This is done to maintain backwards compatibility with previous flux versions where the ID is a plain string.

func (ID) MarshalText

func (id ID) MarshalText() (text []byte, err error)

MarshalText encodes a ID as a flat string; this is required because ResourceIDs are sometimes used as map keys.

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON decodes a ID from a JSON string. This is done to maintain backwards compatibility with previous flux versions where the ID is a plain string.

func (*ID) UnmarshalText

func (id *ID) UnmarshalText(text []byte) error

MarshalText decodes a ID from a flat string; this is required because ResourceIDs are sometimes used as map keys.

type IDSet

type IDSet map[ID]struct{}

func (IDSet) Add

func (s IDSet) Add(ids []ID)

func (IDSet) Contains

func (s IDSet) Contains(id ID) bool

func (IDSet) Intersection

func (s IDSet) Intersection(others IDSet) IDSet

func (IDSet) String

func (s IDSet) String() string

func (IDSet) ToSlice

func (s IDSet) ToSlice() IDs

func (IDSet) Without

func (s IDSet) Without(others IDSet) IDSet

type IDs

type IDs []ID

func (IDs) Contains

func (ids IDs) Contains(id ID) bool

func (IDs) Intersection

func (ids IDs) Intersection(others IDSet) IDSet

func (IDs) Len

func (p IDs) Len() int

func (IDs) Less

func (p IDs) Less(i, j int) bool

func (IDs) Sort

func (p IDs) Sort()

func (IDs) Swap

func (p IDs) Swap(i, j int)

func (IDs) Without

func (ids IDs) Without(others IDSet) (res IDs)

Jump to

Keyboard shortcuts

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