collection

package
v1.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidName

func IsValidName(name string) bool

IsValidName returns true if the given collection is a valid name.

Types

type Builder

type Builder struct {
	Name         string
	VariableName string
	Resource     resource.Schema
}

Builder is config for the creation of a Schema

func (Builder) Build

func (b Builder) Build() (Schema, error)

Build a Schema instance.

func (Builder) MustBuild

func (b Builder) MustBuild() Schema

MustBuild calls Build and panics if it fails.

type Name

type Name string

Name of a collection.

func NewName

func NewName(n string) Name

NewName returns a strongly typed collection. Panics if the name is not valid.

func (Name) String

func (n Name) String() string

String interface method implementation.

type Names

type Names []Name

Names is a collection of names

func (Names) Clone

func (n Names) Clone() Names

Clone names

func (Names) Sort

func (n Names) Sort()

Sort the names in ascending order.

type Schema

type Schema interface {
	fmt.Stringer

	// Name of the collection.
	Name() Name

	// VariableName is a utility method used to help with codegen. It provides the name of a Schema instance variable.
	VariableName() string

	// Resource is the schema for resources contained in this collection.
	Resource() resource.Schema

	// Equal is a helper function for testing equality between Schema instances. This supports comparison
	// with the cmp library.
	Equal(other Schema) bool
}

Schema for a collection.

type Schemas

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

Schemas contains metadata about configuration resources.

func SchemasFor

func SchemasFor(schemas ...Schema) Schemas

SchemasFor is a shortcut for creating Schemas. It uses MustAdd for each element.

func (Schemas) Add

func (s Schemas) Add(toAdd ...Schema) Schemas

Add creates a copy of this Schemas with the given schemas added.

func (Schemas) All

func (s Schemas) All() []Schema

All returns all known Schemas

func (Schemas) CollectionNames

func (s Schemas) CollectionNames() Names

CollectionNames returns all known collections.

func (Schemas) Equal

func (s Schemas) Equal(o Schemas) bool

func (Schemas) Find

func (s Schemas) Find(collection string) (Schema, bool)

Find looks up a Schema by its collection name.

func (Schemas) FindByGroupVersionKind

func (s Schemas) FindByGroupVersionKind(gvk config.GroupVersionKind) (Schema, bool)

FindByGroupVersionKind searches and returns the first schema with the given GVK

func (Schemas) FindByGroupVersionResource

func (s Schemas) FindByGroupVersionResource(gvr schema.GroupVersionResource) (Schema, bool)

FindByGroupVersionResource searches and returns the first schema with the given GVR

func (Schemas) FindByPlural

func (s Schemas) FindByPlural(group, version, plural string) (Schema, bool)

FindByPlural searches and returns the first schema with the given Group, Version and plural form of the Kind

func (Schemas) ForEach

func (s Schemas) ForEach(handleSchema func(Schema) (done bool))

ForEach executes the given function on each contained schema, until the function returns true.

func (Schemas) Intersect

func (s Schemas) Intersect(otherSchemas Schemas) Schemas

func (Schemas) Kinds

func (s Schemas) Kinds() []string

Kinds returns all known resource kinds.

func (Schemas) MustFind

func (s Schemas) MustFind(collection string) Schema

MustFind calls Find and panics if not found.

func (Schemas) MustFindByGroupVersionKind

func (s Schemas) MustFindByGroupVersionKind(gvk config.GroupVersionKind) Schema

MustFindByGroupVersionKind calls FindByGroupVersionKind and panics if not found.

func (Schemas) Remove

func (s Schemas) Remove(toRemove ...Schema) Schemas

Remove creates a copy of this Schemas with the given schemas removed.

func (Schemas) Union

func (s Schemas) Union(otherSchemas Schemas) Schemas

func (Schemas) Validate

func (s Schemas) Validate() (err error)

Validate the schemas. Returns error if there is a problem.

type SchemasBuilder

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

SchemasBuilder is a builder for the schemas type.

func NewSchemasBuilder

func NewSchemasBuilder() *SchemasBuilder

NewSchemasBuilder returns a new instance of SchemasBuilder.

func (*SchemasBuilder) Add

func (b *SchemasBuilder) Add(s Schema) error

Add a new collection to the schemas.

func (*SchemasBuilder) Build

func (b *SchemasBuilder) Build() Schemas

Build a new schemas from this SchemasBuilder.

func (*SchemasBuilder) MustAdd

func (b *SchemasBuilder) MustAdd(s Schema) *SchemasBuilder

MustAdd calls Add and panics if it fails.

Jump to

Keyboard shortcuts

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