utils

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCreated                      = "Created"
	StatusRetry                        = "Retry"
	StatusError                        = "Error"
	Index                              = "Index"
	Template                           = "Template"
	ElasticMainFnTimeout time.Duration = 10 * time.Second
)

Variables

This section is empty.

Functions

func CompactJson

func CompactJson(data string) (string, error)

func CompareJson

func CompareJson(data1 string, data2 string) bool

func ContainsString

func ContainsString(slice []string, s string) bool

func EsVersion added in v1.2.0

func EsVersion(rawurl string) (int, error)

func FilterByNamespacesRegex

func FilterByNamespacesRegex(meta metav1.Object, regex string, log logr.Logger) bool

func GetElasticsearchVersion added in v1.2.0

func GetElasticsearchVersion(jsonBody string) (int, error)

func GetSecret

func GetSecret(namespace string, secretKeySelector *v1.SecretKeySelector, k8sClient client.Client) (*v1.Secret, error)

func IsValidUpdateProperties

func IsValidUpdateProperties(oldProperties string, newProperties string) bool

func RemoveString

func RemoveString(slice []string, s string) (result []string)

func StreamToString

func StreamToString(r io.Reader) (res string, err error)

Types

type Elasticsearch

type Elasticsearch interface {
	NewClient(config *EsConfig, log logr.Logger) error
	PingES(ctx context.Context) error
	CreateOrUpdateIndex(ctx context.Context, indexName string, model string) (*EsStatus, error)
	DeleteIndex(ctx context.Context, indexName string) error
	CreateOrUpdateTemplate(ctx context.Context, templateName string, model string, order *int) (*EsStatus, error)
	DeleteTemplate(ctx context.Context, templateName string) error
}

type Elasticsearch7 added in v1.2.0

type Elasticsearch7 struct {
	Config *EsConfig
	Client *elasticsearch.Client
	// contains filtered or unexported fields
}

func (*Elasticsearch7) CreateOrUpdateIndex added in v1.2.0

func (es *Elasticsearch7) CreateOrUpdateIndex(ctx context.Context, indexName string, model string) (*EsStatus, error)

func (*Elasticsearch7) CreateOrUpdateTemplate added in v1.2.0

func (es *Elasticsearch7) CreateOrUpdateTemplate(ctx context.Context, templateName string, model string, order *int) (*EsStatus, error)

func (*Elasticsearch7) DeleteIndex added in v1.2.0

func (es *Elasticsearch7) DeleteIndex(ctx context.Context, indexName string) error

func (*Elasticsearch7) DeleteTemplate added in v1.2.0

func (es *Elasticsearch7) DeleteTemplate(ctx context.Context, templateName string) error

func (*Elasticsearch7) NewClient added in v1.2.0

func (es *Elasticsearch7) NewClient(config *EsConfig, log logr.Logger) error

func (*Elasticsearch7) PingES added in v1.2.0

func (es *Elasticsearch7) PingES(ctx context.Context) error

type Elasticsearch8 added in v1.2.0

type Elasticsearch8 struct {
	Config *EsConfig
	Client *elasticsearch.Client
	// contains filtered or unexported fields
}

func (*Elasticsearch8) CreateOrUpdateIndex added in v1.2.0

func (es *Elasticsearch8) CreateOrUpdateIndex(ctx context.Context, indexName string, model string) (*EsStatus, error)

func (*Elasticsearch8) CreateOrUpdateTemplate added in v1.2.0

func (es *Elasticsearch8) CreateOrUpdateTemplate(ctx context.Context, templateName string, model string, order *int) (*EsStatus, error)

func (*Elasticsearch8) DeleteIndex added in v1.2.0

func (es *Elasticsearch8) DeleteIndex(ctx context.Context, indexName string) error

func (*Elasticsearch8) DeleteTemplate added in v1.2.0

func (es *Elasticsearch8) DeleteTemplate(ctx context.Context, templateName string) error

func (*Elasticsearch8) NewClient added in v1.2.0

func (es *Elasticsearch8) NewClient(config *EsConfig, log logr.Logger) error

func (*Elasticsearch8) PingES added in v1.2.0

func (es *Elasticsearch8) PingES(ctx context.Context) error

type EsConfig

type EsConfig struct {
	Scheme   string
	Host     string
	Port     string
	Username string
	Password string
	Version  int
}

func BuildEsConfigFromExistingSecret

func BuildEsConfigFromExistingSecret(secret *v1.Secret, key string) (*EsConfig, error)

func BuildEsConfigFromSecretSelector

func BuildEsConfigFromSecretSelector(namespace string, secretKeySelector *v1.SecretKeySelector, k8sClient client.Client) (*EsConfig, error)

func (*EsConfig) FromURI

func (conf *EsConfig) FromURI(rawurl string) (*EsConfig, error)

func (EsConfig) String

func (conf EsConfig) String() string

type EsMappings

type EsMappings struct {
	Mappings string
}

func (EsMappings) GetProperties

func (m EsMappings) GetProperties(indexName string) *string

type EsModel

type EsModel struct {
	Model string
}

func (*EsModel) AddSettings

func (m *EsModel) AddSettings(replicas int32, shards int32) (string, error)

func (*EsModel) GetNumberOfReplicas

func (m *EsModel) GetNumberOfReplicas() (*int32, error)

func (*EsModel) GetNumberOfShards

func (m *EsModel) GetNumberOfShards() (*int32, error)

func (*EsModel) GetProperties

func (m *EsModel) GetProperties() *string

func (*EsModel) IsMappingWithType

func (m *EsModel) IsMappingWithType() *bool

func (*EsModel) IsValid

func (m *EsModel) IsValid(mType string) (bool, error)

type EsSettings

type EsSettings struct {
	Settings string
}

func (*EsSettings) GetNumberOfReplicas

func (s *EsSettings) GetNumberOfReplicas(indexName string) (*int32, error)

func (*EsSettings) GetNumberOfShards

func (s *EsSettings) GetNumberOfShards(indexName string) (*int32, error)

type EsStatus

type EsStatus struct {
	Status         string
	HttpCodeStatus string
	Message        string
}

func BuildEsStatus

func BuildEsStatus(statusCode int, message string) *EsStatus

type HttpCodeStatus

type HttpCodeStatus string
const (
	Http1xx HttpCodeStatus = "1xx"
	Http2xx HttpCodeStatus = "2xx"
	Http3xx HttpCodeStatus = "3xx"
	Http4xx HttpCodeStatus = "4xx"
	Http5xx HttpCodeStatus = "5xx"
)

Jump to

Keyboard shortcuts

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