model

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMesh = "default"
	// NoMesh defines a marker that resource is not bound to a Mesh.
	// Resources not bound to a mesh (ScopeGlobal) should have an empty string in Mesh field.
	NoMesh = ""
)
View Source
const (
	ScopeMesh   = "Mesh"
	ScopeGlobal = "Global"
)
View Source
const (
	ConsumedByZone   = KDSFlagType(1)
	ConsumedByGlobal = KDSFlagType(1 << 2)
	ProvidedByZone   = KDSFlagType(1 << 3)
	ProvidedByGlobal = KDSFlagType(1 << 4)
	FromZoneToGlobal = ConsumedByGlobal | ProvidedByZone
	FromGlobalToZone = ProvidedByGlobal | ConsumedByZone
)

Variables

View Source
var (
	// ResourceNameExtensionsUnsupported is a convenience constant
	// that is meant to make source code more readable.
	ResourceNameExtensionsUnsupported = ResourceNameExtensions(nil)
)

Functions

func DisplayName added in v1.8.1

func DisplayName(resType string) string

func ErrorInvalidItemType

func ErrorInvalidItemType(expected, actual interface{}) error

func PluralDisplayName added in v1.8.1

func PluralDisplayName(resType string) string

func PluralType added in v1.8.1

func PluralType(resType string) string

func Validate added in v1.8.1

func Validate(resource Resource) error

Types

type ByMeta

type ByMeta []Resource

func (ByMeta) Len

func (a ByMeta) Len() int

func (ByMeta) Less

func (a ByMeta) Less(i, j int) bool

func (ByMeta) Swap

func (a ByMeta) Swap(i, j int)

type KDSFlagType added in v1.8.1

type KDSFlagType uint32

func (KDSFlagType) Has added in v1.8.1

func (kt KDSFlagType) Has(flag KDSFlagType) bool

Has return whether this flag has all the passed flags on.

type Pagination

type Pagination struct {
	Total      uint32
	NextOffset string
}

func (*Pagination) GetNextOffset

func (p *Pagination) GetNextOffset() string

func (*Pagination) GetTotal

func (p *Pagination) GetTotal() uint32

func (*Pagination) SetNextOffset

func (p *Pagination) SetNextOffset(nextOffset string)

func (*Pagination) SetTotal

func (p *Pagination) SetTotal(total uint32)

type Resource

type Resource interface {
	GetMeta() ResourceMeta
	SetMeta(ResourceMeta)
	GetSpec() ResourceSpec
	SetSpec(ResourceSpec) error
	Descriptor() ResourceTypeDescriptor
}

type ResourceKey

type ResourceKey struct {
	Mesh string
	Name string
}

func MetaToResourceKey

func MetaToResourceKey(meta ResourceMeta) ResourceKey

func WithMesh added in v1.8.1

func WithMesh(mesh string, name string) ResourceKey

func WithoutMesh added in v1.8.1

func WithoutMesh(name string) ResourceKey

type ResourceList

type ResourceList interface {
	GetItemType() ResourceType
	GetItems() []Resource
	NewItem() Resource
	AddItem(Resource) error
	GetPagination() *Pagination
}

type ResourceMeta

type ResourceMeta interface {
	GetName() string
	GetNameExtensions() ResourceNameExtensions
	GetVersion() string
	GetMesh() string
	GetCreationTime() time.Time
	GetModificationTime() time.Time
}

type ResourceNameExtensions

type ResourceNameExtensions map[string]string

ResourceNameExtensions represents an composite resource name in environments other than Universal.

E.g., name of a Kubernetes resource consists of a namespace component and a name component that is local to that namespace.

Technically, ResourceNameExtensions is a mapping between a component identifier and a component value, e.g.

"k8s.kuma.io/namespace" => "my-namespace"
"k8s.kuma.io/name"      => "my-policy"

Component identifier must be considered a part of user-facing Kuma API. In other words, it is supposed to be visible to users and should not be changed lightly.

Component identifier might have any value, however, it's preferable to choose one that is intuitive to users of that particular environment. E.g., on Kubernetes component identifiers should use a label name format, like in "k8s.kuma.io/namespace" and "k8s.kuma.io/name".

type ResourceScope

type ResourceScope string

type ResourceSpec

type ResourceSpec interface {
	// all resources must be defined via Protobuf
	proto.Message
}

type ResourceType

type ResourceType string

type ResourceTypeDescriptor added in v1.8.1

type ResourceTypeDescriptor struct {
	// Name identifier of this resourceType this maps to the k8s entity and universal name.
	Name ResourceType
	// Resource a created element of this type
	Resource Resource
	// ResourceList a create list container of this type
	ResourceList ResourceList
	// ReadOnly if this type will be created, modified and deleted by the system.
	ReadOnly bool
	// AdminOnly if this type requires users to be admin to access.
	AdminOnly bool
	// Scope whether this resource is Global or Mesh scoped.
	Scope ResourceScope
	// KDSFlags a set of flags that defines how this entity is sent using KDS (if unset KDS is disabled).
	KDSFlags KDSFlagType
	// WsPath the path to access on the REST api.
	WsPath string
	// KumactlArg the name of the cmdline argument when doing `get` or `delete`.
	KumactlArg string
	// KumactlListArg the name of the cmdline argument when doing `list`.
	KumactlListArg string
	// AllowToInspect if it's required to generate Inspect API endpoint for this type
	AllowToInspect bool
	// IsPolicy if this type is a policy (Dataplanes, Insights, Ingresses are not policies as they describe either metadata or workload, Retries are policies).
	IsPolicy bool
	// DisplayName the name of the policy showed as plural to be displayed in the UI and maybe CLI
	SingularDisplayName string
	// PluralDisplayName the name of the policy showed as plural to be displayed in the UI and maybe CLI
	PluralDisplayName string
	// IsExperimental indicates if a policy is in experimental state (might not be production ready).
	IsExperimental bool
}

func (ResourceTypeDescriptor) NewList added in v1.8.1

func (ResourceTypeDescriptor) NewObject added in v1.8.1

func (d ResourceTypeDescriptor) NewObject() Resource

type ResourceValidator added in v1.8.1

type ResourceValidator interface {
	Validate() error
}

type ResourceWithAddress added in v1.8.1

type ResourceWithAddress interface {
	Resource
	AdminAddress(defaultAdminPort uint32) string
}

type TypeFilter added in v1.8.1

type TypeFilter interface {
	Apply(descriptor ResourceTypeDescriptor) bool
}

func AllowedToInspect added in v1.8.1

func AllowedToInspect() TypeFilter

func HasKDSFlag added in v1.8.1

func HasKDSFlag(flagType KDSFlagType) TypeFilter

func HasKdsEnabled added in v1.8.1

func HasKdsEnabled() TypeFilter

func HasKumactlEnabled added in v1.8.1

func HasKumactlEnabled() TypeFilter

func HasScope added in v1.8.1

func HasScope(scope ResourceScope) TypeFilter

func HasWsEnabled added in v1.8.1

func HasWsEnabled() TypeFilter

func Named added in v1.8.1

func Named(names ...ResourceType) TypeFilter

func Not added in v1.8.1

func Not(filter TypeFilter) TypeFilter

type TypeFilterFn added in v1.8.1

type TypeFilterFn func(descriptor ResourceTypeDescriptor) bool

func (TypeFilterFn) Apply added in v1.8.1

func (f TypeFilterFn) Apply(descriptor ResourceTypeDescriptor) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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