Conversation
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.
Summary
This PR introduces several improvements to MIG (Managed Instance Group) handling, TUI enhancements, cache management, and fixes instance name uniqueness across projects.
Instance/MIG Names Unique Per Project
Composite Primary Key: Changed the cache schema to use
PRIMARY KEY (name, project)instead of justname. This allows the same instance name (e.g., "netmgt") to exist in multiple projects without conflicts.New Cache API Methods:
GetWithProject(name, project): Precise lookup by name+project combinationGetAllByName(name): Returns all instances with a given name across all projectsDelete(name, project)andMarkInstanceUsed(name, project)to require project parameterCLI Multi-Project Selection: When running
compass gcp ssh <instance>without--projectand the instance name exists in multiple projects, an interactive selection prompt is displayed to choose which project's instance to connect to.Database Migration v6: Added migration that recreates the instances table with composite primary key while preserving existing data.
MIG Improvements
MIG Instance Selection Modal: When connecting to a MIG via TUI SSH that has multiple instances, a selection modal is now displayed allowing the user to choose which instance to connect to. If the MIG has only one instance, it connects directly.
Hide MIG Member Instances: Instances that belong to a MIG are now filtered out from the main instance list in the TUI. They can still be accessed via their parent MIG entry. This reduces clutter and avoids confusion when the same workload appears multiple times.
Fix MIG Details View: Fixed the "d" (details) shortcut for MIGs which was returning 404 errors. Added
GetManagedInstanceGroupAPI call andFormatMIGDetailsLiveformatter to properly fetch and display MIG details.MIG Name Extraction: Added extraction of MIG membership from instance
created-bymetadata. Newmig_namecolumn added to cache via migration v5.TUI Enhancements
Type Column: Added a "Type" column to the instance table to distinguish between "Instance" and "MIG" entries.
Keybindings Refactor: Refactored keyboard handling into a dedicated
KeyBindingsmanager with proper modal/filter mode support. This fixes inconsistencies where keybindings would trigger inappropriately in different modes.Progress Bar Text Clearing: Fixed issue where progress bar titles weren't being fully cleared when updated with shorter text.
CLI Improvements
Refresh All Projects:
compass gcp projects refreshcan now be run without a project name to refresh all currently imported projects. When run without arguments, it prompts to select which projects to refresh.Log File Support: Added
--log-fileparameter to write logs to a file. This is particularly useful for debugging TUI issues since stderr is redirected during TUI mode. File logging continues even when console output is disabled for TUI.Cache Management
ClearProjectInstances- removes instances and MIGsClearProjectSubnets- removes subnetsClearProjectZones- removes zonesFiles Changed
cmd/root.go--log-fileflagcmd/gcp.goMarkInstanceUsedcallcmd/gcp_projects.gointernal/cache/cache.goInstanceMatchtype,GetWithProject,GetAllByNamemethods, updatedDelete/MarkInstanceUsedsignatures, composite key supportinternal/cache/schema.go(name, project)internal/cache/migrations/v5_mig_name.gomig_namecolumninternal/cache/migrations/v6_composite_key.go(name, project)internal/cache/cache_test.gointernal/gcp/cache_ops.goGetWithProject()for IAP preference preservationinternal/gcp/extract.goextractMIGNameFromCreatedByfunctioninternal/gcp/instances.goGetWithProject()for cache lookupinternal/gcp/mig.goGetWithProject()for MIG cache lookupinternal/gcp/scan.gointernal/gcp/types.goMIGNamefield toInstancestructinternal/logger/logger.gointernal/tui/actions.goMarkInstanceUsedcallsinternal/tui/direct.gointernal/tui/keybindings.goTest Plan
Composite Key / Multi-Project Instance Names
compass gcp ssh <shared-name>without--project- verify selection prompt appearscompass gcp ssh <shared-name> --project <project>- verify direct connection without promptgo test ./internal/cache/... -v -run "TestSameNameDifferentProjects|TestDeleteWithProject|TestGetAllByName"MIG Functionality
s- verify selection modal appearss- verify it connects directlydon a MIG entry and verify details are displayed correctlyProject Management
compass gcp projects refreshwithout arguments and verify all projects can be refreshedcompass gcp projects refresh <project>and verify single project refresh worksLogging
--log-file /tmp/test.log --log-level debugand verify logs are written to fileFull Check
task checkand verify all tests pass with no lint issues