services

package
v0.0.0-...-6788986 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	K8sAttributeField = "k8s-uid"

	ROLES         = "roles"
	INTERNALUSERS = "internalusers"
	ROLESMAPPING  = "rolesmapping"
	ACTIONGROUPS  = "actiongroups"
	TENANTS       = "tenants"
)

Variables

View Source
var (
	ErrClusterHealthOperation   = errors.New("cluster health failed")
	ErrClusterSettingsOperation = errors.New("cluster settings failed")
	ErrCatIndicesOperation      = errors.New("cat indices failed")
)
View Source
var AdditionalSystemIndices = []string{
	".opendistro-alerting-config",
	".opendistro-alerting-alert*",
	".opendistro-anomaly-results*",
	".opendistro-anomaly-detector*",
	".opendistro-anomaly-checkpoints",
	".opendistro-anomaly-detection-state",
	".opendistro-reports-*",
	".opendistro-notifications-*",
	".opendistro-notebooks",
	".opensearch-observability",
	".opendistro-asynchronous-search-response*",
	".replication-metadata-store",
}
View Source
var ClusterSettingsExcludeBrokenPath = []string{"cluster", "routing", "allocation", "exclude", "_name"}
View Source
var ErrNotFound = errors.New("policy not found")
View Source
var ErrRepoNotFound = errors.New("snapshotRepository not found")

Functions

func ActionGroupExists

func ActionGroupExists(ctx context.Context, service *OsClusterClient, actionGroupName string) (bool, error)

ActionGroupExists checks if the passed actionGroup already exists or not

func AppendExcludeNodeHost

func AppendExcludeNodeHost(service *OsClusterClient, nodeNameToExclude string) (bool, error)

func CheckClusterStatusForRestart

func CheckClusterStatusForRestart(service *OsClusterClient, drainNodes bool) (bool, string, error)

func ComponentTemplateExists

func ComponentTemplateExists(ctx context.Context, service *OsClusterClient, templateName string) (bool, error)

ComponentTemplateExists checks if the passed component template already exists or not

func ComponentTemplatePath

func ComponentTemplatePath(templateName string) strings.Builder

ComponentTemplatePath returns a strings.Builder pointing to /_component_template/<templateName>

func CreateISMPolicy

func CreateISMPolicy(ctx context.Context, service *OsClusterClient, ismpolicy requests.ISMPolicy, policyId string) error

CreateISMPolicy creates the passed policy

func CreateIndex

func CreateIndex(clusterClient *OsClusterClient, indexName string, mapping *strings.Reader) (int, error)

func CreateOrUpdateActionGroup

func CreateOrUpdateActionGroup(
	ctx context.Context,
	service *OsClusterClient,
	actionGroupName string,
	actionGroup requests.ActionGroup,
) error

CreateOrUpdateActionGroup creates a new action group or updates a previously created action group

func CreateOrUpdateComponentTemplate

func CreateOrUpdateComponentTemplate(
	ctx context.Context,
	service *OsClusterClient,
	componentTemplateName string,
	componentTemplate requests.ComponentTemplate,
) error

CreateOrUpdateComponentTemplate creates a new component or updates a pre-existing component template

func CreateOrUpdateIndexTemplate

func CreateOrUpdateIndexTemplate(
	ctx context.Context,
	service *OsClusterClient,
	indexTemplateName string,
	indexTemplate requests.IndexTemplate,
) error

CreateOrUpdateIndexTemplate creates a new index or updates a pre-existing index template

func CreateOrUpdateRole

func CreateOrUpdateRole(
	ctx context.Context,
	service *OsClusterClient,
	rolename string,
	role requests.Role,
) error

func CreateOrUpdateRoleMapping

func CreateOrUpdateRoleMapping(
	ctx context.Context,
	service *OsClusterClient,
	rolename string,
	mapping requests.RoleMapping,
) error

func CreateOrUpdateTenant

func CreateOrUpdateTenant(
	ctx context.Context,
	service *OsClusterClient,
	tenantName string,
	tenant requests.Tenant,
) error

CreateOrUpdateTenant creates a new tenant or updates a previously created tenant

func CreateOrUpdateUser

func CreateOrUpdateUser(
	ctx context.Context,
	service *OsClusterClient,
	username string,
	user requests.User,
) error

func CreateSnapshotRepository

func CreateSnapshotRepository(ctx context.Context, service *OsClusterClient, repositoryName string, repository requests.SnapshotRepository) error

creates the given SnapshotRepository

func DeleteActionGroup

func DeleteActionGroup(ctx context.Context, service *OsClusterClient, actionGroupName string) error

DeleteActionGroup deletes a previously created action group

func DeleteComponentTemplate

func DeleteComponentTemplate(ctx context.Context, service *OsClusterClient, componentTemplateName string) error

DeleteComponentTemplate deletes a previously created component template

func DeleteISMPolicy

func DeleteISMPolicy(ctx context.Context, service *OsClusterClient, policyName string) error

DeleteISMPolicy deletes the given policy

func DeleteIndex

func DeleteIndex(clusterClient *OsClusterClient, indexName string) (int, error)

func DeleteIndexTemplate

func DeleteIndexTemplate(ctx context.Context, service *OsClusterClient, indexTemplateName string) error

DeleteIndexTemplate deletes a previously created index template

func DeleteRole

func DeleteRole(ctx context.Context, service *OsClusterClient, rolename string) error

func DeleteRoleMapping

func DeleteRoleMapping(ctx context.Context, service *OsClusterClient, rolename string) error

func DeleteSnapshotRepository

func DeleteSnapshotRepository(ctx context.Context, service *OsClusterClient, repositoryName string) error

deletes the given SnapshotRepository

func DeleteTenant

func DeleteTenant(ctx context.Context, service *OsClusterClient, tenantName string) error

DeleteTenant deletes a previously created tenant

func DeleteUser

func DeleteUser(ctx context.Context, service *OsClusterClient, username string) error

func ErrCatIndicesFailed

func ErrCatIndicesFailed(resp string) error

func ErrClusterHealthGetFailed

func ErrClusterHealthGetFailed(resp string) error

func ErrClusterSettingsGetFailed

func ErrClusterSettingsGetFailed(resp string) error

func FetchExistingRoleMapping

func FetchExistingRoleMapping(
	ctx context.Context,
	service *OsClusterClient,
	rolename string,
) (requests.RoleMapping, error)

func GetExistingSystemIndices

func GetExistingSystemIndices(service *OsClusterClient) ([]string, error)

func GetPolicy

func GetPolicy(ctx context.Context, service *OsClusterClient, policyName string) (*responses.GetISMPolicyResponse, error)

GetPolicy fetches the passed policy

func GetSnapshotRepository

func GetSnapshotRepository(ctx context.Context, service *OsClusterClient, repositoryName string) (*requests.SnapshotRepository, error)

fetches the snapshot repository with the given name

func HasIndexPrimariesOnNode

func HasIndexPrimariesOnNode(service *OsClusterClient, nodeName string, indices []string) (bool, error)

func HasIndicesWithNoReplica

func HasIndicesWithNoReplica(service *OsClusterClient) (bool, error)

func HasShardsOnNode

func HasShardsOnNode(service *OsClusterClient, nodeName string) (bool, error)

func IndexTemplateExists

func IndexTemplateExists(ctx context.Context, service *OsClusterClient, templateName string) (bool, error)

IndexTemplateExists checks if the passed index template already exists or not

func IndexTemplatePath

func IndexTemplatePath(templateName string) strings.Builder

IndexTemplatePath returns a strings.Builder pointing to /_index_template/<templateName>

func MainPage

func MainPage(client *opensearch.Client) (responses.MainResponse, error)

func PreparePodForDelete

func PreparePodForDelete(service *OsClusterClient, lg logr.Logger, podName string, drainNode bool, nodeCount int32) (bool, error)

func ReactivateShardAllocation

func ReactivateShardAllocation(service *OsClusterClient) error

func RemoveExcludeNodeHost

func RemoveExcludeNodeHost(service *OsClusterClient, nodeNameToExclude string) (bool, error)

func RoleExists

func RoleExists(ctx context.Context, service *OsClusterClient, rolename string) (bool, error)

func RoleMappingExists

func RoleMappingExists(
	ctx context.Context,
	service *OsClusterClient,
	rolename string,
) (bool, error)

func SetClusterShardAllocation

func SetClusterShardAllocation(service *OsClusterClient, enableType ClusterSettingsAllocation) error

func ShouldUpdateActionGroup

func ShouldUpdateActionGroup(
	ctx context.Context,
	service *OsClusterClient,
	actionGroupName string,
	actionGroup requests.ActionGroup,
) (bool, error)

ShouldUpdateActionGroup checks whether a previously created actiongroup needs an update or not

func ShouldUpdateComponentTemplate

func ShouldUpdateComponentTemplate(
	ctx context.Context,
	service *OsClusterClient,
	componentTemplateName string,
	componentTemplate requests.ComponentTemplate,
) (bool, error)

ShouldUpdateComponentTemplate checks whether a previously created component template needs an update or not

func ShouldUpdateISMPolicy

func ShouldUpdateISMPolicy(ctx context.Context, newPolicy, existingPolicy requests.ISMPolicy) (bool, error)

ShouldUpdateISMPolicy checks if the passed policy is same as existing or needs update

func ShouldUpdateIndexTemplate

func ShouldUpdateIndexTemplate(
	ctx context.Context,
	service *OsClusterClient,
	indexTemplateName string,
	indexTemplate requests.IndexTemplate,
) (bool, error)

ShouldUpdateIndexTemplate checks whether a previously created index template needs an update or not

func ShouldUpdateRole

func ShouldUpdateRole(
	ctx context.Context,
	service *OsClusterClient,
	rolename string,
	role requests.Role,
) (bool, error)

func ShouldUpdateSnapshotRepository

func ShouldUpdateSnapshotRepository(ctx context.Context, newRepository, existingRepository requests.SnapshotRepository) (bool, error)

checks if the passed SnapshotRepository is same as existing or needs update

func ShouldUpdateTenant

func ShouldUpdateTenant(
	ctx context.Context,
	service *OsClusterClient,
	tenantName string,
	tenant requests.Tenant,
) (bool, error)

ShouldUpdateTenant checks whether a previously created tenant needs an update or not

func ShouldUpdateUser

func ShouldUpdateUser(
	ctx context.Context,
	service *OsClusterClient,
	username string,
	user requests.User,
) (bool, error)

func SnapshotRepositoryExists

func SnapshotRepositoryExists(ctx context.Context, service *OsClusterClient, repositoryName string) (bool, error)

checks if the snapshot repository with the given name already exists

func TenantExists

func TenantExists(ctx context.Context, service *OsClusterClient, tenantName string) (bool, error)

TenantExists checks if the passed tenant already exists or not

func UpdateISMPolicy

func UpdateISMPolicy(ctx context.Context, service *OsClusterClient, ismpolicy requests.ISMPolicy, seqno, primterm *int, policyId string) error

UpdateISMPolicy updates the given policy

func UpdateIndexSettings

func UpdateIndexSettings(clusterClient *OsClusterClient, indexName string, mapping *strings.Reader)

func UpdateSnapshotRepository

func UpdateSnapshotRepository(ctx context.Context, service *OsClusterClient, repositoryName string, repository requests.SnapshotRepository) error

updates the given SnapshotRepository

func UserExists

func UserExists(ctx context.Context, service *OsClusterClient, username string) (bool, error)

func UserUIDMatches

func UserUIDMatches(ctx context.Context, service *OsClusterClient, username string, uid string) (bool, error)

Types

type ClusterSettingsAllocation

type ClusterSettingsAllocation string
const (
	ClusterSettingsAllocationPrimaries ClusterSettingsAllocation = "primaries"
	ClusterSettingsAllocationAll       ClusterSettingsAllocation = "all"
	ClusterSettingsAllocationNone      ClusterSettingsAllocation = "none"
)

type OsClusterClient

type OsClusterClient struct {
	OsClusterClientOptions

	MainPage responses.MainResponse
	// contains filtered or unexported fields
}

func NewOsClusterClient

func NewOsClusterClient(clusterUrl string, username string, password string, opts ...OsClusterClientOption) (*OsClusterClient, error)

func NewOsClusterClientFromConfig

func NewOsClusterClientFromConfig(config opensearch.Config) (*OsClusterClient, error)

func (*OsClusterClient) CatIndices

func (client *OsClusterClient) CatIndices() ([]responses.CatIndicesResponse, error)

func (*OsClusterClient) CatNamedIndicesShards

func (client *OsClusterClient) CatNamedIndicesShards(headers []string, indices []string) ([]responses.CatShardsResponse, error)

func (*OsClusterClient) CatNodes

func (client *OsClusterClient) CatNodes() ([]responses.CatNodesResponse, error)

func (*OsClusterClient) CatShards

func (client *OsClusterClient) CatShards(headers []string) ([]responses.CatShardsResponse, error)

func (*OsClusterClient) CreateSnapshotRepository

func (client *OsClusterClient) CreateSnapshotRepository(ctx context.Context, name string, body io.Reader) (*opensearchapi.Response, error)

performs an HTTP PUT request to OS to create the snapshot repository specified by name

func (*OsClusterClient) DeleteISMConfig

func (client *OsClusterClient) DeleteISMConfig(ctx context.Context, name string) (*opensearchapi.Response, error)

DeleteISMConfig performs an HTTP DELETE request to OS to delete the ISM policy resource specified by name

func (*OsClusterClient) DeleteSecurityResource

func (client *OsClusterClient) DeleteSecurityResource(ctx context.Context, resource, name string) (*opensearchapi.Response, error)

DeleteSecurityResource performs an HTTP DELETE request to OS to delete the security resource specified by name

func (*OsClusterClient) DeleteSnapshotRepository

func (client *OsClusterClient) DeleteSnapshotRepository(ctx context.Context, name string) (*opensearchapi.Response, error)

DeleteISMConfig performs an HTTP DELETE request to OS to delete the ISM policy resource specified by name

func (*OsClusterClient) GetClusterHealth

func (client *OsClusterClient) GetClusterHealth() (responses.ClusterHealthResponse, error)

func (*OsClusterClient) GetClusterSettings

func (client *OsClusterClient) GetClusterSettings() (responses.ClusterSettingsResponse, error)

func (*OsClusterClient) GetFlatClusterSettings

func (client *OsClusterClient) GetFlatClusterSettings() (responses.FlatClusterSettingsResponse, error)

func (*OsClusterClient) GetHealth

func (client *OsClusterClient) GetHealth() (responses.ClusterHealthResponse, error)

func (*OsClusterClient) GetISMConfig

func (client *OsClusterClient) GetISMConfig(ctx context.Context, name string) (*opensearchapi.Response, error)

GetISMConfig performs an HTTP GET request to OS to get the ISM policy resource specified by name

func (*OsClusterClient) GetSecurityResource

func (client *OsClusterClient) GetSecurityResource(ctx context.Context, resource, name string) (*opensearchapi.Response, error)

GetSecurityResource performs an HTTP GET request to OS to fetch the security resource specified by name

func (*OsClusterClient) GetSnapshotRepository

func (client *OsClusterClient) GetSnapshotRepository(ctx context.Context, name string) (*opensearchapi.Response, error)

performs an HTTP GET request to OS to get the snapshot repository specified by name

func (*OsClusterClient) IndexExists

func (client *OsClusterClient) IndexExists(indexName string) (bool, error)

func (*OsClusterClient) NodesStats

func (client *OsClusterClient) NodesStats() (responses.NodesStatsResponse, error)

func (*OsClusterClient) PutClusterSettings

func (*OsClusterClient) PutISMConfig

func (client *OsClusterClient) PutISMConfig(ctx context.Context, name string, body io.Reader) (*opensearchapi.Response, error)

PutISMConfig performs an HTTP PUT request to OS to create the ISM policy resource specified by name

func (*OsClusterClient) PutSecurityResource

func (client *OsClusterClient) PutSecurityResource(ctx context.Context, resource, name string, body io.Reader) (*opensearchapi.Response, error)

PutSecurityResource performs an HTTP PUT request to OS to create/update the security resource specified by name

func (*OsClusterClient) ReRouteShard

func (client *OsClusterClient) ReRouteShard(rerouteJson string) (responses.ClusterRerouteResponse, error)

func (*OsClusterClient) UpdateISMConfig

func (client *OsClusterClient) UpdateISMConfig(ctx context.Context, name string, seqnumber, primterm int, body io.Reader) (*opensearchapi.Response, error)

UpdateISMConfig performs an HTTP PUT request to OS to update the ISM policy resource specified by name

func (*OsClusterClient) UpdateSnapshotRepository

func (client *OsClusterClient) UpdateSnapshotRepository(ctx context.Context, name string, body io.Reader) (*opensearchapi.Response, error)

performs an HTTP PUT request to OS to update the snapshot repository specified by name

type OsClusterClientOption

type OsClusterClientOption func(*OsClusterClientOptions)

func WithTransport

func WithTransport(transport http.RoundTripper) OsClusterClientOption

type OsClusterClientOptions

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

Jump to

Keyboard shortcuts

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