model

package
v0.0.0-...-0ddbb62 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 16 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 (
	// DDSDisabledFlag is a flag that indicates that this resource type is not sent using DDS.
	DDSDisabledFlag = DDSFlagType(0)

	// ZoneToGlobalFlag is a flag that indicates that this resource type is sent from Zone CP to Global CP.
	ZoneToGlobalFlag = DDSFlagType(1)

	// GlobalToAllZonesFlag is a flag that indicates that this resource type is sent from Global CP to all zones.
	GlobalToAllZonesFlag = DDSFlagType(1 << 2)

	// GlobalToAllButOriginalZoneFlag is a flag that indicates that this resource type is sent from Global CP to
	// all zones except the zone where the resource was originally created. Today the only resource that has this
	// flag is ZoneIngress.
	GlobalToAllButOriginalZoneFlag = DDSFlagType(1 << 3)
)
View Source
const (
	// GlobalToZoneSelector is selector for all flags that indicate resource sync from Global to Zone.
	// Can't be used as DDS flag for resource type.
	GlobalToZoneSelector = GlobalToAllZonesFlag | GlobalToAllButOriginalZoneFlag

	// AllowedOnGlobalSelector is selector for all flags that indicate resource can be created on Global.
	AllowedOnGlobalSelector = GlobalToAllZonesFlag

	// AllowedOnZoneSelector is selector for all flags that indicate resource can be created on Zone.
	AllowedOnZoneSelector = ZoneToGlobalFlag | GlobalToAllButOriginalZoneFlag
)
View Source
const (
	// K8sNamespaceComponent identifies the namespace component of a resource name on Kubernetes.
	// The value is considered a part of user-facing dubbo API and should not be changed lightly.
	// The value has a format of a Kubernetes label name.
	K8sNamespaceComponent = "k8s.dubbo.io/namespace"

	// K8sNameComponent identifies the name component of a resource name on Kubernetes.
	// The value is considered a part of user-facing dubbo API and should not be changed lightly.
	// The value has a format of a Kubernetes label name.
	K8sNameComponent = "k8s.dubbo.io/name"
)

Variables

View Source
var ResourceNameExtensionsUnsupported = ResourceNameExtensions(nil)

ResourceNameExtensionsUnsupported is a convenience constant that is meant to make source code more readable.

Functions

func DisplayName

func DisplayName(resType string) string

func Equal

func Equal(x, y ResourceSpec) bool

func ErrorInvalidItemType

func ErrorInvalidItemType(expected, actual interface{}) error

func FromAny

func FromAny(src *anypb.Any, spec ResourceSpec) error

func FromJSON

func FromJSON(src []byte, spec ResourceSpec) error

func FromYAML

func FromYAML(src []byte, spec ResourceSpec) error

func FullName

func FullName(spec ResourceSpec) string

func GetDisplayName

func GetDisplayName(r Resource) string

func Hash

func Hash(resource Resource) []byte

func HashMeta

func HashMeta(r Resource) []byte

func IsEmpty

func IsEmpty(spec ResourceSpec) bool

func IsLocallyOriginated

func IsLocallyOriginated(mode config_core.CpMode, r Resource) bool

func PluralType

func PluralType(resType string) string

func ResourceListByMesh

func ResourceListByMesh(rl ResourceList) (map[string]ResourceList, error)

func ResourceListHash

func ResourceListHash(rl ResourceList) []byte

func ResourceOrigin

func ResourceOrigin(rm ResourceMeta) (mesh_proto.ResourceOrigin, bool)

func ToAny

func ToAny(spec ResourceSpec) (*anypb.Any, error)

func ToJSON

func ToJSON(spec ResourceSpec) ([]byte, error)

func ToYAML

func ToYAML(spec ResourceSpec) ([]byte, error)

func Validate

func Validate(resource Resource) error

func ZoneOfResource

func ZoneOfResource(res Resource) string

ZoneOfResource returns zone from which the resource was synced to Global CP There is no information in the resource itself whether the resource is synced or created on the CP. Therefore, it's a caller responsibility to make use it only on synced resources.

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 DDSFlagType

type DDSFlagType uint32

func (DDSFlagType) Has

func (kt DDSFlagType) Has(flag DDSFlagType) bool

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

type OverviewResource

type OverviewResource interface {
	SetOverviewSpec(resource Resource, insight Resource) error
}

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 Policy

type Policy interface {
	ResourceSpec
}

type PolicyItem

type PolicyItem interface {
	GetDefault() interface{}
}

type PolicyWithFromList

type PolicyWithFromList interface {
	Policy
	GetFromList() []PolicyItem
}

type PolicyWithSingleItem

type PolicyWithSingleItem interface {
	Policy
	GetPolicyItem() PolicyItem
}

type PolicyWithToList

type PolicyWithToList interface {
	Policy
	GetToList() []PolicyItem
}

type Resource

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

type ResourceHasher

type ResourceHasher interface {
	Hash() []byte
}

type ResourceKey

type ResourceKey struct {
	Mesh string
	Name string
}

func MetaToResourceKey

func MetaToResourceKey(meta ResourceMeta) ResourceKey

func ResourceListToResourceKeys

func ResourceListToResourceKeys(rl ResourceList) []ResourceKey

func WithMesh

func WithMesh(mesh string, name string) ResourceKey

func WithoutMesh

func WithoutMesh(name string) ResourceKey

type ResourceList

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

type ResourceMeta

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

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.dubbo.io/namespace" => "my-namespace"
"k8s.dubbo.io/name"      => "my-policy"

Component identifier must be considered a part of user-facing dubbo 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.dubbo.io/namespace" and "k8s.dubbo.io/name".

type ResourceReq

type ResourceReq struct {
	Mesh      string
	Name      string
	PodName   string
	Namespace string
}

type ResourceScope

type ResourceScope string

type ResourceSpec

type ResourceSpec interface{}

type ResourceType

type ResourceType string

type ResourceTypeDescriptor

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
	// DDSFlags a set of flags that defines how this entity is sent using DDS (if unset DDS is disabled).
	DDSFlags DDSFlagType
	// WsPath the path to access on the REST api.
	WsPath string
	// DubboctlArg the name of the cmdline argument when doing `get` or `delete`.
	DubboctlArg string
	// DubboctlListArg the name of the cmdline argument when doing `list`.
	DubboctlListArg 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
	// IsPluginOriginated indicates if a policy is implemented as a plugin
	IsPluginOriginated bool
	// Schema contains an unmarshalled OpenAPI schema of the resource
	Schema *spec.Schema
	// Insight contains the insight type attached to this resourceType
	Insight Resource
	// Overview contains the overview type attached to this resourceType
	Overview Resource
	// DumpForGlobal whether resources of this type should be dumped when exporting a zone to migrate to global
	DumpForGlobal bool
}

func (ResourceTypeDescriptor) HasInsights

func (d ResourceTypeDescriptor) HasInsights() bool

func (ResourceTypeDescriptor) NewInsight

func (d ResourceTypeDescriptor) NewInsight() Resource

func (ResourceTypeDescriptor) NewInsightList

func (d ResourceTypeDescriptor) NewInsightList() ResourceList

func (ResourceTypeDescriptor) NewList

func (ResourceTypeDescriptor) NewObject

func (d ResourceTypeDescriptor) NewObject() Resource

func (ResourceTypeDescriptor) NewOverview

func (d ResourceTypeDescriptor) NewOverview() Resource

func (ResourceTypeDescriptor) NewOverviewList

func (d ResourceTypeDescriptor) NewOverviewList() ResourceList

type ResourceValidator

type ResourceValidator interface {
	Validate() error
}

type ResourceWithAddress

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

type ResourceWithInsights

type ResourceWithInsights interface {
	NewInsightList() ResourceList
	NewOverviewList() ResourceList
}

type TransformDefaultAfterMerge

type TransformDefaultAfterMerge interface {
	Transform()
}

type TypeFilter

type TypeFilter interface {
	Apply(descriptor ResourceTypeDescriptor) bool
}

func AllowedToInspect

func AllowedToInspect() TypeFilter

func HasDDSFlag

func HasDDSFlag(flagType DDSFlagType) TypeFilter

func HasDdsEnabled

func HasDdsEnabled() TypeFilter

func HasDubboctlEnabled

func HasDubboctlEnabled() TypeFilter

func HasScope

func HasScope(scope ResourceScope) TypeFilter

func HasWsEnabled

func HasWsEnabled() TypeFilter

func IsPolicy

func IsPolicy() TypeFilter

func Named

func Named(names ...ResourceType) TypeFilter

func Not

func Not(filter TypeFilter) TypeFilter

func Or

func Or(filters ...TypeFilter) TypeFilter

type TypeFilterFn

type TypeFilterFn func(descriptor ResourceTypeDescriptor) bool

func (TypeFilterFn) Apply

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