v1alpha1

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package v1alpha1 stores definitions and methods to handle archive records

Index

Constants

View Source
const (
	// IDField the name of id field, usually the primary key id of the storage table
	IDField = "id"
	// TopOwnerClusterField the name of top owner cluster field
	TopOwnerClusterField = "topOwnerCluster"
	// TopClusterField the name of top cluster field
	TopClusterField = "topCluster"
	// ParentClusterField the name of parent cluster field
	ParentClusterField = "parentCluster"
	// ClusterField the name of cluster field
	ClusterField = "cluster"
	// TopOwnerUIDField the name of top owner uid field
	TopOwnerUIDField = "topOwnerUid"
	// TopUIDField the name of top uid field
	TopUIDField = "topUid"
	// ParentUIDField the name of parent uid field
	ParentUIDField = "parentUid"
	// UIDField the name of uid field
	UIDField = "uid"
	// TopOwnerNamespaceField the name of top owner namespace field
	TopOwnerNamespaceField = "topOwnerNamespace"
	// TopNamespaceField the name of top namespace field
	TopNamespaceField = "topNamespace"
	// ParentNamespaceField the name of parent namespace field
	ParentNamespaceField = "parentNamespace"
	// NamespaceField the name of namespace field
	NamespaceField = "namespace"
	// TopOwnerNameField the name of top owner name field
	TopOwnerNameField = "topOwnerName"
	// TopNameField the name of top name field
	TopNameField = "topName"
	// ParentNameField the name of parent name field
	ParentNameField = "parentName"
	// NameField the name of name field
	NameField = "name"

	// GroupField the name of group field
	GroupField = "group"
	// VersionField the name of version field
	VersionField = "version"
	// KindField the name of kind field
	KindField = "kind"
	// MetadataFiled the name of metadata field
	MetadataFiled = "metadata"
	// DataField the name of data field
	DataField = "data"
	// CreationTimestampField the name of creation timestamp field
	CreationTimestampField = "creationTimestamp"
	// CleanupTimeField the name of deletion timestamp field
	CleanupTimeField = "cleanupTime"
)

Variables

View Source
var (
	// GroupVersion is group version used to register these objects
	GroupVersion = schema.GroupVersion{Group: "archive.pkg.katanomi.dev", Version: "v1alpha1"}

	// SchemeBuilder is used to add go types to the GroupVersionKind scheme
	SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

	// AddToScheme adds the types in this group-version to the given scheme.
	AddToScheme = SchemeBuilder.AddToScheme
)

Functions

func MetadataKey

func MetadataKey(key string) string

MetadataKey returns the metadata key

func RecordResourceAttributes

func RecordResourceAttributes(verb string) authv1.ResourceAttributes

RecordResourceAttributes returns a ResourceAttribute object to be used in a filter

func ToInterfaceSlice

func ToInterfaceSlice(value interface{}) []interface{}

ToInterfaceSlice convert slice to interface slice

func TopConditionToMetadata

func TopConditionToMetadata(conds apis.Conditions) map[string]string

TopConditionToMetadata convert top level condition to metadata

Types

type AggregateField

type AggregateField struct {
	Field `json:",inline"`
	// Operator is the operator for aggregate
	Operator AggregateOperator `json:"operator"`
}

AggregateField is a field for aggregate

func Count

func Count(alias string) AggregateField

Count generate aggregate field with count operator

func Max

func Max(name, alias string) AggregateField

Max generate aggregate field with max operator

func Min

func Min(name, alias string) AggregateField

Min generate aggregate field with min operator

func Sum

func Sum(name, alias string) AggregateField

Sum generate aggregate field with sum operator

type AggregateOperator

type AggregateOperator string

AggregateOperator describe the operator type for aggregate

const (
	// AggregateOperatorMax is the operator for max
	AggregateOperatorMax AggregateOperator = "max"
	// AggregateOperatorMin is the operator for min
	AggregateOperatorMin AggregateOperator = "min"
	// AggregateOperatorSum is the operator for sum
	AggregateOperatorSum AggregateOperator = "sum"
	// AggregateOperatorCount is the operator for count
	AggregateOperatorCount AggregateOperator = "count"
)

type AggregateParams

type AggregateParams struct {
	Query   AggregateQuery `json:"query,omitempty"`
	Options *ListOptions   `json:"options,omitempty"`
}

AggregateParams params for aggregating archive data

type AggregateQuery

type AggregateQuery struct {
	// Conditions is the conditions for aggregate query
	Conditions []Condition `json:"conditions,omitempty"`
	// GroupFields is the fields for group by
	GroupFields []Field `json:"group_fields"`
	// AggregateFields is the fields for aggregate
	AggregateFields []AggregateField `json:"aggregate_fields"`
}

AggregateQuery describe the query params for aggregate

type AggregateResult

type AggregateResult []map[string]interface{}

AggregateResult describe the result of aggregate query

func (AggregateResult) Unmarshal

func (a AggregateResult) Unmarshal(list interface{}) error

Unmarshal convert aggregate result to list

type Condition

type Condition struct {
	// Key is the key for condition
	Key string `json:"key,omitempty"`
	// Operator is the operator for condition
	Operator ConditionOperator `json:"operator,omitempty"`
	// Value is the value for condition
	Value interface{} `json:"value,omitempty"`
}

Condition describe a query condition

func And

func And(conditions ...Condition) Condition

And generate condition with and operator

func Cluster

func Cluster(v string) Condition

Cluster generate condition for cluster field

func CompletedStatus

func CompletedStatus() Condition

CompletedStatus generate condition for completed status

func Equal

func Equal(key, value string) Condition

Equal generate condition with equal operator

func EqualColumn added in v0.9.0

func EqualColumn(key1, key2 string) Condition

EqualColumn generate condition with equal column operator

func GVK

GVK generate condition for gvk field

func Gt

func Gt(key, value string) Condition

Gt generate condition with gt operator

func Gte

func Gte(key, value string) Condition

Gte generate condition with gte operator

func In

func In(key string, values ...string) Condition

In generate condition with in operator

func Like

func Like(key, value string) Condition

Like generate condition with like operator

func Lt

func Lt(key, value string) Condition

Lt generate condition with lt operator

func Lte

func Lte(key, value string) Condition

Lte generate condition with lte operator

func Name

func Name(v string) Condition

Name generate condition for name field

func Namespace

func Namespace(v string) Condition

Namespace generate condition for namespace field

func NamespacedName

func NamespacedName(ns, name string) []Condition

NamespacedName generate condition for namespace and name field

func NotEqual

func NotEqual(key, value string) Condition

NotEqual generate condition with not equal operator

func Or

func Or(conditions ...Condition) Condition

Or generate condition with or operator

func ParentCluster

func ParentCluster(v string) Condition

ParentCluster generate condition for parent cluster field

func ParentName

func ParentName(v string) Condition

ParentName generate condition for parent name field

func ParentNamespace

func ParentNamespace(v string) Condition

ParentNamespace generate condition for parent namespace field

func ParentUID

func ParentUID(v string) Condition

ParentUID generate condition for parent uid field

func TopCluster

func TopCluster(v string) Condition

TopCluster generate condition for top cluster field

func TopName

func TopName(v string) Condition

TopName generate condition for top name field

func TopNamespace

func TopNamespace(v string) Condition

TopNamespace generate condition for top namespace field

func TopUID

func TopUID(v string) Condition

TopUID generate condition for top uid field

func UID

func UID(v string) Condition

UID generate condition for uid field

func (*Condition) UnmarshalJSON

func (p *Condition) UnmarshalJSON(data []byte) error

UnmarshalJSON override unmarshalJSON method to parse nested condition

type ConditionOperator

type ConditionOperator string

ConditionOperator describe the operator for condition

const (
	// ConditionOperatorAnd is the operator for and
	ConditionOperatorAnd ConditionOperator = "and"
	// ConditionOperatorOr is the operator for or
	ConditionOperatorOr ConditionOperator = "or"
	// ConditionOperatorIn is the operator for in
	ConditionOperatorIn ConditionOperator = "in"

	// ConditionOperatorEqual is the operator for equal
	ConditionOperatorEqual ConditionOperator = "eq"
	// ConditionOperatorEqualColumn is the operator for equal column
	ConditionOperatorEqualColumn ConditionOperator = "eqcol"
	// ConditionOperatorNotEqual is the operator for not equal
	ConditionOperatorNotEqual ConditionOperator = "ne"
	// ConditionOperatorGt is the operator for greater than
	ConditionOperatorGt ConditionOperator = "gt"
	// ConditionOperatorGte is the operator for greater than or equal
	ConditionOperatorGte ConditionOperator = "gte"
	// ConditionOperatorLt is the operator for less than
	ConditionOperatorLt ConditionOperator = "lt"
	// ConditionOperatorLte is the operator for less than or equal
	ConditionOperatorLte ConditionOperator = "lte"
	// ConditionOperatorLike is the operator for like
	ConditionOperatorLike ConditionOperator = "like"
)

type DeleteOption

type DeleteOption struct {
	// Direct delete directly, not soft delete
	Direct bool
}

DeleteOption describe the delete option

type DeleteParams

type DeleteParams struct {
	Conditions []Condition   `json:"conditions,omitempty"`
	Options    *DeleteOption `json:"options,omitempty"`
}

DeleteParams params for deleting archive data

type Field

type Field struct {
	// Name is the field name
	Name string `json:"name"`
	// Alias is the field alias
	Alias string `json:"alias"`
}

Field describe the field to be returned

type GetOptions

type GetOptions struct {
}

GetOptions options for querying a single record

type ListOptions

type ListOptions struct {
	metav1alpha1.Pager
	Orders []Order

	// WithDeletedData describe the deleted data should be returned
	WithDeletedData bool
}

ListOptions options for querying a list of records

type ListParams

type ListParams struct {
	Query   Query        `json:"query,omitempty"`
	Options *ListOptions `json:"options,omitempty"`
}

ListParams params for fetching list archive data

type Order

type Order struct {
	Field string
	Asc   bool
}

Order describe the collation of the results

type Query

type Query struct {
	// Conditions is the query conditions
	Conditions []Condition `json:"conditions,omitempty"`
	// Fields is the fields which will be returned
	Fields []Field `json:"fields,omitempty"`
}

Query describe the query params

type Record

type Record struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// Spec the spec of the resource
	Spec RecordSpec `json:"spec"`

	// RelatedRecords the related records of the resource
	RelatedRecords []Record `json:"relatedRecords,omitempty"`
}

Record describe the archive record of a resource

func ObjectToRecord

func ObjectToRecord(obj client.Object) Record

ObjectToRecord convert k8s resource to a Record

func (*Record) NamespaceName

func (p *Record) NamespaceName() string

NamespaceName returns the namespace/name of the record

type RecordList

type RecordList struct {
	metav1.TypeMeta `json:",inline"`

	Items []Record `json:"items"`
}

RecordList is a list of Record

type RecordSpec

type RecordSpec struct {
	// ID the unique id of the resource in the archive storage
	ID uint `json:"id,omitempty"`
	// TopCluster the cluster name of the top level resource
	TopCluster string `json:"topCluster,omitempty"`
	// TopNamespace the namespace name of the top level resource
	TopNamespace string `json:"topNamespace,omitempty"`
	// TopName the name of the top level resource
	TopName string `json:"topName,omitempty"`
	// TopUID the uid of the top level resource
	TopUID string `json:"topUid,omitempty"`
	// ParentCluster the cluster name of the parent resource
	ParentCluster string `json:"parentCluster,omitempty"`
	// ParentNamespace the namespace name of the parent resource
	ParentNamespace string `json:"parentNamespace,omitempty"`
	// ParentName the name of the parent resource
	ParentName string `json:"parentName,omitempty"`
	// ParentUID the uid of the parent resource
	ParentUID string `json:"parentUid,omitempty"`
	// TopOwnerCluster the cluster name of the top owner resource
	TopOwnerCluster string `json:"topOwnerCluster,omitempty"`
	// TopOwnerNamespace the namespace name of the top owner resource
	TopOwnerNamespace string `json:"topOwnerNamespace,omitempty"`
	// TopOwnerName the name of the top owner resource
	TopOwnerName string `json:"topOwnerName,omitempty"`
	// TopOwnerUID the uid of the top owner resource
	TopOwnerUID string `json:"topOwnerUid,omitempty"`
	// Cluster the cluster name of the resource
	Cluster string `json:"cluster,omitempty"`
	// Namespace the namespace name of the resource
	Namespace string `json:"namespace"`
	// Name the name of the resource
	Name string `json:"name"`
	// UID the uid of the resource
	UID string `json:"uid"`
	// Group the group of the resource
	Group string `json:"group"`
	// Version the version of the resource
	Version string `json:"version"`
	// Kind the kind of the resource
	Kind string `json:"kind"`
	// CreationTimestamp the creation timestamp of the resource
	CreationTimestamp int64 `json:"creationTimestamp,omitempty"`
	// CleanupTime the cleanup time of the resource
	CleanupTime int64 `json:"cleanupTime,omitempty"`

	// Metadata the metadata of the resource
	Metadata map[string]string `json:"metadata"`
	// Data original data of the resource
	Data map[string]interface{} `json:"data,omitempty"`
}

RecordSpec describe the spec of an archive record

func (*RecordSpec) DeepCopy

func (p *RecordSpec) DeepCopy() *RecordSpec

Jump to

Keyboard shortcuts

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