eshandler

package module
v9.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 16 Imported by: 0

README

es-handler

Elasticsearch handler used by Terraform, Crossplane and k8s operator

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StandardDiff

func StandardDiff(actual, expected any, log *logrus.Entry, ignore map[string]any) (diff string, err error)

StandardDiff permit to compare objects

Types

type ElasticsearchHandler

type ElasticsearchHandler interface {
	Client() (client elasticsearch.Client)

	// License scope
	LicenseUpdate(license string) (err error)
	LicenseDelete() (err error)
	LicenseGet() (license *esapi.LicenseInfo, err error)
	LicenseDiff(actual, expected *esapi.LicenseInfo) (diff bool)
	LicenseEnableBasic() (err error)

	// ILM scope
	ILMUpdate(name string, policy *esapi.IlmPolicy) (err error)
	ILMDelete(name string) (err error)
	ILMGet(name string) (policy *esapi.IlmPolicy, err error)
	ILMDiff(actualObject, expectedObject, originalObject *esapi.IlmPolicy) (patchResult *patch.PatchResult, err error)

	// SLM scope
	SLMUpdate(name string, policy *SnapshotLifecyclePolicySpec) (err error)
	SLMDelete(name string) (err error)
	SLMGet(name string) (policy *SnapshotLifecyclePolicySpec, err error)
	SLMDiff(actualObject, expectedObject, originalObject *SnapshotLifecyclePolicySpec) (patchResult *patch.PatchResult, err error)

	// Snapshot repository scope
	SnapshotRepositoryUpdate(name string, repository *esapi.SnapshotRepository) (err error)
	SnapshotRepositoryDelete(name string) (err error)
	SnapshotRepositoryGet(name string) (repository *esapi.SnapshotRepository, err error)
	SnapshotRepositoryDiff(actualObject, expectedObject, originalObject *esapi.SnapshotRepository) (patchResult *patch.PatchResult, err error)

	// Role scope
	RoleUpdate(name string, role *XPackSecurityRole) (err error)
	RoleDelete(name string) (err error)
	RoleGet(name string) (role *XPackSecurityRole, err error)
	RoleDiff(actualObject, expectedObject, originalObject *XPackSecurityRole) (patchResult *patch.PatchResult, err error)

	// Role mapping scope
	RoleMappingUpdate(name string, roleMapping *esapi.SecurityRoleMapping) (err error)
	RoleMappingDelete(name string) (err error)
	RoleMappingGet(name string) (roleMapping *esapi.SecurityRoleMapping, err error)
	RoleMappingDiff(actualObject, expectedObject, originalObject *esapi.SecurityRoleMapping) (patchResult *patch.PatchResult, err error)

	// User scope
	UserCreate(name string, user *SecurityPutUserRequest) (err error)
	UserUpdate(name string, user *SecurityPutUserRequest, isProtected ...bool) (err error)
	UserDelete(name string) (err error)
	UserGet(name string) (user *esapi.SecurityUser, err error)
	UserDiff(actualObject, expectedObject, originalObject *SecurityPutUserRequest) (patchResult *patch.PatchResult, err error)

	// Component template scope
	ComponentTemplateUpdate(name string, component *localpatch.ComponentTemplate) (err error)
	ComponentTemplateDelete(name string) (err error)
	ComponentTemplateGet(name string) (component *localpatch.ComponentTemplate, err error)
	ComponentTemplateDiff(actualObject, expectedObject, originalObject *localpatch.ComponentTemplate) (patchResult *patch.PatchResult, err error)

	// Index template scope
	IndexTemplateUpdate(name string, template *localpatch.IndexTemplate) (err error)
	IndexTemplateDelete(name string) (err error)
	IndexTemplateGet(name string) (template *localpatch.IndexTemplate, err error)
	IndexTemplateDiff(actualObject, expectedObject, originalObject *localpatch.IndexTemplate) (patchResult *patch.PatchResult, err error)

	// Watch scope
	WatchUpdate(name string, watch *XPackWatch) (err error)
	WatchDelete(name string) (err error)
	WatchGet(name string) (watch *XPackWatch, err error)
	WatchDiff(actualObject, expectedObject, originalObject *XPackWatch) (patchResult *patch.PatchResult, err error)

	// Ingest pipline scope
	IngestPipelineUpdate(name string, pipeline *esapi.IngestPipeline) (err error)
	IngestPipelineDelete(name string) (err error)
	IngestPipelineGet(name string) (pipeline *esapi.IngestPipeline, err error)
	IngestPipelineDiff(actualObject, expectedObject, originalObject *esapi.IngestPipeline) (patchResult *patch.PatchResult, err error)

	// Transform scope
	TransformUpdate(name string, transform *Transform) (err error)
	TransformDelete(name string) (err error)
	TransformGet(name string) (transform *Transform, err error)
	TransformDiff(actualObject, expectedObject, originalObject *Transform) (patchResult *patch.PatchResult, err error)

	// Cluster scope
	ClusterHealth() (health *esapi.ClusterHealthResponse, err error)
	EnableRoutingRebalance() (err error)
	DisableRoutingRebalance() (err error)
	EnableRoutingAllocation() (err error)
	DisableRoutingAllocation() (err error)

	SetLogger(log *logrus.Entry)
}

func NewElasticsearchHandler

func NewElasticsearchHandler(cfg *elasticsearch.Config, log *logrus.Entry) (ElasticsearchHandler, error)

type ElasticsearchHandlerImpl

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

func (*ElasticsearchHandlerImpl) Client

func (*ElasticsearchHandlerImpl) ClusterHealth

func (h *ElasticsearchHandlerImpl) ClusterHealth() (health *esapi.ClusterHealthResponse, err error)

ClusterHealth permit to get the cluster health

func (*ElasticsearchHandlerImpl) ComponentTemplateDelete

func (h *ElasticsearchHandlerImpl) ComponentTemplateDelete(name string) (err error)

ComponentTemplateDelete permit to delete component template

func (*ElasticsearchHandlerImpl) ComponentTemplateDiff

func (h *ElasticsearchHandlerImpl) ComponentTemplateDiff(actualObject, expectedObject, originalObject *localpatch.ComponentTemplate) (patchResult *patch.PatchResult, err error)

ComponentTemplateDiff permit to check if 2 component template are the same

func (*ElasticsearchHandlerImpl) ComponentTemplateGet

func (h *ElasticsearchHandlerImpl) ComponentTemplateGet(name string) (component *localpatch.ComponentTemplate, err error)

ComponentTemplateGet permit to get component template

func (*ElasticsearchHandlerImpl) ComponentTemplateUpdate

func (h *ElasticsearchHandlerImpl) ComponentTemplateUpdate(name string, component *localpatch.ComponentTemplate) (err error)

ComponentTemplateUpdate permit to update component template

func (*ElasticsearchHandlerImpl) DisableRoutingAllocation

func (h *ElasticsearchHandlerImpl) DisableRoutingAllocation() (err error)

DisableRoutingAllocation permit to disable cluster routing allocation It put `cluster.routing.allocation.enable` to primaries

func (*ElasticsearchHandlerImpl) DisableRoutingRebalance

func (h *ElasticsearchHandlerImpl) DisableRoutingRebalance() (err error)

DisableRoutingRebalance permit to disable cluster routing rebalance It put `cluster.routing.rebalance.enable` to none

func (*ElasticsearchHandlerImpl) EnableRoutingAllocation

func (h *ElasticsearchHandlerImpl) EnableRoutingAllocation() (err error)

EnableRoutingAllocation permit to enable cluster routing allocation It put `cluster.routing.allocation.enable` to all

func (*ElasticsearchHandlerImpl) EnableRoutingRebalance

func (h *ElasticsearchHandlerImpl) EnableRoutingRebalance() (err error)

EnableRoutingRebalance permit to enable cluster routing rebalance It put `cluster.routing.rebalance.enable` to all

func (*ElasticsearchHandlerImpl) ILMDelete

func (h *ElasticsearchHandlerImpl) ILMDelete(name string) (err error)

ILMDelete permit to delete policy

func (*ElasticsearchHandlerImpl) ILMDiff

func (h *ElasticsearchHandlerImpl) ILMDiff(actualObject, expectedObject, originalObject *esapi.IlmPolicy) (patchResult *patch.PatchResult, err error)

ILMDiff permit to check if 2 policy are the same

func (*ElasticsearchHandlerImpl) ILMGet

func (h *ElasticsearchHandlerImpl) ILMGet(name string) (policy *esapi.IlmPolicy, err error)

ILMGet permit to get policy

func (*ElasticsearchHandlerImpl) ILMUpdate

func (h *ElasticsearchHandlerImpl) ILMUpdate(name string, policy *esapi.IlmPolicy) (err error)

ILMUpdate permit to update or create policy

func (*ElasticsearchHandlerImpl) IndexTemplateDelete

func (h *ElasticsearchHandlerImpl) IndexTemplateDelete(name string) (err error)

IndexTemplateDelete permit to delete index template

func (*ElasticsearchHandlerImpl) IndexTemplateDiff

func (h *ElasticsearchHandlerImpl) IndexTemplateDiff(actualObject, expectedObject, originalObject *localpatch.IndexTemplate) (patchResult *patch.PatchResult, err error)

IndexTemplateDiff permit to check if 2 index template is the same

func (*ElasticsearchHandlerImpl) IndexTemplateGet

func (h *ElasticsearchHandlerImpl) IndexTemplateGet(name string) (template *localpatch.IndexTemplate, err error)

IndexTemplateGet permit to get index template

func (*ElasticsearchHandlerImpl) IndexTemplateUpdate

func (h *ElasticsearchHandlerImpl) IndexTemplateUpdate(name string, template *localpatch.IndexTemplate) (err error)

IndexTemplateUpdate permit to create or update index template

func (*ElasticsearchHandlerImpl) IngestPipelineDelete

func (h *ElasticsearchHandlerImpl) IngestPipelineDelete(name string) (err error)

IngestPipelineDelete permit to delete ingest pipeline

func (*ElasticsearchHandlerImpl) IngestPipelineDiff

func (h *ElasticsearchHandlerImpl) IngestPipelineDiff(actualObject, expectedObject, originalObject *esapi.IngestPipeline) (patchResult *patch.PatchResult, err error)

IngestPipelineDiff permit to check if 2 ingest pipeline are the same

func (*ElasticsearchHandlerImpl) IngestPipelineGet

func (h *ElasticsearchHandlerImpl) IngestPipelineGet(name string) (pipeline *esapi.IngestPipeline, err error)

IngestPipelineGet permit to get ingest pipeline

func (*ElasticsearchHandlerImpl) IngestPipelineUpdate

func (h *ElasticsearchHandlerImpl) IngestPipelineUpdate(name string, pipeline *esapi.IngestPipeline) (err error)

IngestPipelineUpdate permit to create or update ingest pipeline

func (*ElasticsearchHandlerImpl) LicenseDelete

func (h *ElasticsearchHandlerImpl) LicenseDelete() (err error)

LicenseDelete permit to delete the current license

func (*ElasticsearchHandlerImpl) LicenseDiff

func (h *ElasticsearchHandlerImpl) LicenseDiff(actual, expected *esapi.LicenseInfo) (isDiff bool)

LicenseDiff permit to compare actual license with expected license. It only compare the UID if expected is not basic license

func (*ElasticsearchHandlerImpl) LicenseEnableBasic

func (h *ElasticsearchHandlerImpl) LicenseEnableBasic() (err error)

LicenseEnableBasic permit to enable basic license

func (*ElasticsearchHandlerImpl) LicenseGet

func (h *ElasticsearchHandlerImpl) LicenseGet() (license *esapi.LicenseInfo, err error)

LicenseGet permit to get the current license

func (*ElasticsearchHandlerImpl) LicenseUpdate

func (h *ElasticsearchHandlerImpl) LicenseUpdate(license string) (err error)

LicenseUpdate permit to add or update new license

func (*ElasticsearchHandlerImpl) RoleDelete

func (h *ElasticsearchHandlerImpl) RoleDelete(name string) (err error)

RoleDelete permit to delete role

func (*ElasticsearchHandlerImpl) RoleDiff

func (h *ElasticsearchHandlerImpl) RoleDiff(actualObject, expectedObject, originalObject *XPackSecurityRole) (patchResult *patch.PatchResult, err error)

RoleDiff permit to check if 2 role are the same

func (*ElasticsearchHandlerImpl) RoleGet

func (h *ElasticsearchHandlerImpl) RoleGet(name string) (role *XPackSecurityRole, err error)

RoleGet permit to get role

func (*ElasticsearchHandlerImpl) RoleMappingDelete

func (h *ElasticsearchHandlerImpl) RoleMappingDelete(name string) (err error)

RoleMappingDelete permit to delete role mapping

func (*ElasticsearchHandlerImpl) RoleMappingDiff

func (h *ElasticsearchHandlerImpl) RoleMappingDiff(actualObject, expectedObject, originalObject *esapi.SecurityRoleMapping) (patchResult *patch.PatchResult, err error)

RoleMappingDiff permit to check if 2 role mapping are the same

func (*ElasticsearchHandlerImpl) RoleMappingGet

func (h *ElasticsearchHandlerImpl) RoleMappingGet(name string) (roleMapping *esapi.SecurityRoleMapping, err error)

RoleMappingGet permit to get role mapping

func (*ElasticsearchHandlerImpl) RoleMappingUpdate

func (h *ElasticsearchHandlerImpl) RoleMappingUpdate(name string, roleMapping *esapi.SecurityRoleMapping) (err error)

RoleMappingUpdate permit to create or update role mapping

func (*ElasticsearchHandlerImpl) RoleUpdate

func (h *ElasticsearchHandlerImpl) RoleUpdate(name string, role *XPackSecurityRole) (err error)

RoleUpdate permit to update role

func (*ElasticsearchHandlerImpl) SLMDelete

func (h *ElasticsearchHandlerImpl) SLMDelete(name string) (err error)

SLMDelete permit to delete SLM policy

func (*ElasticsearchHandlerImpl) SLMDiff

func (h *ElasticsearchHandlerImpl) SLMDiff(actualObject, expectedObject, originalObject *SnapshotLifecyclePolicySpec) (patchResult *patch.PatchResult, err error)

SLMDiff permit to check if 2 policy are the same

func (*ElasticsearchHandlerImpl) SLMGet

func (h *ElasticsearchHandlerImpl) SLMGet(name string) (policy *SnapshotLifecyclePolicySpec, err error)

SLMGet permit to get SLM policy

func (*ElasticsearchHandlerImpl) SLMUpdate

func (h *ElasticsearchHandlerImpl) SLMUpdate(name string, policy *SnapshotLifecyclePolicySpec) (err error)

SLMUpdate permit to add or update SLM policy

func (*ElasticsearchHandlerImpl) SetLogger

func (h *ElasticsearchHandlerImpl) SetLogger(log *logrus.Entry)

func (*ElasticsearchHandlerImpl) SnapshotRepositoryDelete

func (h *ElasticsearchHandlerImpl) SnapshotRepositoryDelete(name string) (err error)

SnapshotRepositoryDelete permit to delete snapshot repository

func (*ElasticsearchHandlerImpl) SnapshotRepositoryDiff

func (h *ElasticsearchHandlerImpl) SnapshotRepositoryDiff(actualObject, expectedObject, originalObject *esapi.SnapshotRepository) (patchResult *patch.PatchResult, err error)

SnapshotRepositoryDiff permit to check if 2 repositories are the same

func (*ElasticsearchHandlerImpl) SnapshotRepositoryGet

func (h *ElasticsearchHandlerImpl) SnapshotRepositoryGet(name string) (repository *esapi.SnapshotRepository, err error)

SnapshotRepositoryGet permit to get snapshot repository

func (*ElasticsearchHandlerImpl) SnapshotRepositoryUpdate

func (h *ElasticsearchHandlerImpl) SnapshotRepositoryUpdate(name string, repository *esapi.SnapshotRepository) (err error)

SnapshotRepositoryUpdate permit to create or update snapshot repository

func (*ElasticsearchHandlerImpl) TransformDelete

func (h *ElasticsearchHandlerImpl) TransformDelete(name string) (err error)

TransformDelete permit to delete transform

func (*ElasticsearchHandlerImpl) TransformDiff

func (h *ElasticsearchHandlerImpl) TransformDiff(actualObject, expectedObject, originalObject *Transform) (patchResult *patch.PatchResult, err error)

TransformDiff permit to check if 2 transform are the same

func (*ElasticsearchHandlerImpl) TransformGet

func (h *ElasticsearchHandlerImpl) TransformGet(name string) (transform *Transform, err error)

TransformGet permit to get transform

func (*ElasticsearchHandlerImpl) TransformUpdate

func (h *ElasticsearchHandlerImpl) TransformUpdate(name string, transform *Transform) (err error)

TransformUpdate permit to create or update transform

func (*ElasticsearchHandlerImpl) UserCreate

func (h *ElasticsearchHandlerImpl) UserCreate(name string, user *SecurityPutUserRequest) (err error)

UserCreate permit to create new user

func (*ElasticsearchHandlerImpl) UserDelete

func (h *ElasticsearchHandlerImpl) UserDelete(name string) (err error)

UserDelete permit to delete the user

func (*ElasticsearchHandlerImpl) UserDiff

func (h *ElasticsearchHandlerImpl) UserDiff(actualObject, expectedObject, originalObject *SecurityPutUserRequest) (patchResult *patch.PatchResult, err error)

UserDiff permit to check if 2 users are the same

func (*ElasticsearchHandlerImpl) UserGet

func (h *ElasticsearchHandlerImpl) UserGet(name string) (user *esapi.SecurityUser, err error)

UserGet permot to get the user

func (*ElasticsearchHandlerImpl) UserUpdate

func (h *ElasticsearchHandlerImpl) UserUpdate(name string, user *SecurityPutUserRequest, isProtected ...bool) (err error)

UserUpdate permit to update the user

func (*ElasticsearchHandlerImpl) WatchDelete

func (h *ElasticsearchHandlerImpl) WatchDelete(name string) (err error)

WatchDelete permit to delete watch

func (*ElasticsearchHandlerImpl) WatchDiff

func (h *ElasticsearchHandlerImpl) WatchDiff(actualObject, expectedObject, originalObject *XPackWatch) (patchResult *patch.PatchResult, err error)

WatchDiff permit to check if 2 watch are the same

func (*ElasticsearchHandlerImpl) WatchGet

func (h *ElasticsearchHandlerImpl) WatchGet(name string) (watch *XPackWatch, err error)

WatchGet permit to get watch

func (*ElasticsearchHandlerImpl) WatchUpdate

func (h *ElasticsearchHandlerImpl) WatchUpdate(name string, watch *XPackWatch) (err error)

WatchUpdate permit to update or create watch

type ElasticsearchSLMConfig

type ElasticsearchSLMConfig struct {
	ExpendWildcards    string            `json:"expand_wildcards,omitempty"`
	IgnoreUnavailable  bool              `json:"ignore_unavailable,omitempty"`
	IncludeGlobalState bool              `json:"include_global_state,omitempty"`
	Indices            []string          `json:"indices,omitempty"`
	FeatureStates      []string          `json:"feature_states,omitempty"`
	Metadata           map[string]string `json:"metadata,omitempty"`
	Partial            bool              `json:"partial,omitempty"`
}

ElasticsearchSLMConfig is the config sub section

type ElasticsearchSLMRetention

type ElasticsearchSLMRetention struct {
	ExpireAfter string `json:"expire_after,omitempty"`
	MaxCount    int64  `json:"max_count,omitempty"`
	MinCount    int64  `json:"min_count,omitempty"`
}

ElasticsearchSLMRetention is the retention sub section

type SecurityPutUserRequest

type SecurityPutUserRequest struct {
	Enabled      bool           `json:"enabled,omitempty"`
	Email        string         `json:"email,omitempty"`
	FullName     string         `json:"full_name,omitempty"`
	Metadata     map[string]any `json:"metadata,omitempty"`
	Password     string         `json:"password,omitempty"`
	PasswordHash string         `json:"password_hash,omitempty"`
	Roles        []string       `json:"roles,omitempty"`
}

SecurityPutUserRequest is the user create/update request body.

type SnapshotLifecyclePolicy

type SnapshotLifecyclePolicy map[string]*SnapshotLifecyclePolicyGet

SnapshotLifecyclePolicy object returned by API

type SnapshotLifecyclePolicyGet

type SnapshotLifecyclePolicyGet struct {
	Policy *SnapshotLifecyclePolicySpec `json:"policy"`
}

SnapshotLifecyclePolicyGet is the policy

type SnapshotLifecyclePolicySpec

type SnapshotLifecyclePolicySpec struct {
	Schedule   string                     `json:"schedule"`
	Name       string                     `json:"name"`
	Repository string                     `json:"repository"`
	Config     ElasticsearchSLMConfig     `json:"config"`
	Retention  *ElasticsearchSLMRetention `json:"retention,omitempty"`
}

SnapshotLifecyclePolicySpec is the snapshot lifecycle policy object

type Transform

type Transform struct {
	Id          string              `json:"id,omitempty"`
	Version     string              `json:"version,omitempty"`
	CreateTime  int64               `json:"create_time,omitempty"`
	Description string              `json:"description,omitempty"`
	Destination *TransformDest      `json:"dest"`
	Frequency   string              `json:"frequency,omitempty"`
	Lastest     *TransformLatest    `json:"latest,omitempty"`
	Metadata    map[string]any      `json:"_meta,omitempty"`
	Pivot       *TransformPivot     `json:"pivot"`
	Retention   *TransformRetention `json:"retention_policy,omitempty"`
	Settings    map[string]any      `json:"settings,omitempty"`
	Source      *TransformSource    `json:"source"`
	Sync        *TransformSync      `json:"sync"`
}

type TransformDest

type TransformDest struct {
	Index    string `json:"index"`
	Pipeline string `json:"pipeline,omitempty"`
}

type TransformGetResponse

type TransformGetResponse struct {
	Transforms []*Transform `json:"transforms"`
}

type TransformLatest

type TransformLatest struct {
	Sort      string   `json:"sort"`
	UniqueKey []string `json:"unique_key"`
}

type TransformPivot

type TransformPivot struct {
	GroupBy      map[string]any `json:"group_by"`
	Aggregations map[string]any `json:"aggregations"`
}

type TransformRetention

type TransformRetention struct {
	Time TransformRetentionTime `json:"time"`
}

type TransformRetentionTime

type TransformRetentionTime struct {
	Field  string `json:"field"`
	MaxAge string `json:"max_age"`
}

type TransformSource

type TransformSource struct {
	Index           []string `json:"index"`
	Query           any      `json:"query,omitempty"`
	RuntimeMappings any      `json:"runtime_mappings,omitempty"`
}

type TransformSync

type TransformSync struct {
	Time TransformSyncTime `json:"time"`
}

type TransformSyncTime

type TransformSyncTime struct {
	Field string `json:"field"`
	Delay string `json:"delay,omitempty"`
}

type XPackSecurityApplicationPrivileges

type XPackSecurityApplicationPrivileges struct {
	Application string   `json:"application"`
	Privileges  []string `json:"privileges,omitempty"`
	Resources   []string `json:"resources,omitempty"`
}

XPackSecurityApplicationPrivileges is the application privileges object

type XPackSecurityIndicesPermissions

type XPackSecurityIndicesPermissions struct {
	Names                  []string    `json:"names"`
	Privileges             []string    `json:"privileges"`
	FieldSecurity          interface{} `json:"field_security,omitempty"`
	Query                  string      `json:"query,omitempty"`
	AllowRestrictedIndices bool        `json:"allow_restricted_indices,omitempty"`
}

XPackSecurityIndicesPermissions is the indices permission object

type XPackSecurityRole

type XPackSecurityRole struct {
	RunAs             []string                             `json:"run_as,omitempty"`
	Cluster           []string                             `json:"cluster,omitempty"`
	Indices           []XPackSecurityIndicesPermissions    `json:"indices,omitempty"`
	Applications      []XPackSecurityApplicationPrivileges `json:"applications,omitempty"`
	Global            map[string]interface{}               `json:"global,omitempty"`
	Metadata          map[string]interface{}               `json:"metadata,omitempty"`
	TransientMetadata map[string]interface{}               `json:"transient_metadata,omitempty"`
}

Some fix not provided by olivere

type XPackWatch

type XPackWatch = map[string]any

XPackWatch is a watch object.

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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