sets

package
v0.38.6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 123

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotFoundErr = func(resourceType ezkube.ResourceId, id ezkube.ResourceId) error {
	return eris.Errorf("%T with id %v not found", resourceType, Key(id))
}

Functions

func Key

func Key(id ezkube.ResourceId) string

k8s resources are uniquely identified by their name and namespace

func TypedKey added in v0.7.17

func TypedKey(id ezkube.ResourceId) string

typed keys are helpful for logging; currently unused in the Set implementation but placed here for convenience

Types

type ResourceDelta added in v0.7.17

type ResourceDelta struct {
	// the resources inserted into the set
	Inserted ResourceSet
	// the resources removed from the set
	Removed ResourceSet
}

ResourceDelta represents the set of changes between two ResourceSets.

type ResourceSet

type ResourceSet interface {
	Keys() sets.String
	List(filterResource ...func(ezkube.ResourceId) bool) []ezkube.ResourceId
	UnsortedList(filterResource ...func(ezkube.ResourceId) bool) []ezkube.ResourceId
	Map() Resources
	Insert(resource ...ezkube.ResourceId)
	Equal(set ResourceSet) bool
	Has(resource ezkube.ResourceId) bool
	Delete(resource ezkube.ResourceId)
	Union(set ResourceSet) ResourceSet
	Difference(set ResourceSet) ResourceSet
	Intersection(set ResourceSet) ResourceSet
	IsSuperset(set ResourceSet) bool
	Find(resourceType, id ezkube.ResourceId) (ezkube.ResourceId, error)
	Length() int
	// returns the delta between this and and another ResourceSet
	Delta(newSet ResourceSet) ResourceDelta
	// Clone returns a deep copy of the set
	Clone() ResourceSet
}

func NewResourceSet

func NewResourceSet(resources ...ezkube.ResourceId) ResourceSet

type Resources added in v0.23.5

type Resources map[string]ezkube.ResourceId

sets.Resources is a set of strings, implemented via map[string]struct{} for minimal memory consumption.

func (Resources) Clone added in v0.23.5

func (r Resources) Clone() ResourceSet

func (Resources) Delete added in v0.23.5

func (s Resources) Delete(items ...ezkube.ResourceId) Resources

Delete removes all items from the set.

func (Resources) Delta added in v0.23.5

func (r Resources) Delta(newSet ResourceSet) ResourceDelta

func (Resources) Difference added in v0.23.5

func (s Resources) Difference(s2 Resources) Resources

Difference returns a set of objects that are not in s2 For example: s1 = {a1, a2, a3} s2 = {a1, a2, a4, a5} s1.Difference(s2) = {a3} s2.Difference(s1) = {a4, a5}

func (Resources) Equal added in v0.23.5

func (s1 Resources) Equal(s2 Resources) bool

Equal returns true if and only if s1 is equal (as a set) to s2. Two sets are equal if their membership is identical. (In practice, this means same elements, order doesn't matter)

func (Resources) Find added in v0.23.5

func (r Resources) Find(resourceType, id ezkube.ResourceId) (ezkube.ResourceId, error)

func (Resources) Has added in v0.23.5

func (s Resources) Has(item ezkube.ResourceId) bool

Has returns true if and only if item is contained in the set.

func (Resources) HasAll added in v0.23.5

func (s Resources) HasAll(items ...ezkube.ResourceId) bool

HasAll returns true if and only if all items are contained in the set.

func (Resources) HasAny added in v0.23.5

func (s Resources) HasAny(items ...ezkube.ResourceId) bool

HasAny returns true if any items are contained in the set.

func (Resources) Insert added in v0.23.5

func (r Resources) Insert(resources ...ezkube.ResourceId)

func (Resources) Intersection added in v0.23.5

func (s1 Resources) Intersection(s2 Resources) Resources

Intersection returns a new set which includes the item in BOTH s1 and s2 For example: s1 = {a1, a2} s2 = {a2, a3} s1.Intersection(s2) = {a2}

func (Resources) IsSuperset added in v0.23.5

func (s1 Resources) IsSuperset(s2 Resources) bool

IsSuperset returns true if and only if s1 is a superset of s2.

func (Resources) Keys added in v0.23.5

func (r Resources) Keys() sets.String

func (Resources) Len added in v0.23.5

func (s Resources) Len() int

Len returns the size of the set.

func (Resources) Length added in v0.23.5

func (r Resources) Length() int

func (Resources) List added in v0.23.5

func (r Resources) List(filterResource ...func(ezkube.ResourceId) bool) []ezkube.ResourceId

func (Resources) Map added in v0.23.5

func (r Resources) Map() Resources

func (Resources) PopAny added in v0.23.5

func (s Resources) PopAny() (ezkube.ResourceId, bool)

Returns a single element from the set.

func (Resources) Union added in v0.23.5

func (s1 Resources) Union(s2 Resources) Resources

Union returns a new set which includes items in either s1 or s2. For example: s1 = {a1, a2} s2 = {a3, a4} s1.Union(s2) = {a1, a2, a3, a4} s2.Union(s1) = {a1, a2, a3, a4}

func (Resources) UnsortedList added in v0.23.5

func (r Resources) UnsortedList(filterResource ...func(ezkube.ResourceId) bool) []ezkube.ResourceId

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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