esstorage

package
v0.0.0-...-b9dbafa Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2022 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Must = iota
	MustNot
	Should
)
View Source
const (
	CollectionResourceWorkloads     = "workloads"
	CollectionResourceKubeResources = "kuberesources"
)
View Source
const (
	ObjectPath            = "object"
	SpecPath              = "spec"
	ClusterPath           = "object.metadata.annotations.shadow.clusterpedia.io/cluster-name"
	NameSpacePath         = "object.metadata.namespace"
	NamePath              = "object.metadata.name"
	OwnerReferencePath    = "object.metadata.ownerReferences.uid"
	CreationTimestampPath = "object.metadata.creationTimestamp"
	LabelPath             = "object.metadata.labels"
	GroupPath             = "group"
	VersionPath           = "version"
	ResourcePath          = "resource"
	UIDPath               = "object.metadata.uid"
	KeywordPath           = "keyword"
	ApiVersionPath        = "object.apiVersion"
	KindPath              = "object.kind"
	ObjectMetaPath        = "object.metadata"
	FullTextObjectPath    = "custom.fullTextObject"
)
View Source
const (
	ResourceConfigmap = "configmaps"
	ResourceSecret    = "secrets"
	ResourceEvent     = "events"
)
View Source
const (
	// AllowObjectFullTextSearch is a feature gate for the clustersynchro-manager Indexing k8s objects as string.
	//
	// owner: @hanweisen
	// alpha: v0.1.0
	AllowObjectFullTextSearch featuregate.Feature = "AllowObjectFullTextSearch"
)
View Source
const (
	StorageName = "elasticsearch"
)

Variables

This section is empty.

Functions

func GetIndexMapping

func GetIndexMapping(alias string, storageGroupResource schema.GroupResource) string

func NewCollectionResourceStorage

func NewCollectionResourceStorage(client *elasticsearch.Client, indexName string, cr *internal.CollectionResource) storage.CollectionResourceStorage

func NewStorageFactory

func NewStorageFactory(configPath string) (storage.StorageFactory, error)

func RegisterStorageLayer

func RegisterStorageLayer()

Types

type Basic

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

func (*Basic) LogicType

func (b *Basic) LogicType() LogicType

func (*Basic) SetLogicType

func (b *Basic) SetLogicType(t LogicType)

type BoolExpression

type BoolExpression struct {
	Basic
	// contains filtered or unexported fields
}

func NewBoolExpression

func NewBoolExpression() *BoolExpression

func (*BoolExpression) ToMap

func (b *BoolExpression) ToMap() map[string]interface{}

type CollectionResourceStorage

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

func (*CollectionResourceStorage) Get

type Config

type Config struct {
	Addresses []string `env:"ES_ADDRESSES"`
	UserName  string   `env:"ES_USER"`
	Password  string   `env:"ES_PASSWORD"`
}

type ESError

type ESError struct {
	StatusCode int
	Message    string
}

ESError is an error type which represents a single ES error

func (*ESError) Error

func (e *ESError) Error() string

type ExistExpression

type ExistExpression struct {
	Basic
	// contains filtered or unexported fields
}

func (*ExistExpression) ToMap

func (t *ExistExpression) ToMap() map[string]interface{}

type Expression

type Expression interface {
	ToMap() map[string]interface{}
	LogicType() LogicType
}

type FuzzyExpression

type FuzzyExpression struct {
	Basic
	// contains filtered or unexported fields
}

func NewFuzzy

func NewFuzzy(path string, value []string) *FuzzyExpression

func (*FuzzyExpression) ToMap

func (t *FuzzyExpression) ToMap() map[string]interface{}

type Hit

type Hit struct {
	Index  string    `json:"_index"`
	Id     string    `json:"_id"`
	Score  float32   `json:"_score"`
	Source *Resource `json:"_source"`
}

type Hits

type Hits struct {
	Total    *Total  `json:"total"`
	MaxScore float32 `json:"max_score"`
	Hits     []*Hit  `json:"hits"`
}

type Index

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

func NewIndex

func NewIndex(client *elasticsearch.Client) *Index

func (*Index) ClearScroll

func (s *Index) ClearScroll(ctx context.Context, scrollId string) error

func (*Index) DeleteById

func (s *Index) DeleteById(ctx context.Context, docId string, indexName string) error

func (*Index) DeleteByQuery

func (s *Index) DeleteByQuery(ctx context.Context, query map[string]interface{}, indexName ...string) error

func (*Index) ListIndex

func (s *Index) ListIndex() ([]string, error)

func (*Index) ScrollSearch

func (s *Index) ScrollSearch(ctx context.Context, scrollId string) (*SearchResponse, error)

func (*Index) Search

func (s *Index) Search(ctx context.Context, query map[string]interface{}, indexNames []string, searchOpts ...func(request *esapi.SearchRequest)) (*SearchResponse, error)

func (*Index) SearchAll

func (s *Index) SearchAll(ctx context.Context, query map[string]interface{}, indexNames []string) ([]*SearchResponse, error)

func (*Index) Upsert

func (s *Index) Upsert(ctx context.Context, indexName string, uid string, doc map[string]interface{}) error

type LogicType

type LogicType int

type MatchExpression

type MatchExpression struct {
	Basic
	// contains filtered or unexported fields
}

func NewMatch

func NewMatch(path string, value string) *MatchExpression

func (*MatchExpression) ToMap

func (t *MatchExpression) ToMap() map[string]interface{}

type QueryBuilder

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

func NewQueryBuilder

func NewQueryBuilder() *QueryBuilder

type RangeExpression

type RangeExpression struct {
	Basic
	// contains filtered or unexported fields
}

func NewRange

func NewRange(path string, gte, lte *v1.Time) *RangeExpression

func (*RangeExpression) ToMap

func (t *RangeExpression) ToMap() map[string]interface{}

type Resource

type Resource struct {
	Group           string                 `json:"group"`
	Version         string                 `json:"version"`
	Kind            string                 `json:"kind"`
	Resource        string                 `json:"resource"`
	ResourceVersion string                 `json:"resource_version"`
	Name            string                 `json:"name"`
	Namespace       string                 `json:"namespace"`
	Object          map[string]interface{} `json:"object"`
}

func (Resource) GetGroup

func (r Resource) GetGroup() string

func (Resource) GetKind

func (r Resource) GetKind() string

func (Resource) GetName

func (r Resource) GetName() string

func (Resource) GetNamespace

func (r Resource) GetNamespace() string

func (Resource) GetObject

func (r Resource) GetObject() map[string]interface{}

func (Resource) GetResource

func (r Resource) GetResource() string

func (Resource) GetResourceType

func (r Resource) GetResourceType() ResourceType

func (Resource) GetResourceVersion

func (r Resource) GetResourceVersion() string

func (Resource) GetVersion

func (r Resource) GetVersion() string

func (Resource) GroupVersionResource

func (r Resource) GroupVersionResource() schema.GroupVersionResource

type ResourceStorage

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

func (*ResourceStorage) Create

func (s *ResourceStorage) Create(ctx context.Context, cluster string, obj runtime.Object) error

func (*ResourceStorage) Delete

func (s *ResourceStorage) Delete(ctx context.Context, cluster string, obj runtime.Object) error

func (*ResourceStorage) Get

func (s *ResourceStorage) Get(ctx context.Context, cluster, namespace, name string, into runtime.Object) error

func (*ResourceStorage) GetOwnerIds

func (s *ResourceStorage) GetOwnerIds(ctx context.Context, opts *internal.ListOptions) ([]string, error)

func (*ResourceStorage) GetStorageConfig

func (s *ResourceStorage) GetStorageConfig() *storage.ResourceStorageConfig

func (*ResourceStorage) List

func (s *ResourceStorage) List(ctx context.Context, listObject runtime.Object, opts *internal.ListOptions) error

func (*ResourceStorage) Update

func (s *ResourceStorage) Update(ctx context.Context, cluster string, obj runtime.Object) error

func (*ResourceStorage) Watch

type ResourceType

type ResourceType struct {
	Group    string
	Version  string
	Resource string
	Kind     string
}

func (ResourceType) Empty

func (rt ResourceType) Empty() bool

func (ResourceType) GroupVersionResource

func (rt ResourceType) GroupVersionResource() schema.GroupVersionResource

type SearchResponse

type SearchResponse struct {
	ScrollId string `json:"_scroll_id""`
	Took     int    `json:"took"`
	TimeOut  bool   `json:"time_out"`
	Hits     *Hits  `json:"hits"`
}

func (*SearchResponse) GetResources

func (r *SearchResponse) GetResources() []*Resource

func (*SearchResponse) GetTotal

func (r *SearchResponse) GetTotal() int64

TODO total is not exact value. referring: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html

type SimpleQueryStringExpression

type SimpleQueryStringExpression struct {
	Basic
	Query  string
	Fields []string
}

func (*SimpleQueryStringExpression) ToMap

func (q *SimpleQueryStringExpression) ToMap() map[string]interface{}

type StorageFactory

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

func (*StorageFactory) CleanCluster

func (s *StorageFactory) CleanCluster(ctx context.Context, cluster string) error

func (*StorageFactory) CleanClusterResource

func (s *StorageFactory) CleanClusterResource(ctx context.Context, cluster string, gvr schema.GroupVersionResource) error

func (*StorageFactory) GetCollectionResources

func (s *StorageFactory) GetCollectionResources(ctx context.Context) ([]*internal.CollectionResource, error)

func (*StorageFactory) GetResourceVersions

func (s *StorageFactory) GetResourceVersions(ctx context.Context, cluster string) (map[schema.GroupVersionResource]map[string]interface{}, error)

func (*StorageFactory) GetSupportedRequestVerbs

func (s *StorageFactory) GetSupportedRequestVerbs() []string

func (*StorageFactory) NewCollectionResourceStorage

func (s *StorageFactory) NewCollectionResourceStorage(cr *internal.CollectionResource) (storage.CollectionResourceStorage, error)

func (*StorageFactory) NewResourceStorage

func (s *StorageFactory) NewResourceStorage(config *storage.ResourceStorageConfig) (storage.ResourceStorage, error)

func (*StorageFactory) PrepareCluster

func (s *StorageFactory) PrepareCluster(cluster string) error

type TermsExpression

type TermsExpression struct {
	Basic
	// contains filtered or unexported fields
}

func NewTerms

func NewTerms(path string, value []string) *TermsExpression

func (*TermsExpression) ToMap

func (t *TermsExpression) ToMap() map[string]interface{}

type Total

type Total struct {
	Value    int    `json:"value,omitempty"`
	Relation string `json:"relation,omitempty"`
}

Jump to

Keyboard shortcuts

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