Skip to content

feat: update CLI code base to use latest major version of the Go API client #178

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

Merged
merged 59 commits into from
Mar 18, 2025

Conversation

kai687
Copy link
Contributor

@kai687 kai687 commented Mar 14, 2025

... and other improvements

This PR updates dependencies and migrates the CLI code base to use the Algolia Go API client v4. During this process, I also found it valuable to add more formatting and linting to the code base, for better readability and consistency. Unfortunately, I could not untangle this part from the actual migration part.

  • Changes in pkg/cmd are mostly related to the actual migration from v4 to v4
  • Changes outside of pkg/cmd are mostly related to formatting and linting

Improvements

  • Add support for --wait to all indexing operations
  • Add support for --forward-to-replicas to the algolia settings set command
  • Rename --includeReplicas to --include-replicas in the algolia index delete command
  • Add command aliases records for objects, list for browse, and dict for dictionaries
  • Return errors if an index doesn't exist instead of showing an empty response for algolia rules browse and algolia synonyms browse (the empty response comes from the API)

Bug fixes

  • Fixed a bug in algolia index delete when deleting replicas
  • Fixed a bug for the algolia events tail command that didn't work with newer config files (with api_key instead of admin_api_key)

Linting/formatting/tasks

This PR adds gofumpt, gosec, and stylecheck to golangci-lint and defines tasks for formatting and linting in the Taskfile. This has a number of advantages over a Makefile, but introduces a new dependency (the Makefile still works and handles the CI stuff, so nothing should break).

Adds devbox for easy environment management.
In combination with `direnv`, the env is started automatically.
Without `direnv`, just do `devbox shell`.
Running Make as a task runner is phony.
A Taskfile is better suited for this.
Copying the binary into the Docker container doesn't work
if the host CPU architecture is different (like an M1 mac).
Since it's quick to build, we can just build the CLI
inside Docker.
This commit also re-enables support for the `--wait` flag,
which was commented out.
Can also use 'records'
This commit gets rid of some custom validation code.
We don't have to validate the multiple-batch request body
in the CLI, since that is done in the v4 API client now.
This commit also adds support for the 'delete index' and 'clear objects'
actions.
@kai687 kai687 marked this pull request as ready for review March 14, 2025 13:30
Copy link
Collaborator

@dylantientcheu dylantientcheu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a VERY good PR.

It was scary at first, but most of it is formatting. I tested it along with the docker install. It all worked good.

I left a few nits and questions but nothing blocking.

I'm not sure about how the CI react to all the actions upgrades v2 -> v5 is quite the leap IMO. But only one way to know :D.

YOLO

@kai687
Copy link
Contributor Author

kai687 commented Mar 18, 2025

This is a VERY good PR.

It was scary at first, but most of it is formatting. I tested it along with the docker install. It all worked good.

I left a few nits and questions but nothing blocking.

I'm not sure about how the CI react to all the actions upgrades v2 -> v5 is quite the leap IMO. But only one way to know :D.

YOLO

The CI for testing and bilding ran in my fork on every commit. The only things I couldn't test was the release and the PR for updating the docs.

@kai687 kai687 requested a review from dylantientcheu March 18, 2025 13:09
Copy link
Collaborator

@dylantientcheu dylantientcheu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try that release then! 🚀

@kai687
Copy link
Contributor Author

kai687 commented Mar 18, 2025

I have 2 more PRs in the making. One for adding e2e tests and 1 for adding a logs command. Maybe we can create a new release after that?

(Also, I don't have permissions to merge, so if you're cool with this PR, can you merge it please?)

@dylantientcheu dylantientcheu merged commit c96d3e0 into algolia:main Mar 18, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants