Documentation ¶
Overview ¶
Package v1alpha1 stores definitions and methods to handle archive records
Index ¶
- Constants
- Variables
- func MetadataKey(key string) string
- func RecordResourceAttributes(verb string) authv1.ResourceAttributes
- func ToInterfaceSlice(value interface{}) []interface{}
- func TopConditionToMetadata(conds apis.Conditions) map[string]string
- type AggregateField
- type AggregateOperator
- type AggregateParams
- type AggregateQuery
- type AggregateResult
- type Condition
- func And(conditions ...Condition) Condition
- func Cluster(v string) Condition
- func CompletedStatus() Condition
- func ConvertMedataSelectorToConditions(metadataSelectorStr string) ([]Condition, error)
- func Equal(key, value string) Condition
- func EqualColumn(key1, key2 string) Condition
- func Exist(key string) Condition
- func GVK(gvk schema.GroupVersionKind) []Condition
- func Gt(key, value string) Condition
- func Gte(key, value string) Condition
- func In(key string, values ...string) Condition
- func Like(key, value string) Condition
- func Lt(key, value string) Condition
- func Lte(key, value string) Condition
- func Name(v string) Condition
- func Namespace(v string) Condition
- func NamespacedName(ns, name string) []Condition
- func NotEqual(key, value string) Condition
- func Or(conditions ...Condition) Condition
- func ParentCluster(v string) Condition
- func ParentName(v string) Condition
- func ParentNamespace(v string) Condition
- func ParentUID(v string) Condition
- func TopCluster(v string) Condition
- func TopName(v string) Condition
- func TopNamespace(v string) Condition
- func TopUID(v string) Condition
- func UID(v string) Condition
- type ConditionOperator
- type DeleteOption
- type DeleteParams
- type Field
- type GetOptions
- type Index
- type ListOptions
- type ListParams
- type Order
- type Query
- type Record
- type RecordList
- type RecordSpec
Constants ¶
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" )
const (
// LikeValuePrefixForEqualOperator Like operator value prefix
LikeValuePrefixForEqualOperator = "like--"
)
Variables ¶
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 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 CompletedStatus ¶
func CompletedStatus() Condition
CompletedStatus generate condition for completed status
func ConvertMedataSelectorToConditions ¶ added in v0.13.0
ConvertMedataSelectorToConditions convert a string representing a metadata selector and returns Condition array The input will cause an error if it does not follow this form: 'in' operator: key in (value1,value2,value3) 'equal' operator: key=value 'exist' operator: key You can join multi operator, example: "key in (value1,value2,value3),key=value,key2"
func EqualColumn ¶ added in v0.9.0
EqualColumn generate condition with equal column operator
func NamespacedName ¶
NamespacedName generate condition for namespace and name field
func ParentCluster ¶
ParentCluster generate condition for parent cluster field
func ParentName ¶
ParentName generate condition for parent name field
func ParentNamespace ¶
ParentNamespace generate condition for parent namespace field
func TopCluster ¶
TopCluster generate condition for top cluster field
func TopNamespace ¶
TopNamespace generate condition for top namespace field
func (*Condition) UnmarshalJSON ¶
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" // ConditionOperatorExist is the operator for exist ConditionOperatorExist ConditionOperator = "exist" // 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 Index ¶ added in v0.12.0
type Index struct { // Name is the index name Name string `json:"name"` }
Index describe the index
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 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"` // Indexs is the indexs which will be used Indexs []Index `json:"indexs,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 ¶
ObjectToRecord convert k8s resource to a Record
func (*Record) NamespaceName ¶
NamespaceName returns the namespace/name of the record
type RecordList ¶
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