-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Add elastic client #10
base: main
Are you sure you want to change the base?
Conversation
cmd/elastic-cloud/index.go
Outdated
for k, i := range list { | ||
if strings.Contains(k, "elasticsearch_index") { | ||
now := time.Now().UnixMilli() | ||
created, err := strconv.ParseInt(i.IndexItem.IndexDetail.CreationDate, 10, 64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the creation date is a very rudimentary way of identifying stale indices because it does not identify the last time an index was updated.
I believe it may be possible to use data from the shards API to determine how 'fresh' an index is based on refresh, write or read metrics.
However because content is ephemeral and these are development indices we don't need to be too concerned about destructive requests.
README.md
Outdated
> Variables are deployment specific - make sure the deployment you are targeting is not a production deployment. | ||
|
||
* EC_API_KEY - Generated from the deployments Kibana settings | ||
* EC_CLOUD_ID - Found on the deployments Elastic Cloud 'manage' page |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be better as a flag or argument instead of an envvar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because they're creds I thought it safer to keep them stored as env vars but I suppose we could set them as env vars and reference them in the argument. Am I being too cautious in not allowing a user to expose those vars directly in an arg on the cli (and therefore making it available in their shell history)?
main.go
Outdated
Flags: []cli.Flag{ | ||
&cli.BoolFlag{ | ||
Name: "force", | ||
Usage: "Execute any mutations", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usage text should probably be more like skips all confirmation prompts and immediately executes mutations.
@nicksantamaria I've refactored the inputs so the API_KEY is now an env var and Cloud ID a flag. I've also added the age of the indices to target as flag. Ready for review again. |
Suggested changes for feature/add-elastic-client
Motivation
Need to clean-up stale indices on the Elastic Cloud development deployment.
Changes
elastic-cloud
command anddelete-stale
sub-command