Cli dx improvements#933
Merged
Merged
Conversation
This commit introduces functionality for listing indexes in an Enterprise cluster through a new `Indexes` command in the CLI. It adds the `CliClusterIndex` and `CliClusterIndexes` structs for managing index data, along with a new asynchronous function, `fetch_indexes_for_cluster`, to retrieve index information from the API. The command parsing has been updated to handle the new `Indexes` action, and tests have been added to ensure proper command parsing and functionality. These enhancements improve the CLI's capabilities for managing and interacting with cluster indexes.
This commit introduces two new methods in the HelixConfig and ProjectContext structs: `from_file_allow_no_instances` and `find_and_load_allow_no_instances`. These methods allow the loading of configurations that define zero instances, facilitating the re-adding of instances in scenarios where all instances have been removed. Additionally, the validation logic has been updated to support this lenient approach, ensuring that other necessary checks remain enforced. Tests have been added to verify the new behavior and ensure proper handling of configurations with no instances.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Greptile Summary
This PR makes two DX improvements to the Helix CLI: it allows
helix addto run inside a project that currently has zero instances (so users can re-add an instance after deleting the last one), and it adds a newhelix cluster indexessubcommand that lists vector, equality, and range indexes for an Enterprise cluster.helix add:HelixConfig::from_fileandProjectContext::find_and_loadare each split into a strict and a lenient variant;helix addnow uses the lenient path, with new unit tests covering both paths.helix cluster indexescommand: A newIndexessubcommand (aliasedindices) is added underClusterConfigAction; it auto-resolves the cluster ID from the current project's Enterprise instance when--cluster-idis omitted, and supports--format json.MissingInstanceserror now surfaces a concretehelix addcommand as a hint.Important Files Changed
list_indexes_for_clusterhandler andresolve_cluster_id_for_indexesfallback; error fromfind_and_loadis silently swallowed, which can hide config-parse failures behind a generic hint message.CliClusterIndex/CliClusterIndexesstructs andfetch_indexes_for_cluster; alias-only rename means--format jsonserializes toindex_name/index_typeinstead of the API'sname/type.from_fileinto afrom_file_inner(require_instances)gate; new tests cover both strict and lenient validation paths.find_and_load_allow_no_instancesby delegating to a sharedload_with(require_instances)helper; logic is straightforward.find_and_load_allow_no_instancessohelix addcan re-add an instance when the last one was deleted.Indexessubcommand underClusterConfigActionwith--cluster-id/--formatargs andindicesalias; clean.with_hinttoMissingInstanceserror message; no logic changes.cluster indexes --cluster-id ent_123; straightforward test coverage.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[helix cluster indexes] --> B{--cluster-id provided?} B -- yes --> C[trim & validate non-empty] C --> D[Use provided cluster_id] B -- no --> E[ProjectContext::find_and_load\nrequire_instances=true] E -- error --> F[Return: Provide --cluster-id hint] E -- ok --> G{enterprise instances count} G -- 0 --> H[Error: No Enterprise instances\nin helix.toml] G -- 1 --> I[Use sole instance cluster_id] G -- many & interactive --> J[prompts::select_instance] G -- many & non-interactive --> K[Error: list available instances] J --> L[Lookup cluster_id from config] I --> L D --> M[require_auth + fetch_indexes_for_cluster] L --> M M --> N{--format json?} N -- yes --> O[print_json] N -- no --> P[print_cluster_indexes\nvector / equality / range]Reviews (1): Last reviewed commit: "Implement lenient configuration loading ..." | Re-trigger Greptile