Documentation ¶
Index ¶
- Constants
- Variables
- func ActionGroupExists(ctx context.Context, service *OsClusterClient, actionGroupName string) (bool, error)
- func AppendExcludeNodeHost(service *OsClusterClient, nodeNameToExclude string) (bool, error)
- func CheckClusterStatusForRestart(service *OsClusterClient, drainNodes bool) (bool, string, error)
- func ComponentTemplateExists(ctx context.Context, service *OsClusterClient, templateName string) (bool, error)
- func ComponentTemplatePath(templateName string) strings.Builder
- func CreateISMPolicy(ctx context.Context, service *OsClusterClient, ismpolicy requests.ISMPolicy, ...) error
- func CreateIndex(clusterClient *OsClusterClient, indexName string, mapping *strings.Reader) (int, error)
- func CreateOrUpdateActionGroup(ctx context.Context, service *OsClusterClient, actionGroupName string, ...) error
- func CreateOrUpdateComponentTemplate(ctx context.Context, service *OsClusterClient, componentTemplateName string, ...) error
- func CreateOrUpdateIndexTemplate(ctx context.Context, service *OsClusterClient, indexTemplateName string, ...) error
- func CreateOrUpdateRole(ctx context.Context, service *OsClusterClient, rolename string, ...) error
- func CreateOrUpdateRoleMapping(ctx context.Context, service *OsClusterClient, rolename string, ...) error
- func CreateOrUpdateTenant(ctx context.Context, service *OsClusterClient, tenantName string, ...) error
- func CreateOrUpdateUser(ctx context.Context, service *OsClusterClient, username string, ...) error
- func CreateSnapshotRepository(ctx context.Context, service *OsClusterClient, repositoryName string, ...) error
- func DeleteActionGroup(ctx context.Context, service *OsClusterClient, actionGroupName string) error
- func DeleteComponentTemplate(ctx context.Context, service *OsClusterClient, componentTemplateName string) error
- func DeleteISMPolicy(ctx context.Context, service *OsClusterClient, policyName string) error
- func DeleteIndex(clusterClient *OsClusterClient, indexName string) (int, error)
- func DeleteIndexTemplate(ctx context.Context, service *OsClusterClient, indexTemplateName string) error
- func DeleteRole(ctx context.Context, service *OsClusterClient, rolename string) error
- func DeleteRoleMapping(ctx context.Context, service *OsClusterClient, rolename string) error
- func DeleteSnapshotRepository(ctx context.Context, service *OsClusterClient, repositoryName string) error
- func DeleteTenant(ctx context.Context, service *OsClusterClient, tenantName string) error
- func DeleteUser(ctx context.Context, service *OsClusterClient, username string) error
- func ErrCatIndicesFailed(resp string) error
- func ErrClusterHealthGetFailed(resp string) error
- func ErrClusterSettingsGetFailed(resp string) error
- func FetchExistingRoleMapping(ctx context.Context, service *OsClusterClient, rolename string) (requests.RoleMapping, error)
- func GetExistingSystemIndices(service *OsClusterClient) ([]string, error)
- func GetPolicy(ctx context.Context, service *OsClusterClient, policyName string) (*responses.GetISMPolicyResponse, error)
- func GetSnapshotRepository(ctx context.Context, service *OsClusterClient, repositoryName string) (*requests.SnapshotRepository, error)
- func HasIndexPrimariesOnNode(service *OsClusterClient, nodeName string, indices []string) (bool, error)
- func HasIndicesWithNoReplica(service *OsClusterClient) (bool, error)
- func HasShardsOnNode(service *OsClusterClient, nodeName string) (bool, error)
- func IndexTemplateExists(ctx context.Context, service *OsClusterClient, templateName string) (bool, error)
- func IndexTemplatePath(templateName string) strings.Builder
- func MainPage(client *opensearch.Client) (responses.MainResponse, error)
- func PreparePodForDelete(service *OsClusterClient, lg logr.Logger, podName string, drainNode bool, ...) (bool, error)
- func ReactivateShardAllocation(service *OsClusterClient) error
- func RemoveExcludeNodeHost(service *OsClusterClient, nodeNameToExclude string) (bool, error)
- func RoleExists(ctx context.Context, service *OsClusterClient, rolename string) (bool, error)
- func RoleMappingExists(ctx context.Context, service *OsClusterClient, rolename string) (bool, error)
- func SetClusterShardAllocation(service *OsClusterClient, enableType ClusterSettingsAllocation) error
- func ShouldUpdateActionGroup(ctx context.Context, service *OsClusterClient, actionGroupName string, ...) (bool, error)
- func ShouldUpdateComponentTemplate(ctx context.Context, service *OsClusterClient, componentTemplateName string, ...) (bool, error)
- func ShouldUpdateISMPolicy(ctx context.Context, newPolicy, existingPolicy requests.ISMPolicy) (bool, error)
- func ShouldUpdateIndexTemplate(ctx context.Context, service *OsClusterClient, indexTemplateName string, ...) (bool, error)
- func ShouldUpdateRole(ctx context.Context, service *OsClusterClient, rolename string, ...) (bool, error)
- func ShouldUpdateSnapshotRepository(ctx context.Context, ...) (bool, error)
- func ShouldUpdateTenant(ctx context.Context, service *OsClusterClient, tenantName string, ...) (bool, error)
- func ShouldUpdateUser(ctx context.Context, service *OsClusterClient, username string, ...) (bool, error)
- func SnapshotRepositoryExists(ctx context.Context, service *OsClusterClient, repositoryName string) (bool, error)
- func TenantExists(ctx context.Context, service *OsClusterClient, tenantName string) (bool, error)
- func UpdateISMPolicy(ctx context.Context, service *OsClusterClient, ismpolicy requests.ISMPolicy, ...) error
- func UpdateIndexSettings(clusterClient *OsClusterClient, indexName string, mapping *strings.Reader)
- func UpdateSnapshotRepository(ctx context.Context, service *OsClusterClient, repositoryName string, ...) error
- func UserExists(ctx context.Context, service *OsClusterClient, username string) (bool, error)
- func UserUIDMatches(ctx context.Context, service *OsClusterClient, username string, uid string) (bool, error)
- type ClusterSettingsAllocation
- type OsClusterClient
- func (client *OsClusterClient) CatIndices() ([]responses.CatIndicesResponse, error)
- func (client *OsClusterClient) CatNamedIndicesShards(headers []string, indices []string) ([]responses.CatShardsResponse, error)
- func (client *OsClusterClient) CatNodes() ([]responses.CatNodesResponse, error)
- func (client *OsClusterClient) CatShards(headers []string) ([]responses.CatShardsResponse, error)
- func (client *OsClusterClient) CreateSnapshotRepository(ctx context.Context, name string, body io.Reader) (*opensearchapi.Response, error)
- func (client *OsClusterClient) DeleteISMConfig(ctx context.Context, name string) (*opensearchapi.Response, error)
- func (client *OsClusterClient) DeleteSecurityResource(ctx context.Context, resource, name string) (*opensearchapi.Response, error)
- func (client *OsClusterClient) DeleteSnapshotRepository(ctx context.Context, name string) (*opensearchapi.Response, error)
- func (client *OsClusterClient) GetClusterHealth() (responses.ClusterHealthResponse, error)
- func (client *OsClusterClient) GetClusterSettings() (responses.ClusterSettingsResponse, error)
- func (client *OsClusterClient) GetFlatClusterSettings() (responses.FlatClusterSettingsResponse, error)
- func (client *OsClusterClient) GetHealth() (responses.ClusterHealthResponse, error)
- func (client *OsClusterClient) GetISMConfig(ctx context.Context, name string) (*opensearchapi.Response, error)
- func (client *OsClusterClient) GetSecurityResource(ctx context.Context, resource, name string) (*opensearchapi.Response, error)
- func (client *OsClusterClient) GetSnapshotRepository(ctx context.Context, name string) (*opensearchapi.Response, error)
- func (client *OsClusterClient) IndexExists(indexName string) (bool, error)
- func (client *OsClusterClient) NodesStats() (responses.NodesStatsResponse, error)
- func (client *OsClusterClient) PutClusterSettings(settings responses.ClusterSettingsResponse) (responses.ClusterSettingsResponse, error)
- func (client *OsClusterClient) PutISMConfig(ctx context.Context, name string, body io.Reader) (*opensearchapi.Response, error)
- func (client *OsClusterClient) PutSecurityResource(ctx context.Context, resource, name string, body io.Reader) (*opensearchapi.Response, error)
- func (client *OsClusterClient) ReRouteShard(rerouteJson string) (responses.ClusterRerouteResponse, error)
- func (client *OsClusterClient) UpdateISMConfig(ctx context.Context, name string, seqnumber, primterm int, body io.Reader) (*opensearchapi.Response, error)
- func (client *OsClusterClient) UpdateSnapshotRepository(ctx context.Context, name string, body io.Reader) (*opensearchapi.Response, error)
- type OsClusterClientOption
- type OsClusterClientOptions
Constants ¶
const ( K8sAttributeField = "k8s-uid" ROLES = "roles" INTERNALUSERS = "internalusers" ROLESMAPPING = "rolesmapping" ACTIONGROUPS = "actiongroups" TENANTS = "tenants" )
Variables ¶
var ( ErrClusterHealthOperation = errors.New("cluster health failed") ErrClusterSettingsOperation = errors.New("cluster settings failed") ErrCatIndicesOperation = errors.New("cat indices failed") )
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",
}
var ClusterSettingsExcludeBrokenPath = []string{"cluster", "routing", "allocation", "exclude", "_name"}
var ErrNotFound = errors.New("policy not found")
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 ¶
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 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 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 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 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 ¶
IndexTemplatePath returns a strings.Builder pointing to /_index_template/<templateName>
func MainPage ¶
func MainPage(client *opensearch.Client) (responses.MainResponse, error)
func PreparePodForDelete ¶
func ReactivateShardAllocation ¶
func ReactivateShardAllocation(service *OsClusterClient) error
func RemoveExcludeNodeHost ¶
func RemoveExcludeNodeHost(service *OsClusterClient, nodeNameToExclude string) (bool, error)
func RoleExists ¶
func RoleMappingExists ¶
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 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 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 ¶
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 UserUIDMatches ¶
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 (client *OsClusterClient) PutClusterSettings(settings responses.ClusterSettingsResponse) (responses.ClusterSettingsResponse, error)
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
}